Хранилища Subversion ant

Редакция

К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
 
3
/**
4
* Smarty Internal Plugin Run Filter
5
*
6
* Smarty run filter class
7
*
8
* @package Smarty
9
* @subpackage PluginsInternal
10
* @author Uwe Tews
11
*/
12
 
13
/**
14
* Class for filter processing
15
*/
16
class Smarty_Internal_Run_Filter {
17
    function __construct($smarty)
18
    {
19
        $this->smarty = $smarty;
20
    }
21
    /**
22
    * Run filters over content
23
    *
24
    * The filters will be lazy loaded if required
25
    * class name format: Smarty_FilterType_FilterName
26
    * plugin filename format: filtertype.filtername.php
27
    * Smarty2 filter plugins could be used
28
    *
29
    * @param string $type the type of filter ('pre','post','output' or 'variable') which shall run
30
    * @param string $content the content which shall be processed by the filters
31
    * @return string the filtered content
32
    */
33
    public function execute($type, $content, $flag = null)
34
    {
35
        $output = $content;
36
        if ($type != 'variable' || ($this->smarty->variable_filter && $flag !== false) || $flag === true) {
37
            // loop over autoload filters of specified type
38
            if (!empty($this->smarty->autoload_filters[$type])) {
39
                foreach ((array)$this->smarty->autoload_filters[$type] as $name) {
40
                    $plugin_name = "Smarty_{$type}filter_{$name}";
41
                    if ($this->smarty->loadPlugin($plugin_name)) {
42
                        // use class plugin if found
43
                        if (class_exists($plugin_name, false)) {
44
                            // loaded class of filter plugin
45
                            $output = call_user_func_array(array($plugin_name, 'execute'), array($output, $this->smarty));
46
                        } elseif (function_exists($plugin_name)) {
47
                            // use loaded Smarty2 style plugin
48
                            $output = call_user_func_array($plugin_name, array($output, $this->smarty));
49
                        }
50
                    } else {
51
                        // nothing found, throw exception
52
                        throw new Exception("Unable to load filter {$plugin_name}");
53
                    }
54
                }
55
            }
56
            // loop over registerd filters of specified type
57
            if (!empty($this->smarty->registered_filters[$type])) {
58
                foreach ($this->smarty->registered_filters[$type] as $key => $name) {
59
                    $output = call_user_func_array($this->smarty->registered_filters[$type][$key], array($output, $this->smarty));
60
                }
61
            }
62
        }
63
        // return filtered output
64
        return $output;
65
    }
66
}
67
 
68
?>