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