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 * This class does call function defined with the {function} tag\r
11 */\r
12 class Smarty_Internal_Function_Call_Handler extends Smarty_Internal_Template {\r
13 function __construct($name, $smarty, $parent, $nocache)\r
14 {\r
15 parent::__construct('string:', $smarty, $parent);\r
16 if (!isset($this->smarty->template_functions[$name])) {\r
17 throw new Exception("Call to undefined template function \"{$name}\" in template \"{$parent->template_resource}\"");\r
18 } \r
19 $this->called_nocache = $nocache;\r
20 $this->mustCompile = false;\r
21 if ($nocache) {\r
22 $smarty->template_functions[$name]['called_nocache'] = true;\r
23 $this->properties['function'][$name]['called_nocache'] = true;\r
24 } \r
25 $this->properties['nocache_hash'] = $smarty->template_functions[$name]['nocache_hash']; \r
26 // load compiled function\r
27 if ($nocache) {\r
28 // if called in nocache mode convert nocache code to real code\r
29 $this->compiled_template = preg_replace(array("!(<\?php echo ')?/\*/?%%SmartyNocache:{$this->smarty->template_functions[$name]['nocache_hash']}%%\*/(';\?>)?!", "!\\\'!"), array('', "'"), $smarty->template_functions[$name]['compiled']);\r
30 } else {\r
31 $this->compiled_template = $smarty->template_functions[$name]['compiled'];\r
32 } \r
33 // assign default paramter\r
34 if (isset($smarty->template_functions[$name]['parameter'])) {\r
35 $_smarty_tpl = $this;\r
36 foreach ($smarty->template_functions[$name]['parameter'] as $_key => $_value) {\r
37 $this->assign($_key, eval("return {$_value};"));\r
38 } \r
39 } \r
40 // set flag if {function} contains nocache code\r
41 if ($smarty->template_functions[$name]['has_nocache_code']) {\r
42 $this->has_nocache_code = true;\r
43 } \r
44 } \r
45 } \r
46 \r
47 ?>\r