1: | <?php
|
2: |
|
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: |
|
10: | class Smarty_Internal_Runtime_Make_Nocache
|
11: | {
|
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: |
|
21: | public function save(Smarty_Internal_Template $tpl, $var)
|
22: | {
|
23: | if (isset($tpl->tpl_vars[ $var ])) {
|
24: | $export =
|
25: | preg_replace('/^Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true));
|
26: | if (preg_match('/(\w+)::__set_state/', $export, $match)) {
|
27: | throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'");
|
28: | }
|
29: | echo "/*%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/<?php " .
|
30: | addcslashes("\$_smarty_tpl->smarty->ext->_make_nocache->store(\$_smarty_tpl, '{$var}', ", '\\') .
|
31: | $export . ");?>\n/*/%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/";
|
32: | }
|
33: | }
|
34: |
|
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: |
|
42: | public function store(Smarty_Internal_Template $tpl, $var, $properties)
|
43: | {
|
44: |
|
45: | if (!isset($tpl->tpl_vars[ $var ]) || !$tpl->tpl_vars[ $var ]->nocache) {
|
46: | $newVar = new Smarty_Variable();
|
47: | unset($properties[ 'nocache' ]);
|
48: | foreach ($properties as $k => $v) {
|
49: | $newVar->$k = $v;
|
50: | }
|
51: | $tpl->tpl_vars[ $var ] = $newVar;
|
52: | }
|
53: | }
|
54: | }
|
55: | |