1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17:
18: class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase
19: {
20: 21: 22: 23: 24: 25: 26: 27: 28:
29: public function compile($args, $compiler, $parameter)
30: {
31:
32: $_attr = $this->getAttributes($compiler, $args);
33: $output = $parameter['value'];
34:
35: foreach ($parameter['modifierlist'] as $single_modifier) {
36: $modifier = $single_modifier[0];
37: $single_modifier[0] = $output;
38: $params = implode(',', $single_modifier);
39:
40: if (isset($compiler->known_modifier_type[$modifier])) {
41: $modifier_types = array($compiler->known_modifier_type[$modifier]);
42: } else {
43: $modifier_types = array(1, 2, 3, 4, 5, 6);
44: }
45: foreach ($modifier_types as $type) {
46: switch ($type) {
47: case 1:
48:
49: if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
50: $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
51: if (!is_array($function)) {
52: $output = "{$function}({$params})";
53: } else {
54: if (is_object($function[0])) {
55: $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
56: } else {
57: $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
58: }
59: }
60: $compiler->known_modifier_type[$modifier] = $type;
61: break 2;
62: }
63: break;
64: case 2:
65:
66: if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
67: $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
68: $compiler->known_modifier_type[$modifier] = $type;
69: break 2;
70: }
71: break;
72: case 3:
73:
74: if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
75:
76: if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
77: $plugin = 'smarty_modifiercompiler_' . $modifier;
78: $output = $plugin($single_modifier, $compiler);
79: }
80: $compiler->known_modifier_type[$modifier] = $type;
81: break 2;
82: }
83: break;
84: case 4:
85:
86: if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
87:
88: if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
89: $output = "{$function}({$params})";
90: }
91: $compiler->known_modifier_type[$modifier] = $type;
92: break 2;
93: }
94: break;
95: case 5:
96:
97: if (is_callable($modifier)) {
98:
99: if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
100: $output = "{$modifier}({$params})";
101: }
102: $compiler->known_modifier_type[$modifier] = $type;
103: break 2;
104: }
105: break;
106: case 6:
107:
108: if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) {
109: $function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
110:
111: if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
112: if (!is_array($function)) {
113: $output = "{$function}({$params})";
114: } else {
115: if (is_object($function[0])) {
116: $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
117: } else {
118: $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
119: }
120: }
121: }
122: if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
123:
124: $compiler->known_modifier_type[$modifier] = 4;
125: } else {
126: $compiler->known_modifier_type[$modifier] = $type;
127: }
128: break 2;
129: }
130: }
131: }
132: if (!isset($compiler->known_modifier_type[$modifier])) {
133: $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
134: }
135: }
136:
137: return $output;
138: }
139: }
140: