Code

Updated smarty
[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  * Smarty Internal Plugin Compile Registered Function Class\r
13  */\r
14 class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {\r
15     /**\r
16      * Compiles code for the execution of a registered function\r
17      * \r
18      * @param array $args array with attributes from parser\r
19      * @param string $tag name of function\r
20      * @param object $compiler compiler object\r
21      * @return string compiled code\r
22      */\r
23     public function compile($args, $compiler, $tag)\r
24     {\r
25         $this->compiler = $compiler; \r
26         // This tag does create output\r
27         $this->compiler->has_output = true;\r
28 \r
29         $this->required_attributes = array();\r
30         $this->optional_attributes = array('_any'); \r
31         // check and get attributes\r
32         $_attr = $this->_get_attributes($args); \r
33         // not cachable?\r
34         $this->compiler->tag_nocache = !$compiler->smarty->registered_plugins['function'][$tag][1]; \r
35         // convert attributes into parameter array string\r
36         $_paramsArray = array();\r
37         foreach ($_attr as $_key => $_value) {\r
38             if (is_int($_key)) {\r
39                 $_paramsArray[] = "$_key=>$_value";\r
40             } else {\r
41                 $_paramsArray[] = "'$_key'=>$_value";\r
42             } \r
43         } \r
44         $_params = 'array(' . implode(",", $_paramsArray) . ')'; \r
45         // compile code\r
46         $function = $compiler->smarty->registered_plugins['function'][$tag][0]; \r
47         // compile code\r
48         if (!is_array($function)) {\r
49             $output = "<?php echo {$function}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";\r
50         } else if (is_object($function[0])) {\r
51             $output = "<?php echo call_user_func(\$_smarty_tpl->smarty->registered_plugins['function']['{$tag}'][0],{$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";\r
52         } else {\r
53             $output = "<?php echo call_user_func(array('{$function[0]}','{$function[1]}'),{$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";\r
54         } \r
55         return $output;\r
56     } \r
57\r
58 \r
59 ?>