Code

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