Drupal Code Snipits

hook_filter() and Finding Context in D6

Drupal's filter system is a pretty nifty thing- you can grab text coming through the system and modify it to your hearts content. This makes for great things like replacing various kinds of tokens, automatically making URLs link, and so on. I've been looking at the wordfilter module to check for "bad words" coming through the text.

One of the things that this module lacks is logging of the users who are using "bad words". Being able to track usage by user creates the possibility of creating specific kinds of actions around the user- settings various flags, demoting permissions, alerting admin, etc.

Formalize the Media Mover hook

I've been working over the weekend to finish up the media mover hook system. I think I've finally finished out the final form of the hook and the different options that are available. Here's a commented version of what I'm using in the media_mover.inc file


* Implementation of media_mover hook
function media_mover_media_mover($op, $action = null, $config = null, &$file = array() ) {

switch ($op) {

// give your driver a name
case 'name':
  return "Media Mover module";

// create a new configuration option set

Media Mover prelim announcement

update 12/9/06:

I've done quite a bit of working pulling together and administrative system. It's by no means polished, but the database is storing each set of configurations (for harvest, process, and storage) and can pull each of these out for each run of of the configuration. This means that it's possible to have multiple runs of say a video conversion with different conversion rates.

The media_mover hook is almost stable at this point, the major piece left is the "save" function which keeps track of how files were moved around and created.

Search Highlight Module

Just put together a Drupal (4.7) module that highlights search term results in nodes. From the readme file:

This module creates a link on search results pages and if highlighting is enabled for the field (check your input types), it will search and replace the search term in that field with an admin defined string

1) activate "search_highlight" module in admin > modules
2) add the filter to input formats admin > input formats
3) customize highlighting admin > settings > search_highlight (optional)