29 public function compile($args, $compiler, $parameter) {
34 foreach ($parameter[
'modifierlist'] as $single_modifier) {
35 $modifier = $single_modifier[0];
37 $params = implode(
',', $single_modifier);
39 if (isset($compiler->known_modifier_type[$modifier])) {
40 $modifier_types = array($compiler->known_modifier_type[$modifier]);
42 $modifier_types = array(1, 2, 3, 4, 5, 6);
44 foreach ($modifier_types as $type) {
50 if (!is_array($function)) {
51 $output =
"{$function}({$params})";
53 if (is_object($function[0])) {
54 $output =
'$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier .
'\'][0][0]->
' . $function[1] . '(
' . $params . ')
';
56 $output = $function[0] . '::
' . $function[1] . '(
' . $params . ')
';
59 $compiler->known_modifier_type[$modifier] = $type;
64 // registered modifier compiler
65 if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
66 $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
67 $compiler->known_modifier_type[$modifier] = $type;
72 // modifiercompiler plugin
73 if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_
' . $modifier)) {
74 // check if modifier allowed
75 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
76 $plugin = 'smarty_modifiercompiler_
' . $modifier;
77 $output = $plugin($single_modifier, $compiler);
79 $compiler->known_modifier_type[$modifier] = $type;
85 if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
86 // check if modifier allowed
87 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
88 $output = "{$function}({$params})";
90 $compiler->known_modifier_type[$modifier] = $type;
96 if (is_callable($modifier)) {
97 // check if modifier allowed
98 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
99 $output = "{$modifier}({$params})";
101 $compiler->known_modifier_type[$modifier] = $type;
106 // default plugin handler
107 if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) {
108 $function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
109 // check if modifier allowed
110 if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
111 if (!is_array($function)) {
112 $output = "{$function}({$params})";
114 if (is_object($function[0])) {
115 $output = '$_smarty_tpl->smarty->registered_plugins[
Smarty::PLUGIN_MODIFIER][\
'' . $modifier .
'\'][0][0]->
' . $function[1] . '(
' . $params . ')
';
117 $output = $function[0] . '::
' . $function[1] . '(
' . $params . ')
';
121 if (isset($compiler->template->required_plugins['nocache
'][$modifier][Smarty::PLUGIN_MODIFIER]['file
']) || isset($compiler->template->required_plugins['compiled
'][$modifier][Smarty::PLUGIN_MODIFIER]['file
'])) {
123 $compiler->known_modifier_type[$modifier] = 4;
125 $compiler->known_modifier_type[$modifier] = $type;
131 if (!isset($compiler->known_modifier_type[$modifier])) {
132 $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
compile($args, $compiler, $parameter)
Compiles code for modifier execution.