c4fbfa5e2b3fcaf2531d4232c18c354ec705e2d1
[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 * Smarty Internal Plugin Compile Modifier Class\r
13 */\r
14 class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {\r
15 /**\r
16 * Compiles code for modifier execution\r
17 * \r
18 * @param array $args array with attributes from parser\r
19 * @param object $compiler compiler object\r
20 * @return string compiled code\r
21 */\r
22 public function compile($args, $compiler)\r
23 {\r
24 $this->compiler = $compiler;\r
25 $this->smarty = $this->compiler->smarty;\r
26 $this->required_attributes = array('modifier', 'params'); \r
27 // check and get attributes\r
28 $_attr = $this->_get_attributes($args); \r
29 // check for registered modifier\r
30 if (isset($compiler->smarty->registered_plugins['modifier'][$_attr['modifier']])) {\r
31 $function = $compiler->smarty->registered_plugins['modifier'][$_attr['modifier']][0];\r
32 if (!is_array($function)) {\r
33 $output = "{$function}({$_attr['params']})";\r
34 } else if (is_object($function[0])) {\r
35 $output = 'call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $_attr['modifier'] . '\'][0],array(' . $_attr['params'] . '))';\r
36 } else {\r
37 $output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';\r
38 } \r
39 // check for plugin modifier\r
40 } else if ($function = $this->compiler->getPlugin($_attr['modifier'], 'modifier')) {\r
41 if (!is_array($function)) {\r
42 $output = "{$function}({$_attr['params']})";\r
43 } else {\r
44 $output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';\r
45 } \r
46 // check if trusted PHP function\r
47 } else if (is_callable($_attr['modifier'])) {\r
48 // check if modifier allowed\r
49 if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($_attr['modifier'], $this->compiler)) {\r
50 $output = "{$_attr['modifier']}({$_attr['params']})";\r
51 } \r
52 } else {\r
53 $this->compiler->trigger_template_error ("unknown modifier \"" . $_attr['modifier'] . "\"");\r
54 } \r
55 return $output;\r
56 } \r
57 } \r
58 \r
59 ?>\r