Hello, my name is Karim Ratib. I plan and build Drupal applications using the best modules from the community. I maintain or co-maintain many modules, including Views Bulk Operations and Sheetnode. I specialize in multilingual applications (especially Arabic), configuration management using Features, data modelling and processing using Views and Feeds, and integrating 3rd party libraries and services. I have good experience leading Drupal teams.

Functors for your single-parameter callback blues

When using PHP functions such as array_map, usort or preg_replace_callback, you are forced to pass in a single-parameter callback function, making it impossible to send additional context information to the callback. But it ain't necessarily so.

Function objects, aka Functors, are here to help.

A generic filter for system commands

For the information geek, we need a generic filter that sends the text fragment to any pre-defined system command, and sets the rendered HTML output as the output of the command. Graphviz Filter is a special case of such a filter, but we really need a generic system.

I'm thinking: gnuplot, LilyPond, LaTeX, etc. All housed under one roof.

Some design issues arise: Each of these programs produces output in a variety of formats.

Using Drupal to analyze Twitter data

The Twitter dataset is an insanely valuable source of useful social networking information. That explains the huge number of Twitter-related sites that spring up, each one performing one specific analysis of Twitter data. The one I was looking at today is TwitterSheep which just creates a tagadelic-type cloud of keywords, from a user's followers' bios. Pretty neat idea, but it was frustrating that the Web application didn't let me actually see who of my followers are in which category - and make a list out of them, and email them, etc.

ImageField Archive: an action to download zipped images

One of the recurring requests in the Views Bulk Operations issue queue is to create a downloadable archive of files attached to nodes. While the general case is not trivial to solve, I was recently hired by research on BLOGS to write a more specific action: create a Zip archive of all images stored in imagefields.

Actions REST, a poor man's URI interface to actions

I rely on actions extensively to build functionality in my sites. I find them convenient for business logic because they are packaged chunks of functionality that can be called from many places, including Trigger, Rules, and VBO. Today, I've added a new place where actions can be called: the URL. Actions REST provides this functionality.

Consider a job site where a supplier receives an invitation to participate in a project. The supplier logs on the site and views the invitation, then wants to accept or decline it.

Using default arguments to relate nodes by their common taxonomy terms

Given a list of videos tagged with a specific vocabulary, I wanted to show a view of these videos on the page of another node type (a "channel") that is also tagged with the same vocabulary. The idea is to create video channels that implicitly relate to videos by sharing taxonomy terms, instead of explicitly relating the videos to their channel (using node references for example). The videos should show on the channel's node page.

Going fullscreen in JavaScript/jQuery

I'm no fan of Flash. Even the name annoys me :-) But I feel that recreating its capabilities using the trio HTML/CSS/JavaScript (isn't there an acronym for these 3 interrelated technologies?) is often non-trivial.

A case in point: I recently added to Sheetnode the feature of editing the spreadsheet fullscreen. While every Flash component has a fullscreen option, I couldn't even find a jQuery component that implements this functionality.

Overriding menu item themes

In an earlier article, I tried to argue, somewhat inconvincingly, that theming menu items is less than ideal. I think my example was not well chosen. Fortunately, real life furnished me with a perfect example, during the course of my work.

A client required to associate specific icons with menu items, by specifying a custom class for specific menu items. A legitimate request that has been around for years on desktop menu systems. How to implement this on Drupal? Not so simple using the current menu theming setup.

Dealing with deep arrays in PHP

Drupal code is heavily array-based, and it utilizes array structures that can be many levels deep. Here are a couple of complementary functions to query and manipulate such arrays:

<?php /** * Search for a key in an array, returning a path to the entry. * * @param $needle * A key to look for. * @param $haystack * A keyed array. * @param $forbidden * A list of keys to ignore. * @param $path * The intermediate path.

Keeping views under control

It's no secret that version control on Drupal is hard. Specifically, the problem of iteratively building a site on a staging server, then moving it to a running production system has been the source of countless wasted hours, lost data, pulled hair, blog posts, and modules promising a solution. On Twitter, some would say #drupal #migration #fail.

This post is not the answer to this problem. I just want to show actual code that helps with a small part of it, namely keeping views under version control.

Syndicate content