Code

Updated smarty to recent 3.0.8
[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 class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {\r
16         // attribute definitions\r
17     public $optional_attributes = array('_any'); \r
18 \r
19     /**\r
20      * Compiles code for the execution of a registered function\r
21      * \r
22      * @param array $args array with attributes from parser\r
23      * @param object $compiler compiler object\r
24      * @param array $parameter array with compilation parameter\r
25      * @param string $tag name of function\r
26      * @return string compiled code\r
27      */\r
28     public function compile($args, $compiler, $parameter, $tag)\r
29     {\r
30         $this->compiler = $compiler; \r
31         // This tag does create output\r
32         $this->compiler->has_output = true;\r
33         // check and get attributes\r
34         $_attr = $this->_get_attributes($args); \r
35         if ($_attr['nocache']) {\r
36             $this->compiler->tag_nocache = true;\r
37         }\r
38         unset($_attr['nocache']);\r
39         // not cachable?\r
40         $this->compiler->tag_nocache =  $this->compiler->tag_nocache || !$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][1]; \r
41         // convert attributes into parameter array string\r
42         $_paramsArray = array();\r
43         foreach ($_attr as $_key => $_value) {\r
44             if (is_int($_key)) {\r
45                 $_paramsArray[] = "$_key=>$_value";\r
46             } elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][2])) {\r
47                                 $_value = str_replace("'","^#^",$_value);\r
48                 $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";\r
49             } else {\r
50                 $_paramsArray[] = "'$_key'=>$_value";\r
51             } \r
52         } \r
53         $_params = 'array(' . implode(",", $_paramsArray) . ')'; \r
54         $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][0]; \r
55         // compile code\r
56         if (!is_array($function)) {\r
57             $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";\r
58         } else if (is_object($function[0])) {\r
59             $output = "<?php echo \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0][0]->{$function[1]}({$_params},\$_smarty_tpl);?>\n";\r
60         } else {\r
61             $output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";\r
62         } \r
63         return $output;\r
64     } \r
65\r
66 \r
67 ?>