You are here

function _customfilter_process in Custom filter 5

Same name and namespace in other branches
  1. 6.2 customfilter.module \_customfilter_process()
  2. 6 customfilter.module \_customfilter_process()
  3. 7.2 customfilter.module \_customfilter_process()
  4. 7 customfilter.module \_customfilter_process()

Filter process function.

1 call to _customfilter_process()
customfilter_filter in ./customfilter.module
Implements hook_filter().

File

./customfilter.module, line 1163

Code

function _customfilter_process($delta, $format, $text) {
  global $_customfilter_globals;
  if (!isset($_customfilter_globals)) {
    $_customfilter_globals = new stdClass();
  }
  $_customfilter_globals->text = $text;

  // Get the filter set, according to $delta
  if ($set = customfilter_get_set($delta, 'sid')) {
    $filters = customfilter_get_filters($delta);
    if (count($filters) > 0) {

      // Preparation
      // The stack is used to save the parent filter when traversing
      $_customfilter_globals->stack = array();
      foreach ($filters as $filter) {
        $_customfilter_globals->stack[] = $filter;
        $_customfilter_globals->text = preg_replace_callback($filter['pattern'], '_customfilter_process_filter', $_customfilter_globals->text);
        array_pop($_customfilter_globals->stack);
      }
    }
  }
  return $_customfilter_globals->text;
}