3 * Smarty Internal Plugin Function Call Handler
6 * @subpackage PluginsInternal
11 * This class does call function defined with the {function} tag
13 class Smarty_Internal_Function_Call_Handler extends Smarty_Internal_Template {
14 static function call ($_name, $_template, $_params, $_hash, $_nocache)
17 $_function = "smarty_template_function_{$_name}_nocache";
18 $_template->smarty->template_functions[$_name]['called_nocache'] = true;
20 $_function = "smarty_template_function_{$_hash}_{$_name}";
22 if (!is_callable($_function)) {
23 $_code = "function {$_function}(\$_smarty_tpl,\$params) {
24 \$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
25 foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(trim(\$value,'\''));};
26 foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
28 $_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",
29 "!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']);
31 $_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']);
33 $_code .= "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}";
36 $_function($_template, $_params);