| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |  * Smarty Internal Plugin Template | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * This file contains the Smarty template engine | 
					
						
							|  |  |  |  *  | 
					
						
							|  |  |  |  * @package Smarty | 
					
						
							|  |  |  |  * @subpackage Templates | 
					
						
							|  |  |  |  * @author Uwe Tews  | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |  * Main class with template data structures and methods | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  | class Smarty_Internal_Template extends Smarty_Internal_Data { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // object cache
 | 
					
						
							|  |  |  |     public $compiler_object = null; | 
					
						
							|  |  |  |     public $cacher_object = null;  | 
					
						
							|  |  |  |     // Smarty parameter
 | 
					
						
							|  |  |  |     public $cache_id = null; | 
					
						
							|  |  |  |     public $compile_id = null; | 
					
						
							|  |  |  |     public $caching = null; | 
					
						
							| 
									
										
										
										
											2009-09-01 21:11:42 +00:00
										 |  |  |     public $cache_lifetime = null; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public $cacher_class = null; | 
					
						
							|  |  |  |     public $caching_type = null; | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |     public $force_compile = null; | 
					
						
							| 
									
										
										
										
											2009-11-12 22:50:48 +00:00
										 |  |  |     public $forceNocache = false;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // Template resource
 | 
					
						
							|  |  |  |     public $template_resource = null; | 
					
						
							|  |  |  |     public $resource_type = null; | 
					
						
							|  |  |  |     public $resource_name = null; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public $resource_object = null; | 
					
						
							| 
									
										
										
										
											2010-01-05 21:10:25 +00:00
										 |  |  |     private $isExisting = null; | 
					
						
							| 
									
										
										
										
											2010-01-25 18:10:35 +00:00
										 |  |  |     public $templateUid = '';  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // Template source
 | 
					
						
							| 
									
										
										
										
											2009-07-21 17:41:16 +00:00
										 |  |  |     public $template_filepath = null; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public $template_source = null; | 
					
						
							|  |  |  |     private $template_timestamp = null;  | 
					
						
							|  |  |  |     // Compiled template
 | 
					
						
							|  |  |  |     private $compiled_filepath = null; | 
					
						
							|  |  |  |     public $compiled_template = null; | 
					
						
							|  |  |  |     private $compiled_timestamp = null; | 
					
						
							|  |  |  |     public $mustCompile = null; | 
					
						
							|  |  |  |     public $suppressHeader = false; | 
					
						
							| 
									
										
										
										
											2009-10-19 18:32:35 +00:00
										 |  |  |     public $suppressFileDependency = false; | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |     public $has_nocache_code = false;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // Rendered content
 | 
					
						
							|  |  |  |     public $rendered_content = null;  | 
					
						
							|  |  |  |     // Cache file
 | 
					
						
							|  |  |  |     private $cached_filepath = null; | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |     public $cached_timestamp = null; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     private $isCached = null; | 
					
						
							| 
									
										
										
										
											2009-12-05 15:10:47 +00:00
										 |  |  |     private $cache_resource_object = null; | 
					
						
							|  |  |  |     private $cacheFileChecked = false;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     // template variables
 | 
					
						
							|  |  |  |     public $tpl_vars = array(); | 
					
						
							|  |  |  |     public $parent = null; | 
					
						
							|  |  |  |     public $config_vars = array();  | 
					
						
							|  |  |  |     // storage for plugin
 | 
					
						
							|  |  |  |     public $plugin_data = array();  | 
					
						
							| 
									
										
										
										
											2009-04-30 17:39:17 +00:00
										 |  |  |     // special properties
 | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |     public $properties = array ('file_dependency' => array(), | 
					
						
							|  |  |  |         'nocache_hash' => '', | 
					
						
							|  |  |  |         'function' => array());  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     // required plugins
 | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |     public $required_plugins = array('compiled' => array(), 'nocache' => array()); | 
					
						
							| 
									
										
										
										
											2010-03-09 21:11:21 +00:00
										 |  |  |     public $security = false; | 
					
						
							| 
									
										
										
										
											2010-04-07 15:19:02 +00:00
										 |  |  |     public $saved_modifier = null; | 
					
						
							| 
									
										
										
										
											2010-03-09 15:14:11 +00:00
										 |  |  |     public $smarty = null; | 
					
						
							| 
									
										
										
										
											2010-09-08 17:40:00 +00:00
										 |  |  |     // blocks for template inheritance
 | 
					
						
							|  |  |  |     public $block_data = array(); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Create template data object | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * Some of the global Smarty settings copied to template scope | 
					
						
							|  |  |  |      * It load the required template resources and cacher plugins | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $template_resource template resource string | 
					
						
							|  |  |  |      * @param object $_parent back pointer to parent object with variables or null | 
					
						
							|  |  |  |      * @param mixed $_cache_id cache id or null | 
					
						
							|  |  |  |      * @param mixed $_compile_id compile id or null | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-11-26 22:49:56 +00:00
										 |  |  |     public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $this->smarty = &$smarty;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // Smarty parameter
 | 
					
						
							|  |  |  |         $this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id; | 
					
						
							|  |  |  |         $this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id; | 
					
						
							|  |  |  |         $this->force_compile = $this->smarty->force_compile; | 
					
						
							| 
									
										
										
										
											2009-11-26 22:49:56 +00:00
										 |  |  |         $this->caching = $_caching === null ? $this->smarty->caching : $_caching; | 
					
						
							| 
									
										
										
										
											2009-11-30 17:52:13 +00:00
										 |  |  |         if ($this->caching === true) $this->caching = SMARTY_CACHING_LIFETIME_CURRENT; | 
					
						
							| 
									
										
										
										
											2009-11-26 22:49:56 +00:00
										 |  |  |         $this->cache_lifetime = $_cache_lifetime === null ?$this->smarty->cache_lifetime : $_cache_lifetime; | 
					
						
							| 
									
										
										
										
											2009-08-27 14:59:28 +00:00
										 |  |  |         $this->force_cache = $this->smarty->force_cache; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->security = $this->smarty->security; | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $this->parent = $_parent;  | 
					
						
							| 
									
										
										
										
											2009-05-05 17:19:33 +00:00
										 |  |  |         // dummy local smarty variable
 | 
					
						
							| 
									
										
										
										
											2009-05-08 11:34:21 +00:00
										 |  |  |         $this->tpl_vars['smarty'] = new Smarty_Variable;  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // Template resource
 | 
					
						
							|  |  |  |         $this->template_resource = $template_resource;  | 
					
						
							|  |  |  |         // parse resource name
 | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |         if (!$this->parseResourceName ($template_resource, $this->resource_type, $this->resource_name, $this->resource_object)) { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |             throw new SmartyException ("Unable to parse resource name \"{$template_resource}\""); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         // load cache resource
 | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |         if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) { | 
					
						
							| 
									
										
										
										
											2010-02-06 22:11:10 +00:00
										 |  |  |             $this->cache_resource_object = $this->smarty->cache->loadResource(); | 
					
						
							| 
									
										
										
										
											2010-09-10 11:15:15 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         // copy block data of template inheritance
 | 
					
						
							|  |  |  |         if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) { | 
					
						
							|  |  |  |         	$this->block_data = $this->parent->block_data; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the template filepath | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The template filepath is determined by the actual resource handler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string the template filepath | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getTemplateFilepath () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->template_filepath === null ? | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |         $this->template_filepath = $this->resource_object->getTemplateFilepath($this) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->template_filepath; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the timpestamp of the template source | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The template timestamp is determined by the actual resource handler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return integer the template timestamp | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getTemplateTimestamp () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->template_timestamp === null ? | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |         $this->template_timestamp = $this->resource_object->getTemplateTimestamp($this) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->template_timestamp; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the template source code | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The template source is being read by the actual resource handler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string the template source | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getTemplateSource () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($this->template_source === null) { | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |             if (!$this->resource_object->getTemplateSource($this)) { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |                 throw new SmartyException("Unable to read template {$this->resource_type} '{$this->resource_name}'"); | 
					
						
							| 
									
										
										
										
											2009-08-29 16:29:52 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-04-03 15:59:40 +00:00
										 |  |  |         return $this->template_source; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-30 18:28:50 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns if the  template is existing | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The status is determined by the actual resource handler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return boolean true if the template exists | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |     public function isExisting ($error = false) | 
					
						
							| 
									
										
										
										
											2009-09-30 18:28:50 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         if ($this->isExisting === null) { | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |             $this->isExisting = $this->resource_object->isExisting($this); | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         if (!$this->isExisting && $error) { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |             throw new SmartyException("Unable to load template {$this->resource_type} '{$this->resource_name}'"); | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         return $this->isExisting; | 
					
						
							| 
									
										
										
										
											2009-09-30 18:28:50 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns if the current template must be compiled by the Smarty compiler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * It does compare the timestamps of template source and the compiled templates and checks the force compile configuration | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return boolean true if the template must be compiled | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function mustCompile () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         $this->isExisting(true); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         if ($this->mustCompile === null) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $this->mustCompile = ($this->resource_object->usesCompiler && ($this->force_compile || $this->resource_object->isEvaluated || $this->getCompiledTimestamp () === false ||  | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |                     // ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ())));
 | 
					
						
							| 
									
										
										
										
											2009-11-19 14:45:04 +00:00
										 |  |  |                     ($this->smarty->compile_check && $this->getCompiledTimestamp () < $this->getTemplateTimestamp ()))); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         return $this->mustCompile; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the compiled template filepath | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string the template filepath | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCompiledFilepath () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->compiled_filepath === null ? | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         ($this->compiled_filepath = !$this->resource_object->isEvaluated ? $this->resource_object->getCompiledFilepath($this) : false) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->compiled_filepath; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the timpestamp of the compiled template | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return integer the template timestamp | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCompiledTimestamp () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->compiled_timestamp === null ? | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         ($this->compiled_timestamp = (!$this->resource_object->isEvaluated && file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->compiled_timestamp; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the compiled template  | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * It checks if the template must be compiled or just read from the template resource | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string the compiled template | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCompiledTemplate () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($this->compiled_template === null) { | 
					
						
							|  |  |  |             // see if template needs compiling.
 | 
					
						
							|  |  |  |             if ($this->mustCompile()) { | 
					
						
							|  |  |  |                 $this->compileTemplateSource(); | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                 if ($this->compiled_template === null) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                     $this->compiled_template = !$this->resource_object->isEvaluated && $this->resource_object->usesCompiler ? file_get_contents($this->getCompiledFilepath()) : false; | 
					
						
							| 
									
										
										
										
											2009-04-30 17:39:17 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         return $this->compiled_template; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Compiles the template | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * If the template is not evaluated the compiled template is saved on disk | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function compileTemplateSource () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if (!$this->resource_object->isEvaluated) { | 
					
						
							|  |  |  |             $this->properties['file_dependency'] = array(); | 
					
						
							| 
									
										
										
										
											2010-01-05 21:10:25 +00:00
										 |  |  |             $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); | 
					
						
							| 
									
										
										
										
											2009-09-23 16:50:16 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |         if ($this->smarty->debugging) { | 
					
						
							|  |  |  |             Smarty_Internal_Debug::start_compile($this); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // compile template
 | 
					
						
							|  |  |  |         if (!is_object($this->compiler_object)) { | 
					
						
							|  |  |  |             // load compiler
 | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |             $this->smarty->loadPlugin($this->resource_object->compiler_class); | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |         // compile locking
 | 
					
						
							|  |  |  |         if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated) { | 
					
						
							|  |  |  |             if ($saved_timestamp = $this->getCompiledTimestamp()) { | 
					
						
							|  |  |  |                 touch($this->getCompiledFilepath()); | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // call compiler
 | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |         try { | 
					
						
							|  |  |  |             $this->compiler_object->compileTemplate($this); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         catch (Exception $e) { | 
					
						
							|  |  |  |             // restore old timestamp in case of error
 | 
					
						
							|  |  |  |             if ($this->smarty->compile_locking && !$this->resource_object->isEvaluated && $saved_timestamp) { | 
					
						
							|  |  |  |                 touch($this->getCompiledFilepath(), $saved_timestamp); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |             throw $e; | 
					
						
							| 
									
										
										
										
											2010-05-11 16:24:24 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |         // compiling succeded
 | 
					
						
							|  |  |  |         if (!$this->resource_object->isEvaluated) { | 
					
						
							|  |  |  |             // write compiled template
 | 
					
						
							|  |  |  |             Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |         if ($this->smarty->debugging) { | 
					
						
							|  |  |  |             Smarty_Internal_Debug::end_compile($this); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the filepath of the cached template output | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The filepath is determined by the actual cache resource | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string the cache filepath | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCachedFilepath () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-05-11 16:24:24 +00:00
										 |  |  |         if (!isset($this->cache_resource_object)) { | 
					
						
							|  |  |  |             $this->cache_resource_object = $this->smarty->cache->loadResource(); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $this->cached_filepath === null ? | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |         $this->cached_filepath = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedFilepath($this) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->cached_filepath; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the timpestamp of the cached template output | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The timestamp is determined by the actual cache resource | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return integer the template timestamp | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCachedTimestamp () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-05-11 16:24:24 +00:00
										 |  |  |         if (!isset($this->cache_resource_object)) { | 
					
						
							|  |  |  |             $this->cache_resource_object = $this->smarty->cache->loadResource(); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $this->cached_timestamp === null ? | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |         $this->cached_timestamp = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedTimestamp($this) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->cached_timestamp; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the cached template output | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string |booelan the template content or false if the file does not exist | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function getCachedContent () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-05-11 16:24:24 +00:00
										 |  |  |         if (!isset($this->cache_resource_object)) { | 
					
						
							|  |  |  |             $this->cache_resource_object = $this->smarty->cache->loadResource(); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         return $this->rendered_content === null ? | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |         $this->rendered_content = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedContents($this) : | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         $this->rendered_content; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Writes the cached template output | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-01-03 11:53:28 +00:00
										 |  |  |     public function writeCachedContent ($content) | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-01-02 12:15:04 +00:00
										 |  |  |         if ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             // don't write cache file
 | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $this->properties['cache_lifetime'] = $this->cache_lifetime; | 
					
						
							| 
									
										
										
										
											2010-01-03 11:53:28 +00:00
										 |  |  |         return $this->cache_resource_object->writeCachedContent($this, $this->createPropertyHeader(true) . $content); | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Checks of a valid version redered HTML output is in the cache | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * If the cache is valid the contents is stored in the template object | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return boolean true if cache is valid | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function isCached () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($this->isCached === null) { | 
					
						
							| 
									
										
										
										
											2009-12-29 22:27:04 +00:00
										 |  |  |             $this->isCached = false; | 
					
						
							| 
									
										
										
										
											2010-02-08 17:39:48 +00:00
										 |  |  |             if (($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED) && !$this->resource_object->isEvaluated) { | 
					
						
							| 
									
										
										
										
											2010-01-25 18:10:35 +00:00
										 |  |  |                 if (!isset($this->cache_resource_object)) { | 
					
						
							| 
									
										
										
										
											2010-03-10 16:21:16 +00:00
										 |  |  |                     $this->cache_resource_object = $this->smarty->cache->loadResource(); | 
					
						
							| 
									
										
										
										
											2010-01-25 18:10:35 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 $cachedTimestamp = $this->getCachedTimestamp(); | 
					
						
							| 
									
										
										
										
											2010-02-08 17:39:48 +00:00
										 |  |  |                 if ($cachedTimestamp === false || $this->force_compile || $this->force_cache) { | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |                     return $this->isCached; | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($cachedTimestamp + $this->cache_lifetime) || $this->cache_lifetime < 0))) { | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |                     if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                         Smarty_Internal_Debug::start_cache($this); | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |                     $this->rendered_content = $this->cache_resource_object->getCachedContents($this); | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |                     if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                         Smarty_Internal_Debug::end_cache($this); | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-12-05 15:10:47 +00:00
										 |  |  |                     if ($this->cacheFileChecked) { | 
					
						
							|  |  |  |                         $this->isCached = true; | 
					
						
							|  |  |  |                         return $this->isCached; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                     $this->cacheFileChecked = true; | 
					
						
							| 
									
										
										
										
											2010-03-23 17:08:46 +00:00
										 |  |  |                     if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED && $this->properties['cache_lifetime'] >= 0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) { | 
					
						
							| 
									
										
										
										
											2010-08-23 14:40:10 +00:00
										 |  |  |                         $this->tpl_vars = array(); | 
					
						
							|  |  |  |                         $this->rendered_content = null; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                         return $this->isCached; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                     if (!empty($this->properties['file_dependency']) && $this->smarty->compile_check) { | 
					
						
							| 
									
										
										
										
											2010-08-23 14:40:10 +00:00
										 |  |  |                         $resource_type = null; | 
					
						
							|  |  |  |                         $resource_name = null; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                         foreach ($this->properties['file_dependency'] as $_file_to_check) { | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                             $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name); | 
					
						
							|  |  |  |                             If ($resource_type == 'file') { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $mtime = filemtime($_file_to_check[0]); | 
					
						
							|  |  |  |                             } else { | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                                 $resource_handler = $this->loadTemplateResourceHandler($resource_type); | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); | 
					
						
							|  |  |  |                             }  | 
					
						
							|  |  |  |                             // If ($mtime > $this->getCachedTimestamp()) {
 | 
					
						
							|  |  |  |                             If ($mtime > $_file_to_check[1]) { | 
					
						
							| 
									
										
										
										
											2010-07-31 13:29:59 +00:00
										 |  |  |                                 $this->tpl_vars = array(); | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $this->rendered_content = null; | 
					
						
							|  |  |  |                                 return $this->isCached; | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |                             }  | 
					
						
							|  |  |  |                         }  | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                     $this->isCached = true; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         return $this->isCached; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Render the output using the compiled template or the PHP template source | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * The rendering process is accomplished by just including the PHP files. | 
					
						
							|  |  |  |      * The only exceptions are evaluated templates (string template). Their code has  | 
					
						
							|  |  |  |      * to be evaluated | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     public function renderTemplate () | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if ($this->resource_object->usesCompiler) { | 
					
						
							| 
									
										
										
										
											2009-10-13 19:44:38 +00:00
										 |  |  |             if ($this->mustCompile() && $this->compiled_template === null) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 $this->compileTemplateSource(); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |             if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                 Smarty_Internal_Debug::start_render($this); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             $_smarty_tpl = $this; | 
					
						
							|  |  |  |             ob_start(); | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             if ($this->resource_object->isEvaluated) { | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 eval("?>" . $this->compiled_template); | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                 include($this->getCompiledFilepath ());  | 
					
						
							|  |  |  |                 // check file dependencies at compiled code
 | 
					
						
							|  |  |  |                 if ($this->smarty->compile_check) { | 
					
						
							|  |  |  |                     if (!empty($this->properties['file_dependency'])) { | 
					
						
							|  |  |  |                         $this->mustCompile = false; | 
					
						
							| 
									
										
										
										
											2010-08-23 14:40:10 +00:00
										 |  |  |                         $resource_type = null; | 
					
						
							|  |  |  |                         $resource_name = null; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                         foreach ($this->properties['file_dependency'] as $_file_to_check) { | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                             $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name); | 
					
						
							|  |  |  |                             If ($resource_type == 'file') { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $mtime = filemtime($_file_to_check[0]); | 
					
						
							|  |  |  |                             } else { | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                                 $resource_handler = $this->loadTemplateResourceHandler($resource_type); | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); | 
					
						
							|  |  |  |                             }  | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |                             // If ($mtime != $_file_to_check[1]) {
 | 
					
						
							| 
									
										
										
										
											2009-11-19 14:45:04 +00:00
										 |  |  |                             If ($mtime > $_file_to_check[1]) { | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                                 $this->mustCompile = true; | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                                 break; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                             }  | 
					
						
							|  |  |  |                         }  | 
					
						
							|  |  |  |                         if ($this->mustCompile) { | 
					
						
							|  |  |  |                             // recompile and render again
 | 
					
						
							|  |  |  |                             ob_get_clean(); | 
					
						
							|  |  |  |                             $this->compileTemplateSource(); | 
					
						
							|  |  |  |                             ob_start(); | 
					
						
							|  |  |  |                             include($this->getCompiledFilepath ()); | 
					
						
							|  |  |  |                         }  | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |             if (is_callable(array($this->resource_object, 'renderUncompiled'))) { | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |                 if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                     Smarty_Internal_Debug::start_render($this); | 
					
						
							|  |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  |                 ob_start(); | 
					
						
							| 
									
										
										
										
											2009-10-21 15:19:00 +00:00
										 |  |  |                 $this->resource_object->renderUncompiled($this); | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |                 throw new SmartyException("Resource '$this->resource_type' must have 'renderUncompiled' methode"); | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |         $this->rendered_content = ob_get_clean(); | 
					
						
							| 
									
										
										
										
											2010-01-07 19:33:18 +00:00
										 |  |  |         if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) { | 
					
						
							| 
									
										
										
										
											2010-01-05 21:10:25 +00:00
										 |  |  |             $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) { | 
					
						
							|  |  |  |             $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']); | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |             foreach($this->required_plugins as $code => $tmp1) { | 
					
						
							|  |  |  |                 foreach($tmp1 as $name => $tmp) { | 
					
						
							|  |  |  |                     foreach($tmp as $type => $data) { | 
					
						
							|  |  |  |                         $this->parent->required_plugins[$code][$name][$type] = $data; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-04-26 16:56:17 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |         if ($this->smarty->debugging) { | 
					
						
							|  |  |  |             Smarty_Internal_Debug::end_render($this); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // write to cache when nessecary
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) { | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |             if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                 Smarty_Internal_Debug::start_cache($this); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-01-03 11:53:28 +00:00
										 |  |  |             $this->properties['has_nocache_code'] = false;  | 
					
						
							|  |  |  |             // get text between non-cached items
 | 
					
						
							|  |  |  |             $cache_split = preg_split("!/\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\*/!s", $this->rendered_content);  | 
					
						
							|  |  |  |             // get non-cached items
 | 
					
						
							|  |  |  |             preg_match_all("!/\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\*/!s", $this->rendered_content, $cache_parts); | 
					
						
							|  |  |  |             $output = '';  | 
					
						
							|  |  |  |             // loop over items, stitch back together
 | 
					
						
							|  |  |  |             foreach($cache_split as $curr_idx => $curr_split) { | 
					
						
							|  |  |  |                 // escape PHP tags in template content
 | 
					
						
							|  |  |  |                 $output .= preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php echo \'$1\'; ?>', $curr_split); | 
					
						
							|  |  |  |                 if (isset($cache_parts[0][$curr_idx])) { | 
					
						
							|  |  |  |                     $this->properties['has_nocache_code'] = true;  | 
					
						
							|  |  |  |                     // remove nocache tags from cache output
 | 
					
						
							|  |  |  |                     $output .= preg_replace("!/\*/?%%SmartyNocache:{$this->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             // rendering (must be done before writing cache file because of {function} nocache handling)
 | 
					
						
							| 
									
										
										
										
											2009-12-31 16:38:12 +00:00
										 |  |  |             $_smarty_tpl = $this; | 
					
						
							|  |  |  |             ob_start(); | 
					
						
							| 
									
										
										
										
											2010-01-03 11:53:28 +00:00
										 |  |  |             eval("?>" . $output); | 
					
						
							|  |  |  |             $this->rendered_content = ob_get_clean();  | 
					
						
							|  |  |  |             // write cache file content
 | 
					
						
							| 
									
										
										
										
											2010-01-25 18:10:35 +00:00
										 |  |  |             $this->writeCachedContent($output); | 
					
						
							| 
									
										
										
										
											2009-11-11 22:09:06 +00:00
										 |  |  |             if ($this->smarty->debugging) { | 
					
						
							|  |  |  |                 Smarty_Internal_Debug::end_cache($this); | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-12-31 16:38:12 +00:00
										 |  |  |             // var_dump('renderTemplate', $this->has_nocache_code, $this->template_resource, $this->properties['nocache_hash'], $this->parent->properties['nocache_hash'], $this->rendered_content);
 | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |             if ($this->has_nocache_code && !empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) { | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |                 // replace nocache_hash
 | 
					
						
							|  |  |  |                 $this->rendered_content = preg_replace("/{$this->properties['nocache_hash']}/", $this->parent->properties['nocache_hash'], $this->rendered_content); | 
					
						
							| 
									
										
										
										
											2009-12-31 16:38:12 +00:00
										 |  |  |                 $this->parent->has_nocache_code = $this->has_nocache_code; | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-14 09:04:15 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Returns the rendered HTML output  | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * If the cache is valid the cached content is used, otherwise | 
					
						
							|  |  |  |      * the output is rendered from the compiled template or PHP template source | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @return string rendered HTML output | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-04-14 09:04:15 +00:00
										 |  |  |     public function getRenderedTemplate () | 
					
						
							|  |  |  |     {  | 
					
						
							|  |  |  |         // disable caching for evaluated code
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if ($this->resource_object->isEvaluated) { | 
					
						
							| 
									
										
										
										
											2009-04-14 09:04:15 +00:00
										 |  |  |             $this->caching = false; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         // checks if template exists
 | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         $this->isExisting(true);  | 
					
						
							| 
									
										
										
										
											2009-04-14 09:04:15 +00:00
										 |  |  |         // read from cache or render
 | 
					
						
							|  |  |  |         if ($this->rendered_content === null && !$this->isCached()) { | 
					
						
							|  |  |  |             // render template (not loaded and not in cache)
 | 
					
						
							|  |  |  |             $this->renderTemplate(); | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |         $this->updateParentVariables(); | 
					
						
							| 
									
										
										
										
											2009-12-05 15:10:47 +00:00
										 |  |  |         $this->isCached = null; | 
					
						
							| 
									
										
										
										
											2009-11-14 13:02:48 +00:00
										 |  |  |         return $this->rendered_content; | 
					
						
							| 
									
										
										
										
											2009-04-14 09:04:15 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Parse a template resource in its name and type | 
					
						
							|  |  |  |      * Load required resource handler | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $template_resource template resource specification | 
					
						
							|  |  |  |      * @param string $resource_type return resource type | 
					
						
							|  |  |  |      * @param string $resource_name return resource name | 
					
						
							|  |  |  |      * @param object $resource_handler return resource handler object | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |     public function parseResourceName($template_resource, &$resource_type, &$resource_name, &$resource_handler) | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (empty($template_resource)) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |         $this->getResourceTypeName($template_resource, $resource_type, $resource_name); | 
					
						
							|  |  |  |         $resource_handler = $this->loadTemplateResourceHandler($resource_type);  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |         // cache template object under a unique ID
 | 
					
						
							|  |  |  |         // do not cache string resources
 | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |         // *****        if ($resource_type != 'string' && $this->smarty->caching) {
 | 
					
						
							| 
									
										
										
										
											2009-08-29 16:29:52 +00:00
										 |  |  |         if ($resource_type != 'string') { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $this->smarty->template_objects[crc32($this->template_resource . $this->cache_id . $this->compile_id)] = $this; | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * get system filepath to template | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |     public function buildTemplateFilepath ($file = null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($file == null) { | 
					
						
							|  |  |  |             $file = $this->resource_name; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         foreach((array)$this->smarty->template_dir as $_template_dir) { | 
					
						
							| 
									
										
										
										
											2009-08-27 14:59:28 +00:00
										 |  |  |             if (strpos('/\\', substr($_template_dir, -1)) === false) { | 
					
						
							| 
									
										
										
										
											2009-08-29 22:57:29 +00:00
										 |  |  |                 $_template_dir .= DS; | 
					
						
							| 
									
										
										
										
											2009-04-03 15:59:40 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |             $_filepath = $_template_dir . $file; | 
					
						
							|  |  |  |             if (file_exists($_filepath)) | 
					
						
							|  |  |  |                 return $_filepath; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (file_exists($file)) return $file;  | 
					
						
							|  |  |  |         // no tpl file found
 | 
					
						
							|  |  |  |         if (!empty($this->smarty->default_template_handler_func)) { | 
					
						
							|  |  |  |             if (!is_callable($this->smarty->default_template_handler_func)) { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |                 throw new SmartyException("Default template handler not callable"); | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 $_return = call_user_func_array($this->smarty->default_template_handler_func, | 
					
						
							| 
									
										
										
										
											2009-11-23 16:05:30 +00:00
										 |  |  |                     array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this)); | 
					
						
							| 
									
										
										
										
											2009-11-26 22:49:56 +00:00
										 |  |  |                 if (is_string($_return)) { | 
					
						
							| 
									
										
										
										
											2009-11-23 16:05:30 +00:00
										 |  |  |                     return $_return; | 
					
						
							| 
									
										
										
										
											2009-11-26 22:49:56 +00:00
										 |  |  |                 } elseif ($_return === true) { | 
					
						
							|  |  |  |                     return $file; | 
					
						
							| 
									
										
										
										
											2009-11-27 20:46:56 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-04-18 14:46:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Update Smarty variables in other scopes | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |     public function updateParentVariables ($scope = SMARTY_LOCAL_SCOPE) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         $has_root = false; | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |         foreach ($this->tpl_vars as $_key => $_variable) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             $_variable_scope = $this->tpl_vars[$_key]->scope; | 
					
						
							|  |  |  |             if ($scope == SMARTY_LOCAL_SCOPE && $_variable_scope == SMARTY_LOCAL_SCOPE) { | 
					
						
							|  |  |  |                 continue; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             if (isset($this->parent) && ($scope == SMARTY_PARENT_SCOPE || $_variable_scope == SMARTY_PARENT_SCOPE)) { | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                 if (isset($this->parent->tpl_vars[$_key])) { | 
					
						
							|  |  |  |                     // variable is already defined in parent, copy value
 | 
					
						
							|  |  |  |                     $this->parent->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     // create variable in parent
 | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |                     $this->parent->tpl_vars[$_key] = clone $_variable; | 
					
						
							| 
									
										
										
										
											2009-09-19 13:22:32 +00:00
										 |  |  |                     $this->parent->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             if ($scope == SMARTY_ROOT_SCOPE || $_variable_scope == SMARTY_ROOT_SCOPE) { | 
					
						
							|  |  |  |                 if ($this->parent == null) { | 
					
						
							|  |  |  |                     continue; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |                 if (!$has_root) { | 
					
						
							|  |  |  |                     // find  root
 | 
					
						
							|  |  |  |                     $root_ptr = $this; | 
					
						
							|  |  |  |                     while ($root_ptr->parent != null) { | 
					
						
							|  |  |  |                         $root_ptr = $root_ptr->parent; | 
					
						
							|  |  |  |                         $has_root = true; | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 if (isset($root_ptr->tpl_vars[$_key])) { | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                     // variable is already defined in root, copy value
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                     $root_ptr->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                 } else { | 
					
						
							|  |  |  |                     // create variable in root
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                     $root_ptr->tpl_vars[$_key] = clone $_variable; | 
					
						
							|  |  |  |                     $root_ptr->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; | 
					
						
							| 
									
										
										
										
											2009-04-10 12:33:51 +00:00
										 |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             if ($scope == SMARTY_GLOBAL_SCOPE || $_variable_scope == SMARTY_GLOBAL_SCOPE) { | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                 if (isset($this->smarty->global_tpl_vars[$_key])) { | 
					
						
							|  |  |  |                     // variable is already defined in root, copy value
 | 
					
						
							|  |  |  |                     $this->smarty->global_tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     // create variable in root
 | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |                     $this->smarty->global_tpl_vars[$_key] = clone $_variable; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |                 $this->smarty->global_tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-09-29 21:00:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Split a template resource in its name and type | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $template_resource template resource specification | 
					
						
							|  |  |  |      * @param string $resource_type return resource type | 
					
						
							|  |  |  |      * @param string $resource_name return resource name | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-02-27 20:10:32 +00:00
										 |  |  |     protected function getResourceTypeName ($template_resource, &$resource_type, &$resource_name) | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (strpos($template_resource, ':') === false) { | 
					
						
							|  |  |  |             // no resource given, use default
 | 
					
						
							|  |  |  |             $resource_type = $this->smarty->default_resource_type; | 
					
						
							|  |  |  |             $resource_name = $template_resource; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // get type and name from path
 | 
					
						
							|  |  |  |             list($resource_type, $resource_name) = explode(':', $template_resource, 2); | 
					
						
							|  |  |  |             if (strlen($resource_type) == 1) { | 
					
						
							|  |  |  |                 // 1 char is not resource type, but part of filepath
 | 
					
						
							|  |  |  |                 $resource_type = 'file'; | 
					
						
							|  |  |  |                 $resource_name = $template_resource; | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2010-03-04 15:49:48 +00:00
										 |  |  |                 $resource_type = $resource_type; | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Load template resource handler by type | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $resource_type template resource type | 
					
						
							|  |  |  |      * @return object resource handler object | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2010-02-27 20:10:32 +00:00
										 |  |  |     protected function loadTemplateResourceHandler ($resource_type) | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |     {  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         // try registered resource
 | 
					
						
							|  |  |  |         if (isset($this->smarty->_plugins['resource'][$resource_type])) { | 
					
						
							|  |  |  |             return new Smarty_Internal_Resource_Registered($this->smarty); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // try sysplugins dir
 | 
					
						
							|  |  |  |             if (in_array($resource_type, array('file', 'string', 'extends', 'php', 'registered', 'stream'))) { | 
					
						
							| 
									
										
										
										
											2010-09-15 15:17:28 +00:00
										 |  |  |                 $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($resource_type); | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 return new $_resource_class($this->smarty); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 // try plugins dir
 | 
					
						
							| 
									
										
										
										
											2010-09-15 15:17:28 +00:00
										 |  |  |                 $_resource_class = 'Smarty_Resource_' . ucfirst($resource_type); | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                 if ($this->smarty->loadPlugin($_resource_class)) { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                     if (class_exists($_resource_class, false)) { | 
					
						
							|  |  |  |                         return new $_resource_class($this->smarty); | 
					
						
							|  |  |  |                     } else { | 
					
						
							| 
									
										
										
										
											2010-05-26 20:35:15 +00:00
										 |  |  |                         $this->smarty->register->resource($resource_type, | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                             array("smarty_resource_{$resource_type}_source", | 
					
						
							|  |  |  |                                 "smarty_resource_{$resource_type}_timestamp", | 
					
						
							|  |  |  |                                 "smarty_resource_{$resource_type}_secure", | 
					
						
							|  |  |  |                                 "smarty_resource_{$resource_type}_trusted")); | 
					
						
							|  |  |  |                         return new Smarty_Internal_Resource_Registered($this->smarty); | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                     // try streams
 | 
					
						
							|  |  |  |                     $_known_stream = stream_get_wrappers(); | 
					
						
							|  |  |  |                     if (in_array($resource_type, $_known_stream)) { | 
					
						
							|  |  |  |                         // is known stream
 | 
					
						
							|  |  |  |                         if ($this->smarty->security) { | 
					
						
							|  |  |  |                             $this->smarty->security_handler->isTrustedStream($resource_type); | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                         }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                         return new Smarty_Internal_Resource_Stream($this->smarty); | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                     } else { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |                         throw new SmartyException('Unkown resource type \'' . $resource_type . '\''); | 
					
						
							| 
									
										
										
										
											2009-10-12 14:37:31 +00:00
										 |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Create property header | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function createPropertyHeader ($cache = false) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $plugins_string = '';  | 
					
						
							|  |  |  |         // include code for plugins
 | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if (!$cache) { | 
					
						
							|  |  |  |             if (!empty($this->required_plugins['compiled'])) { | 
					
						
							|  |  |  |                 $plugins_string = '<?php '; | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |                 foreach($this->required_plugins['compiled'] as $tmp) { | 
					
						
							|  |  |  |                     foreach($tmp as $data) { | 
					
						
							|  |  |  |                         $plugins_string .= "if (!is_callable('{$data['function']}')) include '{$data['file']}';\n"; | 
					
						
							|  |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 }  | 
					
						
							|  |  |  |                 $plugins_string .= '?>'; | 
					
						
							|  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |             if (!empty($this->required_plugins['nocache'])) { | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |                 $this->has_nocache_code = true; | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |                 $plugins_string .= "<?php echo '/*%%SmartyNocache:{$this->properties['nocache_hash']}%%*/<?php "; | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |                 foreach($this->required_plugins['nocache'] as $tmp) { | 
					
						
							|  |  |  |                     foreach($tmp as $data) { | 
					
						
							| 
									
										
										
										
											2010-02-07 20:45:44 +00:00
										 |  |  |                         $plugins_string .= "if (!is_callable(\'{$data['function']}\')) include \'{$data['file']}\';\n"; | 
					
						
							| 
									
										
										
										
											2010-02-05 17:03:22 +00:00
										 |  |  |                     }  | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |                 }  | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |                 $plugins_string .= "?>/*/%%SmartyNocache:{$this->properties['nocache_hash']}%%*/';?>\n"; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         // build property code
 | 
					
						
							|  |  |  |         $this->properties['has_nocache_code'] = $this->has_nocache_code; | 
					
						
							|  |  |  |         $properties_string = "<?php /*%%SmartyHeaderCode:{$this->properties['nocache_hash']}%%*/" ; | 
					
						
							|  |  |  |         if ($this->smarty->direct_access_security) { | 
					
						
							|  |  |  |             $properties_string .= "if(!defined('SMARTY_DIR')) exit('no direct access allowed');\n"; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if ($cache) { | 
					
						
							|  |  |  |             // remove compiled code of{function} definition
 | 
					
						
							|  |  |  |             unset($this->properties['function']); | 
					
						
							|  |  |  |             if (!empty($this->smarty->template_functions)) { | 
					
						
							|  |  |  |                 // copy code of {function} tags called in nocache mode
 | 
					
						
							|  |  |  |                 foreach ($this->smarty->template_functions as $name => $function_data) { | 
					
						
							|  |  |  |                     if (isset($function_data['called_nocache'])) { | 
					
						
							|  |  |  |                         unset($function_data['called_nocache'], $this->smarty->template_functions[$name]['called_nocache']); | 
					
						
							|  |  |  |                         $this->properties['function'][$name] = $function_data; | 
					
						
							|  |  |  |                     }  | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         $properties_string .= "\$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . "); /*/%%SmartyHeaderCode%%*/?>\n"; | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |         return $properties_string . $plugins_string; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * Decode saved properties from compiled template and cache files | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |     public function decodeProperties ($properties) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |         $this->has_nocache_code = $properties['has_nocache_code']; | 
					
						
							| 
									
										
										
										
											2009-12-28 15:27:13 +00:00
										 |  |  |         $this->properties['nocache_hash'] = $properties['nocache_hash']; | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         if (isset($properties['cache_lifetime'])) { | 
					
						
							|  |  |  |             $this->properties['cache_lifetime'] = $properties['cache_lifetime']; | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (isset($properties['file_dependency'])) { | 
					
						
							|  |  |  |             $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (!empty($properties['function'])) { | 
					
						
							| 
									
										
										
										
											2009-12-31 16:38:12 +00:00
										 |  |  |             $this->properties['function'] = array_merge($this->properties['function'], $properties['function']); | 
					
						
							| 
									
										
										
										
											2009-12-29 20:12:11 +00:00
										 |  |  |             $this->smarty->template_functions = array_merge($this->smarty->template_functions, $properties['function']); | 
					
						
							| 
									
										
										
										
											2009-12-27 15:06:49 +00:00
										 |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-10-04 18:12:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-08 18:30:03 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * creates a loacal Smarty variable for array assihgments | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (!isset($this->tpl_vars[$tpl_var])) { | 
					
						
							|  |  |  |             $tpl_var_inst = $this->getVariable($tpl_var, null, true, false); | 
					
						
							|  |  |  |             if ($tpl_var_inst instanceof Undefined_Smarty_Variable) { | 
					
						
							|  |  |  |                 $this->tpl_vars[$tpl_var] = new Smarty_variable(array(), $nocache, $scope); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 $this->tpl_vars[$tpl_var] = clone $tpl_var_inst; | 
					
						
							|  |  |  |                 if ($scope != SMARTY_LOCAL_SCOPE) { | 
					
						
							|  |  |  |                     $this->tpl_vars[$tpl_var]->scope = $scope; | 
					
						
							|  |  |  |                 }  | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |         if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) { | 
					
						
							|  |  |  |             settype($this->tpl_vars[$tpl_var]->value, 'array'); | 
					
						
							|  |  |  |         }  | 
					
						
							|  |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-09-29 21:00:00 +00:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * wrapper for display | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-09-29 21:00:00 +00:00
										 |  |  |     public function display () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->smarty->display($this); | 
					
						
							|  |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |      * wrapper for fetch | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-09-29 21:00:00 +00:00
										 |  |  |     public function fetch () | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->smarty->fetch($this); | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 16:20:19 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * lazy loads (valid) property objects | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $name property name | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __get($name) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (in_array($name, array('register', 'unregister', 'utility', 'cache'))) { | 
					
						
							|  |  |  |             $class = "Smarty_Internal_" . ucfirst($name); | 
					
						
							|  |  |  |             $this->$name = new $class($this); | 
					
						
							|  |  |  |             return $this->$name; | 
					
						
							|  |  |  |         } else if ($name == '_version') { | 
					
						
							|  |  |  |             // Smarty 2 BC
 | 
					
						
							|  |  |  |             $this->_version = self::SMARTY_VERSION; | 
					
						
							|  |  |  |             return $this->_version; | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-03-08 16:20:19 +00:00
										 |  |  |         return null; | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |     }  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 15:15:41 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Takes unknown class methods and lazy loads sysplugin files for them | 
					
						
							|  |  |  |      * class name format: Smarty_Method_MethodName | 
					
						
							|  |  |  |      * plugin filename format: method.methodname.php | 
					
						
							|  |  |  |      *  | 
					
						
							|  |  |  |      * @param string $name unknown methode name | 
					
						
							|  |  |  |      * @param array $args aurgument array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __call($name, $args) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         static $camel_func; | 
					
						
							|  |  |  |         if (!isset($camel_func)) | 
					
						
							|  |  |  |             $camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');  | 
					
						
							|  |  |  |         // see if this is a set/get for a property
 | 
					
						
							|  |  |  |         $first3 = strtolower(substr($name, 0, 3)); | 
					
						
							|  |  |  |         if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') { | 
					
						
							|  |  |  |             // try to keep case correct for future PHP 6.0 case-sensitive class methods
 | 
					
						
							|  |  |  |             // lcfirst() not available < PHP 5.3.0, so improvise
 | 
					
						
							|  |  |  |             $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);  | 
					
						
							|  |  |  |             // convert camel case to underscored name
 | 
					
						
							|  |  |  |             $property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name); | 
					
						
							|  |  |  |             if (!property_exists($this, $property_name)) { | 
					
						
							| 
									
										
										
										
											2010-08-13 10:39:51 +00:00
										 |  |  |                 throw new SmartyException("property '$property_name' does not exist."); | 
					
						
							| 
									
										
										
										
											2010-03-08 15:15:41 +00:00
										 |  |  |                 return false; | 
					
						
							|  |  |  |             }  | 
					
						
							|  |  |  |             if ($first3 == 'get') | 
					
						
							|  |  |  |                 return $this->$property_name; | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 return $this->$property_name = $args[0]; | 
					
						
							|  |  |  |         }  | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-03-31 16:23:01 +00:00
										 |  |  |  * wrapper for template class | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-04-21 22:09:17 +00:00
										 |  |  | class Smarty_Template extends Smarty_Internal_Template { | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2009-03-22 16:09:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-23 17:08:46 +00:00
										 |  |  | ?>
 |