Code

Removed x bits
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_registered_function.php
1 <?php\r
2 /**\r
3  * Smarty Internal Plugin Compile Registered Function\r
4  *\r
5  * Compiles code for the execution of a registered function\r
6  *\r
7  * @package Smarty\r
8  * @subpackage Compiler\r
9  * @author Uwe Tews\r
10  */\r
11 \r
12 /**\r
13  * Smarty Internal Plugin Compile Registered Function Class\r
14  *\r
15  * @package Smarty\r
16  * @subpackage Compiler\r
17  */\r
18 class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {\r
19 \r
20     /**\r
21      * Attribute definition: Overwrites base class.\r
22      *\r
23      * @var array\r
24      * @see Smarty_Internal_CompileBase\r
25      */\r
26     public $optional_attributes = array('_any');\r
27 \r
28     /**\r
29      * Compiles code for the execution of a registered function\r
30      *\r
31      * @param array  $args      array with attributes from parser\r
32      * @param object $compiler  compiler object\r
33      * @param array  $parameter array with compilation parameter\r
34      * @param string $tag       name of function\r
35      * @return string compiled code\r
36      */\r
37     public function compile($args, $compiler, $parameter, $tag)\r
38     {\r
39         // This tag does create output\r
40         $compiler->has_output = true;\r
41         // check and get attributes\r
42         $_attr = $this->getAttributes($compiler, $args);\r
43         if ($_attr['nocache']) {\r
44             $compiler->tag_nocache = true;\r
45         }\r
46         unset($_attr['nocache']);\r
47                if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {\r
48                    $tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag];\r
49                } else {\r
50                    $tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag];\r
51                }\r
52         // not cachable?\r
53         $compiler->tag_nocache =  $compiler->tag_nocache || !$tag_info[1];\r
54         // convert attributes into parameter array string\r
55         $_paramsArray = array();\r
56         foreach ($_attr as $_key => $_value) {\r
57             if (is_int($_key)) {\r
58                 $_paramsArray[] = "$_key=>$_value";\r
59             } elseif ($compiler->template->caching && in_array($_key,$tag_info[2])) {\r
60                 $_value = str_replace("'","^#^",$_value);\r
61                 $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";\r
62             } else {\r
63                 $_paramsArray[] = "'$_key'=>$_value";\r
64             }\r
65         }\r
66         $_params = 'array(' . implode(",", $_paramsArray) . ')';\r
67         $function = $tag_info[0];\r
68         // compile code\r
69         if (!is_array($function)) {\r
70             $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";\r
71         } else if (is_object($function[0])) {\r
72             $output = "<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";\r
73         } else {\r
74             $output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";\r
75         }\r
76         return $output;\r
77     }\r
78 \r
79 }\r
80 \r
81 ?>