| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Resource Plugin | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage TemplateResources | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @author     Rodney Rehm | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Resource Plugin | 
					
						
							|  |  |  |  * Base implementation for resource plugins | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage TemplateResources | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | abstract class Smarty_Resource | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * cache for Smarty_Template_Source instances | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-15 18:18:28 +00:00
										 |  |  |     public static $sources = array(); | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * cache for Smarty_Template_Compiled instances | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-15 18:18:28 +00:00
										 |  |  |     public static $compileds = array(); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * cache for Smarty_Resource instances | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-15 18:18:28 +00:00
										 |  |  |     public static $resources = array(); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * resource types provided by the core | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected static $sysplugins = array( | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |         'file'    => true, | 
					
						
							|  |  |  |         'string'  => true, | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         'extends' => true, | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |         'stream'  => true, | 
					
						
							|  |  |  |         'eval'    => true, | 
					
						
							|  |  |  |         'php'     => true | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to compile this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to tokenize this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_lexer_class = 'Smarty_Internal_Templatelexer'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to parse this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_parser_class = 'Smarty_Internal_Templateparser'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Load template's source into current template object | 
					
						
							|  |  |  |      * {@internal The loaded source is assigned to $_template->source->content directly.}} | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Template_Source $source source object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return string                 template source | 
					
						
							|  |  |  |      * @throws SmartyException        if source cannot be loaded | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |     abstract public function getContent(Smarty_Template_Source $source); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * populate Source Object with meta data from Resource | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param Smarty_Template_Source   $source    source object | 
					
						
							|  |  |  |      * @param Smarty_Internal_Template $_template template object | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |     abstract public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * populate Source Object with timestamp and exists from Resource | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Smarty_Template_Source $source source object | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function populateTimestamp(Smarty_Template_Source $source) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // intentionally left blank
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * modify resource_name according to resource handlers specifications | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  Smarty  $smarty        Smarty instance | 
					
						
							|  |  |  |      * @param  string  $resource_name resource_name to make unique | 
					
						
							|  |  |  |      * @param  boolean $is_config     flag for config resource | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @return string unique resource name | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-08-13 20:54:59 +00:00
										 |  |  |     protected function buildUniqueResourceName(Smarty $smarty, $resource_name, $is_config = false) | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-08-13 20:54:59 +00:00
										 |  |  |         if ($is_config) { | 
					
						
							|  |  |  |             return get_class($this) . '#' . $smarty->joined_config_dir . '#' . $resource_name; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return get_class($this) . '#' . $smarty->joined_template_dir . '#' . $resource_name; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * populate Compiled Object with compiled filepath | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Smarty_Template_Compiled $compiled  compiled object | 
					
						
							|  |  |  |      * @param Smarty_Internal_Template $_template template object | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null; | 
					
						
							|  |  |  |         $_filepath = $compiled->source->uid; | 
					
						
							|  |  |  |         // if use_sub_dirs, break file into directories
 | 
					
						
							|  |  |  |         if ($_template->smarty->use_sub_dirs) { | 
					
						
							|  |  |  |             $_filepath = substr($_filepath, 0, 2) . DS | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                 . substr($_filepath, 2, 2) . DS | 
					
						
							|  |  |  |                 . substr($_filepath, 4, 2) . DS | 
					
						
							|  |  |  |                 . $_filepath; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; | 
					
						
							|  |  |  |         if (isset($_compile_id)) { | 
					
						
							|  |  |  |             $_filepath = $_compile_id . $_compile_dir_sep . $_filepath; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // caching token
 | 
					
						
							|  |  |  |         if ($_template->caching) { | 
					
						
							|  |  |  |             $_cache = '.cache'; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $_cache = ''; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $_compile_dir = $_template->smarty->getCompileDir(); | 
					
						
							|  |  |  |         // set basename if not specified
 | 
					
						
							|  |  |  |         $_basename = $this->getBasename($compiled->source); | 
					
						
							|  |  |  |         if ($_basename === null) { | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |             $_basename = basename(preg_replace('![^\w\/]+!', '_', $compiled->source->name)); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         // separate (optional) basename by dot
 | 
					
						
							|  |  |  |         if ($_basename) { | 
					
						
							|  |  |  |             $_basename = '.' . $_basename; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $compiled->filepath = $_compile_dir . $_filepath . '.' . $compiled->source->type . $_basename . $_cache . '.php'; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * Normalize Paths "foo/../bar" to "bar" | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  string  $_path path to normalize | 
					
						
							|  |  |  |      * @param  boolean $ds    respect windows directory separator | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return string  normalized path | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |     protected function normalizePath($_path, $ds = true) | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if ($ds) { | 
					
						
							|  |  |  |             // don't we all just love windows?
 | 
					
						
							|  |  |  |             $_path = str_replace('\\', '/', $_path); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-31 19:39:28 +00:00
										 |  |  |         $offset = 0; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |         // resolve simples
 | 
					
						
							| 
									
										
										
										
											2013-07-12 00:16:43 +00:00
										 |  |  |         $_path = preg_replace('#/\./(\./)*#', '/', $_path); | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |         // resolve parents
 | 
					
						
							|  |  |  |         while (true) { | 
					
						
							| 
									
										
										
										
											2012-08-31 19:39:28 +00:00
										 |  |  |             $_parent = strpos($_path, '/../', $offset); | 
					
						
							|  |  |  |             if (!$_parent) { | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |             } elseif ($_path[$_parent - 1] === '.') { | 
					
						
							| 
									
										
										
										
											2012-08-31 19:39:28 +00:00
										 |  |  |                 $offset = $_parent + 3; | 
					
						
							|  |  |  |                 continue; | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |             $_pos = strrpos($_path, '/', $_parent - strlen($_path) - 1); | 
					
						
							|  |  |  |             if ($_pos === false) { | 
					
						
							|  |  |  |                 // don't we all just love windows?
 | 
					
						
							|  |  |  |                 $_pos = $_parent; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |             $_path = substr_replace($_path, '', $_pos, $_parent + 3 - $_pos); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |         if ($ds && DS != '/') { | 
					
						
							|  |  |  |             // don't we all just love windows?
 | 
					
						
							|  |  |  |             $_path = str_replace('/', '\\', $_path); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |         return $_path; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * build template filepath by traversing the template_dir array | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Template_Source   $source    source object | 
					
						
							|  |  |  |      * @param  Smarty_Internal_Template $_template template object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return string                   fully qualified filepath | 
					
						
							|  |  |  |      * @throws SmartyException          if default template handler is registered but not callable | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |     protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $file = $source->name; | 
					
						
							|  |  |  |         if ($source instanceof Smarty_Config_Source) { | 
					
						
							|  |  |  |             $_directories = $source->smarty->getConfigDir(); | 
					
						
							|  |  |  |             $_default_handler = $source->smarty->default_config_handler_func; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $_directories = $source->smarty->getTemplateDir(); | 
					
						
							|  |  |  |             $_default_handler = $source->smarty->default_template_handler_func; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // go relative to a given template?
 | 
					
						
							|  |  |  |         $_file_is_dotted = $file[0] == '.' && ($file[1] == '.' || $file[1] == '/' || $file[1] == "\\"); | 
					
						
							|  |  |  |         if ($_template && $_template->parent instanceof Smarty_Internal_Template && $_file_is_dotted) { | 
					
						
							| 
									
										
										
										
											2011-09-23 20:21:16 +00:00
										 |  |  |             if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $file = dirname($_template->parent->source->filepath) . DS . $file; | 
					
						
							|  |  |  |             $_file_exact_match = true; | 
					
						
							| 
									
										
										
										
											2011-09-20 14:12:34 +00:00
										 |  |  |             if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) { | 
					
						
							|  |  |  |                 // the path gained from the parent template is relative to the current working directory
 | 
					
						
							|  |  |  |                 // as expansions (like include_path) have already been done
 | 
					
						
							|  |  |  |                 $file = getcwd() . DS . $file; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2011-09-23 20:21:16 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // resolve relative path
 | 
					
						
							|  |  |  |         if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) { | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |             // don't we all just love windows?
 | 
					
						
							|  |  |  |             $_path = DS . trim($file, '/'); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             $_was_relative = true; | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |             // don't we all just love windows?
 | 
					
						
							|  |  |  |             $_path = str_replace('\\', '/', $file); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |         $_path = $this->normalizePath($_path, false); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         if (DS != '/') { | 
					
						
							|  |  |  |             // don't we all just love windows?
 | 
					
						
							|  |  |  |             $_path = str_replace('/', '\\', $_path); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // revert to relative
 | 
					
						
							|  |  |  |         if (isset($_was_relative)) { | 
					
						
							| 
									
										
										
										
											2012-08-31 19:39:28 +00:00
										 |  |  |             $_path = substr($_path, 1); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-09-21 23:06:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         // this is only required for directories
 | 
					
						
							|  |  |  |         $file = rtrim($_path, '/\\'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // files relative to a template only get one shot
 | 
					
						
							|  |  |  |         if (isset($_file_exact_match)) { | 
					
						
							|  |  |  |             return $this->fileExists($source, $file) ? $file : false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // template_dir index?
 | 
					
						
							|  |  |  |         if (preg_match('#^\[(?P<key>[^\]]+)\](?P<file>.+)$#', $file, $match)) { | 
					
						
							|  |  |  |             $_directory = null; | 
					
						
							|  |  |  |             // try string indexes
 | 
					
						
							|  |  |  |             if (isset($_directories[$match['key']])) { | 
					
						
							|  |  |  |                 $_directory = $_directories[$match['key']]; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |             } elseif (is_numeric($match['key'])) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 // try numeric index
 | 
					
						
							|  |  |  |                 $match['key'] = (int) $match['key']; | 
					
						
							|  |  |  |                 if (isset($_directories[$match['key']])) { | 
					
						
							|  |  |  |                     $_directory = $_directories[$match['key']]; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     // try at location index
 | 
					
						
							|  |  |  |                     $keys = array_keys($_directories); | 
					
						
							|  |  |  |                     $_directory = $_directories[$keys[$match['key']]]; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ($_directory) { | 
					
						
							|  |  |  |                 $_file = substr($file, strpos($file, ']') + 1); | 
					
						
							|  |  |  |                 $_filepath = $_directory . $_file; | 
					
						
							|  |  |  |                 if ($this->fileExists($source, $_filepath)) { | 
					
						
							|  |  |  |                     return $_filepath; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-05-24 17:03:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-06 20:45:10 +00:00
										 |  |  |         $_stream_resolve_include_path = function_exists('stream_resolve_include_path'); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // relative file name?
 | 
					
						
							|  |  |  |         if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) { | 
					
						
							|  |  |  |             foreach ($_directories as $_directory) { | 
					
						
							|  |  |  |                 $_filepath = $_directory . $file; | 
					
						
							|  |  |  |                 if ($this->fileExists($source, $_filepath)) { | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |                     return $this->normalizePath($_filepath); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |                 if ($source->smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) { | 
					
						
							|  |  |  |                     // try PHP include_path
 | 
					
						
							| 
									
										
										
										
											2012-02-06 20:45:10 +00:00
										 |  |  |                     if ($_stream_resolve_include_path) { | 
					
						
							|  |  |  |                         $_filepath = stream_resolve_include_path($_filepath); | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath); | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2012-05-24 17:03:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-06 20:45:10 +00:00
										 |  |  |                     if ($_filepath !== false) { | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  |                         if ($this->fileExists($source, $_filepath)) { | 
					
						
							| 
									
										
										
										
											2012-06-07 12:54:02 +00:00
										 |  |  |                             return $this->normalizePath($_filepath); | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  |                         } | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // try absolute filepath
 | 
					
						
							|  |  |  |         if ($this->fileExists($source, $file)) { | 
					
						
							|  |  |  |             return $file; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // no tpl file found
 | 
					
						
							|  |  |  |         if ($_default_handler) { | 
					
						
							|  |  |  |             if (!is_callable($_default_handler)) { | 
					
						
							|  |  |  |                 if ($source instanceof Smarty_Config_Source) { | 
					
						
							|  |  |  |                     throw new SmartyException("Default config handler not callable"); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     throw new SmartyException("Default template handler not callable"); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $_return = call_user_func_array($_default_handler, | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                                             array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty)); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             if (is_string($_return)) { | 
					
						
							|  |  |  |                 $source->timestamp = @filemtime($_return); | 
					
						
							|  |  |  |                 $source->exists = !!$source->timestamp; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 return $_return; | 
					
						
							|  |  |  |             } elseif ($_return === true) { | 
					
						
							|  |  |  |                 $source->content = $_content; | 
					
						
							|  |  |  |                 $source->timestamp = $_timestamp; | 
					
						
							|  |  |  |                 $source->exists = true; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 return $_filepath; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // give up
 | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * test is file exists and save timestamp | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Template_Source $source source object | 
					
						
							|  |  |  |      * @param  string                 $file   file name | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return bool                   true if file exists | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     protected function fileExists(Smarty_Template_Source $source, $file) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-10-01 18:56:49 +00:00
										 |  |  |         $source->timestamp = is_file($file) ? @filemtime($file) : false; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         return $source->exists = !!$source->timestamp; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Determine basename for compiled filename | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Template_Source $source source object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return string                 resource's basename | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     protected function getBasename(Smarty_Template_Source $source) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Load Resource Handler | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  Smarty $smarty smarty object | 
					
						
							|  |  |  |      * @param  string $type   name of the resource | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @throws SmartyException | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @return Smarty_Resource Resource Handler | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-15 18:18:28 +00:00
										 |  |  |     public static function load(Smarty $smarty, $type) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |         // try smarty's cache
 | 
					
						
							|  |  |  |         if (isset($smarty->_resource_handlers[$type])) { | 
					
						
							|  |  |  |             return $smarty->_resource_handlers[$type]; | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         // try registered resource
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |         if (isset($smarty->registered_resources[$type])) { | 
					
						
							|  |  |  |             if ($smarty->registered_resources[$type] instanceof Smarty_Resource) { | 
					
						
							|  |  |  |                 $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type]; | 
					
						
							|  |  |  |                 // note registered to smarty is not kept unique!
 | 
					
						
							|  |  |  |                 return $smarty->_resource_handlers[$type]; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             if (!isset(self::$resources['registered'])) { | 
					
						
							|  |  |  |                 self::$resources['registered'] = new Smarty_Internal_Resource_Registered(); | 
					
						
							| 
									
										
										
										
											2011-11-16 08:25:33 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             if (!isset($smarty->_resource_handlers[$type])) { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 $smarty->_resource_handlers[$type] = self::$resources['registered']; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |             return $smarty->_resource_handlers[$type]; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // try sysplugins dir
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |         if (isset(self::$sysplugins[$type])) { | 
					
						
							|  |  |  |             if (!isset(self::$resources[$type])) { | 
					
						
							|  |  |  |                 $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); | 
					
						
							|  |  |  |                 self::$resources[$type] = new $_resource_class(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |             return $smarty->_resource_handlers[$type] = self::$resources[$type]; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // try plugins dir
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |         $_resource_class = 'Smarty_Resource_' . ucfirst($type); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         if ($smarty->loadPlugin($_resource_class)) { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |             if (isset(self::$resources[$type])) { | 
					
						
							|  |  |  |                 return $smarty->_resource_handlers[$type] = self::$resources[$type]; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             if (class_exists($_resource_class, false)) { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 self::$resources[$type] = new $_resource_class(); | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 return $smarty->_resource_handlers[$type] = self::$resources[$type]; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 $smarty->registerResource($type, array( | 
					
						
							|  |  |  |                     "smarty_resource_{$type}_source", | 
					
						
							|  |  |  |                     "smarty_resource_{$type}_timestamp", | 
					
						
							|  |  |  |                     "smarty_resource_{$type}_secure", | 
					
						
							|  |  |  |                     "smarty_resource_{$type}_trusted" | 
					
						
							|  |  |  |                 )); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 // give it another try, now that the resource is registered properly
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 return self::load($smarty, $type); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // try streams
 | 
					
						
							|  |  |  |         $_known_stream = stream_get_wrappers(); | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |         if (in_array($type, $_known_stream)) { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             // is known stream
 | 
					
						
							|  |  |  |             if (is_object($smarty->security_policy)) { | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |                 $smarty->security_policy->isTrustedStream($type); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |             if (!isset(self::$resources['stream'])) { | 
					
						
							|  |  |  |                 self::$resources['stream'] = new Smarty_Internal_Resource_Stream(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-15 10:46:03 +00:00
										 |  |  |             return $smarty->_resource_handlers[$type] = self::$resources['stream']; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // TODO: try default_(template|config)_handler
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // give up
 | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |         throw new SmartyException("Unknown resource type '{$type}'"); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * extract resource_type and resource_name from template_resource and config_resource | 
					
						
							|  |  |  |      * @note "C:/foo.tpl" was forced to file resource up till Smarty 3.1.3 (including). | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  string $resource_name    template_resource or config_resource to parse | 
					
						
							|  |  |  |      * @param  string $default_resource the default resource_type defined in $smarty | 
					
						
							|  |  |  |      * @param  string &$name            the parsed resource name | 
					
						
							|  |  |  |      * @param  string &$type            the parsed resource type | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected static function parseResourceName($resource_name, $default_resource, &$name, &$type) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $parts = explode(':', $resource_name, 2); | 
					
						
							|  |  |  |         if (!isset($parts[1]) || !isset($parts[0][1])) { | 
					
						
							|  |  |  |             // no resource given, use default
 | 
					
						
							|  |  |  |             // or single character before the colon is not a resource type, but part of the filepath
 | 
					
						
							|  |  |  |             $type = $default_resource; | 
					
						
							|  |  |  |             $name = $resource_name; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $type = $parts[0]; | 
					
						
							|  |  |  |             $name = $parts[1]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * modify resource_name according to resource handlers specifications | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty $smarty        Smarty instance | 
					
						
							|  |  |  |      * @param  string $resource_name resource_name to make unique | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @return string unique resource name | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * modify template_resource according to resource handlers specifications | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  Smarty_Internal_template $template          Smarty instance | 
					
						
							|  |  |  |      * @param  string                   $template_resource template_resource to extract resource handler and name of | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @return string unique resource name | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |     public static function getUniqueTemplateName($template, $template_resource) | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         self::parseResourceName($template_resource, $template->smarty->default_resource_type, $name, $type); | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // TODO: optimize for Smarty's internal resource types
 | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         $resource = Smarty_Resource::load($template->smarty, $type); | 
					
						
							|  |  |  |         // go relative to a given template?
 | 
					
						
							|  |  |  |         $_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/' || $name[1] == "\\"); | 
					
						
							|  |  |  |         if ($template instanceof Smarty_Internal_Template && $_file_is_dotted && ($template->source->type == 'file' || $template->parent->source->type == 'extends')) { | 
					
						
							|  |  |  |             $name = dirname($template->source->filepath) . DS . $name; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return $resource->buildUniqueResourceName($template->smarty, $name); | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * initialize Source Object for given resource | 
					
						
							|  |  |  |      * Either [$_template] or [$smarty, $template_resource] must be specified | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Internal_Template $_template         template object | 
					
						
							|  |  |  |      * @param  Smarty                   $smarty            smarty object | 
					
						
							|  |  |  |      * @param  string                   $template_resource resource identifier | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return Smarty_Template_Source   Source Object | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |     public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if ($_template) { | 
					
						
							|  |  |  |             $smarty = $_template->smarty; | 
					
						
							|  |  |  |             $template_resource = $_template->template_resource; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // parse resource_name, load resource handler, identify unique resource name
 | 
					
						
							|  |  |  |         self::parseResourceName($template_resource, $smarty->default_resource_type, $name, $type); | 
					
						
							|  |  |  |         $resource = Smarty_Resource::load($smarty, $type); | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         // go relative to a given template?
 | 
					
						
							| 
									
										
										
										
											2013-10-28 23:53:01 +00:00
										 |  |  |         $_file_is_dotted = isset($name[0]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/' || $name[1] == "\\"); | 
					
						
							|  |  |  |         if ($_file_is_dotted && isset($_template) && $_template->parent instanceof Smarty_Internal_Template && ($_template->parent->source->type == 'file' || $_template->parent->source->type == 'extends')) { | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |             $name2 = dirname($_template->parent->source->filepath) . DS . $name; | 
					
						
							| 
									
										
										
										
											2013-10-14 07:47:49 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             $name2 = $name; | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         $unique_resource_name = $resource->buildUniqueResourceName($smarty, $name2); | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         // check runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         $_cache_key = 'template|' . $unique_resource_name; | 
					
						
							| 
									
										
										
										
											2012-05-24 17:03:31 +00:00
										 |  |  |         if ($smarty->compile_id) { | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |             $_cache_key .= '|' . $smarty->compile_id; | 
					
						
							| 
									
										
										
										
											2012-05-24 17:03:31 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         if (isset(self::$sources[$_cache_key])) { | 
					
						
							|  |  |  |             return self::$sources[$_cache_key]; | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         // create source
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         $source = new Smarty_Template_Source($resource, $smarty, $template_resource, $type, $name, $unique_resource_name); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $resource->populate($source, $_template); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |         // runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         self::$sources[$_cache_key] = $source; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         return $source; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * initialize Config Source Object for given resource | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param  Smarty_Internal_Config $_config config object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @throws SmartyException | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @return Smarty_Config_Source   Source Object | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2013-07-15 18:18:28 +00:00
										 |  |  |     public static function config(Smarty_Internal_Config $_config) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-10-01 18:10:48 +00:00
										 |  |  |         static $_incompatible_resources = array('eval' => true, 'string' => true, 'extends' => true, 'php' => true); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $config_resource = $_config->config_resource; | 
					
						
							|  |  |  |         $smarty = $_config->smarty; | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // parse resource_name
 | 
					
						
							|  |  |  |         self::parseResourceName($config_resource, $smarty->default_config_type, $name, $type); | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // make sure configs are not loaded via anything smarty can't handle
 | 
					
						
							|  |  |  |         if (isset($_incompatible_resources[$type])) { | 
					
						
							|  |  |  |             throw new SmartyException ("Unable to use resource '{$type}' for config"); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // load resource handler, identify unique resource name
 | 
					
						
							|  |  |  |         $resource = Smarty_Resource::load($smarty, $type); | 
					
						
							| 
									
										
										
										
											2013-08-13 20:54:59 +00:00
										 |  |  |         $unique_resource_name = $resource->buildUniqueResourceName($smarty, $name, true); | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         // check runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         $_cache_key = 'config|' . $unique_resource_name; | 
					
						
							|  |  |  |         if (isset(self::$sources[$_cache_key])) { | 
					
						
							|  |  |  |             return self::$sources[$_cache_key]; | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         // create source
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         $source = new Smarty_Config_Source($resource, $smarty, $config_resource, $type, $name, $unique_resource_name); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $resource->populate($source, null); | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 09:50:55 +00:00
										 |  |  |         // runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         self::$sources[$_cache_key] = $source; | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         return $source; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Resource Data Object | 
					
						
							|  |  |  |  * Meta Data Container for Template Files | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage TemplateResources | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @author     Rodney Rehm | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @property integer $timestamp Source Timestamp | 
					
						
							| 
									
										
										
										
											2013-06-17 12:34:10 +00:00
										 |  |  |  * @property boolean $exists    Source Existence | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @property boolean $template  Extended Template reference | 
					
						
							|  |  |  |  * @property string  $content   Source Content | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | class Smarty_Template_Source | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to compile this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $compiler_class = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to tokenize this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_lexer_class = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to parse this resource's contents with | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_parser_class = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Unique Template ID | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $uid = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Template Resource (Smarty_Internal_Template::$template_resource) | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $resource = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Type | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $type = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Name | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $name = null; | 
					
						
							| 
									
										
										
										
											2011-12-16 17:00:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Unique Resource Name | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $unique_resource = null; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source Filepath | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $filepath = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source is bypassing compiler | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $uncompiled = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source must be recompiled on every occasion | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $recompiled = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * The Components an extended template is made of | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $components = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Handler | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var Smarty_Resource | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $handler = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Smarty instance | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var Smarty | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $smarty = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * create Source Object container | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  |      * @param Smarty_Resource $handler         Resource Handler this source object communicates with | 
					
						
							|  |  |  |      * @param Smarty          $smarty          Smarty instance this source object belongs to | 
					
						
							|  |  |  |      * @param string          $resource        full template_resource | 
					
						
							|  |  |  |      * @param string          $type            type of resource | 
					
						
							|  |  |  |      * @param string          $name            resource name | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param string          $unique_resource unique resource name | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->handler = $handler; // Note: prone to circular references
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->compiler_class = $handler->compiler_class; | 
					
						
							|  |  |  |         $this->template_lexer_class = $handler->template_lexer_class; | 
					
						
							|  |  |  |         $this->template_parser_class = $handler->template_parser_class; | 
					
						
							|  |  |  |         $this->uncompiled = $this->handler instanceof Smarty_Resource_Uncompiled; | 
					
						
							|  |  |  |         $this->recompiled = $this->handler instanceof Smarty_Resource_Recompiled; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         $this->smarty = $smarty; | 
					
						
							|  |  |  |         $this->resource = $resource; | 
					
						
							|  |  |  |         $this->type = $type; | 
					
						
							|  |  |  |         $this->name = $name; | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         $this->unique_resource = $unique_resource; | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * get a Compiled Object of this source | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  Smarty_Internal_Template|Smarty_Internal_Config $_template template object | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @return Smarty_Template_Compiled compiled object | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |     public function getCompiled($_template) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |         // check runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-14 09:31:09 +00:00
										 |  |  |         $_cache_key = $this->unique_resource . '#' . $_template->compile_id; | 
					
						
							|  |  |  |         if (isset(Smarty_Resource::$compileds[$_cache_key])) { | 
					
						
							|  |  |  |             return Smarty_Resource::$compileds[$_cache_key]; | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         $compiled = new Smarty_Template_Compiled($this); | 
					
						
							|  |  |  |         $this->handler->populateCompiledFilepath($compiled, $_template); | 
					
						
							|  |  |  |         $compiled->timestamp = @filemtime($compiled->filepath); | 
					
						
							|  |  |  |         $compiled->exists = !!$compiled->timestamp; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  |         // runtime cache
 | 
					
						
							| 
									
										
										
										
											2011-10-14 09:31:09 +00:00
										 |  |  |         Smarty_Resource::$compileds[$_cache_key] = $compiled; | 
					
						
							| 
									
										
										
										
											2011-09-17 16:29:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |         return $compiled; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * render the uncompiled source | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Smarty_Internal_Template $_template template object | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function renderUncompiled(Smarty_Internal_Template $_template) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->handler->renderUncompiled($this, $_template); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * <<magic>> Generic Setter. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  string $property_name valid: timestamp, exists, content, template | 
					
						
							|  |  |  |      * @param  mixed  $value         new value (is not checked) | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @throws SmartyException if $property_name is not valid | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __set($property_name, $value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch ($property_name) { | 
					
						
							|  |  |  |             // regular attributes
 | 
					
						
							|  |  |  |             case 'timestamp': | 
					
						
							|  |  |  |             case 'exists': | 
					
						
							|  |  |  |             case 'content': | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |                 // required for extends: only
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |             case 'template': | 
					
						
							|  |  |  |                 $this->$property_name = $value; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 throw new SmartyException("invalid source property '$property_name'."); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * <<magic>> Generic getter. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * @param  string $property_name valid: timestamp, exists, content | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @return mixed | 
					
						
							|  |  |  |      * @throws SmartyException if $property_name is not valid | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __get($property_name) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch ($property_name) { | 
					
						
							|  |  |  |             case 'timestamp': | 
					
						
							|  |  |  |             case 'exists': | 
					
						
							|  |  |  |                 $this->handler->populateTimestamp($this); | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |                 return $this->$property_name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             case 'content': | 
					
						
							|  |  |  |                 return $this->content = $this->handler->getContent($this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 throw new SmartyException("source property '$property_name' does not exist."); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Resource Data Object | 
					
						
							|  |  |  |  * Meta Data Container for Template Files | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @package    Smarty | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @subpackage TemplateResources | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |  * @author     Rodney Rehm | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |  * @property string $content compiled content | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-07-14 22:15:45 +00:00
										 |  |  | class Smarty_Template_Compiled | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Compiled Filepath | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $filepath = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Compiled Timestamp | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var integer | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $timestamp = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2013-06-17 12:34:10 +00:00
										 |  |  |      * Compiled Existence | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $exists = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Compiled Content Loaded | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $loaded = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Template was compiled | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $isCompiled = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source Object | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var Smarty_Template_Source | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $source = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Metadata properties | 
					
						
							|  |  |  |      * populated by Smarty_Internal_Template::decodeProperties() | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $_properties = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * create Compiled Object container | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param Smarty_Template_Source $source source object this compiled object belongs to | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __construct(Smarty_Template_Source $source) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->source = $source; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |