Code

Removed smarty packages from references
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_modifier.php
index c4fbfa5e2b3fcaf2531d4232c18c354ec705e2d1..ca4d90774f526ca75f9932331db21849de2da514 100644 (file)
@@ -1,59 +1,81 @@
 <?php\r
+\r
 /**\r
-* Smarty Internal Plugin Compile Modifier\r
-* \r
-* Compiles code for modifier execution\r
-* \r
-* @package Smarty\r
-* @subpackage Compiler\r
-* @author Uwe Tews \r
-*/\r
+ * Smarty Internal Plugin Compile Modifier\r
+ *\r
+ * Compiles code for modifier execution\r
+ *\r
+ * @package Smarty\r
+ * @subpackage Compiler\r
+ * @author Uwe Tews\r
+ */\r
+\r
 /**\r
-* Smarty Internal Plugin Compile Modifier Class\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
-    * @return string compiled code\r
-    */\r
-    public function compile($args, $compiler)\r
+     * Compiles code for modifier execution\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, $parameter)\r
     {\r
-        $this->compiler = $compiler;\r
-        $this->smarty = $this->compiler->smarty;\r
-        $this->required_attributes = array('modifier', 'params'); \r
         // check and get attributes\r
-        $_attr = $this->_get_attributes($args); \r
-        // check for registered modifier\r
-        if (isset($compiler->smarty->registered_plugins['modifier'][$_attr['modifier']])) {\r
-            $function = $compiler->smarty->registered_plugins['modifier'][$_attr['modifier']][0];\r
-            if (!is_array($function)) {\r
-                $output = "{$function}({$_attr['params']})";\r
-            } else if (is_object($function[0])) {\r
-                $output = 'call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $_attr['modifier'] . '\'][0],array(' . $_attr['params'] . '))';\r
+        $_attr = $this->getAttributes($compiler, $args);\r
+        $output = $parameter['value'];\r
+        // loop over list of modifiers\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[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[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';\r
+                    } else {\r
+                        $output = $function[0] . '::' . $function[1] . '(' . $params . ')';\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
+                // 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 = $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 (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {\r
+                    $output = "{$modifier}({$params})";\r
+                }\r
             } else {\r
-                $output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';\r
-            } \r
-        // check for plugin modifier\r
-        } else if ($function = $this->compiler->getPlugin($_attr['modifier'], 'modifier')) {\r
-            if (!is_array($function)) {\r
-                $output = "{$function}({$_attr['params']})";\r
-            } else {\r
-                $output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';\r
-            } \r
-            // check if trusted PHP function\r
-        } else if (is_callable($_attr['modifier'])) {\r
-            // check if modifier allowed\r
-            if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($_attr['modifier'], $this->compiler)) {\r
-                $output = "{$_attr['modifier']}({$_attr['params']})";\r
-            } \r
-        } else {\r
-            $this->compiler->trigger_template_error ("unknown modifier \"" . $_attr['modifier'] . "\"");\r
-        } \r
+                $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);\r
+            }\r
+        }\r
         return $output;\r
-    } \r
-} \r
+    }\r
+\r
+}\r
 \r
-?>\r
+?>
\ No newline at end of file