[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_modifier.php
diff --git a/gosa-core/include/smarty/sysplugins/smarty_internal_compile_private_modifier.php b/gosa-core/include/smarty/sysplugins/smarty_internal_compile_private_modifier.php
index 06b5a885e4309acf71d8f6e94edc11748ca3f6c8..ca4d90774f526ca75f9932331db21849de2da514 100644 (file)
<?php\r
+\r
/**\r
* Smarty Internal Plugin Compile Modifier\r
- * \r
+ *\r
* Compiles code for modifier execution\r
- * \r
+ *\r
* @package Smarty\r
* @subpackage Compiler\r
- * @author Uwe Tews \r
+ * @author Uwe Tews\r
*/\r
\r
/**\r
* Smarty Internal Plugin Compile Modifier Class\r
+ *\r
+ * @package Smarty\r
+ * @subpackage Compiler\r
*/\r
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {\r
+\r
/**\r
* Compiles code for modifier execution\r
- * \r
- * @param array $args array with attributes from parser\r
- * @param object $compiler compiler object\r
+ *\r
+ * @param array $args array with attributes from parser\r
+ * @param object $compiler compiler object\r
+ * @param array $parameter array with compilation parameter\r
* @return string compiled code\r
*/\r
- public function compile($args, $compiler)\r
+ public function compile($args, $compiler, $parameter)\r
{\r
- $this->compiler = $compiler;\r
- $this->smarty = $this->compiler->smarty;\r
- $this->required_attributes = array('value', 'modifierlist'); \r
// check and get attributes\r
- $_attr = $this->_get_attributes($args);\r
- $output = $_attr['value']; \r
+ $_attr = $this->getAttributes($compiler, $args);\r
+ $output = $parameter['value'];\r
// loop over list of modifiers\r
- foreach ($_attr['modifierlist'] as $single_modifier) {\r
- preg_match_all('/(((\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^:"]*"[^"\\\\]*(?:\\\\.[^"\\\\]*)*")[^:]*)+|::?|[^:]+)/', $single_modifier, $mod_array);\r
- $modifier = $mod_array[0][0];\r
- for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {\r
- if ($mod_array[0][$i] == ':') {\r
- $mod_array[0][$i] = ',';\r
- } \r
- if ($mod_array[0][$i] == '::') {\r
- $mod_array[0][$i-1] = $mod_array[0][$i-1] . $mod_array[0][$i] . $mod_array[0][$i + 1];\r
- unset($mod_array[0][$i], $mod_array[0][$i + 1]);\r
- $i++;\r
- } \r
- } \r
- unset($mod_array[0][0]);\r
- $params = $output . implode('', $mod_array[0]); \r
+ foreach ($parameter['modifierlist'] as $single_modifier) {\r
+ $modifier = $single_modifier[0];\r
+ $single_modifier[0] = $output;\r
+ $params = implode(',', $single_modifier);\r
// check for registered modifier\r
- if (isset($compiler->smarty->registered_plugins['modifier'][$modifier])) {\r
- $function = $compiler->smarty->registered_plugins['modifier'][$modifier][0];\r
+ if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {\r
+ $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];\r
if (!is_array($function)) {\r
$output = "{$function}({$params})";\r
} else {\r
if (is_object($function[0])) {\r
- $output = '$_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';\r
+ $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';\r
} else {\r
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';\r
- } \r
- } \r
+ }\r
+ }\r
+ } else if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {\r
+ $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);\r
// check for plugin modifiercompiler\r
} else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {\r
- $plugin = 'smarty_modifiercompiler_' . $modifier;\r
- foreach($mod_array[0] as $key => $value) {\r
- if ($value == ',') {\r
- unset ($mod_array[0][$key]);\r
- } \r
- } \r
- $args = array_merge((array)$output, $mod_array[0]);\r
- $output = $plugin($args, $compiler); \r
+ // check if modifier allowed\r
+ if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {\r
+ $plugin = 'smarty_modifiercompiler_' . $modifier;\r
+ $output = $plugin($single_modifier, $compiler);\r
+ }\r
// check for plugin modifier\r
- } else if ($function = $this->compiler->getPlugin($modifier, 'modifier')) {\r
- $output = "{$function}({$params})"; \r
+ } else if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {\r
+ // check if modifier allowed\r
+ if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {\r
+ $output = "{$function}({$params})";\r
+ }\r
// check if trusted PHP function\r
} else if (is_callable($modifier)) {\r
// check if modifier allowed\r
- if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($modifier, $this->compiler)) {\r
+ if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {\r
$output = "{$modifier}({$params})";\r
- } \r
+ }\r
} else {\r
- $this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"");\r
- } \r
- } \r
+ $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);\r
+ }\r
+ }\r
return $output;\r
- } \r
-} \r
+ }\r
+\r
+}\r
\r
?>
\ No newline at end of file