source: pro-violet-viettel/sourcecode/application/third_party/Smarty/sysplugins/smarty_internal_compile_private_modifier.php

Last change on this file was 345, checked in by quyenla, 11 years ago

collaborator page

File size: 3.5 KB
Line 
1<?php
2
3/**
4 * Smarty Internal Plugin Compile Modifier
5 *
6 * Compiles code for modifier execution
7 *
8 * @package Smarty
9 * @subpackage Compiler
10 * @author Uwe Tews
11 */
12
13/**
14 * Smarty Internal Plugin Compile Modifier Class
15 *
16 * @package Smarty
17 * @subpackage Compiler
18 */
19class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {
20
21    /**
22     * Compiles code for modifier execution
23     *
24     * @param array  $args      array with attributes from parser
25     * @param object $compiler  compiler object
26     * @param array  $parameter array with compilation parameter
27     * @return string compiled code
28     */
29    public function compile($args, $compiler, $parameter)
30    {
31        // check and get attributes
32        $_attr = $this->getAttributes($compiler, $args);
33        $output = $parameter['value'];
34        // loop over list of modifiers
35        foreach ($parameter['modifierlist'] as $single_modifier) {
36            $modifier = $single_modifier[0];
37            $single_modifier[0] = $output;
38            $params = implode(',', $single_modifier);
39            // check for registered modifier
40            if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
41                $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
42                if (!is_array($function)) {
43                    $output = "{$function}({$params})";
44                } else {
45                    if (is_object($function[0])) {
46                        $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
47                    } else {
48                        $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
49                    }
50                }
51            } else if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
52                $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
53                // check for plugin modifiercompiler
54            } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
55                // check if modifier allowed
56                if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
57                    $plugin = 'smarty_modifiercompiler_' . $modifier;
58                    $output = $plugin($single_modifier, $compiler);
59                }
60                // check for plugin modifier
61            } else if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
62                // check if modifier allowed
63                if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
64                    $output = "{$function}({$params})";
65                }
66                // check if trusted PHP function
67            } else if (is_callable($modifier)) {
68                // check if modifier allowed
69                if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
70                    $output = "{$modifier}({$params})";
71                }
72            } else {
73                $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
74            }
75        }
76        return $output;
77    }
78
79}
80
81?>
Note: See TracBrowser for help on using the repository browser.