Code

Readded smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_modifier.php
diff --git a/gosa-core/include/smarty/sysplugins/smarty_internal_compile_private_modifier.php b/gosa-core/include/smarty/sysplugins/smarty_internal_compile_private_modifier.php
new file mode 100644 (file)
index 0000000..ca4d907
--- /dev/null
@@ -0,0 +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
+\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
+     * @param array  $parameter array with compilation parameter\r
+     * @return string compiled code\r
+     */\r
+    public function compile($args, $compiler, $parameter)\r
+    {\r
+        // check and get attributes\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
+                $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);\r
+            }\r
+        }\r
+        return $output;\r
+    }\r
+\r
+}\r
+\r
+?>
\ No newline at end of file