function do_filtering($name, $args)
{
static $filter;
if (!$filter) {
$filter = Haanga_Extension::getInstance('Filter');
}
if (is_array($name)) {
/*
prepare array for ($func_name, $arg1, $arg2 ... )
where $arg1 = last expression and $arg2.. $argX is
defined in the template
*/
$args = array_merge($args, $name['args']);
$name = $name[0];
}
if (!$filter->isValid($name)) {
throw new Exception("{$name} is an invalid filter");
}
if ($filter->isSafe($name)) {
/* check if the filter is return HTML-safe data (to avoid double scape) */
$this->var_is_safe = TRUE;
}
if ($filter->hasGenerator($name)) {
return $filter->generator($name, $this, $args);
}
$fnc = $filter->getFunctionAlias($name);
if (!$fnc) {
$fnc = $this->get_custom_filter($name);
}
$args = array_merge(array($fnc), $args);
$exec = call_user_func_array('hexec', $args);
return $exec;
}