Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | |||
3 | /** |
||
4 | * Smarty Internal Plugin Cacher InlineCode |
||
5 | * |
||
6 | * Process nocached code. |
||
7 | * Version to inject nocache code directly into cache file |
||
8 | * if caching is disabled at render time the code is being evaluated |
||
9 | * |
||
10 | * @package Smarty |
||
11 | * @subpackage Cacher |
||
12 | * @author Uwe Tews |
||
13 | */ |
||
14 | |||
15 | /** |
||
16 | * Smarty Internal Plugin Cacher InlineCode Class |
||
17 | */ |
||
18 | class Smarty_Internal_Cacher_InlineCode { |
||
19 | function __construct($smarty) |
||
20 | { |
||
21 | $this->smarty = $smarty; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Inject inline code for nocache template sections |
||
26 | * |
||
27 | * This method gets the content of each template element from the parser. |
||
28 | * If the content is compiled code and it should be not cached the code is injected |
||
29 | * into the rendered output. |
||
30 | * |
||
31 | * @param string $content content of template element |
||
32 | * @param object $compiler intance of compiler class |
||
33 | * @param boolean $tag_nocache true if the parser detected a nocache situation |
||
34 | * @param boolean $is_code true if content is compiled code |
||
35 | * @return string content |
||
36 | */ |
||
37 | public function processNocacheCode ($content, $compiler, $tag_nocache, $is_code) |
||
38 | { |
||
39 | // If the template is not evaluated and we have a nocache section and or a nocache tag |
||
40 | if ($is_code) { |
||
41 | // generate replacement code |
||
42 | if (!$compiler->template->isEvaluated() && $compiler->template->caching && |
||
43 | ($tag_nocache || $compiler->nocache || $compiler->tag_nocache)) { |
||
44 | $compiler->tag_nocache = false; |
||
45 | $_output = str_replace("'", "\'", $content); |
||
46 | $_output = '<?php echo \'' . $_output . '\';?>'; |
||
47 | } else { |
||
48 | $_output = $content; |
||
49 | } |
||
50 | } else { |
||
51 | $_output = $content; |
||
52 | } |
||
53 | // if compiled code shall be grabbed |
||
54 | if ($compiler->template->extract_code == false) { |
||
55 | // return output |
||
56 | return $_output; |
||
57 | } else { |
||
58 | // store code in extract buffer |
||
59 | $compiler->template->extracted_compiled_code .= $_output; |
||
60 | return ''; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Initialize cacher |
||
66 | * |
||
67 | * Is a noop in current implementation |
||
68 | * |
||
69 | * @param object $compiler intance of compiler class |
||
70 | */ |
||
71 | public function initCacher ($compiler) |
||
72 | { |
||
73 | return; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Close cacher |
||
78 | * |
||
79 | * Hook to perform any post processing on the final compiled template |
||
80 | * Is a noop in current implementation |
||
81 | * |
||
82 | * @param object $compiler intance of compiler class |
||
83 | * @param string $template_code complete compiled template |
||
84 | * @return string compiled template output |
||
85 | */ |
||
86 | public function closeCacher ($compiler, $template_code) |
||
87 | { |
||
88 | return $template_code; |
||
89 | } |
||
90 | |||
91 | } |
||
92 | |||
93 | ?> |