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