| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Resource Data Object | 
					
						
							|  |  |  |  * Meta Data Container for Template Files | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage TemplateResources | 
					
						
							|  |  |  |  * @author     Rodney Rehm | 
					
						
							| 
									
										
										
										
											2015-08-17 21:52:32 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Template_Source | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Unique Template ID | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $uid = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Template Resource (Smarty_Internal_Template::$template_resource) | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $resource = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Type | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $type = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Name | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $name = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source Filepath | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $filepath = null; | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-01 03:27:06 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Source Timestamp | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var integer | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $timestamp = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source Existence | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $exists = false; | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 21:27:33 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Source File Base name | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $basename = null; | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * The Components an extended template is made of | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-08-23 02:00:25 +02:00
										 |  |  |      * @var \Smarty_Template_Source[] | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public $components = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Resource Handler | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-08-23 02:00:25 +02:00
										 |  |  |      * @var \Smarty_Resource | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public $handler = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Smarty instance | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var Smarty | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $smarty = null; | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Resource is source | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var bool | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $isConfig = false; | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Template source content eventually set by default handler | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $content = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to compile this resource's contents with | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to tokenize this resource's contents with | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_lexer_class = 'Smarty_Internal_Templatelexer'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to parse this resource's contents with | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_parser_class = 'Smarty_Internal_Templateparser'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * create Source Object container | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @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 | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |     public function __construct(Smarty $smarty, $resource, $type, $name) | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |         $this->handler = isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : | 
					
						
							|  |  |  |             Smarty_Resource::load($smarty, $type); | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         $this->smarty = $smarty; | 
					
						
							|  |  |  |         $this->resource = $resource; | 
					
						
							|  |  |  |         $this->type = $type; | 
					
						
							|  |  |  |         $this->name = $name; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * initialize Source Object for given resource | 
					
						
							|  |  |  |      * Either [$_template] or [$smarty, $template_resource] must be specified | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param  Smarty_Internal_Template $_template         template object | 
					
						
							|  |  |  |      * @param  Smarty                   $smarty            smarty object | 
					
						
							|  |  |  |      * @param  string                   $template_resource resource identifier | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return Smarty_Template_Source Source Object | 
					
						
							|  |  |  |      * @throws SmartyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-09-01 02:27:22 +02:00
										 |  |  |     public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, | 
					
						
							|  |  |  |                                 $template_resource = null) | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         if ($_template) { | 
					
						
							|  |  |  |             $smarty = $_template->smarty; | 
					
						
							|  |  |  |             $template_resource = $_template->template_resource; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (empty($template_resource)) { | 
					
						
							|  |  |  |             throw new SmartyException('Missing template name'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // parse resource_name, load resource handler, identify unique resource name
 | 
					
						
							| 
									
										
										
										
											2015-10-29 21:41:21 +01:00
										 |  |  |         if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |             $type = $match[ 1 ]; | 
					
						
							|  |  |  |             $name = $match[ 2 ]; | 
					
						
							| 
									
										
										
										
											2015-09-01 02:27:22 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // no resource given, use default
 | 
					
						
							|  |  |  |             // or single character before the colon is not a resource type, but part of the filepath
 | 
					
						
							|  |  |  |             $type = $smarty->default_resource_type; | 
					
						
							|  |  |  |             $name = $template_resource; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         // create new source  object
 | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |         $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name); | 
					
						
							|  |  |  |         $source->handler->populate($source, $_template); | 
					
						
							| 
									
										
										
										
											2015-08-06 19:05:11 +02:00
										 |  |  |         if (!$source->exists && isset($_template->smarty->default_template_handler_func)) { | 
					
						
							| 
									
										
										
										
											2015-08-17 21:52:32 +02:00
										 |  |  |             Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         return $source; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2015-07-01 03:27:06 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Get source time stamp | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return int | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |     public function getTimeStamp() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-07-01 03:27:06 +02:00
										 |  |  |         if (!isset($this->timestamp)) { | 
					
						
							|  |  |  |             $this->handler->populateTimestamp($this); | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |         return $this->timestamp; | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |      * Get source content | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |      * @return string | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |     public function getContent() | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-07-06 03:25:03 +02:00
										 |  |  |         return isset($this->content) ? $this->content : $this->handler->getContent($this); | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } |