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