Initial repo created
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_nocache_insert.php
1 <?php
2
3 /**
4  * Smarty Internal Plugin Nocache Insert
5  * 
6  * Compiles the {insert} tag into the cache file
7  * 
8  * @package Smarty
9  * @subpackage Compiler
10  * @author Uwe Tews 
11  */
12
13 /**
14  * Smarty Internal Plugin Compile Insert Class
15  */
16 class Smarty_Internal_Nocache_Insert {
17     /**
18      * Compiles code for the {insert} tag into cache file
19      * 
20      * @param string $_function insert function name
21      * @param array $_attr array with paramter
22      * @param object $template template object
23      * @param string $_script script name to load or 'null'
24      * @param string $_assign soptinal variable name
25      * @return string compiled code
26      */
27     static function compile($_function, $_attr, $_template, $_script, $_assign = null)
28     {
29         $_output = '<?php ';
30         if ($_script != 'null') {
31             // script which must be included
32             // code for script file loading
33             $_output .= "require_once '{$_script}';";
34         } 
35         // call insert
36         if (isset($_assign)) {
37             $_output .= "\$_smarty_tpl->assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl), true);?>";
38         } else {
39             $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
40         } 
41         $_tpl = $_template;
42         while ($_tpl->parent instanceof Smarty_Internal_Template) {
43             $_tpl = $_tpl->parent;
44         } 
45         return "/*%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/";
46     } 
47
48
49 ?>