1 |
cvsjoko |
1.1 |
<?php |
2 |
joko |
1.3 |
|
3 |
|
|
/** |
4 |
cvsjoko |
1.1 |
* Project: Smarty: the PHP compiling template engine |
5 |
|
|
* File: Smarty.class.php |
6 |
|
|
* |
7 |
|
|
* This library is free software; you can redistribute it and/or |
8 |
|
|
* modify it under the terms of the GNU Lesser General Public |
9 |
|
|
* License as published by the Free Software Foundation; either |
10 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This library is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
|
|
* Lesser General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU Lesser General Public |
18 |
|
|
* License along with this library; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
|
|
* |
21 |
|
|
* For questions, help, comments, discussion, etc., please join the |
22 |
|
|
* Smarty mailing list. Send a blank e-mail to |
23 |
|
|
* smarty-general-subscribe@lists.php.net |
24 |
|
|
* |
25 |
joko |
1.3 |
* @link http://smarty.php.net/ |
26 |
|
|
* @copyright 2001-2004 ispi of Lincoln, Inc. |
27 |
|
|
* @author Monte Ohrt <monte@ispi.net> |
28 |
|
|
* @author Andrei Zmievski <andrei@php.net> |
29 |
|
|
* @package Smarty |
30 |
|
|
* @version 2.6.3 |
31 |
cvsjoko |
1.1 |
*/ |
32 |
|
|
|
33 |
joko |
1.3 |
/* $Id: Smarty.class.php,v 1.490 2004/06/08 10:48:50 messju Exp $ */ |
34 |
cvsjoko |
1.1 |
|
35 |
joko |
1.3 |
/** |
36 |
|
|
* DIR_SEP isn't used anymore, but third party apps might |
37 |
|
|
*/ |
38 |
|
|
if(!defined('DIR_SEP')) { |
39 |
|
|
define('DIR_SEP', DIRECTORY_SEPARATOR); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* set SMARTY_DIR to absolute path to Smarty library files. |
44 |
|
|
* if not defined, include_path will be used. Sets SMARTY_DIR only if user |
45 |
|
|
* application has not already defined it. |
46 |
|
|
*/ |
47 |
cvsjoko |
1.1 |
|
48 |
|
|
if (!defined('SMARTY_DIR')) { |
49 |
joko |
1.3 |
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); |
50 |
cvsjoko |
1.1 |
} |
51 |
|
|
|
52 |
|
|
define('SMARTY_PHP_PASSTHRU', 0); |
53 |
|
|
define('SMARTY_PHP_QUOTE', 1); |
54 |
|
|
define('SMARTY_PHP_REMOVE', 2); |
55 |
|
|
define('SMARTY_PHP_ALLOW', 3); |
56 |
|
|
|
57 |
joko |
1.3 |
/** |
58 |
|
|
* @package Smarty |
59 |
|
|
*/ |
60 |
cvsjoko |
1.1 |
class Smarty |
61 |
|
|
{ |
62 |
joko |
1.3 |
/**#@+ |
63 |
|
|
* Smarty Configuration Section |
64 |
|
|
*/ |
65 |
|
|
|
66 |
|
|
/** |
67 |
|
|
* The name of the directory where templates are located. |
68 |
|
|
* |
69 |
|
|
* @var string |
70 |
|
|
*/ |
71 |
|
|
var $template_dir = 'templates'; |
72 |
|
|
|
73 |
|
|
/** |
74 |
|
|
* The directory where compiled templates are located. |
75 |
|
|
* |
76 |
|
|
* @var string |
77 |
|
|
*/ |
78 |
|
|
var $compile_dir = 'templates_c'; |
79 |
|
|
|
80 |
|
|
/** |
81 |
|
|
* The directory where config files are located. |
82 |
|
|
* |
83 |
|
|
* @var string |
84 |
|
|
*/ |
85 |
|
|
var $config_dir = 'configs'; |
86 |
|
|
|
87 |
|
|
/** |
88 |
|
|
* An array of directories searched for plugins. |
89 |
|
|
* |
90 |
|
|
* @var array |
91 |
|
|
*/ |
92 |
|
|
var $plugins_dir = array('plugins'); |
93 |
|
|
|
94 |
|
|
/** |
95 |
|
|
* If debugging is enabled, a debug console window will display |
96 |
|
|
* when the page loads (make sure your browser allows unrequested |
97 |
|
|
* popup windows) |
98 |
|
|
* |
99 |
|
|
* @var boolean |
100 |
|
|
*/ |
101 |
|
|
var $debugging = false; |
102 |
|
|
|
103 |
|
|
/** |
104 |
|
|
* When set, smarty does uses this value as error_reporting-level. |
105 |
|
|
* |
106 |
|
|
* @var boolean |
107 |
|
|
*/ |
108 |
|
|
var $error_reporting = null; |
109 |
|
|
|
110 |
|
|
/** |
111 |
|
|
* This is the path to the debug console template. If not set, |
112 |
|
|
* the default one will be used. |
113 |
|
|
* |
114 |
|
|
* @var string |
115 |
|
|
*/ |
116 |
|
|
var $debug_tpl = ''; |
117 |
|
|
|
118 |
|
|
/** |
119 |
|
|
* This determines if debugging is enable-able from the browser. |
120 |
|
|
* <ul> |
121 |
|
|
* <li>NONE => no debugging control allowed</li> |
122 |
|
|
* <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li> |
123 |
|
|
* </ul> |
124 |
|
|
* @link http://www.foo.dom/index.php?SMARTY_DEBUG |
125 |
|
|
* @var string |
126 |
|
|
*/ |
127 |
|
|
var $debugging_ctrl = 'NONE'; |
128 |
|
|
|
129 |
|
|
/** |
130 |
|
|
* This tells Smarty whether to check for recompiling or not. Recompiling |
131 |
|
|
* does not need to happen unless a template or config file is changed. |
132 |
|
|
* Typically you enable this during development, and disable for |
133 |
|
|
* production. |
134 |
|
|
* |
135 |
|
|
* @var boolean |
136 |
|
|
*/ |
137 |
|
|
var $compile_check = true; |
138 |
|
|
|
139 |
|
|
/** |
140 |
|
|
* This forces templates to compile every time. Useful for development |
141 |
|
|
* or debugging. |
142 |
|
|
* |
143 |
|
|
* @var boolean |
144 |
|
|
*/ |
145 |
|
|
var $force_compile = false; |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
* This enables template caching. |
149 |
|
|
* <ul> |
150 |
|
|
* <li>0 = no caching</li> |
151 |
|
|
* <li>1 = use class cache_lifetime value</li> |
152 |
|
|
* <li>2 = use cache_lifetime in cache file</li> |
153 |
|
|
* </ul> |
154 |
|
|
* @var integer |
155 |
|
|
*/ |
156 |
|
|
var $caching = 0; |
157 |
|
|
|
158 |
|
|
/** |
159 |
|
|
* The name of the directory for cache files. |
160 |
|
|
* |
161 |
|
|
* @var string |
162 |
|
|
*/ |
163 |
|
|
var $cache_dir = 'cache'; |
164 |
|
|
|
165 |
|
|
/** |
166 |
|
|
* This is the number of seconds cached content will persist. |
167 |
|
|
* <ul> |
168 |
|
|
* <li>0 = always regenerate cache</li> |
169 |
|
|
* <li>-1 = never expires</li> |
170 |
|
|
* </ul> |
171 |
|
|
* |
172 |
|
|
* @var integer |
173 |
|
|
*/ |
174 |
|
|
var $cache_lifetime = 3600; |
175 |
|
|
|
176 |
|
|
/** |
177 |
|
|
* Only used when $caching is enabled. If true, then If-Modified-Since headers |
178 |
|
|
* are respected with cached content, and appropriate HTTP headers are sent. |
179 |
|
|
* This way repeated hits to a cached page do not send the entire page to the |
180 |
|
|
* client every time. |
181 |
|
|
* |
182 |
|
|
* @var boolean |
183 |
|
|
*/ |
184 |
|
|
var $cache_modified_check = false; |
185 |
|
|
|
186 |
|
|
/** |
187 |
|
|
* This determines how Smarty handles "<?php ... ?>" tags in templates. |
188 |
|
|
* possible values: |
189 |
|
|
* <ul> |
190 |
|
|
* <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li> |
191 |
|
|
* <li>SMARTY_PHP_QUOTE -> escape tags as entities</li> |
192 |
|
|
* <li>SMARTY_PHP_REMOVE -> remove php tags</li> |
193 |
|
|
* <li>SMARTY_PHP_ALLOW -> execute php tags</li> |
194 |
|
|
* </ul> |
195 |
|
|
* |
196 |
|
|
* @var integer |
197 |
|
|
*/ |
198 |
cvsjoko |
1.1 |
var $php_handling = SMARTY_PHP_PASSTHRU; |
199 |
|
|
|
200 |
joko |
1.3 |
/** |
201 |
|
|
* This enables template security. When enabled, many things are restricted |
202 |
|
|
* in the templates that normally would go unchecked. This is useful when |
203 |
|
|
* untrusted parties are editing templates and you want a reasonable level |
204 |
|
|
* of security. (no direct execution of PHP in templates for example) |
205 |
|
|
* |
206 |
|
|
* @var boolean |
207 |
|
|
*/ |
208 |
|
|
var $security = false; |
209 |
|
|
|
210 |
|
|
/** |
211 |
|
|
* This is the list of template directories that are considered secure. This |
212 |
|
|
* is used only if {@link $security} is enabled. One directory per array |
213 |
|
|
* element. {@link $template_dir} is in this list implicitly. |
214 |
|
|
* |
215 |
|
|
* @var array |
216 |
|
|
*/ |
217 |
|
|
var $secure_dir = array(); |
218 |
|
|
|
219 |
|
|
/** |
220 |
|
|
* These are the security settings for Smarty. They are used only when |
221 |
|
|
* {@link $security} is enabled. |
222 |
|
|
* |
223 |
|
|
* @var array |
224 |
|
|
*/ |
225 |
cvsjoko |
1.1 |
var $security_settings = array( |
226 |
|
|
'PHP_HANDLING' => false, |
227 |
|
|
'IF_FUNCS' => array('array', 'list', |
228 |
|
|
'isset', 'empty', |
229 |
|
|
'count', 'sizeof', |
230 |
joko |
1.3 |
'in_array', 'is_array', |
231 |
|
|
'true','false'), |
232 |
cvsjoko |
1.1 |
'INCLUDE_ANY' => false, |
233 |
|
|
'PHP_TAGS' => false, |
234 |
|
|
'MODIFIER_FUNCS' => array('count') |
235 |
|
|
); |
236 |
|
|
|
237 |
joko |
1.3 |
/** |
238 |
|
|
* This is an array of directories where trusted php scripts reside. |
239 |
|
|
* {@link $security} is disabled during their inclusion/execution. |
240 |
|
|
* |
241 |
|
|
* @var array |
242 |
|
|
*/ |
243 |
|
|
var $trusted_dir = array(); |
244 |
|
|
|
245 |
|
|
/** |
246 |
|
|
* The left delimiter used for the template tags. |
247 |
|
|
* |
248 |
|
|
* @var string |
249 |
|
|
*/ |
250 |
|
|
var $left_delimiter = '{'; |
251 |
|
|
|
252 |
|
|
/** |
253 |
|
|
* The right delimiter used for the template tags. |
254 |
|
|
* |
255 |
|
|
* @var string |
256 |
|
|
*/ |
257 |
cvsjoko |
1.1 |
var $right_delimiter = '}'; |
258 |
|
|
|
259 |
joko |
1.3 |
/** |
260 |
|
|
* The order in which request variables are registered, similar to |
261 |
|
|
* variables_order in php.ini E = Environment, G = GET, P = POST, |
262 |
|
|
* C = Cookies, S = Server |
263 |
|
|
* |
264 |
|
|
* @var string |
265 |
|
|
*/ |
266 |
|
|
var $request_vars_order = "EGPCS"; |
267 |
|
|
|
268 |
|
|
/** |
269 |
|
|
* Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) |
270 |
|
|
* are uses as request-vars or $_*[]-vars. note: if |
271 |
|
|
* request_use_auto_globals is true, then $request_vars_order has |
272 |
|
|
* no effect, but the php-ini-value "gpc_order" |
273 |
|
|
* |
274 |
|
|
* @var boolean |
275 |
|
|
*/ |
276 |
|
|
var $request_use_auto_globals = true; |
277 |
|
|
|
278 |
|
|
/** |
279 |
|
|
* Set this if you want different sets of compiled files for the same |
280 |
|
|
* templates. This is useful for things like different languages. |
281 |
|
|
* Instead of creating separate sets of templates per language, you |
282 |
|
|
* set different compile_ids like 'en' and 'de'. |
283 |
|
|
* |
284 |
|
|
* @var string |
285 |
|
|
*/ |
286 |
|
|
var $compile_id = null; |
287 |
|
|
|
288 |
|
|
/** |
289 |
|
|
* This tells Smarty whether or not to use sub dirs in the cache/ and |
290 |
|
|
* templates_c/ directories. sub directories better organized, but |
291 |
|
|
* may not work well with PHP safe mode enabled. |
292 |
|
|
* |
293 |
|
|
* @var boolean |
294 |
|
|
* |
295 |
|
|
*/ |
296 |
|
|
var $use_sub_dirs = false; |
297 |
|
|
|
298 |
|
|
/** |
299 |
|
|
* This is a list of the modifiers to apply to all template variables. |
300 |
|
|
* Put each modifier in a separate array element in the order you want |
301 |
|
|
* them applied. example: <code>array('escape:"htmlall"');</code> |
302 |
|
|
* |
303 |
|
|
* @var array |
304 |
|
|
*/ |
305 |
|
|
var $default_modifiers = array(); |
306 |
|
|
|
307 |
|
|
/** |
308 |
|
|
* This is the resource type to be used when not specified |
309 |
|
|
* at the beginning of the resource path. examples: |
310 |
|
|
* $smarty->display('file:index.tpl'); |
311 |
|
|
* $smarty->display('db:index.tpl'); |
312 |
|
|
* $smarty->display('index.tpl'); // will use default resource type |
313 |
|
|
* {include file="file:index.tpl"} |
314 |
|
|
* {include file="db:index.tpl"} |
315 |
|
|
* {include file="index.tpl"} {* will use default resource type *} |
316 |
|
|
* |
317 |
|
|
* @var array |
318 |
|
|
*/ |
319 |
|
|
var $default_resource_type = 'file'; |
320 |
|
|
|
321 |
|
|
/** |
322 |
|
|
* The function used for cache file handling. If not set, built-in caching is used. |
323 |
|
|
* |
324 |
|
|
* @var null|string function name |
325 |
|
|
*/ |
326 |
|
|
var $cache_handler_func = null; |
327 |
|
|
|
328 |
|
|
/** |
329 |
|
|
* This indicates which filters are automatically loaded into Smarty. |
330 |
|
|
* |
331 |
|
|
* @var array array of filter names |
332 |
|
|
*/ |
333 |
|
|
var $autoload_filters = array(); |
334 |
|
|
|
335 |
|
|
/**#@+ |
336 |
|
|
* @var boolean |
337 |
|
|
*/ |
338 |
|
|
/** |
339 |
|
|
* This tells if config file vars of the same name overwrite each other or not. |
340 |
|
|
* if disabled, same name variables are accumulated in an array. |
341 |
|
|
*/ |
342 |
|
|
var $config_overwrite = true; |
343 |
|
|
|
344 |
|
|
/** |
345 |
|
|
* This tells whether or not to automatically booleanize config file variables. |
346 |
|
|
* If enabled, then the strings "on", "true", and "yes" are treated as boolean |
347 |
|
|
* true, and "off", "false" and "no" are treated as boolean false. |
348 |
|
|
*/ |
349 |
|
|
var $config_booleanize = true; |
350 |
|
|
|
351 |
|
|
/** |
352 |
|
|
* This tells whether hidden sections [.foobar] are readable from the |
353 |
|
|
* tempalates or not. Normally you would never allow this since that is |
354 |
|
|
* the point behind hidden sections: the application can access them, but |
355 |
|
|
* the templates cannot. |
356 |
|
|
*/ |
357 |
|
|
var $config_read_hidden = false; |
358 |
|
|
|
359 |
|
|
/** |
360 |
|
|
* This tells whether or not automatically fix newlines in config files. |
361 |
|
|
* It basically converts \r (mac) or \r\n (dos) to \n |
362 |
|
|
*/ |
363 |
|
|
var $config_fix_newlines = true; |
364 |
|
|
/**#@-*/ |
365 |
|
|
|
366 |
|
|
/** |
367 |
|
|
* If a template cannot be found, this PHP function will be executed. |
368 |
|
|
* Useful for creating templates on-the-fly or other special action. |
369 |
|
|
* |
370 |
|
|
* @var string function name |
371 |
|
|
*/ |
372 |
|
|
var $default_template_handler_func = ''; |
373 |
|
|
|
374 |
|
|
/** |
375 |
|
|
* The file that contains the compiler class. This can a full |
376 |
|
|
* pathname, or relative to the php_include path. |
377 |
|
|
* |
378 |
|
|
* @var string |
379 |
|
|
*/ |
380 |
|
|
var $compiler_file = 'Smarty_Compiler.class.php'; |
381 |
|
|
|
382 |
|
|
/** |
383 |
|
|
* The class used for compiling templates. |
384 |
|
|
* |
385 |
|
|
* @var string |
386 |
|
|
*/ |
387 |
|
|
var $compiler_class = 'Smarty_Compiler'; |
388 |
|
|
|
389 |
|
|
/** |
390 |
|
|
* The class used to load config vars. |
391 |
|
|
* |
392 |
|
|
* @var string |
393 |
|
|
*/ |
394 |
|
|
var $config_class = 'Config_File'; |
395 |
|
|
|
396 |
|
|
/**#@+ |
397 |
|
|
* END Smarty Configuration Section |
398 |
|
|
* There should be no need to touch anything below this line. |
399 |
|
|
* @access private |
400 |
|
|
*/ |
401 |
|
|
/** |
402 |
|
|
* where assigned template vars are kept |
403 |
|
|
* |
404 |
|
|
* @var array |
405 |
|
|
*/ |
406 |
|
|
var $_tpl_vars = array(); |
407 |
|
|
|
408 |
|
|
/** |
409 |
|
|
* stores run-time $smarty.* vars |
410 |
|
|
* |
411 |
|
|
* @var null|array |
412 |
|
|
*/ |
413 |
|
|
var $_smarty_vars = null; |
414 |
|
|
|
415 |
|
|
/** |
416 |
|
|
* keeps track of sections |
417 |
|
|
* |
418 |
|
|
* @var array |
419 |
|
|
*/ |
420 |
|
|
var $_sections = array(); |
421 |
|
|
|
422 |
|
|
/** |
423 |
|
|
* keeps track of foreach blocks |
424 |
|
|
* |
425 |
|
|
* @var array |
426 |
|
|
*/ |
427 |
|
|
var $_foreach = array(); |
428 |
|
|
|
429 |
|
|
/** |
430 |
|
|
* keeps track of tag hierarchy |
431 |
|
|
* |
432 |
|
|
* @var array |
433 |
|
|
*/ |
434 |
|
|
var $_tag_stack = array(); |
435 |
|
|
|
436 |
|
|
/** |
437 |
|
|
* configuration object |
438 |
|
|
* |
439 |
|
|
* @var Config_file |
440 |
|
|
*/ |
441 |
|
|
var $_conf_obj = null; |
442 |
|
|
|
443 |
|
|
/** |
444 |
|
|
* loaded configuration settings |
445 |
|
|
* |
446 |
|
|
* @var array |
447 |
|
|
*/ |
448 |
|
|
var $_config = array(array('vars' => array(), 'files' => array())); |
449 |
|
|
|
450 |
|
|
/** |
451 |
|
|
* md5 checksum of the string 'Smarty' |
452 |
|
|
* |
453 |
|
|
* @var string |
454 |
|
|
*/ |
455 |
|
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; |
456 |
|
|
|
457 |
|
|
/** |
458 |
|
|
* Smarty version number |
459 |
|
|
* |
460 |
|
|
* @var string |
461 |
|
|
*/ |
462 |
|
|
var $_version = '2.6.3'; |
463 |
|
|
|
464 |
|
|
/** |
465 |
|
|
* current template inclusion depth |
466 |
|
|
* |
467 |
|
|
* @var integer |
468 |
|
|
*/ |
469 |
|
|
var $_inclusion_depth = 0; |
470 |
|
|
|
471 |
|
|
/** |
472 |
|
|
* for different compiled templates |
473 |
|
|
* |
474 |
|
|
* @var string |
475 |
|
|
*/ |
476 |
|
|
var $_compile_id = null; |
477 |
|
|
|
478 |
|
|
/** |
479 |
|
|
* text in URL to enable debug mode |
480 |
|
|
* |
481 |
|
|
* @var string |
482 |
|
|
*/ |
483 |
|
|
var $_smarty_debug_id = 'SMARTY_DEBUG'; |
484 |
|
|
|
485 |
|
|
/** |
486 |
|
|
* debugging information for debug console |
487 |
|
|
* |
488 |
|
|
* @var array |
489 |
|
|
*/ |
490 |
|
|
var $_smarty_debug_info = array(); |
491 |
|
|
|
492 |
|
|
/** |
493 |
|
|
* info that makes up a cache file |
494 |
|
|
* |
495 |
|
|
* @var array |
496 |
|
|
*/ |
497 |
|
|
var $_cache_info = array(); |
498 |
|
|
|
499 |
|
|
/** |
500 |
|
|
* default file permissions |
501 |
|
|
* |
502 |
|
|
* @var integer |
503 |
|
|
*/ |
504 |
|
|
var $_file_perms = 0644; |
505 |
|
|
|
506 |
|
|
/** |
507 |
|
|
* default dir permissions |
508 |
|
|
* |
509 |
|
|
* @var integer |
510 |
|
|
*/ |
511 |
|
|
var $_dir_perms = 0771; |
512 |
|
|
|
513 |
|
|
/** |
514 |
|
|
* registered objects |
515 |
|
|
* |
516 |
|
|
* @var array |
517 |
|
|
*/ |
518 |
|
|
var $_reg_objects = array(); |
519 |
|
|
|
520 |
|
|
/** |
521 |
|
|
* table keeping track of plugins |
522 |
|
|
* |
523 |
|
|
* @var array |
524 |
|
|
*/ |
525 |
|
|
var $_plugins = array( |
526 |
cvsjoko |
1.1 |
'modifier' => array(), |
527 |
|
|
'function' => array(), |
528 |
|
|
'block' => array(), |
529 |
|
|
'compiler' => array(), |
530 |
|
|
'prefilter' => array(), |
531 |
|
|
'postfilter' => array(), |
532 |
|
|
'outputfilter' => array(), |
533 |
|
|
'resource' => array(), |
534 |
|
|
'insert' => array()); |
535 |
|
|
|
536 |
|
|
|
537 |
joko |
1.3 |
/** |
538 |
|
|
* cache serials |
539 |
|
|
* |
540 |
|
|
* @var array |
541 |
|
|
*/ |
542 |
|
|
var $_cache_serials = array(); |
543 |
|
|
|
544 |
|
|
/** |
545 |
|
|
* name of optional cache include file |
546 |
|
|
* |
547 |
|
|
* @var string |
548 |
|
|
*/ |
549 |
|
|
var $_cache_include = null; |
550 |
|
|
|
551 |
|
|
/** |
552 |
|
|
* indicate if the current code is used in a compiled |
553 |
|
|
* include |
554 |
|
|
* |
555 |
|
|
* @var string |
556 |
|
|
*/ |
557 |
|
|
var $_cache_including = false; |
558 |
|
|
|
559 |
|
|
/**#@-*/ |
560 |
|
|
/** |
561 |
|
|
* The class constructor. |
562 |
|
|
*/ |
563 |
cvsjoko |
1.1 |
function Smarty() |
564 |
|
|
{ |
565 |
joko |
1.3 |
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] |
566 |
|
|
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); |
567 |
cvsjoko |
1.1 |
} |
568 |
|
|
|
569 |
joko |
1.3 |
/** |
570 |
|
|
* assigns values to template variables |
571 |
|
|
* |
572 |
|
|
* @param array|string $tpl_var the template variable name(s) |
573 |
|
|
* @param mixed $value the value to assign |
574 |
|
|
*/ |
575 |
|
|
function assign($tpl_var, $value = null) |
576 |
cvsjoko |
1.1 |
{ |
577 |
|
|
if (is_array($tpl_var)){ |
578 |
|
|
foreach ($tpl_var as $key => $val) { |
579 |
joko |
1.3 |
if ($key != '') { |
580 |
cvsjoko |
1.1 |
$this->_tpl_vars[$key] = $val; |
581 |
|
|
} |
582 |
|
|
} |
583 |
|
|
} else { |
584 |
joko |
1.3 |
if ($tpl_var != '') |
585 |
cvsjoko |
1.1 |
$this->_tpl_vars[$tpl_var] = $value; |
586 |
|
|
} |
587 |
|
|
} |
588 |
|
|
|
589 |
joko |
1.3 |
/** |
590 |
|
|
* assigns values to template variables by reference |
591 |
|
|
* |
592 |
|
|
* @param string $tpl_var the template variable name |
593 |
|
|
* @param mixed $value the referenced value to assign |
594 |
|
|
*/ |
595 |
cvsjoko |
1.1 |
function assign_by_ref($tpl_var, &$value) |
596 |
|
|
{ |
597 |
joko |
1.3 |
if ($tpl_var != '') |
598 |
cvsjoko |
1.1 |
$this->_tpl_vars[$tpl_var] = &$value; |
599 |
|
|
} |
600 |
joko |
1.3 |
|
601 |
|
|
/** |
602 |
|
|
* appends values to template variables |
603 |
|
|
* |
604 |
|
|
* @param array|string $tpl_var the template variable name(s) |
605 |
|
|
* @param mixed $value the value to append |
606 |
|
|
*/ |
607 |
|
|
function append($tpl_var, $value=null, $merge=false) |
608 |
cvsjoko |
1.1 |
{ |
609 |
|
|
if (is_array($tpl_var)) { |
610 |
joko |
1.3 |
// $tpl_var is an array, ignore $value |
611 |
|
|
foreach ($tpl_var as $_key => $_val) { |
612 |
|
|
if ($_key != '') { |
613 |
|
|
if(!@is_array($this->_tpl_vars[$_key])) { |
614 |
|
|
settype($this->_tpl_vars[$_key],'array'); |
615 |
|
|
} |
616 |
|
|
if($merge && is_array($_val)) { |
617 |
|
|
foreach($_val as $_mkey => $_mval) { |
618 |
|
|
$this->_tpl_vars[$_key][$_mkey] = $_mval; |
619 |
|
|
} |
620 |
|
|
} else { |
621 |
|
|
$this->_tpl_vars[$_key][] = $_val; |
622 |
|
|
} |
623 |
cvsjoko |
1.1 |
} |
624 |
|
|
} |
625 |
|
|
} else { |
626 |
|
|
if ($tpl_var != '' && isset($value)) { |
627 |
joko |
1.3 |
if(!@is_array($this->_tpl_vars[$tpl_var])) { |
628 |
|
|
settype($this->_tpl_vars[$tpl_var],'array'); |
629 |
|
|
} |
630 |
|
|
if($merge && is_array($value)) { |
631 |
|
|
foreach($value as $_mkey => $_mval) { |
632 |
|
|
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval; |
633 |
|
|
} |
634 |
|
|
} else { |
635 |
|
|
$this->_tpl_vars[$tpl_var][] = $value; |
636 |
|
|
} |
637 |
cvsjoko |
1.1 |
} |
638 |
|
|
} |
639 |
|
|
} |
640 |
|
|
|
641 |
joko |
1.3 |
/** |
642 |
|
|
* appends values to template variables by reference |
643 |
|
|
* |
644 |
|
|
* @param string $tpl_var the template variable name |
645 |
|
|
* @param mixed $value the referenced value to append |
646 |
|
|
*/ |
647 |
|
|
function append_by_ref($tpl_var, &$value, $merge=false) |
648 |
cvsjoko |
1.1 |
{ |
649 |
|
|
if ($tpl_var != '' && isset($value)) { |
650 |
joko |
1.3 |
if(!@is_array($this->_tpl_vars[$tpl_var])) { |
651 |
|
|
settype($this->_tpl_vars[$tpl_var],'array'); |
652 |
|
|
} |
653 |
|
|
if ($merge && is_array($value)) { |
654 |
|
|
foreach($value as $_key => $_val) { |
655 |
|
|
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key]; |
656 |
|
|
} |
657 |
|
|
} else { |
658 |
|
|
$this->_tpl_vars[$tpl_var][] = &$value; |
659 |
|
|
} |
660 |
cvsjoko |
1.1 |
} |
661 |
|
|
} |
662 |
|
|
|
663 |
|
|
|
664 |
joko |
1.3 |
/** |
665 |
|
|
* clear the given assigned template variable. |
666 |
|
|
* |
667 |
|
|
* @param string $tpl_var the template variable to clear |
668 |
|
|
*/ |
669 |
cvsjoko |
1.1 |
function clear_assign($tpl_var) |
670 |
|
|
{ |
671 |
|
|
if (is_array($tpl_var)) |
672 |
|
|
foreach ($tpl_var as $curr_var) |
673 |
|
|
unset($this->_tpl_vars[$curr_var]); |
674 |
|
|
else |
675 |
|
|
unset($this->_tpl_vars[$tpl_var]); |
676 |
|
|
} |
677 |
|
|
|
678 |
|
|
|
679 |
joko |
1.3 |
/** |
680 |
|
|
* Registers custom function to be used in templates |
681 |
|
|
* |
682 |
|
|
* @param string $function the name of the template function |
683 |
|
|
* @param string $function_impl the name of the PHP function to register |
684 |
|
|
*/ |
685 |
|
|
function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) |
686 |
cvsjoko |
1.1 |
{ |
687 |
|
|
$this->_plugins['function'][$function] = |
688 |
joko |
1.3 |
array($function_impl, null, null, false, $cacheable, $cache_attrs); |
689 |
|
|
|
690 |
cvsjoko |
1.1 |
} |
691 |
|
|
|
692 |
joko |
1.3 |
/** |
693 |
|
|
* Unregisters custom function |
694 |
|
|
* |
695 |
|
|
* @param string $function name of template function |
696 |
|
|
*/ |
697 |
cvsjoko |
1.1 |
function unregister_function($function) |
698 |
|
|
{ |
699 |
|
|
unset($this->_plugins['function'][$function]); |
700 |
|
|
} |
701 |
|
|
|
702 |
joko |
1.3 |
/** |
703 |
|
|
* Registers object to be used in templates |
704 |
|
|
* |
705 |
|
|
* @param string $object name of template object |
706 |
|
|
* @param object &$object_impl the referenced PHP object to register |
707 |
|
|
* @param null|array $allowed list of allowed methods (empty = all) |
708 |
|
|
* @param boolean $smarty_args smarty argument format, else traditional |
709 |
|
|
* @param null|array $block_functs list of methods that are block format |
710 |
|
|
*/ |
711 |
|
|
function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) |
712 |
|
|
{ |
713 |
|
|
settype($allowed, 'array'); |
714 |
|
|
settype($smarty_args, 'boolean'); |
715 |
|
|
$this->_reg_objects[$object] = |
716 |
|
|
array(&$object_impl, $allowed, $smarty_args, $block_methods); |
717 |
|
|
} |
718 |
|
|
|
719 |
|
|
/** |
720 |
|
|
* Unregisters object |
721 |
|
|
* |
722 |
|
|
* @param string $object name of template object |
723 |
|
|
*/ |
724 |
|
|
function unregister_object($object) |
725 |
|
|
{ |
726 |
|
|
unset($this->_reg_objects[$object]); |
727 |
|
|
} |
728 |
|
|
|
729 |
|
|
|
730 |
|
|
/** |
731 |
|
|
* Registers block function to be used in templates |
732 |
|
|
* |
733 |
|
|
* @param string $block name of template block |
734 |
|
|
* @param string $block_impl PHP function to register |
735 |
|
|
*/ |
736 |
|
|
function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) |
737 |
cvsjoko |
1.1 |
{ |
738 |
|
|
$this->_plugins['block'][$block] = |
739 |
joko |
1.3 |
array($block_impl, null, null, false, $cacheable, $cache_attrs); |
740 |
cvsjoko |
1.1 |
} |
741 |
|
|
|
742 |
joko |
1.3 |
/** |
743 |
|
|
* Unregisters block function |
744 |
|
|
* |
745 |
|
|
* @param string $block name of template function |
746 |
|
|
*/ |
747 |
cvsjoko |
1.1 |
function unregister_block($block) |
748 |
|
|
{ |
749 |
|
|
unset($this->_plugins['block'][$block]); |
750 |
|
|
} |
751 |
|
|
|
752 |
joko |
1.3 |
/** |
753 |
|
|
* Registers compiler function |
754 |
|
|
* |
755 |
|
|
* @param string $function name of template function |
756 |
|
|
* @param string $function_impl name of PHP function to register |
757 |
|
|
*/ |
758 |
|
|
function register_compiler_function($function, $function_impl, $cacheable=true) |
759 |
cvsjoko |
1.1 |
{ |
760 |
|
|
$this->_plugins['compiler'][$function] = |
761 |
joko |
1.3 |
array($function_impl, null, null, false, $cacheable); |
762 |
cvsjoko |
1.1 |
} |
763 |
|
|
|
764 |
joko |
1.3 |
/** |
765 |
|
|
* Unregisters compiler function |
766 |
|
|
* |
767 |
|
|
* @param string $function name of template function |
768 |
|
|
*/ |
769 |
cvsjoko |
1.1 |
function unregister_compiler_function($function) |
770 |
|
|
{ |
771 |
|
|
unset($this->_plugins['compiler'][$function]); |
772 |
|
|
} |
773 |
|
|
|
774 |
joko |
1.3 |
/** |
775 |
|
|
* Registers modifier to be used in templates |
776 |
|
|
* |
777 |
|
|
* @param string $modifier name of template modifier |
778 |
|
|
* @param string $modifier_impl name of PHP function to register |
779 |
|
|
*/ |
780 |
cvsjoko |
1.1 |
function register_modifier($modifier, $modifier_impl) |
781 |
|
|
{ |
782 |
|
|
$this->_plugins['modifier'][$modifier] = |
783 |
|
|
array($modifier_impl, null, null, false); |
784 |
|
|
} |
785 |
|
|
|
786 |
joko |
1.3 |
/** |
787 |
|
|
* Unregisters modifier |
788 |
|
|
* |
789 |
|
|
* @param string $modifier name of template modifier |
790 |
|
|
*/ |
791 |
cvsjoko |
1.1 |
function unregister_modifier($modifier) |
792 |
|
|
{ |
793 |
|
|
unset($this->_plugins['modifier'][$modifier]); |
794 |
|
|
} |
795 |
|
|
|
796 |
joko |
1.3 |
/** |
797 |
|
|
* Registers a resource to fetch a template |
798 |
|
|
* |
799 |
|
|
* @param string $type name of resource |
800 |
|
|
* @param array $functions array of functions to handle resource |
801 |
|
|
*/ |
802 |
cvsjoko |
1.1 |
function register_resource($type, $functions) |
803 |
|
|
{ |
804 |
joko |
1.3 |
if (count($functions)==4) { |
805 |
|
|
$this->_plugins['resource'][$type] = |
806 |
|
|
array($functions, false); |
807 |
|
|
|
808 |
|
|
} elseif (count($functions)==5) { |
809 |
|
|
$this->_plugins['resource'][$type] = |
810 |
|
|
array(array(array(&$functions[0], $functions[1]) |
811 |
|
|
,array(&$functions[0], $functions[2]) |
812 |
|
|
,array(&$functions[0], $functions[3]) |
813 |
|
|
,array(&$functions[0], $functions[4])) |
814 |
|
|
,false); |
815 |
|
|
|
816 |
|
|
} else { |
817 |
|
|
$this->trigger_error("malformed function-list for '$type' in register_resource"); |
818 |
|
|
|
819 |
|
|
} |
820 |
cvsjoko |
1.1 |
} |
821 |
|
|
|
822 |
joko |
1.3 |
/** |
823 |
|
|
* Unregisters a resource |
824 |
|
|
* |
825 |
|
|
* @param string $type name of resource |
826 |
|
|
*/ |
827 |
cvsjoko |
1.1 |
function unregister_resource($type) |
828 |
|
|
{ |
829 |
|
|
unset($this->_plugins['resource'][$type]); |
830 |
|
|
} |
831 |
|
|
|
832 |
joko |
1.3 |
/** |
833 |
|
|
* Registers a prefilter function to apply |
834 |
|
|
* to a template before compiling |
835 |
|
|
* |
836 |
|
|
* @param string $function name of PHP function to register |
837 |
|
|
*/ |
838 |
cvsjoko |
1.1 |
function register_prefilter($function) |
839 |
|
|
{ |
840 |
joko |
1.3 |
$_name = (is_array($function)) ? $function[1] : $function; |
841 |
|
|
$this->_plugins['prefilter'][$_name] |
842 |
cvsjoko |
1.1 |
= array($function, null, null, false); |
843 |
|
|
} |
844 |
|
|
|
845 |
joko |
1.3 |
/** |
846 |
|
|
* Unregisters a prefilter function |
847 |
|
|
* |
848 |
|
|
* @param string $function name of PHP function |
849 |
|
|
*/ |
850 |
cvsjoko |
1.1 |
function unregister_prefilter($function) |
851 |
|
|
{ |
852 |
|
|
unset($this->_plugins['prefilter'][$function]); |
853 |
|
|
} |
854 |
|
|
|
855 |
joko |
1.3 |
/** |
856 |
|
|
* Registers a postfilter function to apply |
857 |
|
|
* to a compiled template after compilation |
858 |
|
|
* |
859 |
|
|
* @param string $function name of PHP function to register |
860 |
|
|
*/ |
861 |
cvsjoko |
1.1 |
function register_postfilter($function) |
862 |
|
|
{ |
863 |
joko |
1.3 |
$_name = (is_array($function)) ? $function[1] : $function; |
864 |
|
|
$this->_plugins['postfilter'][$_name] |
865 |
cvsjoko |
1.1 |
= array($function, null, null, false); |
866 |
|
|
} |
867 |
|
|
|
868 |
joko |
1.3 |
/** |
869 |
|
|
* Unregisters a postfilter function |
870 |
|
|
* |
871 |
|
|
* @param string $function name of PHP function |
872 |
|
|
*/ |
873 |
cvsjoko |
1.1 |
function unregister_postfilter($function) |
874 |
|
|
{ |
875 |
|
|
unset($this->_plugins['postfilter'][$function]); |
876 |
|
|
} |
877 |
|
|
|
878 |
joko |
1.3 |
/** |
879 |
|
|
* Registers an output filter function to apply |
880 |
|
|
* to a template output |
881 |
|
|
* |
882 |
|
|
* @param string $function name of PHP function |
883 |
|
|
*/ |
884 |
cvsjoko |
1.1 |
function register_outputfilter($function) |
885 |
|
|
{ |
886 |
joko |
1.3 |
$_name = (is_array($function)) ? $function[1] : $function; |
887 |
|
|
$this->_plugins['outputfilter'][$_name] |
888 |
cvsjoko |
1.1 |
= array($function, null, null, false); |
889 |
|
|
} |
890 |
|
|
|
891 |
joko |
1.3 |
/** |
892 |
|
|
* Unregisters an outputfilter function |
893 |
|
|
* |
894 |
|
|
* @param string $function name of PHP function |
895 |
|
|
*/ |
896 |
cvsjoko |
1.1 |
function unregister_outputfilter($function) |
897 |
|
|
{ |
898 |
|
|
unset($this->_plugins['outputfilter'][$function]); |
899 |
|
|
} |
900 |
|
|
|
901 |
joko |
1.3 |
/** |
902 |
|
|
* load a filter of specified type and name |
903 |
|
|
* |
904 |
|
|
* @param string $type filter type |
905 |
|
|
* @param string $name filter name |
906 |
|
|
*/ |
907 |
cvsjoko |
1.1 |
function load_filter($type, $name) |
908 |
|
|
{ |
909 |
|
|
switch ($type) { |
910 |
|
|
case 'output': |
911 |
joko |
1.3 |
$_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); |
912 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); |
913 |
|
|
smarty_core_load_plugins($_params, $this); |
914 |
cvsjoko |
1.1 |
break; |
915 |
|
|
|
916 |
|
|
case 'pre': |
917 |
|
|
case 'post': |
918 |
|
|
if (!isset($this->_plugins[$type . 'filter'][$name])) |
919 |
|
|
$this->_plugins[$type . 'filter'][$name] = false; |
920 |
|
|
break; |
921 |
|
|
} |
922 |
|
|
} |
923 |
|
|
|
924 |
joko |
1.3 |
/** |
925 |
|
|
* clear cached content for the given template and cache id |
926 |
|
|
* |
927 |
|
|
* @param string $tpl_file name of template file |
928 |
|
|
* @param string $cache_id name of cache_id |
929 |
|
|
* @param string $compile_id name of compile_id |
930 |
|
|
* @param string $exp_time expiration time |
931 |
|
|
* @return boolean |
932 |
|
|
*/ |
933 |
cvsjoko |
1.1 |
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) |
934 |
|
|
{ |
935 |
joko |
1.3 |
|
936 |
cvsjoko |
1.1 |
if (!isset($compile_id)) |
937 |
|
|
$compile_id = $this->compile_id; |
938 |
|
|
|
939 |
joko |
1.3 |
if (!isset($tpl_file)) |
940 |
|
|
$compile_id = null; |
941 |
|
|
|
942 |
|
|
$_auto_id = $this->_get_auto_id($cache_id, $compile_id); |
943 |
cvsjoko |
1.1 |
|
944 |
|
|
if (!empty($this->cache_handler_func)) { |
945 |
joko |
1.3 |
return call_user_func_array($this->cache_handler_func, |
946 |
|
|
array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time)); |
947 |
cvsjoko |
1.1 |
} else { |
948 |
joko |
1.3 |
$_params = array('auto_base' => $this->cache_dir, |
949 |
|
|
'auto_source' => $tpl_file, |
950 |
|
|
'auto_id' => $_auto_id, |
951 |
|
|
'exp_time' => $exp_time); |
952 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); |
953 |
|
|
return smarty_core_rm_auto($_params, $this); |
954 |
cvsjoko |
1.1 |
} |
955 |
joko |
1.3 |
|
956 |
cvsjoko |
1.1 |
} |
957 |
|
|
|
958 |
|
|
|
959 |
joko |
1.3 |
/** |
960 |
|
|
* clear the entire contents of cache (all templates) |
961 |
|
|
* |
962 |
|
|
* @param string $exp_time expire time |
963 |
|
|
* @return boolean results of {@link smarty_core_rm_auto()} |
964 |
|
|
*/ |
965 |
cvsjoko |
1.1 |
function clear_all_cache($exp_time = null) |
966 |
|
|
{ |
967 |
joko |
1.3 |
return $this->clear_cache(null, null, null, $exp_time); |
968 |
cvsjoko |
1.1 |
} |
969 |
|
|
|
970 |
|
|
|
971 |
joko |
1.3 |
/** |
972 |
|
|
* test to see if valid cache exists for this template |
973 |
|
|
* |
974 |
|
|
* @param string $tpl_file name of template file |
975 |
|
|
* @param string $cache_id |
976 |
|
|
* @param string $compile_id |
977 |
|
|
* @return string|false results of {@link _read_cache_file()} |
978 |
|
|
*/ |
979 |
cvsjoko |
1.1 |
function is_cached($tpl_file, $cache_id = null, $compile_id = null) |
980 |
|
|
{ |
981 |
|
|
if (!$this->caching) |
982 |
|
|
return false; |
983 |
|
|
|
984 |
|
|
if (!isset($compile_id)) |
985 |
|
|
$compile_id = $this->compile_id; |
986 |
|
|
|
987 |
joko |
1.3 |
$_params = array( |
988 |
|
|
'tpl_file' => $tpl_file, |
989 |
|
|
'cache_id' => $cache_id, |
990 |
|
|
'compile_id' => $compile_id |
991 |
|
|
); |
992 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); |
993 |
|
|
return smarty_core_read_cache_file($_params, $this); |
994 |
cvsjoko |
1.1 |
} |
995 |
|
|
|
996 |
|
|
|
997 |
joko |
1.3 |
/** |
998 |
|
|
* clear all the assigned template variables. |
999 |
|
|
* |
1000 |
|
|
*/ |
1001 |
cvsjoko |
1.1 |
function clear_all_assign() |
1002 |
|
|
{ |
1003 |
|
|
$this->_tpl_vars = array(); |
1004 |
|
|
} |
1005 |
|
|
|
1006 |
joko |
1.3 |
/** |
1007 |
|
|
* clears compiled version of specified template resource, |
1008 |
|
|
* or all compiled template files if one is not specified. |
1009 |
|
|
* This function is for advanced use only, not normally needed. |
1010 |
|
|
* |
1011 |
|
|
* @param string $tpl_file |
1012 |
|
|
* @param string $compile_id |
1013 |
|
|
* @param string $exp_time |
1014 |
|
|
* @return boolean results of {@link smarty_core_rm_auto()} |
1015 |
|
|
*/ |
1016 |
cvsjoko |
1.1 |
function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) |
1017 |
|
|
{ |
1018 |
joko |
1.3 |
if (!isset($compile_id)) { |
1019 |
cvsjoko |
1.1 |
$compile_id = $this->compile_id; |
1020 |
joko |
1.3 |
} |
1021 |
|
|
$_params = array('auto_base' => $this->compile_dir, |
1022 |
|
|
'auto_source' => $tpl_file, |
1023 |
|
|
'auto_id' => $compile_id, |
1024 |
|
|
'exp_time' => $exp_time, |
1025 |
|
|
'extensions' => array('.inc', '.php')); |
1026 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); |
1027 |
|
|
return smarty_core_rm_auto($_params, $this); |
1028 |
cvsjoko |
1.1 |
} |
1029 |
|
|
|
1030 |
joko |
1.3 |
/** |
1031 |
|
|
* Checks whether requested template exists. |
1032 |
|
|
* |
1033 |
|
|
* @param string $tpl_file |
1034 |
|
|
* @return boolean |
1035 |
|
|
*/ |
1036 |
cvsjoko |
1.1 |
function template_exists($tpl_file) |
1037 |
|
|
{ |
1038 |
joko |
1.3 |
$_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); |
1039 |
|
|
return $this->_fetch_resource_info($_params); |
1040 |
cvsjoko |
1.1 |
} |
1041 |
|
|
|
1042 |
joko |
1.3 |
/** |
1043 |
|
|
* Returns an array containing template variables |
1044 |
|
|
* |
1045 |
|
|
* @param string $name |
1046 |
|
|
* @param string $type |
1047 |
|
|
* @return array |
1048 |
|
|
*/ |
1049 |
|
|
function &get_template_vars($name=null) |
1050 |
cvsjoko |
1.1 |
{ |
1051 |
joko |
1.3 |
if(!isset($name)) { |
1052 |
|
|
return $this->_tpl_vars; |
1053 |
|
|
} |
1054 |
|
|
if(isset($this->_tpl_vars[$name])) { |
1055 |
|
|
return $this->_tpl_vars[$name]; |
1056 |
|
|
} |
1057 |
cvsjoko |
1.1 |
} |
1058 |
|
|
|
1059 |
joko |
1.3 |
/** |
1060 |
|
|
* Returns an array containing config variables |
1061 |
|
|
* |
1062 |
|
|
* @param string $name |
1063 |
|
|
* @param string $type |
1064 |
|
|
* @return array |
1065 |
|
|
*/ |
1066 |
|
|
function &get_config_vars($name=null) |
1067 |
|
|
{ |
1068 |
|
|
if(!isset($name) && is_array($this->_config[0])) { |
1069 |
|
|
return $this->_config[0]['vars']; |
1070 |
|
|
} else if(isset($this->_config[0]['vars'][$name])) { |
1071 |
|
|
return $this->_config[0]['vars'][$name]; |
1072 |
|
|
} |
1073 |
|
|
} |
1074 |
cvsjoko |
1.1 |
|
1075 |
joko |
1.3 |
/** |
1076 |
|
|
* trigger Smarty error |
1077 |
|
|
* |
1078 |
|
|
* @param string $error_msg |
1079 |
|
|
* @param integer $error_type |
1080 |
|
|
*/ |
1081 |
cvsjoko |
1.1 |
function trigger_error($error_msg, $error_type = E_USER_WARNING) |
1082 |
|
|
{ |
1083 |
|
|
trigger_error("Smarty error: $error_msg", $error_type); |
1084 |
|
|
} |
1085 |
|
|
|
1086 |
|
|
|
1087 |
joko |
1.3 |
/** |
1088 |
|
|
* executes & displays the template results |
1089 |
|
|
* |
1090 |
|
|
* @param string $resource_name |
1091 |
|
|
* @param string $cache_id |
1092 |
|
|
* @param string $compile_id |
1093 |
|
|
*/ |
1094 |
|
|
function display($resource_name, $cache_id = null, $compile_id = null) |
1095 |
|
|
{ |
1096 |
|
|
$this->fetch($resource_name, $cache_id, $compile_id, true); |
1097 |
|
|
} |
1098 |
|
|
|
1099 |
|
|
/** |
1100 |
|
|
* executes & returns or displays the template results |
1101 |
|
|
* |
1102 |
|
|
* @param string $resource_name |
1103 |
|
|
* @param string $cache_id |
1104 |
|
|
* @param string $compile_id |
1105 |
|
|
* @param boolean $display |
1106 |
|
|
*/ |
1107 |
|
|
function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) |
1108 |
|
|
{ |
1109 |
|
|
static $_cache_info = array(); |
1110 |
|
|
|
1111 |
|
|
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) |
1112 |
|
|
? $this->error_reporting : error_reporting() & ~E_NOTICE); |
1113 |
|
|
|
1114 |
|
|
if (!$this->debugging && $this->debugging_ctrl == 'URL') { |
1115 |
|
|
$_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; |
1116 |
|
|
if (@strstr($_query_string, $this->_smarty_debug_id)) { |
1117 |
|
|
if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) { |
1118 |
|
|
// enable debugging for this browser session |
1119 |
|
|
@setcookie('SMARTY_DEBUG', true); |
1120 |
|
|
$this->debugging = true; |
1121 |
|
|
} elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) { |
1122 |
|
|
// disable debugging for this browser session |
1123 |
|
|
@setcookie('SMARTY_DEBUG', false); |
1124 |
|
|
$this->debugging = false; |
1125 |
|
|
} else { |
1126 |
|
|
// enable debugging for this page |
1127 |
|
|
$this->debugging = true; |
1128 |
|
|
} |
1129 |
|
|
} else { |
1130 |
|
|
$_cookie_var = $this->request_use_auto_globals ? $_COOKIE['SMARTY_DEBUG'] : $GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']; |
1131 |
|
|
$this->debugging = $_cookie_var ? true : false; |
1132 |
|
|
} |
1133 |
cvsjoko |
1.1 |
} |
1134 |
|
|
|
1135 |
|
|
if ($this->debugging) { |
1136 |
|
|
// capture time for debugging info |
1137 |
joko |
1.3 |
$_params = array(); |
1138 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); |
1139 |
|
|
$_debug_start_time = smarty_core_get_microtime($_params, $this); |
1140 |
cvsjoko |
1.1 |
$this->_smarty_debug_info[] = array('type' => 'template', |
1141 |
joko |
1.3 |
'filename' => $resource_name, |
1142 |
cvsjoko |
1.1 |
'depth' => 0); |
1143 |
joko |
1.3 |
$_included_tpls_idx = count($this->_smarty_debug_info) - 1; |
1144 |
cvsjoko |
1.1 |
} |
1145 |
|
|
|
1146 |
joko |
1.3 |
if (!isset($compile_id)) { |
1147 |
|
|
$compile_id = $this->compile_id; |
1148 |
|
|
} |
1149 |
cvsjoko |
1.1 |
|
1150 |
joko |
1.3 |
$this->_compile_id = $compile_id; |
1151 |
cvsjoko |
1.1 |
$this->_inclusion_depth = 0; |
1152 |
|
|
|
1153 |
|
|
if ($this->caching) { |
1154 |
joko |
1.3 |
// save old cache_info, initialize cache_info |
1155 |
|
|
array_push($_cache_info, $this->_cache_info); |
1156 |
|
|
$this->_cache_info = array(); |
1157 |
|
|
$_params = array( |
1158 |
|
|
'tpl_file' => $resource_name, |
1159 |
|
|
'cache_id' => $cache_id, |
1160 |
|
|
'compile_id' => $compile_id, |
1161 |
|
|
'results' => null |
1162 |
|
|
); |
1163 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); |
1164 |
|
|
if (smarty_core_read_cache_file($_params, $this)) { |
1165 |
|
|
$_smarty_results = $_params['results']; |
1166 |
cvsjoko |
1.1 |
if (@count($this->_cache_info['insert_tags'])) { |
1167 |
joko |
1.3 |
$_params = array('plugins' => $this->_cache_info['insert_tags']); |
1168 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); |
1169 |
|
|
smarty_core_load_plugins($_params, $this); |
1170 |
|
|
$_params = array('results' => $_smarty_results); |
1171 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); |
1172 |
|
|
$_smarty_results = smarty_core_process_cached_inserts($_params, $this); |
1173 |
|
|
} |
1174 |
|
|
if (@count($this->_cache_info['cache_serials'])) { |
1175 |
|
|
$_params = array('results' => $_smarty_results); |
1176 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_compiled_include.php'); |
1177 |
|
|
$_smarty_results = smarty_core_process_compiled_include($_params, $this); |
1178 |
cvsjoko |
1.1 |
} |
1179 |
joko |
1.3 |
|
1180 |
|
|
|
1181 |
|
|
if ($display) { |
1182 |
cvsjoko |
1.1 |
if ($this->debugging) |
1183 |
|
|
{ |
1184 |
|
|
// capture time for debugging info |
1185 |
joko |
1.3 |
$_params = array(); |
1186 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); |
1187 |
|
|
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; |
1188 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); |
1189 |
|
|
$_smarty_results .= smarty_core_display_debug_console($_params, $this); |
1190 |
cvsjoko |
1.1 |
} |
1191 |
|
|
if ($this->cache_modified_check) { |
1192 |
joko |
1.3 |
$_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; |
1193 |
|
|
$_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); |
1194 |
|
|
$_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT'; |
1195 |
cvsjoko |
1.1 |
if (@count($this->_cache_info['insert_tags']) == 0 |
1196 |
joko |
1.3 |
&& !$this->_cache_serials |
1197 |
|
|
&& $_gmt_mtime == $_last_modified_date) { |
1198 |
|
|
if (php_sapi_name()=='cgi') |
1199 |
|
|
header("Status: 304 Not Modified"); |
1200 |
|
|
else |
1201 |
|
|
header("HTTP/1.1 304 Not Modified"); |
1202 |
|
|
|
1203 |
cvsjoko |
1.1 |
} else { |
1204 |
joko |
1.3 |
header("Last-Modified: ".$_gmt_mtime); |
1205 |
|
|
echo $_smarty_results; |
1206 |
cvsjoko |
1.1 |
} |
1207 |
|
|
} else { |
1208 |
joko |
1.3 |
echo $_smarty_results; |
1209 |
|
|
} |
1210 |
cvsjoko |
1.1 |
error_reporting($_smarty_old_error_level); |
1211 |
joko |
1.3 |
// restore initial cache_info |
1212 |
|
|
$this->_cache_info = array_pop($_cache_info); |
1213 |
|
|
return true; |
1214 |
cvsjoko |
1.1 |
} else { |
1215 |
|
|
error_reporting($_smarty_old_error_level); |
1216 |
joko |
1.3 |
// restore initial cache_info |
1217 |
|
|
$this->_cache_info = array_pop($_cache_info); |
1218 |
cvsjoko |
1.1 |
return $_smarty_results; |
1219 |
|
|
} |
1220 |
|
|
} else { |
1221 |
joko |
1.3 |
$this->_cache_info['template'][$resource_name] = true; |
1222 |
|
|
if ($this->cache_modified_check && $display) { |
1223 |
|
|
header("Last-Modified: ".gmdate('D, d M Y H:i:s', time()).' GMT'); |
1224 |
|
|
} |
1225 |
cvsjoko |
1.1 |
} |
1226 |
|
|
} |
1227 |
|
|
|
1228 |
joko |
1.3 |
// load filters that are marked as autoload |
1229 |
|
|
if (count($this->autoload_filters)) { |
1230 |
|
|
foreach ($this->autoload_filters as $_filter_type => $_filters) { |
1231 |
|
|
foreach ($_filters as $_filter) { |
1232 |
|
|
$this->load_filter($_filter_type, $_filter); |
1233 |
|
|
} |
1234 |
|
|
} |
1235 |
|
|
} |
1236 |
cvsjoko |
1.1 |
|
1237 |
joko |
1.3 |
$_smarty_compile_path = $this->_get_compile_path($resource_name); |
1238 |
cvsjoko |
1.1 |
|
1239 |
|
|
// if we just need to display the results, don't perform output |
1240 |
|
|
// buffering - for speed |
1241 |
joko |
1.3 |
$_cache_including = $this->_cache_including; |
1242 |
|
|
$this->_cache_including = false; |
1243 |
|
|
if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { |
1244 |
|
|
if ($this->_is_compiled($resource_name, $_smarty_compile_path) |
1245 |
|
|
|| $this->_compile_resource($resource_name, $_smarty_compile_path)) |
1246 |
cvsjoko |
1.1 |
{ |
1247 |
|
|
include($_smarty_compile_path); |
1248 |
|
|
} |
1249 |
|
|
} else { |
1250 |
|
|
ob_start(); |
1251 |
joko |
1.3 |
if ($this->_is_compiled($resource_name, $_smarty_compile_path) |
1252 |
|
|
|| $this->_compile_resource($resource_name, $_smarty_compile_path)) |
1253 |
cvsjoko |
1.1 |
{ |
1254 |
|
|
include($_smarty_compile_path); |
1255 |
|
|
} |
1256 |
|
|
$_smarty_results = ob_get_contents(); |
1257 |
|
|
ob_end_clean(); |
1258 |
|
|
|
1259 |
joko |
1.3 |
foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) { |
1260 |
|
|
$_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this)); |
1261 |
cvsjoko |
1.1 |
} |
1262 |
|
|
} |
1263 |
|
|
|
1264 |
|
|
if ($this->caching) { |
1265 |
joko |
1.3 |
$_params = array('tpl_file' => $resource_name, |
1266 |
|
|
'cache_id' => $cache_id, |
1267 |
|
|
'compile_id' => $compile_id, |
1268 |
|
|
'results' => $_smarty_results); |
1269 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php'); |
1270 |
|
|
smarty_core_write_cache_file($_params, $this); |
1271 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); |
1272 |
|
|
$_smarty_results = smarty_core_process_cached_inserts($_params, $this); |
1273 |
|
|
|
1274 |
|
|
if ($this->_cache_serials) { |
1275 |
|
|
// strip nocache-tags from output |
1276 |
|
|
$_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s' |
1277 |
|
|
,'' |
1278 |
|
|
,$_smarty_results); |
1279 |
|
|
} |
1280 |
|
|
// restore initial cache_info |
1281 |
|
|
$this->_cache_info = array_pop($_cache_info); |
1282 |
cvsjoko |
1.1 |
} |
1283 |
joko |
1.3 |
$this->_cache_including = $_cache_including; |
1284 |
cvsjoko |
1.1 |
|
1285 |
joko |
1.3 |
if ($display) { |
1286 |
cvsjoko |
1.1 |
if (isset($_smarty_results)) { echo $_smarty_results; } |
1287 |
|
|
if ($this->debugging) { |
1288 |
|
|
// capture time for debugging info |
1289 |
joko |
1.3 |
$_params = array(); |
1290 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); |
1291 |
|
|
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); |
1292 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); |
1293 |
|
|
echo smarty_core_display_debug_console($_params, $this); |
1294 |
cvsjoko |
1.1 |
} |
1295 |
|
|
error_reporting($_smarty_old_error_level); |
1296 |
|
|
return; |
1297 |
|
|
} else { |
1298 |
|
|
error_reporting($_smarty_old_error_level); |
1299 |
|
|
if (isset($_smarty_results)) { return $_smarty_results; } |
1300 |
|
|
} |
1301 |
|
|
} |
1302 |
|
|
|
1303 |
joko |
1.3 |
/** |
1304 |
|
|
* load configuration values |
1305 |
|
|
* |
1306 |
|
|
* @param string $file |
1307 |
|
|
* @param string $section |
1308 |
|
|
* @param string $scope |
1309 |
|
|
*/ |
1310 |
|
|
function config_load($file, $section = null, $scope = 'global') |
1311 |
|
|
{ |
1312 |
|
|
require_once($this->_get_plugin_filepath('function', 'config_load')); |
1313 |
|
|
smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this); |
1314 |
|
|
} |
1315 |
|
|
|
1316 |
|
|
/** |
1317 |
|
|
* return a reference to a registered object |
1318 |
|
|
* |
1319 |
|
|
* @param string $name |
1320 |
|
|
* @return object |
1321 |
|
|
*/ |
1322 |
|
|
function &get_registered_object($name) { |
1323 |
|
|
if (!isset($this->_reg_objects[$name])) |
1324 |
|
|
$this->_trigger_fatal_error("'$name' is not a registered object"); |
1325 |
|
|
|
1326 |
|
|
if (!is_object($this->_reg_objects[$name][0])) |
1327 |
|
|
$this->_trigger_fatal_error("registered '$name' is not an object"); |
1328 |
|
|
|
1329 |
|
|
return $this->_reg_objects[$name][0]; |
1330 |
|
|
} |
1331 |
|
|
|
1332 |
|
|
/** |
1333 |
|
|
* clear configuration values |
1334 |
|
|
* |
1335 |
|
|
* @param string $var |
1336 |
|
|
*/ |
1337 |
|
|
function clear_config($var = null) |
1338 |
|
|
{ |
1339 |
|
|
if(!isset($var)) { |
1340 |
|
|
// clear all values |
1341 |
|
|
$this->_config = array(array('vars' => array(), |
1342 |
|
|
'files' => array())); |
1343 |
|
|
} else { |
1344 |
|
|
unset($this->_config[0]['vars'][$var]); |
1345 |
cvsjoko |
1.1 |
} |
1346 |
|
|
} |
1347 |
|
|
|
1348 |
joko |
1.3 |
/** |
1349 |
|
|
* get filepath of requested plugin |
1350 |
|
|
* |
1351 |
|
|
* @param string $type |
1352 |
|
|
* @param string $name |
1353 |
|
|
* @return string|false |
1354 |
|
|
*/ |
1355 |
|
|
function _get_plugin_filepath($type, $name) |
1356 |
cvsjoko |
1.1 |
{ |
1357 |
joko |
1.3 |
$_params = array('type' => $type, 'name' => $name); |
1358 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php'); |
1359 |
|
|
return smarty_core_assemble_plugin_filepath($_params, $this); |
1360 |
cvsjoko |
1.1 |
} |
1361 |
|
|
|
1362 |
joko |
1.3 |
/** |
1363 |
|
|
* test if resource needs compiling |
1364 |
|
|
* |
1365 |
|
|
* @param string $resource_name |
1366 |
|
|
* @param string $compile_path |
1367 |
|
|
* @return boolean |
1368 |
|
|
*/ |
1369 |
|
|
function _is_compiled($resource_name, $compile_path) |
1370 |
cvsjoko |
1.1 |
{ |
1371 |
|
|
if (!$this->force_compile && file_exists($compile_path)) { |
1372 |
|
|
if (!$this->compile_check) { |
1373 |
joko |
1.3 |
// no need to check compiled file |
1374 |
cvsjoko |
1.1 |
return true; |
1375 |
|
|
} else { |
1376 |
joko |
1.3 |
// get file source and timestamp |
1377 |
|
|
$_params = array('resource_name' => $resource_name, 'get_source'=>false); |
1378 |
|
|
if (!$this->_fetch_resource_info($_params)) { |
1379 |
cvsjoko |
1.1 |
return false; |
1380 |
|
|
} |
1381 |
joko |
1.3 |
if ($_params['resource_timestamp'] <= filemtime($compile_path)) { |
1382 |
cvsjoko |
1.1 |
// template not expired, no recompile |
1383 |
|
|
return true; |
1384 |
|
|
} else { |
1385 |
|
|
// compile template |
1386 |
joko |
1.3 |
return false; |
1387 |
cvsjoko |
1.1 |
} |
1388 |
|
|
} |
1389 |
|
|
} else { |
1390 |
|
|
// compiled template does not exist, or forced compile |
1391 |
joko |
1.3 |
return false; |
1392 |
cvsjoko |
1.1 |
} |
1393 |
|
|
} |
1394 |
|
|
|
1395 |
joko |
1.3 |
/** |
1396 |
|
|
* compile the template |
1397 |
|
|
* |
1398 |
|
|
* @param string $resource_name |
1399 |
|
|
* @param string $compile_path |
1400 |
|
|
* @return boolean |
1401 |
|
|
*/ |
1402 |
|
|
function _compile_resource($resource_name, $compile_path) |
1403 |
cvsjoko |
1.1 |
{ |
1404 |
|
|
|
1405 |
joko |
1.3 |
$_params = array('resource_name' => $resource_name); |
1406 |
|
|
if (!$this->_fetch_resource_info($_params)) { |
1407 |
|
|
return false; |
1408 |
cvsjoko |
1.1 |
} |
1409 |
|
|
|
1410 |
joko |
1.3 |
$_source_content = $_params['source_content']; |
1411 |
|
|
$_resource_timestamp = $_params['resource_timestamp']; |
1412 |
|
|
$_cache_include = substr($compile_path, 0, -4).'.inc'; |
1413 |
|
|
|
1414 |
|
|
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) { |
1415 |
|
|
// if a _cache_serial was set, we also have to write an include-file: |
1416 |
|
|
if ($this->_cache_include_info) { |
1417 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_include.php'); |
1418 |
|
|
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this); |
1419 |
cvsjoko |
1.1 |
} |
1420 |
|
|
|
1421 |
joko |
1.3 |
$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp); |
1422 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); |
1423 |
|
|
smarty_core_write_compiled_resource($_params, $this); |
1424 |
cvsjoko |
1.1 |
|
1425 |
joko |
1.3 |
return true; |
1426 |
|
|
} else { |
1427 |
cvsjoko |
1.1 |
return false; |
1428 |
|
|
} |
1429 |
|
|
|
1430 |
|
|
} |
1431 |
|
|
|
1432 |
joko |
1.3 |
/** |
1433 |
|
|
* compile the given source |
1434 |
|
|
* |
1435 |
|
|
* @param string $resource_name |
1436 |
|
|
* @param string $source_content |
1437 |
|
|
* @param string $compiled_content |
1438 |
|
|
* @return boolean |
1439 |
|
|
*/ |
1440 |
|
|
function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null) |
1441 |
|
|
{ |
1442 |
|
|
if (file_exists(SMARTY_DIR . $this->compiler_file)) { |
1443 |
|
|
require_once(SMARTY_DIR . $this->compiler_file); |
1444 |
|
|
} else { |
1445 |
|
|
// use include_path |
1446 |
|
|
require_once($this->compiler_file); |
1447 |
|
|
} |
1448 |
cvsjoko |
1.1 |
|
1449 |
|
|
|
1450 |
|
|
$smarty_compiler = new $this->compiler_class; |
1451 |
|
|
|
1452 |
|
|
$smarty_compiler->template_dir = $this->template_dir; |
1453 |
|
|
$smarty_compiler->compile_dir = $this->compile_dir; |
1454 |
|
|
$smarty_compiler->plugins_dir = $this->plugins_dir; |
1455 |
|
|
$smarty_compiler->config_dir = $this->config_dir; |
1456 |
|
|
$smarty_compiler->force_compile = $this->force_compile; |
1457 |
|
|
$smarty_compiler->caching = $this->caching; |
1458 |
|
|
$smarty_compiler->php_handling = $this->php_handling; |
1459 |
|
|
$smarty_compiler->left_delimiter = $this->left_delimiter; |
1460 |
|
|
$smarty_compiler->right_delimiter = $this->right_delimiter; |
1461 |
|
|
$smarty_compiler->_version = $this->_version; |
1462 |
|
|
$smarty_compiler->security = $this->security; |
1463 |
|
|
$smarty_compiler->secure_dir = $this->secure_dir; |
1464 |
|
|
$smarty_compiler->security_settings = $this->security_settings; |
1465 |
|
|
$smarty_compiler->trusted_dir = $this->trusted_dir; |
1466 |
joko |
1.3 |
$smarty_compiler->use_sub_dirs = $this->use_sub_dirs; |
1467 |
|
|
$smarty_compiler->_reg_objects = &$this->_reg_objects; |
1468 |
cvsjoko |
1.1 |
$smarty_compiler->_plugins = &$this->_plugins; |
1469 |
|
|
$smarty_compiler->_tpl_vars = &$this->_tpl_vars; |
1470 |
|
|
$smarty_compiler->default_modifiers = $this->default_modifiers; |
1471 |
joko |
1.3 |
$smarty_compiler->compile_id = $this->_compile_id; |
1472 |
|
|
$smarty_compiler->_config = $this->_config; |
1473 |
|
|
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; |
1474 |
cvsjoko |
1.1 |
|
1475 |
joko |
1.3 |
$smarty_compiler->_cache_serial = null; |
1476 |
|
|
$smarty_compiler->_cache_include = $cache_include_path; |
1477 |
cvsjoko |
1.1 |
|
1478 |
|
|
|
1479 |
joko |
1.3 |
$_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content); |
1480 |
cvsjoko |
1.1 |
|
1481 |
joko |
1.3 |
if ($smarty_compiler->_cache_serial) { |
1482 |
|
|
$this->_cache_include_info = array( |
1483 |
|
|
'cache_serial'=>$smarty_compiler->_cache_serial |
1484 |
|
|
,'plugins_code'=>$smarty_compiler->_plugins_code |
1485 |
|
|
,'include_file_path' => $cache_include_path); |
1486 |
cvsjoko |
1.1 |
|
1487 |
joko |
1.3 |
} else { |
1488 |
|
|
$this->_cache_include_info = null; |
1489 |
cvsjoko |
1.1 |
|
1490 |
|
|
} |
1491 |
|
|
|
1492 |
joko |
1.3 |
return $_results; |
1493 |
cvsjoko |
1.1 |
} |
1494 |
|
|
|
1495 |
joko |
1.3 |
/** |
1496 |
|
|
* Get the compile path for this resource |
1497 |
|
|
* |
1498 |
|
|
* @param string $resource_name |
1499 |
|
|
* @return string results of {@link _get_auto_filename()} |
1500 |
|
|
*/ |
1501 |
|
|
function _get_compile_path($resource_name) |
1502 |
cvsjoko |
1.1 |
{ |
1503 |
joko |
1.3 |
return $this->_get_auto_filename($this->compile_dir, $resource_name, |
1504 |
|
|
$this->_compile_id) . '.php'; |
1505 |
cvsjoko |
1.1 |
} |
1506 |
|
|
|
1507 |
joko |
1.3 |
/** |
1508 |
|
|
* fetch the template info. Gets timestamp, and source |
1509 |
|
|
* if get_source is true |
1510 |
|
|
* |
1511 |
|
|
* sets $source_content to the source of the template, and |
1512 |
|
|
* $resource_timestamp to its time stamp |
1513 |
|
|
* @param string $resource_name |
1514 |
|
|
* @param string $source_content |
1515 |
|
|
* @param integer $resource_timestamp |
1516 |
|
|
* @param boolean $get_source |
1517 |
|
|
* @param boolean $quiet |
1518 |
|
|
* @return boolean |
1519 |
|
|
*/ |
1520 |
cvsjoko |
1.1 |
|
1521 |
joko |
1.3 |
function _fetch_resource_info(&$params) |
1522 |
|
|
{ |
1523 |
|
|
if(!isset($params['get_source'])) { $params['get_source'] = true; } |
1524 |
|
|
if(!isset($params['quiet'])) { $params['quiet'] = false; } |
1525 |
cvsjoko |
1.1 |
|
1526 |
joko |
1.3 |
$_return = false; |
1527 |
|
|
$_params = array('resource_name' => $params['resource_name']) ; |
1528 |
|
|
if (isset($params['resource_base_path'])) |
1529 |
|
|
$_params['resource_base_path'] = $params['resource_base_path']; |
1530 |
|
|
else |
1531 |
|
|
$_params['resource_base_path'] = $this->template_dir; |
1532 |
cvsjoko |
1.1 |
|
1533 |
joko |
1.3 |
if ($this->_parse_resource_name($_params)) { |
1534 |
|
|
$_resource_type = $_params['resource_type']; |
1535 |
|
|
$_resource_name = $_params['resource_name']; |
1536 |
|
|
switch ($_resource_type) { |
1537 |
|
|
case 'file': |
1538 |
|
|
if ($params['get_source']) { |
1539 |
|
|
$params['source_content'] = $this->_read_file($_resource_name); |
1540 |
|
|
} |
1541 |
|
|
$params['resource_timestamp'] = filemtime($_resource_name); |
1542 |
|
|
$_return = is_file($_resource_name); |
1543 |
|
|
break; |
1544 |
cvsjoko |
1.1 |
|
1545 |
joko |
1.3 |
default: |
1546 |
|
|
// call resource functions to fetch the template source and timestamp |
1547 |
|
|
if ($params['get_source']) { |
1548 |
|
|
$_source_return = isset($this->_plugins['resource'][$_resource_type]) && |
1549 |
|
|
call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], |
1550 |
|
|
array($_resource_name, &$params['source_content'], &$this)); |
1551 |
|
|
} else { |
1552 |
|
|
$_source_return = true; |
1553 |
|
|
} |
1554 |
cvsjoko |
1.1 |
|
1555 |
joko |
1.3 |
$_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && |
1556 |
|
|
call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], |
1557 |
|
|
array($_resource_name, &$params['resource_timestamp'], &$this)); |
1558 |
cvsjoko |
1.1 |
|
1559 |
joko |
1.3 |
$_return = $_source_return && $_timestamp_return; |
1560 |
|
|
break; |
1561 |
cvsjoko |
1.1 |
} |
1562 |
joko |
1.3 |
} |
1563 |
cvsjoko |
1.1 |
|
1564 |
joko |
1.3 |
if (!$_return) { |
1565 |
|
|
// see if we can get a template with the default template handler |
1566 |
|
|
if (!empty($this->default_template_handler_func)) { |
1567 |
|
|
if (!is_callable($this->default_template_handler_func)) { |
1568 |
|
|
$this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); |
1569 |
cvsjoko |
1.1 |
} else { |
1570 |
joko |
1.3 |
$_return = call_user_func_array( |
1571 |
|
|
$this->default_template_handler_func, |
1572 |
|
|
array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this)); |
1573 |
cvsjoko |
1.1 |
} |
1574 |
|
|
} |
1575 |
joko |
1.3 |
} |
1576 |
cvsjoko |
1.1 |
|
1577 |
joko |
1.3 |
if (!$_return) { |
1578 |
|
|
if (!$params['quiet']) { |
1579 |
|
|
$this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"'); |
1580 |
|
|
} |
1581 |
|
|
} else if ($_return && $this->security) { |
1582 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); |
1583 |
|
|
if (!smarty_core_is_secure($_params, $this)) { |
1584 |
|
|
if (!$params['quiet']) |
1585 |
|
|
$this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed'); |
1586 |
|
|
$params['source_content'] = null; |
1587 |
|
|
$params['resource_timestamp'] = null; |
1588 |
|
|
return false; |
1589 |
cvsjoko |
1.1 |
} |
1590 |
|
|
} |
1591 |
joko |
1.3 |
return $_return; |
1592 |
|
|
} |
1593 |
cvsjoko |
1.1 |
|
1594 |
|
|
|
1595 |
joko |
1.3 |
/** |
1596 |
|
|
* parse out the type and name from the resource |
1597 |
|
|
* |
1598 |
|
|
* @param string $resource_base_path |
1599 |
|
|
* @param string $resource_name |
1600 |
|
|
* @param string $resource_type |
1601 |
|
|
* @param string $resource_name |
1602 |
|
|
* @return boolean |
1603 |
|
|
*/ |
1604 |
cvsjoko |
1.1 |
|
1605 |
joko |
1.3 |
function _parse_resource_name(&$params) |
1606 |
|
|
{ |
1607 |
cvsjoko |
1.1 |
|
1608 |
joko |
1.3 |
// split tpl_path by the first colon |
1609 |
|
|
$_resource_name_parts = explode(':', $params['resource_name'], 2); |
1610 |
cvsjoko |
1.1 |
|
1611 |
joko |
1.3 |
if (count($_resource_name_parts) == 1) { |
1612 |
|
|
// no resource type given |
1613 |
|
|
$params['resource_type'] = $this->default_resource_type; |
1614 |
|
|
$params['resource_name'] = $_resource_name_parts[0]; |
1615 |
|
|
} else { |
1616 |
|
|
if(strlen($_resource_name_parts[0]) == 1) { |
1617 |
|
|
// 1 char is not resource type, but part of filepath |
1618 |
|
|
$params['resource_type'] = $this->default_resource_type; |
1619 |
|
|
$params['resource_name'] = $params['resource_name']; |
1620 |
cvsjoko |
1.1 |
} else { |
1621 |
joko |
1.3 |
$params['resource_type'] = $_resource_name_parts[0]; |
1622 |
|
|
$params['resource_name'] = $_resource_name_parts[1]; |
1623 |
cvsjoko |
1.1 |
} |
1624 |
|
|
} |
1625 |
|
|
|
1626 |
joko |
1.3 |
if ($params['resource_type'] == 'file') { |
1627 |
|
|
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { |
1628 |
|
|
// relative pathname to $params['resource_base_path'] |
1629 |
|
|
// use the first directory where the file is found |
1630 |
|
|
foreach ((array)$params['resource_base_path'] as $_curr_path) { |
1631 |
|
|
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; |
1632 |
|
|
if (file_exists($_fullpath) && is_file($_fullpath)) { |
1633 |
|
|
$params['resource_name'] = $_fullpath; |
1634 |
|
|
return true; |
1635 |
|
|
} |
1636 |
|
|
// didn't find the file, try include_path |
1637 |
|
|
$_params = array('file_path' => $_fullpath); |
1638 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); |
1639 |
|
|
if(smarty_core_get_include_path($_params, $this)) { |
1640 |
|
|
$params['resource_name'] = $_params['new_file_path']; |
1641 |
|
|
return true; |
1642 |
|
|
} |
1643 |
|
|
} |
1644 |
|
|
return false; |
1645 |
|
|
} else { |
1646 |
|
|
/* absolute path */ |
1647 |
|
|
return file_exists($params['resource_name']); |
1648 |
|
|
} |
1649 |
|
|
} elseif (empty($this->_plugins['resource'][$params['resource_type']])) { |
1650 |
|
|
$_params = array('type' => $params['resource_type']); |
1651 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_resource_plugin.php'); |
1652 |
|
|
smarty_core_load_resource_plugin($_params, $this); |
1653 |
cvsjoko |
1.1 |
} |
1654 |
|
|
|
1655 |
joko |
1.3 |
return true; |
1656 |
cvsjoko |
1.1 |
} |
1657 |
|
|
|
1658 |
|
|
|
1659 |
joko |
1.3 |
/** |
1660 |
|
|
* Handle modifiers |
1661 |
|
|
* |
1662 |
|
|
* @param string|null $modifier_name |
1663 |
|
|
* @param array|null $map_array |
1664 |
|
|
* @return string result of modifiers |
1665 |
|
|
*/ |
1666 |
cvsjoko |
1.1 |
function _run_mod_handler() |
1667 |
|
|
{ |
1668 |
joko |
1.3 |
$_args = func_get_args(); |
1669 |
|
|
list($_modifier_name, $_map_array) = array_splice($_args, 0, 2); |
1670 |
|
|
list($_func_name, $_tpl_file, $_tpl_line) = |
1671 |
|
|
$this->_plugins['modifier'][$_modifier_name]; |
1672 |
|
|
|
1673 |
|
|
$_var = $_args[0]; |
1674 |
|
|
foreach ($_var as $_key => $_val) { |
1675 |
|
|
$_args[0] = $_val; |
1676 |
|
|
$_var[$_key] = call_user_func_array($_func_name, $_args); |
1677 |
|
|
} |
1678 |
|
|
return $_var; |
1679 |
|
|
} |
1680 |
|
|
|
1681 |
|
|
/** |
1682 |
|
|
* Remove starting and ending quotes from the string |
1683 |
|
|
* |
1684 |
|
|
* @param string $string |
1685 |
|
|
* @return string |
1686 |
|
|
*/ |
1687 |
cvsjoko |
1.1 |
function _dequote($string) |
1688 |
|
|
{ |
1689 |
|
|
if (($string{0} == "'" || $string{0} == '"') && |
1690 |
|
|
$string{strlen($string)-1} == $string{0}) |
1691 |
|
|
return substr($string, 1, -1); |
1692 |
|
|
else |
1693 |
|
|
return $string; |
1694 |
|
|
} |
1695 |
|
|
|
1696 |
|
|
|
1697 |
joko |
1.3 |
/** |
1698 |
|
|
* read in a file from line $start for $lines. |
1699 |
|
|
* read the entire file if $start and $lines are null. |
1700 |
|
|
* |
1701 |
|
|
* @param string $filename |
1702 |
|
|
* @param integer $start |
1703 |
|
|
* @param integer $lines |
1704 |
|
|
* @return string |
1705 |
|
|
*/ |
1706 |
|
|
function _read_file($filename) |
1707 |
cvsjoko |
1.1 |
{ |
1708 |
joko |
1.3 |
if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) { |
1709 |
|
|
$contents = ($size = filesize($filename)) ? fread($fd, $size) : ''; |
1710 |
|
|
fclose($fd); |
1711 |
|
|
return $contents; |
1712 |
|
|
} else { |
1713 |
cvsjoko |
1.1 |
return false; |
1714 |
|
|
} |
1715 |
|
|
} |
1716 |
|
|
|
1717 |
joko |
1.3 |
/** |
1718 |
|
|
* get a concrete filename for automagically created content |
1719 |
|
|
* |
1720 |
|
|
* @param string $auto_base |
1721 |
|
|
* @param string $auto_source |
1722 |
|
|
* @param string $auto_id |
1723 |
|
|
* @return string |
1724 |
|
|
* @staticvar string|null |
1725 |
|
|
* @staticvar string|null |
1726 |
|
|
*/ |
1727 |
|
|
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) |
1728 |
cvsjoko |
1.1 |
{ |
1729 |
joko |
1.3 |
$_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; |
1730 |
cvsjoko |
1.1 |
|
1731 |
joko |
1.3 |
if(@is_dir($auto_base)) { |
1732 |
|
|
$_return = $auto_base . DIRECTORY_SEPARATOR; |
1733 |
|
|
} else { |
1734 |
|
|
// auto_base not found, try include_path |
1735 |
|
|
$_params = array('file_path' => $auto_base); |
1736 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); |
1737 |
|
|
smarty_core_get_include_path($_params, $this); |
1738 |
|
|
$_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null; |
1739 |
|
|
} |
1740 |
|
|
|
1741 |
|
|
if(isset($auto_id)) { |
1742 |
|
|
// make auto_id safe for directory names |
1743 |
|
|
$auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id))); |
1744 |
|
|
// split into separate directories |
1745 |
|
|
$_return .= $auto_id . $_compile_dir_sep; |
1746 |
|
|
} |
1747 |
|
|
|
1748 |
|
|
if(isset($auto_source)) { |
1749 |
|
|
// make source name safe for filename |
1750 |
|
|
$_filename = urlencode(basename($auto_source)); |
1751 |
|
|
$_crc32 = sprintf("%08X", crc32($auto_source)); |
1752 |
|
|
// prepend %% to avoid name conflicts with |
1753 |
|
|
// with $params['auto_id'] names |
1754 |
|
|
$_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . |
1755 |
|
|
substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32; |
1756 |
|
|
$_return .= '%%' . $_crc32 . '%%' . $_filename; |
1757 |
cvsjoko |
1.1 |
} |
1758 |
|
|
|
1759 |
joko |
1.3 |
return $_return; |
1760 |
cvsjoko |
1.1 |
} |
1761 |
|
|
|
1762 |
joko |
1.3 |
/** |
1763 |
|
|
* unlink a file, possibly using expiration time |
1764 |
|
|
* |
1765 |
|
|
* @param string $resource |
1766 |
|
|
* @param integer $exp_time |
1767 |
|
|
*/ |
1768 |
cvsjoko |
1.1 |
function _unlink($resource, $exp_time = null) |
1769 |
|
|
{ |
1770 |
joko |
1.3 |
if(isset($exp_time)) { |
1771 |
|
|
if(time() - @filemtime($resource) >= $exp_time) { |
1772 |
|
|
return @unlink($resource); |
1773 |
|
|
} |
1774 |
|
|
} else { |
1775 |
|
|
return @unlink($resource); |
1776 |
cvsjoko |
1.1 |
} |
1777 |
|
|
} |
1778 |
|
|
|
1779 |
joko |
1.3 |
/** |
1780 |
|
|
* returns an auto_id for auto-file-functions |
1781 |
|
|
* |
1782 |
|
|
* @param string $cache_id |
1783 |
|
|
* @param string $compile_id |
1784 |
|
|
* @return string|null |
1785 |
|
|
*/ |
1786 |
|
|
function _get_auto_id($cache_id=null, $compile_id=null) { |
1787 |
|
|
if (isset($cache_id)) |
1788 |
|
|
return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; |
1789 |
|
|
elseif(isset($compile_id)) |
1790 |
|
|
return $compile_id; |
1791 |
|
|
else |
1792 |
|
|
return null; |
1793 |
|
|
} |
1794 |
|
|
|
1795 |
|
|
/** |
1796 |
|
|
* trigger Smarty plugin error |
1797 |
|
|
* |
1798 |
|
|
* @param string $error_msg |
1799 |
|
|
* @param string $tpl_file |
1800 |
|
|
* @param integer $tpl_line |
1801 |
|
|
* @param string $file |
1802 |
|
|
* @param integer $line |
1803 |
|
|
* @param integer $error_type |
1804 |
|
|
*/ |
1805 |
|
|
function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null, |
1806 |
|
|
$file = null, $line = null, $error_type = E_USER_ERROR) |
1807 |
cvsjoko |
1.1 |
{ |
1808 |
joko |
1.3 |
if(isset($file) && isset($line)) { |
1809 |
|
|
$info = ' ('.basename($file).", line $line)"; |
1810 |
cvsjoko |
1.1 |
} else { |
1811 |
joko |
1.3 |
$info = ''; |
1812 |
cvsjoko |
1.1 |
} |
1813 |
joko |
1.3 |
if (isset($tpl_line) && isset($tpl_file)) { |
1814 |
|
|
$this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type); |
1815 |
cvsjoko |
1.1 |
} else { |
1816 |
joko |
1.3 |
$this->trigger_error($error_msg . $info, $error_type); |
1817 |
cvsjoko |
1.1 |
} |
1818 |
|
|
} |
1819 |
|
|
|
1820 |
|
|
|
1821 |
joko |
1.3 |
/** |
1822 |
|
|
* callback function for preg_replace, to call a non-cacheable block |
1823 |
|
|
* @return string |
1824 |
|
|
*/ |
1825 |
|
|
function _process_compiled_include_callback($match) { |
1826 |
|
|
$_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3]; |
1827 |
|
|
ob_start(); |
1828 |
|
|
$_func($this); |
1829 |
|
|
$_ret = ob_get_contents(); |
1830 |
|
|
ob_end_clean(); |
1831 |
|
|
return $_ret; |
1832 |
|
|
} |
1833 |
cvsjoko |
1.1 |
|
1834 |
|
|
|
1835 |
joko |
1.3 |
/** |
1836 |
|
|
* called for included templates |
1837 |
|
|
* |
1838 |
|
|
* @param string $_smarty_include_tpl_file |
1839 |
|
|
* @param string $_smarty_include_vars |
1840 |
|
|
*/ |
1841 |
cvsjoko |
1.1 |
|
1842 |
joko |
1.3 |
// $_smarty_include_tpl_file, $_smarty_include_vars |
1843 |
cvsjoko |
1.1 |
|
1844 |
joko |
1.3 |
function _smarty_include($params) |
1845 |
|
|
{ |
1846 |
|
|
if ($this->debugging) { |
1847 |
|
|
$_params = array(); |
1848 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); |
1849 |
|
|
$debug_start_time = smarty_core_get_microtime($_params, $this); |
1850 |
|
|
$this->_smarty_debug_info[] = array('type' => 'template', |
1851 |
|
|
'filename' => $params['smarty_include_tpl_file'], |
1852 |
|
|
'depth' => ++$this->_inclusion_depth); |
1853 |
|
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1; |
1854 |
cvsjoko |
1.1 |
} |
1855 |
|
|
|
1856 |
joko |
1.3 |
$this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']); |
1857 |
cvsjoko |
1.1 |
|
1858 |
joko |
1.3 |
// config vars are treated as local, so push a copy of the |
1859 |
|
|
// current ones onto the front of the stack |
1860 |
|
|
array_unshift($this->_config, $this->_config[0]); |
1861 |
cvsjoko |
1.1 |
|
1862 |
joko |
1.3 |
$_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']); |
1863 |
cvsjoko |
1.1 |
|
1864 |
|
|
|
1865 |
joko |
1.3 |
if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) |
1866 |
|
|
|| $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) |
1867 |
|
|
{ |
1868 |
|
|
include($_smarty_compile_path); |
1869 |
cvsjoko |
1.1 |
} |
1870 |
|
|
|
1871 |
joko |
1.3 |
// pop the local vars off the front of the stack |
1872 |
|
|
array_shift($this->_config); |
1873 |
cvsjoko |
1.1 |
|
1874 |
joko |
1.3 |
$this->_inclusion_depth--; |
1875 |
|
|
|
1876 |
|
|
if ($this->debugging) { |
1877 |
|
|
// capture time for debugging info |
1878 |
|
|
$_params = array(); |
1879 |
|
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); |
1880 |
|
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time; |
1881 |
cvsjoko |
1.1 |
} |
1882 |
|
|
|
1883 |
joko |
1.3 |
if ($this->caching) { |
1884 |
|
|
$this->_cache_info['template'][$params['smarty_include_tpl_file']] = true; |
1885 |
cvsjoko |
1.1 |
} |
1886 |
|
|
} |
1887 |
|
|
|
1888 |
|
|
|
1889 |
joko |
1.3 |
/** |
1890 |
|
|
* get or set an array of cached attributes for function that is |
1891 |
|
|
* not cacheable |
1892 |
|
|
* @return array |
1893 |
|
|
*/ |
1894 |
|
|
function &_smarty_cache_attrs($cache_serial, $count) { |
1895 |
|
|
$_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count]; |
1896 |
cvsjoko |
1.1 |
|
1897 |
joko |
1.3 |
if ($this->_cache_including) { |
1898 |
|
|
/* return next set of cache_attrs */ |
1899 |
|
|
$_return =& current($_cache_attrs); |
1900 |
|
|
next($_cache_attrs); |
1901 |
|
|
return $_return; |
1902 |
cvsjoko |
1.1 |
|
1903 |
joko |
1.3 |
} else { |
1904 |
|
|
/* add a reference to a new set of cache_attrs */ |
1905 |
|
|
$_cache_attrs[] = array(); |
1906 |
|
|
return $_cache_attrs[count($_cache_attrs)-1]; |
1907 |
cvsjoko |
1.1 |
|
1908 |
joko |
1.3 |
} |
1909 |
cvsjoko |
1.1 |
|
1910 |
|
|
} |
1911 |
|
|
|
1912 |
joko |
1.3 |
|
1913 |
|
|
/** |
1914 |
|
|
* wrapper for include() retaining $this |
1915 |
|
|
* @return mixed |
1916 |
|
|
*/ |
1917 |
|
|
function _include($filename, $once=false, $params=null) |
1918 |
cvsjoko |
1.1 |
{ |
1919 |
joko |
1.3 |
if ($once) { |
1920 |
|
|
return include_once($filename); |
1921 |
|
|
} else { |
1922 |
|
|
return include($filename); |
1923 |
cvsjoko |
1.1 |
} |
1924 |
|
|
} |
1925 |
|
|
|
1926 |
|
|
|
1927 |
joko |
1.3 |
/** |
1928 |
|
|
* wrapper for eval() retaining $this |
1929 |
|
|
* @return mixed |
1930 |
|
|
*/ |
1931 |
|
|
function _eval($code, $params=null) |
1932 |
cvsjoko |
1.1 |
{ |
1933 |
joko |
1.3 |
return eval($code); |
1934 |
cvsjoko |
1.1 |
} |
1935 |
joko |
1.3 |
/**#@-*/ |
1936 |
cvsjoko |
1.1 |
|
1937 |
|
|
} |
1938 |
|
|
|
1939 |
|
|
/* vim: set expandtab: */ |
1940 |
|
|
|
1941 |
|
|
?> |