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