3  * Smarty Internal Plugin Compile Modifier
 
   5  * Compiles code for modifier execution
 
  13  * Smarty Internal Plugin Compile Modifier Class
 
  15 class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {
 
  17      * Compiles code for modifier execution
 
  19      * @param array $args array with attributes from parser
 
  20      * @param object $compiler compiler object
 
  21      * @param array $parameter array with compilation parameter
 
  22      * @return string compiled code
 
  24     public function compile($args, $compiler, $parameter)
 
  26         $this->compiler = $compiler;
 
  27         $this->smarty = $this->compiler->smarty;
 
  28         // check and get attributes
 
  29         $_attr = $this->_get_attributes($args);
 
  30         $output = $parameter['value']; 
 
  31         // loop over list of modifiers
 
  32         foreach ($parameter['modifierlist'] as $single_modifier) {
 
  33             $modifier = $single_modifier[0];
 
  34            $single_modifier[0] = $output;
 
  35             $params = implode(',', $single_modifier); 
 
  36             // check for registered modifier
 
  37             if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
 
  38                 $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
 
  39                 if (!is_array($function)) {
 
  40                     $output = "{$function}({$params})";
 
  42                     if (is_object($function[0])) {
 
  43                         $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
 
  45                         $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
 
  48                 // check for plugin modifiercompiler
 
  49             } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
 
  50                 $plugin = 'smarty_modifiercompiler_' . $modifier;
 
  51                 $output = $plugin($single_modifier, $compiler); 
 
  52                 // check for plugin modifier
 
  53             } else if ($function = $this->compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
 
  54                 $output = "{$function}({$params})"; 
 
  55                 // check if trusted PHP function
 
  56             } else if (is_callable($modifier)) {
 
  57                 // check if modifier allowed
 
  58                 if (!is_object($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedModifier($modifier, $this->compiler)) {
 
  59                     $output = "{$modifier}({$params})";
 
  62                 $this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"", $this->compiler->lex->taglineno);