4 * Smarty Internal Plugin Filter Handler
6 * Smarty filter handler class
9 * @subpackage PluginsInternal
14 * Class for filter processing
16 class Smarty_Internal_Filter_Handler {
18 * Run filters over content
20 * The filters will be lazy loaded if required
21 * class name format: Smarty_FilterType_FilterName
22 * plugin filename format: filtertype.filtername.php
23 * Smarty2 filter plugins could be used
25 * @param string $type the type of filter ('pre','post','output' or 'variable') which shall run
26 * @param string $content the content which shall be processed by the filters
27 * @return string the filtered content
29 static function runFilter($type, $content, $template, $flag = null)
32 if ($type != 'variable' || ($template->smarty->variable_filter && $flag !== false) || $flag === true) {
33 // loop over autoload filters of specified type
34 if (!empty($template->smarty->autoload_filters[$type])) {
35 foreach ((array)$template->smarty->autoload_filters[$type] as $name) {
36 $plugin_name = "Smarty_{$type}filter_{$name}";
37 if ($template->smarty->loadPlugin($plugin_name)) {
38 if (function_exists($plugin_name)) {
39 // use loaded Smarty2 style plugin
40 $output = $plugin_name($output, $template);
41 } elseif (class_exists($plugin_name, false)) {
42 // loaded class of filter plugin
43 $output = call_user_func(array($plugin_name, 'execute'), $output, $template);
46 // nothing found, throw exception
47 throw new SmartyException("Unable to load filter {$plugin_name}");
51 // loop over registerd filters of specified type
52 if (!empty($template->smarty->registered_filters[$type])) {
53 foreach ($template->smarty->registered_filters[$type] as $key => $name) {
54 if (is_array($template->smarty->registered_filters[$type][$key])) {
55 $output = call_user_func($template->smarty->registered_filters[$type][$key], $output, $template);
57 $output = $template->smarty->registered_filters[$type][$key]($output, $template);
62 // return filtered output