Code

Updated smarty to 3.0.8
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_function_call_handler.php
1 <?php\r
2 /**\r
3  * Smarty Internal Plugin Function Call Handler\r
4  *\r
5  * @package Smarty\r
6  * @subpackage PluginsInternal\r
7  * @author Uwe Tews\r
8  */\r
9 \r
10 /**\r
11  * This class does call function defined with the {function} tag\r
12  */\r
13 class Smarty_Internal_Function_Call_Handler extends Smarty_Internal_Template {\r
14     static function call ($_name, $_template, $_params, $_hash, $_nocache)\r
15     {\r
16         if ($_nocache) {\r
17             $_function = "smarty_template_function_{$_name}_nocache";\r
18             $_template->smarty->template_functions[$_name]['called_nocache'] = true;\r
19         } else {\r
20             $_function = "smarty_template_function_{$_hash}_{$_name}";\r
21         }\r
22         if (!is_callable($_function)) {\r
23             $_code = "function {$_function}(\$_smarty_tpl,\$params) {\r
24     \$saved_tpl_vars = \$_smarty_tpl->tpl_vars;\r
25     foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};\r
26     foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";\r
27             if ($_nocache) {\r
28                 $_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",\r
29                         "!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']);\r
30             } else {\r
31                 $_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']);\r
32             }\r
33             $_code .= "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}";\r
34             eval($_code);\r
35         }\r
36         $_function($_template, $_params);\r
37     }\r
38 }\r
39 \r
40 ?>