PEEL Shopping
Open source ecommerce : PEEL Shopping
smarty_internal_compile_private_modifier.php
Go to the documentation of this file.
1 <?php
2 
20 
29  public function compile($args, $compiler, $parameter) {
30  // check and get attributes
31  $_attr = $this->getAttributes($compiler, $args);
32  $output = $parameter['value'];
33  // loop over list of modifiers
34  foreach ($parameter['modifierlist'] as $single_modifier) {
35  $modifier = $single_modifier[0];
36  $single_modifier[0] = $output;
37  $params = implode(',', $single_modifier);
38  // check if we know already the type of modifier
39  if (isset($compiler->known_modifier_type[$modifier])) {
40  $modifier_types = array($compiler->known_modifier_type[$modifier]);
41  } else {
42  $modifier_types = array(1, 2, 3, 4, 5, 6);
43  }
44  foreach ($modifier_types as $type) {
45  switch ($type) {
46  case 1:
47  // registered modifier
48  if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
49  $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
50  if (!is_array($function)) {
51  $output = "{$function}({$params})";
52  } else {
53  if (is_object($function[0])) {
54  $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
55  } else {
56  $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
57  }
58  }
59  $compiler->known_modifier_type[$modifier] = $type;
60  break 2;
61  }
62  break;
63  case 2:
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;
68  break 2;
69  }
70  break;
71  case 3:
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);
78  }
79  $compiler->known_modifier_type[$modifier] = $type;
80  break 2;
81  }
82  break;
83  case 4:
84  // modifier plugin
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})";
89  }
90  $compiler->known_modifier_type[$modifier] = $type;
91  break 2;
92  }
93  break;
94  case 5:
95  // PHP function
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})";
100  }
101  $compiler->known_modifier_type[$modifier] = $type;
102  break 2;
103  }
104  break;
105  case 6:
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})";
113  } else {
114  if (is_object($function[0])) {
115  $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
116  } else {
117  $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
118  }
119  }
120  }
121  if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
122  // was a plugin
123  $compiler->known_modifier_type[$modifier] = 4;
124  } else {
125  $compiler->known_modifier_type[$modifier] = $type;
126  }
127  break 2;
128  }
129  }
130  }
131  if (!isset($compiler->known_modifier_type[$modifier])) {
132  $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
133  }
134  }
135  return $output;
136  }
137 
138 }
139 
140 ?>
getAttributes($compiler, $attributes)
This function checks if the attributes passed are valid.
const PLUGIN_MODIFIER
compile($args, $compiler, $parameter)
Compiles code for modifier execution.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:17 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.