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