К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | |||
3 | /** |
||
4 | * Smarty Internal Plugin Resource Stream |
||
5 | * |
||
6 | * Implements the streams as resource for Smarty template |
||
7 | * |
||
8 | * @package Smarty |
||
9 | * @subpackage TemplateResources |
||
10 | * @author Uwe Tews |
||
11 | */ |
||
12 | /** |
||
13 | * Smarty Internal Plugin Resource Stream |
||
14 | */ |
||
15 | |||
16 | class Smarty_Internal_Resource_Stream { |
||
17 | public function __construct($smarty) |
||
18 | { |
||
19 | $this->smarty = $smarty; |
||
20 | } |
||
21 | // classes used for compiling Smarty templates from file resource |
||
22 | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
||
23 | public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
||
24 | public $template_parser_class = 'Smarty_Internal_Templateparser'; |
||
25 | |||
26 | /** |
||
27 | * Return flag if template source is existing |
||
28 | * |
||
29 | * @return boolean true |
||
30 | */ |
||
31 | public function isExisting($template) |
||
32 | { |
||
33 | if ($template->getTemplateSource() == '') { |
||
34 | return false; |
||
35 | } else { |
||
36 | return true; |
||
37 | } |
||
38 | } |
||
39 | /** |
||
40 | * Get filepath to template source |
||
41 | * |
||
42 | * @param object $_template template object |
||
43 | * @return string return 'string' as template source is not a file |
||
44 | */ |
||
45 | public function getTemplateFilepath($_template) |
||
46 | { |
||
47 | // no filepath for strings |
||
48 | // return resource name for compiler error messages |
||
49 | return str_replace(':', '://', $_template->template_resource); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get timestamp to template source |
||
54 | * |
||
55 | * @param object $_template template object |
||
56 | * @return boolean false as string resources have no timestamp |
||
57 | */ |
||
58 | public function getTemplateTimestamp($_template) |
||
59 | { |
||
60 | // strings must always be compiled and have no timestamp |
||
61 | return false; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Retuen template source from resource name |
||
66 | * |
||
67 | * @param object $_template template object |
||
68 | * @return string content of template source |
||
69 | */ |
||
70 | public function getTemplateSource($_template) |
||
71 | { |
||
72 | // return template string |
||
73 | $_template->template_source = ''; |
||
74 | $fp = fopen(str_replace(':', '://', $_template->template_resource),'r+'); |
||
75 | while (!feof($fp)) { |
||
76 | $_template->template_source .= fgets($fp); |
||
77 | } |
||
78 | fclose($fp); |
||
79 | |||
80 | return true; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Return flag that this resource uses the compiler |
||
85 | * |
||
86 | * @return boolean true |
||
87 | */ |
||
88 | public function usesCompiler() |
||
89 | { |
||
90 | // resource string is template, needs compiler |
||
91 | return true; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Return flag that this resource is evaluated |
||
96 | * |
||
97 | * @return boolean true |
||
98 | */ |
||
99 | public function isEvaluated() |
||
100 | { |
||
101 | // compiled template is evaluated instead of saved to disk |
||
102 | return true; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * Get filepath to compiled template |
||
107 | * |
||
108 | * @param object $_template template object |
||
109 | * @return boolean return false as compiled template is not stored |
||
110 | */ |
||
111 | public function getCompiledFilepath($_template) |
||
112 | { |
||
113 | // no filepath for strings |
||
114 | return false; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | ?> |