You are here

function _customfilter_process_filter in Custom filter 5

1 string reference to '_customfilter_process_filter'
_customfilter_process in ./customfilter.module
Filter process function.

File

./customfilter.module, line 1228

Code

function _customfilter_process_filter($matches) {
  global $_customfilter_globals;
  $result = $matches[0];
  $filter = end($_customfilter_globals->stack);

  // if there is subfilter
  if (is_array($filter['sub']) && count($filter['sub']) > 0) {

    // do the same thing to each of them
    foreach ($filter['sub'] as $subfilter) {
      $_customfilter_globals->stack[] = $subfilter;
      $substr =& $matches[$subfilter['matches']];
      $substr = preg_replace_callback($subfilter['pattern'], '_customfilter_process_filter', $substr);
      array_pop($_customfilter_globals->stack);
    }
    $result = _customfilter_process_replace_sub($filter['replacement'], $matches, $filter['func']);
  }
  elseif ($filter['func'] == 1) {
    $result = preg_replace_callback($filter['pattern'], create_function('$matches', CUSTOMFILTER_CODE_DECLARE . $filter['replacement']), $result);
  }
  else {
    $result = preg_replace($filter['pattern'], $filter['replacement'], $result);
  }
  return $result;
}