| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Smarty Config Source Plugin | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage TemplateResources | 
					
						
							|  |  |  |  * @author     Uwe Tews | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |  * Smarty Config Resource Data Object | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |  * Meta Data Container for Template Files | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package    Smarty | 
					
						
							|  |  |  |  * @subpackage TemplateResources | 
					
						
							|  |  |  |  * @author     Uwe Tews | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Smarty_Template_Config extends Smarty_Template_Source | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * array of section names, single section or null | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var null|string|array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $config_sections = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * scope into which the config variables shall be loaded | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-02-09 23:27:07 +01:00
										 |  |  |      * @var int | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-02-09 23:27:07 +01:00
										 |  |  |     public $scope = 0; | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Flag that source is a config file | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var bool | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $isConfig = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |      * Name of the Class to compile this resource's contents with | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |      * @var string | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |     public $compiler_class = 'Smarty_Internal_Config_File_Compiler'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to tokenize this resource's contents with | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_lexer_class = 'Smarty_Internal_Configfilelexer'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Name of the Class to parse this resource's contents with | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var string | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $template_parser_class = 'Smarty_Internal_Configfileparser'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * initialize Source Object for given resource | 
					
						
							|  |  |  |      * Either [$_template] or [$smarty, $template_resource] must be specified | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |      * @param Smarty_Internal_Template $_template         template object | 
					
						
							|  |  |  |      * @param Smarty                   $smarty            smarty object | 
					
						
							|  |  |  |      * @param string                   $template_resource resource identifier | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-08-17 21:52:32 +02:00
										 |  |  |      * @return Smarty_Template_Config Source Object | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |      * @throws SmartyException | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |     public static function load( | 
					
						
							|  |  |  |         Smarty_Internal_Template $_template = null, | 
					
						
							|  |  |  |         Smarty $smarty = null, | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |         $template_resource = null | 
					
						
							|  |  |  |     ) { | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         static $_incompatible_resources = array('extends' => true, 'php' => true); | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |         if ($_template) { | 
					
						
							|  |  |  |             $smarty = $_template->smarty; | 
					
						
							|  |  |  |             $template_resource = $_template->template_resource; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         if (empty($template_resource)) { | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |             throw new SmartyException('Source: Missing  name'); | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-31 16:45:09 +02:00
										 |  |  |         // parse resource_name, load resource handler
 | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |         list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         // make sure configs are not loaded via anything smarty can't handle
 | 
					
						
							| 
									
										
										
										
											2016-02-09 01:27:15 +01:00
										 |  |  |         if (isset($_incompatible_resources[ $type ])) { | 
					
						
							| 
									
										
										
										
											2018-06-12 09:58:15 +02:00
										 |  |  |             throw new SmartyException("Unable to use resource '{$type}' for config"); | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |         $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name); | 
					
						
							| 
									
										
										
										
											2016-03-10 22:22:46 +01:00
										 |  |  |         $source->handler->populate($source, $_template); | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |         if (!$source->exists && isset($smarty->default_config_handler_func)) { | 
					
						
							| 
									
										
										
										
											2015-08-17 21:52:32 +02:00
										 |  |  |             Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); | 
					
						
							| 
									
										
										
										
											2016-08-05 21:29:15 +02:00
										 |  |  |             $source->handler->populate($source, $_template); | 
					
						
							| 
									
										
										
										
											2015-01-02 12:11:21 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         return $source; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |