| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Project:     Smarty: the PHP compiling template engine | 
					
						
							|  |  |  | * File:        Smarty.class.php | 
					
						
							| 
									
										
										
										
											2009-10-29 13:39:02 +00:00
										 |  |  | * SVN:         $Id$ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | *  | 
					
						
							|  |  |  | * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  | * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  | * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  | * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  | * Lesser General Public License for more details. | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  | * License along with this library; if not, write to the Free Software | 
					
						
							|  |  |  | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * For questions, help, comments, discussion, etc., please join the | 
					
						
							|  |  |  | * Smarty mailing list. Send a blank e-mail to | 
					
						
							|  |  |  | * smarty-discussion-subscribe@googlegroups.com | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * @link http://www.smarty.net/ | 
					
						
							|  |  |  | * @copyright 2008 New Digital Group, Inc. | 
					
						
							|  |  |  | * @author Monte Ohrt <monte at ohrt dot com>  | 
					
						
							|  |  |  | * @author Uwe Tews  | 
					
						
							|  |  |  | * @package Smarty | 
					
						
							| 
									
										
										
										
											2009-10-29 13:39:02 +00:00
										 |  |  | * @version 3-SVN$Rev: 3286 $ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * define shorthand directory separator constant | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | if (!defined('DS')) { | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     define('DS', DIRECTORY_SEPARATOR); | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * set SMARTY_DIR to absolute path to Smarty library files. | 
					
						
							| 
									
										
										
										
											2009-08-30 18:10:01 +00:00
										 |  |  | * Sets SMARTY_DIR only if user application has not already defined it. | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | if (!defined('SMARTY_DIR')) { | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |     define('SMARTY_DIR', dirname(__FILE__) . DS); | 
					
						
							| 
									
										
										
										
											2009-04-10 01:15:53 +00:00
										 |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-04-06 02:53:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-30 18:10:01 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. | 
					
						
							|  |  |  | * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | if (!defined('SMARTY_SYSPLUGINS_DIR')) { | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); | 
					
						
							| 
									
										
										
										
											2009-08-30 18:10:01 +00:00
										 |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  | if (!defined('SMARTY_PLUGINS_DIR')) { | 
					
						
							|  |  |  |     define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | if (!defined('SMARTY_RESOURCE_CHAR_SET')) { | 
					
						
							|  |  |  |     define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8'); | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-11-17 17:46:03 +00:00
										 |  |  | if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { | 
					
						
							|  |  |  |     define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-06 02:53:09 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2009-04-10 01:15:53 +00:00
										 |  |  | * define variable scopes | 
					
						
							| 
									
										
										
										
											2009-04-06 02:53:09 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-04-10 01:15:53 +00:00
										 |  |  | define('SMARTY_LOCAL_SCOPE', 0); | 
					
						
							|  |  |  | define('SMARTY_PARENT_SCOPE', 1); | 
					
						
							|  |  |  | define('SMARTY_ROOT_SCOPE', 2); | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  | define('SMARTY_GLOBAL_SCOPE', 3); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * define caching modes | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | define('SMARTY_CACHING_OFF', 0); | 
					
						
							|  |  |  | define('SMARTY_CACHING_LIFETIME_CURRENT', 1); | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  | define('SMARTY_CACHING_LIFETIME_SAVED', 2); | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 16:23:35 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * This determines how Smarty handles "<?php ... ?>" tags in templates. | 
					
						
							|  |  |  | * possible values: | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | define('SMARTY_PHP_PASSTHRU', 0); //-> print tags as plain text
 | 
					
						
							|  |  |  | define('SMARTY_PHP_QUOTE', 1); //-> escape tags as entities
 | 
					
						
							|  |  |  | define('SMARTY_PHP_REMOVE', 2); //-> escape tags as entities
 | 
					
						
							|  |  |  | define('SMARTY_PHP_ALLOW', 3); //-> escape tags as entities
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2009-10-21 09:49:43 +00:00
										 |  |  | * register the class autoloader | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-11-09 17:26:59 +00:00
										 |  |  | if (!defined('SMARTY_SPL_AUTOLOAD')) { | 
					
						
							| 
									
										
										
										
											2009-11-14 13:02:48 +00:00
										 |  |  |     define('SMARTY_SPL_AUTOLOAD', 0); | 
					
						
							| 
									
										
										
										
											2009-11-09 17:26:59 +00:00
										 |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { | 
					
						
							|  |  |  |     $registeredAutoLoadFunctions = spl_autoload_functions(); | 
					
						
							|  |  |  |     if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { | 
					
						
							|  |  |  |         spl_autoload_register(); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |     spl_autoload_register('smartyAutoload'); | 
					
						
							| 
									
										
										
										
											2009-11-14 13:02:48 +00:00
										 |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-11-06 16:51:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * This is the main Smarty class | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty extends Smarty_Internal_Data { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // smarty version
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     const SMARTY_VERSION = 'Smarty3-SVN$Rev: 3286 $';  | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |     // auto literal on delimiters with whitspace
 | 
					
						
							|  |  |  |     public $auto_literal = true;  | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |     // display error on not assigned variables
 | 
					
						
							|  |  |  |     public $error_unassigned = false;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // template directory
 | 
					
						
							| 
									
										
										
										
											2009-04-10 01:15:53 +00:00
										 |  |  |     public $template_dir = null;  | 
					
						
							| 
									
										
										
										
											2009-04-03 15:59:40 +00:00
										 |  |  |     // default template handler
 | 
					
						
							|  |  |  |     public $default_template_handler_func = null;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // compile directory
 | 
					
						
							|  |  |  |     public $compile_dir = null;  | 
					
						
							|  |  |  |     // plugins directory
 | 
					
						
							|  |  |  |     public $plugins_dir = null;  | 
					
						
							|  |  |  |     // cache directory
 | 
					
						
							|  |  |  |     public $cache_dir = null;  | 
					
						
							|  |  |  |     // config directory
 | 
					
						
							|  |  |  |     public $config_dir = null;  | 
					
						
							|  |  |  |     // force template compiling?
 | 
					
						
							|  |  |  |     public $force_compile = false;  | 
					
						
							| 
									
										
										
										
											2009-03-31 14:20:10 +00:00
										 |  |  |     // check template for modifications?
 | 
					
						
							|  |  |  |     public $compile_check = true;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // use sub dirs for compiled/cached files?
 | 
					
						
							|  |  |  |     public $use_sub_dirs = false;  | 
					
						
							|  |  |  |     // compile_error?
 | 
					
						
							|  |  |  |     public $compile_error = false;  | 
					
						
							|  |  |  |     // caching enabled
 | 
					
						
							|  |  |  |     public $caching = false;  | 
					
						
							| 
									
										
										
										
											2009-10-13 19:44:38 +00:00
										 |  |  |     // merge compiled includea
 | 
					
						
							| 
									
										
										
										
											2009-11-18 17:25:18 +00:00
										 |  |  |     public $merge_compiled_includes = false;  | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     // cache lifetime
 | 
					
						
							| 
									
										
										
										
											2009-12-28 03:22:57 +00:00
										 |  |  |     public $cache_lifetime = 3600;  | 
					
						
							| 
									
										
										
										
											2009-08-27 14:59:28 +00:00
										 |  |  |     // force cache file creation
 | 
					
						
							|  |  |  |     public $force_cache = false;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // cache_id
 | 
					
						
							|  |  |  |     public $cache_id = null;  | 
					
						
							|  |  |  |     // compile_id
 | 
					
						
							|  |  |  |     public $compile_id = null;  | 
					
						
							|  |  |  |     // template delimiters
 | 
					
						
							|  |  |  |     public $left_delimiter = "{"; | 
					
						
							|  |  |  |     public $right_delimiter = "}";  | 
					
						
							|  |  |  |     // security
 | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |     public $security_class = 'Smarty_Security'; | 
					
						
							| 
									
										
										
										
											2009-09-29 16:23:35 +00:00
										 |  |  |     public $php_handling = SMARTY_PHP_PASSTHRU; | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  |     public $allow_php_tag = false; | 
					
						
							|  |  |  |     public $allow_php_templates = false; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public $security = false; | 
					
						
							|  |  |  |     public $security_policy = null; | 
					
						
							|  |  |  |     public $security_handler = null; | 
					
						
							|  |  |  |     public $direct_access_security = true;  | 
					
						
							|  |  |  |     // debug mode
 | 
					
						
							|  |  |  |     public $debugging = false; | 
					
						
							|  |  |  |     public $debugging_ctrl = 'URL'; | 
					
						
							|  |  |  |     public $smarty_debug_id = 'SMARTY_DEBUG'; | 
					
						
							| 
									
										
										
										
											2009-08-08 17:28:23 +00:00
										 |  |  |     public $debug_tpl = null;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // When set, smarty does uses this value as error_reporting-level.
 | 
					
						
							| 
									
										
										
										
											2009-05-06 07:46:08 +00:00
										 |  |  |     public $error_reporting = null;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // config var settings
 | 
					
						
							|  |  |  |     public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
 | 
					
						
							|  |  |  |     public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
 | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.                                                
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // config vars
 | 
					
						
							|  |  |  |     public $config_vars = array();  | 
					
						
							|  |  |  |     // assigned tpl vars
 | 
					
						
							|  |  |  |     public $tpl_vars = array();  | 
					
						
							|  |  |  |     // assigned global tpl vars
 | 
					
						
							|  |  |  |     public $global_tpl_vars = array();  | 
					
						
							|  |  |  |     // dummy parent object
 | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |     public $parent = null;  | 
					
						
							| 
									
										
										
										
											2009-04-30 17:39:17 +00:00
										 |  |  |     // global template functions
 | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |     public $template_functions = array();  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // resource type used if none given
 | 
					
						
							|  |  |  |     public $default_resource_type = 'file';  | 
					
						
							|  |  |  |     // caching type
 | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     public $caching_type = 'file';  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // internal cache resource types
 | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     public $cache_resource_types = array('file');  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     // internal cache resource objects
 | 
					
						
							|  |  |  |     public $cache_resource_objects = array();  | 
					
						
							|  |  |  |     // internal config properties
 | 
					
						
							|  |  |  |     public $properties = array();  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // config type
 | 
					
						
							|  |  |  |     public $default_config_type = 'file';  | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |     // exception handler: array('ExceptionClass','ExceptionMethod');
 | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     public $exception_handler = null;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // cached template objects
 | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |     public $template_objects = null;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // check If-Modified-Since headers
 | 
					
						
							|  |  |  |     public $cache_modified_check = false;  | 
					
						
							|  |  |  |     // registered plugins
 | 
					
						
							|  |  |  |     public $registered_plugins = array();  | 
					
						
							|  |  |  |     // plugin search order
 | 
					
						
							|  |  |  |     public $plugin_search_order = array('function', 'block', 'compiler', 'class');  | 
					
						
							|  |  |  |     // registered objects
 | 
					
						
							|  |  |  |     public $registered_objects = array();  | 
					
						
							|  |  |  |     // registered filters
 | 
					
						
							|  |  |  |     public $registered_filters = array();  | 
					
						
							| 
									
										
										
										
											2009-04-10 01:15:53 +00:00
										 |  |  |     // autoload filter
 | 
					
						
							|  |  |  |     public $autoload_filters = array();  | 
					
						
							|  |  |  |     // status of filter on variable output
 | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |     public $variable_filter = true;  | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     // default modifier
 | 
					
						
							|  |  |  |     public $default_modifiers = array();  | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  |     // global internal smarty  vars
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public $_smarty_vars = array();  | 
					
						
							|  |  |  |     // start time for execution time calculation
 | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |     public $start_time = 0;  | 
					
						
							|  |  |  |     // default file permissions
 | 
					
						
							|  |  |  |     public $_file_perms = 0644;  | 
					
						
							|  |  |  |     // default dir permissions
 | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |     public $_dir_perms = 0771;  | 
					
						
							| 
									
										
										
										
											2009-11-03 15:51:29 +00:00
										 |  |  |     // smarty object reference
 | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     public $smarty = null;  | 
					
						
							|  |  |  |     // block data at template inheritance
 | 
					
						
							|  |  |  |     public $block_data = array();  | 
					
						
							| 
									
										
										
										
											2010-02-09 21:20:17 +00:00
										 |  |  |     // block tag hierarchy
 | 
					
						
							|  |  |  |     public $_tag_stack = array(); | 
					
						
							| 
									
										
										
										
											2010-02-14 16:42:39 +00:00
										 |  |  |     // plugins
 | 
					
						
							|  |  |  |     public $_plugins = array(); | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     // generate deprecated function call notices?
 | 
					
						
							|  |  |  |     public $deprecation_notices = true; | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Class constructor, initializes basic smarty properties | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function __construct() { | 
					
						
							| 
									
										
										
										
											2009-11-03 15:51:29 +00:00
										 |  |  |         // self reference needed by other classes methods
 | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         $this->smarty = $this; | 
					
						
							| 
									
										
										
										
											2009-09-29 16:23:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-10 15:52:59 +00:00
										 |  |  |         if (is_callable('mb_internal_encoding')) { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |             mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET); | 
					
						
							| 
									
										
										
										
											2009-04-10 15:52:59 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->start_time = $this->_get_time();  | 
					
						
							|  |  |  |         // set exception handler
 | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |         if (!empty($this->exception_handler)) | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         set_exception_handler($this->exception_handler);  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // set default dirs
 | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |         $this->template_dir = array('.' . DS . 'templates' . DS); | 
					
						
							|  |  |  |         $this->compile_dir = '.' . DS . 'templates_c' . DS; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         $this->plugins_dir = array(SMARTY_PLUGINS_DIR); | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |         $this->cache_dir = '.' . DS . 'cache' . DS; | 
					
						
							|  |  |  |         $this->config_dir = '.' . DS . 'configs' . DS; | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         $this->debug_tpl = SMARTY_DIR . 'debug.tpl'; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         if (!$this->debugging && $this->debugging_ctrl == 'URL') { | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |             if (isset($_SERVER['QUERY_STRING'])) { | 
					
						
							|  |  |  |                 $_query_string = $_SERVER['QUERY_STRING']; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |             else { | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |                 $_query_string = ''; | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             if (false !== strpos($_query_string, $this->smarty_debug_id)) { | 
					
						
							|  |  |  |                 if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) { | 
					
						
							|  |  |  |                     // enable debugging for this browser session
 | 
					
						
							|  |  |  |                     setcookie('SMARTY_DEBUG', true); | 
					
						
							|  |  |  |                     $this->debugging = true; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 }  | 
					
						
							|  |  |  |                 elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     // disable debugging for this browser session
 | 
					
						
							|  |  |  |                     setcookie('SMARTY_DEBUG', false); | 
					
						
							|  |  |  |                     $this->debugging = false; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 }  | 
					
						
							|  |  |  |                 else { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     // enable debugging for this page
 | 
					
						
							|  |  |  |                     $this->debugging = true; | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |             else { | 
					
						
							| 
									
										
										
										
											2009-06-22 14:23:21 +00:00
										 |  |  |                 if (isset($_COOKIE['SMARTY_DEBUG'])) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     $this->debugging = true; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |         if (isset($_SERVER['SCRIPT_NAME'])) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |             $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Class destructor | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function __destruct() { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // restore to previous exception handler, if any
 | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |         if (!empty($this->exception_handler)) | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         restore_exception_handler(); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * fetches a rendered Smarty template | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $template the resource handle of the template file or template object | 
					
						
							|  |  |  |     * @param mixed $cache_id cache id to be used with this template | 
					
						
							|  |  |  |     * @param mixed $compile_id compile id to be used with this template | 
					
						
							| 
									
										
										
										
											2009-09-29 20:36:29 +00:00
										 |  |  |     * @param object $ |null $parent next higher level of Smarty variables | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     * @return string rendered template output | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function fetch($template, $cache_id = null, $compile_id = null, $parent = null) { | 
					
						
							| 
									
										
										
										
											2009-09-29 20:36:29 +00:00
										 |  |  |         if (is_object($cache_id)) { | 
					
						
							|  |  |  |             $parent = $cache_id; | 
					
						
							|  |  |  |             $cache_id = null; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         if ($parent === null) { | 
					
						
							|  |  |  |             // get default Smarty data object
 | 
					
						
							|  |  |  |             $parent = $this; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // create template object if necessary
 | 
					
						
							|  |  |  |         ($template instanceof $this->template_class)? $_template = $template : | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); | 
					
						
							| 
									
										
										
										
											2009-03-22 22:35:10 +00:00
										 |  |  |         $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) | 
					
						
							|  |  |  |             ? $this->error_reporting : error_reporting() &~E_NOTICE);  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // return redered template
 | 
					
						
							| 
									
										
										
										
											2009-11-14 13:02:48 +00:00
										 |  |  |         if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2009-11-14 13:02:48 +00:00
										 |  |  |             $_output = $_template->getRenderedTemplate(); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $_template->rendered_content = null; | 
					
						
							| 
									
										
										
										
											2009-03-22 22:35:10 +00:00
										 |  |  |         error_reporting($_smarty_old_error_level); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $_output; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * displays a Smarty template | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $ |object $template the resource handle of the template file  or template object | 
					
						
							|  |  |  |     * @param mixed $cache_id cache id to be used with this template | 
					
						
							|  |  |  |     * @param mixed $compile_id compile id to be used with this template | 
					
						
							| 
									
										
										
										
											2009-09-29 20:36:29 +00:00
										 |  |  |     * @param object $parent next higher level of Smarty variables | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function display($template, $cache_id = null, $compile_id = null, $parent = null) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // display template
 | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         echo $this->fetch ($template, $cache_id, $compile_id, $parent);  | 
					
						
							| 
									
										
										
										
											2009-10-13 19:44:38 +00:00
										 |  |  |         // debug output
 | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |         if ($this->debugging) { | 
					
						
							|  |  |  |             Smarty_Internal_Debug::display_debug($this); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * test if cache i valid | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $ |object $template the resource handle of the template file or template object | 
					
						
							|  |  |  |     * @param mixed $cache_id cache id to be used with this template | 
					
						
							|  |  |  |     * @param mixed $compile_id compile id to be used with this template | 
					
						
							|  |  |  |     * @return boolean cache status | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function isCached($template, $cache_id = null, $compile_id = null) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         if (!($template instanceof $this->template_class)) { | 
					
						
							| 
									
										
										
										
											2009-09-20 02:02:44 +00:00
										 |  |  |             $template = $this->createTemplate ($template, $cache_id, $compile_id, $this); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         // return cache status of template
 | 
					
						
							|  |  |  |         return $template->isCached(); | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * creates a data object | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param object $parent next higher level of Smarty variables | 
					
						
							|  |  |  |     * @returns object data object | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |     public function createData($parent = null) { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |         return new Smarty_Data($parent, $this); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * creates a template object | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $template the resource handle of the template file | 
					
						
							|  |  |  |     * @param object $parent next higher level of Smarty variables | 
					
						
							|  |  |  |     * @param mixed $cache_id cache id to be used with this template | 
					
						
							|  |  |  |     * @param mixed $compile_id compile id to be used with this template | 
					
						
							|  |  |  |     * @returns object template object | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |     public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null) { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |         if (is_object($cache_id) || is_array($cache_id)) { | 
					
						
							|  |  |  |             $parent = $cache_id; | 
					
						
							|  |  |  |             $cache_id = null; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (is_array($parent)) { | 
					
						
							|  |  |  |             $data = $parent; | 
					
						
							|  |  |  |             $parent = null; | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |             $data = null; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (!is_object($template)) { | 
					
						
							|  |  |  |             // we got a template resource
 | 
					
						
							|  |  |  |             // already in template cache?
 | 
					
						
							|  |  |  |             $_templateId = crc32($template . $cache_id . $compile_id); | 
					
						
							|  |  |  |             if (isset($this->template_objects[$_templateId]) && $this->caching) { | 
					
						
							|  |  |  |                 // return cached template object
 | 
					
						
							|  |  |  |                 $tpl = $this->template_objects[$_templateId]; | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |             else { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |                 // create new template object
 | 
					
						
							|  |  |  |                 $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2010-01-22 16:39:30 +00:00
										 |  |  |             // just return a copy of template class
 | 
					
						
							|  |  |  |             $tpl = $template; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // fill data if present
 | 
					
						
							|  |  |  |         if (is_array($data)) { | 
					
						
							|  |  |  |             // set up variable values
 | 
					
						
							|  |  |  |             foreach ($data as $_key => $_val) { | 
					
						
							|  |  |  |                 $tpl->tpl_vars[$_key] = new Smarty_variable($_val); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         return $tpl; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |     * Loads security class and enables security | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function enableSecurity() { | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |         if (isset($this->security_class)) { | 
					
						
							|  |  |  |             $this->security_policy = new $this->security_class; | 
					
						
							| 
									
										
										
										
											2009-08-08 17:28:23 +00:00
										 |  |  |             $this->security_handler = new Smarty_Internal_Security_Handler($this); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             $this->security = true; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |             throw new Exception('Property security_class is not defined'); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Disable security | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function disableSecurity() { | 
					
						
							|  |  |  |         $this->security = true; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Set template directory | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $ |array $template_dir folder(s) of template sorces | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function setTemplateDir($template_dir) { | 
					
						
							| 
									
										
										
										
											2009-04-29 17:56:56 +00:00
										 |  |  |         $this->template_dir = (array)$template_dir; | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |         return; | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Adds template directory(s) to existing ones | 
					
						
							|  |  |  |     *  | 
					
						
							| 
									
										
										
										
											2009-03-31 14:20:10 +00:00
										 |  |  |     * @param string $ |array $template_dir folder(s) of template sources | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function addTemplateDir($template_dir) { | 
					
						
							| 
									
										
										
										
											2009-04-29 17:56:56 +00:00
										 |  |  |         $this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir); | 
					
						
							|  |  |  |         $this->template_dir = array_unique($this->template_dir); | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |         return; | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * Check if a template resource exists | 
					
						
							| 
									
										
										
										
											2009-03-31 14:20:10 +00:00
										 |  |  |     *  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * @param string $resource_name template name | 
					
						
							|  |  |  |     * @return boolean status | 
					
						
							| 
									
										
										
										
											2009-03-30 17:05:37 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function templateExists($resource_name) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         // create template object
 | 
					
						
							|  |  |  |         $tpl = new $this->template_class($resource_name, $this);  | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         // check if it does exists
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         return $tpl->isExisting(); | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Takes unknown classes and loads plugin files for them | 
					
						
							|  |  |  |     * class name format: Smarty_PluginType_PluginName | 
					
						
							|  |  |  |     * plugin filename format: plugintype.pluginname.php | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $plugin_name class plugin name to load | 
					
						
							| 
									
										
										
										
											2010-01-25 19:02:34 +00:00
										 |  |  |     * @return string |boolean filepath of loaded file or false | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function loadPlugin($plugin_name, $check = true) { | 
					
						
							|  |  |  |         // if function or class exists, exit silently (already loaded)
 | 
					
						
							|  |  |  |         if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) | 
					
						
							|  |  |  |         return true;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // Plugin name is expected to be: Smarty_[Type]_[Name]
 | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         $_plugin_name = strtolower($plugin_name); | 
					
						
							|  |  |  |         $_name_parts = explode('_', $_plugin_name, 3);  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // class name must have three parts to be valid plugin
 | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |         if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             throw new Exception("plugin {$plugin_name} is not a valid name format"); | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // if type is "internal", get plugin from sysplugins
 | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |         if ($_name_parts[1] == 'internal') { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php'; | 
					
						
							|  |  |  |             if (file_exists($file)) { | 
					
						
							|  |  |  |                 require_once($file); | 
					
						
							|  |  |  |                 return $file; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             else { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         // plugin filename is expected to be: [type].[name].php
 | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |         $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // loop through plugin dirs and find the plugin
 | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |         foreach((array)$this->plugins_dir as $_plugin_dir) { | 
					
						
							| 
									
										
										
										
											2009-08-08 17:28:23 +00:00
										 |  |  |             if (strpos('/\\', substr($_plugin_dir, -1)) === false) { | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |                 $_plugin_dir .= DS; | 
					
						
							| 
									
										
										
										
											2009-05-06 07:46:08 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $file = $_plugin_dir . $_plugin_filename; | 
					
						
							|  |  |  |             if (file_exists($file)) { | 
					
						
							|  |  |  |                 require_once($file); | 
					
						
							|  |  |  |                 return $file; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // no plugin loaded
 | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * load a filter of specified type and name | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $type filter type | 
					
						
							|  |  |  |     * @param string $name filter name | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     * @return bool  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function loadFilter($type, $name) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         $_plugin = "smarty_{$type}filter_{$name}"; | 
					
						
							|  |  |  |         $_filter_name = $_plugin; | 
					
						
							|  |  |  |         if ($this->loadPlugin($_plugin)) { | 
					
						
							|  |  |  |             if (class_exists($_plugin, false)) { | 
					
						
							|  |  |  |                 $_plugin = array($_plugin, 'execute'); | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |             if (is_callable($_plugin)) { | 
					
						
							|  |  |  |                 return $this->registered_filters[$type][$_filter_name] = $_plugin; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         throw new Exception("{$type}filter \"{$name}\" not callable"); | 
					
						
							|  |  |  |         return false; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Sets the exception handler for Smarty. | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param mixed $handler function name or array with object/method names | 
					
						
							|  |  |  |     * @return string previous exception handler | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function setExceptionHandler($handler) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->exception_handler = $handler; | 
					
						
							|  |  |  |         return set_exception_handler($handler); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * trigger Smarty error | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     *  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * @param string $error_msg  | 
					
						
							|  |  |  |     * @param integer $error_type  | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     public function trigger_error($error_msg, $error_type = E_USER_WARNING) { | 
					
						
							|  |  |  |         throw new Exception("Smarty error: $error_msg"); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Return internal filter name | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param callback $function_name  | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     public function _get_filter_name($function_name) { | 
					
						
							|  |  |  |         if (is_array($function_name)) { | 
					
						
							|  |  |  |             $_class_name = (is_object($function_name[0]) ? | 
					
						
							|  |  |  |                 get_class($function_name[0]) : $function_name[0]); | 
					
						
							|  |  |  |             return $_class_name . '_' . $function_name[1]; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return $function_name; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * Adds directory of plugin files | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param object $smarty  | 
					
						
							|  |  |  |     * @param string $ |array $ plugins folder | 
					
						
							|  |  |  |     * @return  | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function addPluginsDir($plugins_dir) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         $this->plugins_dir = array_merge((array)$this->plugins_dir, (array)$plugins_dir); | 
					
						
							|  |  |  |         $this->plugins_dir = array_unique($this->plugins_dir); | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Returns a single or all global  variables | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param object $smarty  | 
					
						
							|  |  |  |     * @param string $varname variable name or null | 
					
						
							|  |  |  |     * @return string variable value or or array of variables | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function getGlobal($varname = null) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         if (isset($varname)) { | 
					
						
							|  |  |  |             if (isset($this->global_tpl_vars[$varname])) { | 
					
						
							|  |  |  |                 return $this->global_tpl_vars[$varname]->value; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |             else { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |                 return ''; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |             $_result = array(); | 
					
						
							|  |  |  |             foreach ($this->global_tpl_vars AS $key => $var) { | 
					
						
							|  |  |  |                 $_result[$key] = $var->value; | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |             return $_result; | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * return a reference to a registered object | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     *  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * @param string $name object name | 
					
						
							|  |  |  |     * @return object  | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function getRegisteredObject($name) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         if (!isset($this->registered_objects[$name])) | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         throw new Exception("'$name' is not a registered object"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         if (!is_object($this->registered_objects[$name][0])) | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         throw new Exception("registered '$name' is not an object"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         return $this->registered_objects[$name][0]; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |     * return name of debugging template | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @return string  | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function getDebugTemplate() { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         return $this->debug_tpl; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * set the debug template | 
					
						
							|  |  |  |     *  | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     * @param string $tpl_name  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     * @return bool  | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     function setDebugTemplate($tpl_name) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         return $this->debug_tpl = $tpl_name; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * lazy loads (valid) property objects | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $name property name | 
					
						
							|  |  |  |     */ | 
					
						
							|  |  |  |     public function __get($name) { | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         if(in_array($name, array('register', 'unregister', 'utility', 'cache'))) { | 
					
						
							|  |  |  |             $class = "Smarty_Internal_" . ucfirst($name); | 
					
						
							| 
									
										
										
										
											2010-02-20 21:48:19 +00:00
										 |  |  |             $this->$name = new $class($this); | 
					
						
							|  |  |  |             return $this->$name; | 
					
						
							|  |  |  |         } else if ($name == '_version') { | 
					
						
							|  |  |  |             // Smarty 2 BC
 | 
					
						
							|  |  |  |             $this->_version = self::SMARTY_VERSION; | 
					
						
							|  |  |  |             return $this->_version; | 
					
						
							|  |  |  |         }   	 | 
					
						
							|  |  |  |         return null; | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |     * Takes unknown class methods and lazy loads sysplugin files for them | 
					
						
							|  |  |  |     * class name format: Smarty_Method_MethodName | 
					
						
							|  |  |  |     * plugin filename format: method.methodname.php | 
					
						
							|  |  |  |     *  | 
					
						
							|  |  |  |     * @param string $name unknown methode name | 
					
						
							|  |  |  |     * @param array $args aurgument array | 
					
						
							|  |  |  |     */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function __call($name, $args) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         static $camel_func; | 
					
						
							|  |  |  |         if(!isset($camel_func)) | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         // PHP4 call to constructor?
 | 
					
						
							|  |  |  |         if (strtolower($name) == 'smarty') { | 
					
						
							|  |  |  |             throw new Exception('Please use parent::__construct() to call parent constuctor'); | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // see if this is a set/get for a property
 | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |         $first3 = strtolower(substr($name, 0, 3)); | 
					
						
							|  |  |  |         if(in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') { | 
					
						
							|  |  |  |             // try to keep case correct for future PHP 6.0 case-sensitive class methods
 | 
					
						
							|  |  |  |             // lcfirst() not available < PHP 5.3.0, so improvise
 | 
					
						
							|  |  |  |             $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);  | 
					
						
							|  |  |  |             // convert camel case to underscored name
 | 
					
						
							|  |  |  |             $property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name); | 
					
						
							|  |  |  |             if(!property_exists($this, $property_name)) { | 
					
						
							|  |  |  |                 throw new Exception("property '$property_name' does not exist."); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             if($first3 == 'get') | 
					
						
							|  |  |  |             return $this->$property_name; | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             return $this->$property_name = $args[0]; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         // Smarty Backward Compatible wrapper
 | 
					
						
							|  |  |  |         if(!isset($this->wrapper)) { | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  |             $this->wrapper = new Smarty_Internal_Wrapper($this); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         return $this->wrapper->convert($name, $args); | 
					
						
							| 
									
										
										
										
											2010-02-07 22:21:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         /* | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |         $name = strtolower($name); | 
					
						
							|  |  |  |         if ($name == 'smarty') { | 
					
						
							| 
									
										
										
										
											2009-11-02 23:04:10 +00:00
										 |  |  |             throw new Exception('Please use parent::__construct() to call parent constuctor'); | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         $function_name = 'smarty_method_' . $name; | 
					
						
							|  |  |  |         if (!is_callable($function_name)) { | 
					
						
							|  |  |  |             if (!file_exists(SMARTY_SYSPLUGINS_DIR . $function_name . '.php')) { | 
					
						
							|  |  |  |                 throw new Exception('Undefined Smarty method "' . $name . '"'); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |             require_once(SMARTY_SYSPLUGINS_DIR . $function_name . '.php'); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-11-03 20:38:38 +00:00
										 |  |  |         return call_user_func_array($function_name, array_merge(array($this), $args)); | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |         */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | function smartyAutoload($class) { | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |     $_class = strtolower($class); | 
					
						
							| 
									
										
										
										
											2009-11-06 17:40:20 +00:00
										 |  |  |     if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') { | 
					
						
							| 
									
										
										
										
											2009-10-31 00:44:58 +00:00
										 |  |  |         include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; | 
					
						
							| 
									
										
										
										
											2009-10-21 09:49:43 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-20 21:48:19 +00:00
										 |  |  | ?>
 |