You are here

function highlight_filter in Highlight 5

Same name and namespace in other branches
  1. 6 highlight.module \highlight_filter()

Implementation of hook_filter

File

./highlight.module, line 155

Code

function highlight_filter($op, $delta = 0, $format = -1, $text = '') {

  // list filters
  if ($op == 'list') {
    return array(
      0 => t('Highlight search results'),
    );
  }
  if ($op == "description") {
    return array(
      t("Highlight search terms in this content area"),
    );
  }

  // All operations besides "list" provide a $delta argument so we know which
  switch ($delta) {

    // First we define the simple string substitution filter.
    case 0:
      switch ($op) {

        // no caching
        case 'no cache':
          return TRUE;

        // describe the filter
        case 'description':
          return t('Highlights search terms in the text.');

        // We don't need the "prepare" operation for this filter, but it's required
        // to at least return the input text as-is.
        case 'prepare':
          return $text;

        // process the filter
        case 'process':
          if (highlight_check_display()) {
            return highlight_process($text, $_GET['highlight']);
          }
          else {
            return $text;
          }
      }
      break;
  }
}