| 
									
										
										
										
											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 | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Source is bypassing compiler | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $uncompiled = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Source must be recompiled on every occasion | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var boolean | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $recompiled = false; | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * resource handler object | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var Smarty_Resource | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $handler = null; | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     /** | 
					
						
							|  |  |  |      * 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( | 
					
						
							| 
									
										
										
										
											2015-05-08 06:02:59 +02:00
										 |  |  |         'file'    => 'smarty_internal_resource_file.php', | 
					
						
							|  |  |  |         'string'  => 'smarty_internal_resource_string.php', | 
					
						
							|  |  |  |         'extends' => 'smarty_internal_resource_extends.php', | 
					
						
							|  |  |  |         'stream'  => 'smarty_internal_resource_stream.php', | 
					
						
							|  |  |  |         'eval'    => 'smarty_internal_resource_eval.php', | 
					
						
							|  |  |  |         'php'     => 'smarty_internal_resource_php.php' | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      * @param  boolean $isConfig      flag for config resource | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      * @return string unique resource name | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         if ($isConfig) { | 
					
						
							| 
									
										
										
										
											2013-08-13 20:54:59 +00:00
										 |  |  |             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
										 |  |  |     /** | 
					
						
							|  |  |  |      * 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
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |     public function getBasename(Smarty_Template_Source $source) | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         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]; | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_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])) { | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |             $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); | 
					
						
							| 
									
										
										
										
											2015-05-08 06:02:59 +02:00
										 |  |  |             if (!class_exists($_resource_class, false)) { | 
					
						
							|  |  |  |                 require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type]; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |             return $smarty->_resource_handlers[$type] = new $_resource_class(); | 
					
						
							| 
									
										
										
										
											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)) { | 
					
						
							|  |  |  |             if (class_exists($_resource_class, false)) { | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |                 return $smarty->_resource_handlers[$type] = new $_resource_class(); | 
					
						
							| 
									
										
										
										
											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
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |             return $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_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 | 
					
						
							| 
									
										
										
										
											2014-06-06 02:40:04 +00:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-02-14 21:57:42 +01:00
										 |  |  |      * @return array with parsed resource name and type | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-02-14 21:57:42 +01:00
										 |  |  |     public static function parseResourceName($resource_name, $default_resource) | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-05-04 22:44:29 +02:00
										 |  |  |          if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { | 
					
						
							|  |  |  |             $type = $match[1]; | 
					
						
							|  |  |  |             $name = substr($resource_name, strlen($match[0])); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |             // 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; | 
					
						
							| 
									
										
										
										
											2015-05-04 22:44:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-02-14 21:57:42 +01:00
										 |  |  |         return array($name, $type); | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-02-15 01:45:37 +01:00
										 |  |  |         $smarty = isset($template->smarty) ? $template->smarty : $template; | 
					
						
							|  |  |  |         list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type); | 
					
						
							| 
									
										
										
										
											2011-10-13 13:10:06 +00:00
										 |  |  |         // TODO: optimize for Smarty's internal resource types
 | 
					
						
							| 
									
										
										
										
											2015-02-15 01:45:37 +01:00
										 |  |  |         $resource = Smarty_Resource::load($smarty, $type); | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         // go relative to a given template?
 | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         $_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'); | 
					
						
							| 
									
										
										
										
											2013-10-13 17:49:38 +00:00
										 |  |  |         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; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-02-15 01:45:37 +01:00
										 |  |  |         return $resource->buildUniqueResourceName($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 | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |      * wrapper for backward compatibility to versions < 3.1.22 | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |      * 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
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-01-01 23:34:29 +01:00
										 |  |  |         return Smarty_Template_Source::load($_template, $smarty, $template_resource); | 
					
						
							| 
									
										
										
										
											2011-09-16 14:19:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |