PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_function_call_handler.php

http://zoop.googlecode.com/
PHP | 47 lines | 35 code | 0 blank | 12 comment | 3 complexity | 99674c24e5c80e2218c8cc671cf8154f MD5 | raw file
 1<?php
 2/**
 3* Smarty Internal Plugin Function Call Handler
 4* 
 5* @package Smarty
 6* @subpackage PluginsInternal
 7* @author Uwe Tews 
 8*/
 9/**
10* This class does call function defined with the {function} tag
11*/
12class Smarty_Internal_Function_Call_Handler extends Smarty_Internal_Template {
13    function __construct($name, $smarty, $parent, $nocache)
14    {
15        parent::__construct('string:', $smarty, $parent);
16        if (!isset($this->smarty->template_functions[$name])) {
17            throw new Exception("Call to undefined template function \"{$name}\" in template \"{$parent->template_resource}\"");
18        } 
19        $this->called_nocache = $nocache;
20        $this->mustCompile = false;
21        if ($nocache) {
22            $smarty->template_functions[$name]['called_nocache'] = true;
23            $this->properties['function'][$name]['called_nocache'] = true;
24        } 
25        $this->properties['nocache_hash'] = $smarty->template_functions[$name]['nocache_hash']; 
26        // load compiled function
27        if ($nocache) {
28            // if called in nocache mode convert nocache code to real code
29            $this->compiled_template = preg_replace(array("!(<\?php echo ')?/\*/?%%SmartyNocache:{$this->smarty->template_functions[$name]['nocache_hash']}%%\*/(';\?>)?!", "!\\\'!"), array('', "'"), $smarty->template_functions[$name]['compiled']);
30        } else {
31            $this->compiled_template = $smarty->template_functions[$name]['compiled'];
32        } 
33        // assign default paramter
34        if (isset($smarty->template_functions[$name]['parameter'])) {
35            $_smarty_tpl = $this;
36            foreach ($smarty->template_functions[$name]['parameter'] as $_key => $_value) {
37                $this->assign($_key, eval("return {$_value};"));
38            } 
39        } 
40        // set flag if {function} contains nocache code
41        if ($smarty->template_functions[$name]['has_nocache_code']) {
42            $this->has_nocache_code = true;
43        } 
44    } 
45} 
46
47?>