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
|
2011-03-16 23:57:04 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage Template
|
2014-06-06 02:40:04 +00:00
|
|
|
* @author Uwe Tews
|
2010-03-31 16:23:01 +00:00
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2010-03-31 16:23:01 +00:00
|
|
|
* Main class with template data structures and methods
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2011-09-16 14:19:56 +00:00
|
|
|
* @subpackage Template
|
2015-01-07 17:46:12 +01:00
|
|
|
*
|
2015-08-15 18:35:51 +02:00
|
|
|
* @property Smarty_Template_Source|Smarty_Template_Config $source
|
|
|
|
* @property Smarty_Template_Compiled $compiled
|
|
|
|
* @property Smarty_Template_Cached $cached
|
2015-10-18 04:46:05 +02:00
|
|
|
* @property Smarty_Internal_Runtime_Inheritance $_inheritance
|
2015-10-21 02:02:42 +02:00
|
|
|
* @property Smarty_Internal_Runtime_Subtemplate $_subtemplate
|
|
|
|
* @property Smarty_Internal_Runtime_Inline $_inline
|
|
|
|
* @property Smarty_Internal_Runtime_Tplfunc $_tplfunc
|
|
|
|
* @property Smarty_Internal_Runtime_Var $_var
|
|
|
|
* @property Smarty_Internal_Runtime_Foreach $_foreach
|
2015-08-17 21:52:32 +02:00
|
|
|
* @method bool mustCompile()
|
2010-03-31 16:23:01 +00:00
|
|
|
*/
|
2013-07-14 22:15:45 +00:00
|
|
|
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|
|
|
{
|
2015-08-17 21:52:32 +02:00
|
|
|
/**
|
|
|
|
* This object type (Smarty = 1, template = 2, data = 4)
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $_objType = 2;
|
|
|
|
|
2015-02-15 01:45:37 +01:00
|
|
|
/**
|
|
|
|
* Global smarty instance
|
|
|
|
*
|
|
|
|
* @var Smarty
|
|
|
|
*/
|
|
|
|
public $smarty = null;
|
|
|
|
|
2015-08-06 19:12:24 +02:00
|
|
|
/**
|
|
|
|
* Source instance
|
|
|
|
*
|
|
|
|
* @var Smarty_Template_Source|Smarty_Template_Config
|
|
|
|
*/
|
|
|
|
public $source = null;
|
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
2014-12-31 15:44:08 +01:00
|
|
|
* Template resource
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-09-16 14:19:56 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
2014-12-31 15:44:08 +01:00
|
|
|
public $template_resource = null;
|
2015-07-07 17:51:40 +02:00
|
|
|
|
2011-09-16 14:19:56 +00:00
|
|
|
/**
|
|
|
|
* flag if compiled template is invalid and must be (re)compiled
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2011-09-16 14:19:56 +00:00
|
|
|
* @var bool
|
|
|
|
*/
|
2009-03-22 16:09:05 +00:00
|
|
|
public $mustCompile = null;
|
2015-07-07 17:51:40 +02:00
|
|
|
|
2015-08-10 21:57:06 +02:00
|
|
|
/**
|
|
|
|
* Template Id
|
|
|
|
*
|
2015-09-01 02:27:22 +02:00
|
|
|
* @var null|string
|
2015-08-10 21:57:06 +02:00
|
|
|
*/
|
2015-09-01 02:27:22 +02:00
|
|
|
public $templateId = null;
|
2015-08-10 21:57:06 +02:00
|
|
|
|
2015-08-09 20:43:04 +02:00
|
|
|
/**
|
|
|
|
* Known template functions
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $tpl_function = array();
|
|
|
|
|
2015-09-01 01:54:28 +02:00
|
|
|
/**
|
2010-03-31 16:23:01 +00:00
|
|
|
* Create template data object
|
|
|
|
* Some of the global Smarty settings copied to template scope
|
2015-01-07 17:46:12 +01:00
|
|
|
* It load the required template resources and caching plugins
|
2011-03-16 23:57:04 +00:00
|
|
|
*
|
2015-08-15 18:35:51 +02:00
|
|
|
* @param string $template_resource template resource string
|
|
|
|
* @param Smarty $smarty Smarty instance
|
|
|
|
* @param \Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_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
|
|
|
|
* @param bool $_caching use caching?
|
|
|
|
* @param int $_cache_lifetime cache life-time in seconds
|
|
|
|
*
|
|
|
|
* @throws \SmartyException
|
2010-03-31 16:23:01 +00:00
|
|
|
*/
|
2015-09-01 02:27:22 +02:00
|
|
|
public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
|
|
|
|
$_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2014-11-01 22:42:34 +01: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;
|
2009-11-26 22:49:56 +00:00
|
|
|
$this->caching = $_caching === null ? $this->smarty->caching : $_caching;
|
2014-06-06 02:40:04 +00:00
|
|
|
if ($this->caching === true) {
|
2011-09-16 14:19:56 +00:00
|
|
|
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
|
2014-06-06 02:40:04 +00:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
$this->cache_lifetime = $_cache_lifetime === null ? $this->smarty->cache_lifetime : $_cache_lifetime;
|
2011-03-16 23:57:04 +00:00
|
|
|
$this->parent = $_parent;
|
2009-03-22 16:09:05 +00:00
|
|
|
// Template resource
|
2011-03-16 23:57:04 +00:00
|
|
|
$this->template_resource = $template_resource;
|
2015-08-06 19:12:24 +02:00
|
|
|
$this->source = Smarty_Template_Source::load($this);
|
2011-03-16 23:57:04 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
2015-01-02 09:12:01 +01:00
|
|
|
/**
|
|
|
|
* render template
|
|
|
|
*
|
|
|
|
* @param bool $merge_tpl_vars if true parent template variables merged in to local scope
|
|
|
|
* @param bool $no_output_filter if true do not run output filter
|
2015-05-07 04:36:49 +02:00
|
|
|
* @param bool $display true: display, false: fetch null: subtemplate
|
2015-01-02 09:12:01 +01:00
|
|
|
*
|
|
|
|
* @throws Exception
|
|
|
|
* @throws SmartyException
|
|
|
|
* @return string rendered template output
|
|
|
|
*/
|
2015-05-07 04:36:49 +02:00
|
|
|
public function render($merge_tpl_vars = false, $no_output_filter = true, $display = null)
|
2015-01-02 09:12:01 +01:00
|
|
|
{
|
2015-08-23 01:25:57 +02:00
|
|
|
$parentIsTpl = isset($this->parent) && $this->parent->_objType == 2;
|
2015-01-02 09:12:01 +01:00
|
|
|
if ($this->smarty->debugging) {
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->start_template($this, $display);
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
2015-07-01 06:44:28 +02:00
|
|
|
// checks if template exists
|
|
|
|
if (!$this->source->exists) {
|
|
|
|
if ($parentIsTpl) {
|
|
|
|
$parent_resource = " in '{$this->parent->template_resource}'";
|
|
|
|
} else {
|
|
|
|
$parent_resource = '';
|
|
|
|
}
|
|
|
|
throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
|
|
|
|
}
|
2015-01-07 17:46:12 +01:00
|
|
|
$save_tpl_vars = null;
|
|
|
|
$save_config_vars = null;
|
2015-01-02 09:12:01 +01:00
|
|
|
// merge all variable scopes into template
|
|
|
|
if ($merge_tpl_vars) {
|
|
|
|
// save local variables
|
|
|
|
$save_tpl_vars = $this->tpl_vars;
|
|
|
|
$save_config_vars = $this->config_vars;
|
|
|
|
$ptr_array = array($this);
|
|
|
|
$ptr = $this;
|
|
|
|
while (isset($ptr->parent)) {
|
|
|
|
$ptr_array[] = $ptr = $ptr->parent;
|
|
|
|
}
|
|
|
|
$ptr_array = array_reverse($ptr_array);
|
|
|
|
$parent_ptr = reset($ptr_array);
|
|
|
|
$tpl_vars = $parent_ptr->tpl_vars;
|
|
|
|
$config_vars = $parent_ptr->config_vars;
|
|
|
|
while ($parent_ptr = next($ptr_array)) {
|
|
|
|
if (!empty($parent_ptr->tpl_vars)) {
|
|
|
|
$tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
|
|
|
|
}
|
|
|
|
if (!empty($parent_ptr->config_vars)) {
|
|
|
|
$config_vars = array_merge($config_vars, $parent_ptr->config_vars);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty(Smarty::$global_tpl_vars)) {
|
|
|
|
$tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
|
|
|
|
}
|
|
|
|
$this->tpl_vars = $tpl_vars;
|
|
|
|
$this->config_vars = $config_vars;
|
|
|
|
}
|
2015-08-23 01:25:57 +02:00
|
|
|
// check URL debugging control
|
2015-01-02 09:12:01 +01:00
|
|
|
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->debugUrl($this);
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
2015-08-23 05:35:13 +02:00
|
|
|
// disable caching for evaluated code
|
|
|
|
if ($this->source->handler->recompiled) {
|
|
|
|
$this->caching = false;
|
|
|
|
}
|
|
|
|
// read from cache or render
|
2015-09-01 02:27:22 +02:00
|
|
|
$isCacheTpl =
|
|
|
|
$this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
|
2015-08-23 05:35:13 +02:00
|
|
|
if ($isCacheTpl) {
|
|
|
|
if (!isset($this->cached)) {
|
|
|
|
$this->loadCached();
|
|
|
|
}
|
|
|
|
$this->cached->render($this, $no_output_filter);
|
|
|
|
} elseif ($this->source->handler->uncompiled) {
|
2015-08-23 01:25:57 +02:00
|
|
|
$this->source->render($this);
|
|
|
|
} else {
|
2015-08-23 05:35:13 +02:00
|
|
|
if (!isset($this->compiled)) {
|
|
|
|
$this->loadCompiled();
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
2015-08-23 05:35:13 +02:00
|
|
|
$this->compiled->render($this);
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
2015-08-23 05:35:13 +02:00
|
|
|
|
2015-01-02 09:12:01 +01:00
|
|
|
// display or fetch
|
|
|
|
if ($display) {
|
|
|
|
if ($this->caching && $this->smarty->cache_modified_check) {
|
2015-08-19 01:09:08 +02:00
|
|
|
$this->cached->cacheModifiedCheck($this, isset($content) ? $content : ob_get_clean());
|
2015-01-02 09:12:01 +01:00
|
|
|
} else {
|
2015-10-18 04:54:09 +02:00
|
|
|
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
|
|
|
!$no_output_filter && (isset($this->smarty->autoload_filters['output']) ||
|
|
|
|
isset($this->smarty->registered_filters['output']))
|
|
|
|
) {
|
|
|
|
echo Smarty_Internal_Filter_Handler::runFilter('output', ob_get_clean(), $this);
|
|
|
|
} else {
|
|
|
|
ob_end_flush();
|
|
|
|
flush();
|
|
|
|
}
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
|
|
|
if ($this->smarty->debugging) {
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->end_template($this);
|
2015-10-21 02:02:42 +02:00
|
|
|
// debug output
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->display_debug($this, true);
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
|
|
|
if ($merge_tpl_vars) {
|
|
|
|
// restore local variables
|
|
|
|
$this->tpl_vars = $save_tpl_vars;
|
|
|
|
$this->config_vars = $save_config_vars;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
} else {
|
|
|
|
if ($merge_tpl_vars) {
|
|
|
|
// restore local variables
|
|
|
|
$this->tpl_vars = $save_tpl_vars;
|
|
|
|
$this->config_vars = $save_config_vars;
|
|
|
|
}
|
|
|
|
if ($this->smarty->debugging) {
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->end_template($this);
|
2015-10-21 02:02:42 +02:00
|
|
|
if ($this->smarty->debugging == 2 and $display === false) {
|
2015-08-19 00:58:47 +02:00
|
|
|
$this->smarty->_debug->display_debug($this, true);
|
2015-05-07 04:36:49 +02:00
|
|
|
}
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
2015-03-17 01:10:51 +01:00
|
|
|
if ($parentIsTpl) {
|
2015-08-23 01:25:57 +02:00
|
|
|
if (!empty($this->tpl_function)) {
|
|
|
|
$this->parent->tpl_function = array_merge($this->parent->tpl_function, $this->tpl_function);
|
|
|
|
}
|
2015-08-09 20:53:32 +02:00
|
|
|
foreach ($this->compiled->required_plugins as $code => $tmp1) {
|
|
|
|
foreach ($tmp1 as $name => $tmp) {
|
2015-03-14 12:02:57 +01:00
|
|
|
foreach ($tmp as $type => $data) {
|
2015-08-09 20:53:32 +02:00
|
|
|
$this->parent->compiled->required_plugins[$code][$name][$type] = $data;
|
2015-03-14 12:02:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-18 04:54:09 +02:00
|
|
|
if (!$no_output_filter &&
|
|
|
|
(!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
|
|
|
(isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))
|
|
|
|
) {
|
|
|
|
return Smarty_Internal_Filter_Handler::runFilter('output', ob_get_clean(), $this);
|
|
|
|
}
|
2015-03-17 01:10:51 +01:00
|
|
|
// return cache content
|
2015-10-18 04:54:09 +02:00
|
|
|
return null;
|
2015-01-02 09:12:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-22 16:09:05 +00:00
|
|
|
/**
|
2010-03-31 16:23:01 +00:00
|
|
|
* Compiles the template
|
|
|
|
* If the template is not evaluated the compiled template is saved on disk
|
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function compileTemplateSource()
|
2009-03-22 16:09:05 +00:00
|
|
|
{
|
2015-01-02 09:12:01 +01:00
|
|
|
return $this->compiled->compileTemplateSource($this);
|
2011-03-16 23:57:04 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2015-01-02 09:12:01 +01:00
|
|
|
* Writes the content to cache resource
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @param string $content
|
|
|
|
*
|
2011-09-16 14:19:56 +00:00
|
|
|
* @return bool
|
2010-03-31 16:23:01 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function writeCachedContent($content)
|
2009-12-27 15:06:49 +00:00
|
|
|
{
|
2015-01-02 09:12:01 +01:00
|
|
|
return $this->cached->writeCachedContent($this, $content);
|
2011-03-16 23:57:04 +00:00
|
|
|
}
|
2009-03-22 16:09:05 +00:00
|
|
|
|
|
|
|
/**
|
2015-09-01 02:27:22 +02:00
|
|
|
* Get unique template id
|
2014-11-01 22:42:34 +01:00
|
|
|
*
|
2015-09-01 02:27:22 +02:00
|
|
|
* @return string
|
2014-11-01 22:42:34 +01:00
|
|
|
*/
|
2015-09-01 02:27:22 +02:00
|
|
|
public function _getTemplateId()
|
2014-11-01 22:42:34 +01:00
|
|
|
{
|
2015-09-01 02:27:22 +02:00
|
|
|
return isset($this->templateId) ? $this->templateId : $this->templateId =
|
|
|
|
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
|
2014-11-01 22:42:34 +01:00
|
|
|
}
|
|
|
|
|
2015-09-14 23:50:20 +02:00
|
|
|
/**
|
2011-09-16 14:19:56 +00:00
|
|
|
* This function is executed automatically when a compiled or cached template file is included
|
|
|
|
* - Decode saved properties from compiled template and cache files
|
|
|
|
* - Check if compiled or cache file is valid
|
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param array $properties special template properties
|
|
|
|
* @param bool $cache flag if called from cache file
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return bool flag if compiled or cache file is valid
|
2010-03-31 16:23:01 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function decodeProperties($properties, $cache = false)
|
2009-12-27 15:06:49 +00:00
|
|
|
{
|
2011-09-16 14:19:56 +00:00
|
|
|
$is_valid = true;
|
2014-11-01 22:42:34 +01:00
|
|
|
if (Smarty::SMARTY_VERSION != $properties['version']) {
|
|
|
|
// new version must rebuild
|
2011-09-16 14:19:56 +00:00
|
|
|
$is_valid = false;
|
2015-07-07 17:51:40 +02:00
|
|
|
} elseif (!empty($properties['file_dependency']) &&
|
|
|
|
((!$cache && $this->smarty->compile_check) || $this->smarty->compile_check == 1)
|
|
|
|
) {
|
2014-11-01 22:42:34 +01:00
|
|
|
// check file dependencies at compiled code
|
|
|
|
foreach ($properties['file_dependency'] as $_file_to_check) {
|
2015-09-01 02:52:09 +02:00
|
|
|
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
|
2015-07-01 03:27:06 +02:00
|
|
|
if ($this->source->filepath == $_file_to_check[0]) {
|
2011-09-16 14:19:56 +00:00
|
|
|
// do not recheck current template
|
2015-07-01 03:27:06 +02:00
|
|
|
continue;
|
|
|
|
//$mtime = $this->source->getTimeStamp();
|
2011-09-16 14:19:56 +00:00
|
|
|
} else {
|
|
|
|
// file and php types can be checked without loading the respective resource handlers
|
2015-07-01 03:27:06 +02:00
|
|
|
$mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false;
|
2015-05-06 23:10:39 +02:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
} elseif ($_file_to_check[2] == 'string') {
|
|
|
|
continue;
|
|
|
|
} else {
|
2015-07-06 03:25:03 +02:00
|
|
|
$source = Smarty_Template_Source::load(null, $this->smarty, $_file_to_check[0]);
|
2015-07-01 03:27:06 +02:00
|
|
|
$mtime = $source->getTimeStamp();
|
2011-09-16 14:19:56 +00:00
|
|
|
}
|
2012-03-30 14:21:16 +00:00
|
|
|
if (!$mtime || $mtime > $_file_to_check[1]) {
|
2011-09-16 14:19:56 +00:00
|
|
|
$is_valid = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($cache) {
|
2013-02-28 19:17:26 +00:00
|
|
|
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
2015-07-07 17:51:40 +02:00
|
|
|
if ($this->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 &&
|
2014-11-01 22:42:34 +01:00
|
|
|
(time() > ($this->cached->timestamp + $properties['cache_lifetime']))
|
2014-06-06 02:40:04 +00:00
|
|
|
) {
|
2013-02-28 19:17:26 +00:00
|
|
|
$is_valid = false;
|
|
|
|
}
|
2015-08-15 18:35:51 +02:00
|
|
|
$this->cached->cache_lifetime = $properties['cache_lifetime'];
|
2011-09-16 14:19:56 +00:00
|
|
|
$this->cached->valid = $is_valid;
|
2015-08-09 20:43:04 +02:00
|
|
|
$resource = $this->cached;
|
2011-09-16 14:19:56 +00:00
|
|
|
} else {
|
2014-06-06 02:40:04 +00:00
|
|
|
$this->mustCompile = !$is_valid;
|
2015-08-09 20:43:04 +02:00
|
|
|
$resource = $this->compiled;
|
2015-08-19 00:58:47 +02:00
|
|
|
$resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
|
2014-06-06 02:40:04 +00:00
|
|
|
}
|
2014-11-01 22:42:34 +01:00
|
|
|
if ($is_valid) {
|
2015-08-09 20:43:04 +02:00
|
|
|
$resource->unifunc = $properties['unifunc'];
|
|
|
|
$resource->has_nocache_code = $properties['has_nocache_code'];
|
|
|
|
// $this->compiled->nocache_hash = $properties['nocache_hash'];
|
|
|
|
$resource->file_dependency = $properties['file_dependency'];
|
2015-08-15 18:35:51 +02:00
|
|
|
if (isset($properties['tpl_function'])) {
|
|
|
|
$this->tpl_function = $properties['tpl_function'];
|
|
|
|
}
|
2014-11-01 22:42:34 +01:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
return $is_valid;
|
2011-03-16 23:57:04 +00:00
|
|
|
}
|
2009-10-04 18:12:30 +00:00
|
|
|
|
2010-11-11 21:34:36 +00:00
|
|
|
/**
|
2011-10-11 15:49:19 +00:00
|
|
|
* runtime error not matching capture tags
|
|
|
|
*/
|
|
|
|
public function capture_error()
|
|
|
|
{
|
|
|
|
throw new SmartyException("Not matching {capture} open/close in \"{$this->template_resource}\"");
|
|
|
|
}
|
2011-10-21 12:08:35 +00:00
|
|
|
|
2015-05-07 22:57:59 +02:00
|
|
|
/**
|
|
|
|
* Load compiled object
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function loadCompiled()
|
|
|
|
{
|
|
|
|
if (!isset($this->compiled)) {
|
|
|
|
$this->compiled = Smarty_Template_Compiled::load($this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load cached object
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function loadCached()
|
|
|
|
{
|
|
|
|
if (!isset($this->cached)) {
|
|
|
|
$this->cached = Smarty_Template_Cached::load($this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load compiler object
|
|
|
|
*
|
|
|
|
* @throws \SmartyException
|
|
|
|
*/
|
|
|
|
public function loadCompiler()
|
|
|
|
{
|
2015-08-23 01:46:30 +02:00
|
|
|
if (!class_exists($this->source->handler->compiler_class)) {
|
|
|
|
$this->smarty->loadPlugin($this->source->handler->compiler_class);
|
2015-06-27 21:23:22 +02:00
|
|
|
}
|
2015-09-01 02:27:22 +02:00
|
|
|
$this->compiler = new $this->source->handler->compiler_class($this->source->handler->template_lexer_class,
|
|
|
|
$this->source->handler->template_parser_class,
|
|
|
|
$this->smarty);
|
2015-05-07 22:57:59 +02:00
|
|
|
}
|
|
|
|
|
2014-06-06 02:40:04 +00:00
|
|
|
/**
|
2015-02-15 01:45:37 +01:00
|
|
|
* Handle unknown class methods
|
|
|
|
*
|
|
|
|
* @param string $name unknown method-name
|
|
|
|
* @param array $args argument array
|
|
|
|
*
|
2015-05-10 12:09:24 +02:00
|
|
|
* @return mixed
|
2015-02-15 01:45:37 +01:00
|
|
|
* @throws SmartyException
|
|
|
|
*/
|
|
|
|
public function __call($name, $args)
|
|
|
|
{
|
|
|
|
// method of Smarty object?
|
|
|
|
if (method_exists($this->smarty, $name)) {
|
|
|
|
return call_user_func_array(array($this->smarty, $name), $args);
|
|
|
|
}
|
|
|
|
// parent
|
|
|
|
return parent::__call($name, $args);
|
|
|
|
}
|
2015-03-17 01:10:51 +01:00
|
|
|
|
|
|
|
/**
|
2011-03-16 23:57:04 +00:00
|
|
|
* set Smarty property in template context
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2010-11-11 21:34:36 +00:00
|
|
|
* @param string $property_name property name
|
2011-09-16 14:19:56 +00:00
|
|
|
* @param mixed $value value
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
|
|
|
* @throws SmartyException
|
2010-11-11 21:34:36 +00:00
|
|
|
*/
|
|
|
|
public function __set($property_name, $value)
|
|
|
|
{
|
2015-09-01 00:33:10 +02:00
|
|
|
if ($property_name[0] == '_') {
|
|
|
|
$this->$property_name = $value;
|
|
|
|
return;
|
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
switch ($property_name) {
|
|
|
|
case 'compiled':
|
|
|
|
case 'cached':
|
|
|
|
case 'compiler':
|
|
|
|
$this->$property_name = $value;
|
|
|
|
return;
|
|
|
|
default:
|
2015-05-07 22:57:59 +02:00
|
|
|
// Smarty property ?
|
2011-09-16 14:19:56 +00:00
|
|
|
if (property_exists($this->smarty, $property_name)) {
|
|
|
|
$this->smarty->$property_name = $value;
|
|
|
|
return;
|
|
|
|
}
|
2010-11-11 21:34:36 +00:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
throw new SmartyException("invalid template property '$property_name'.");
|
2010-11-11 21:34:36 +00:00
|
|
|
}
|
2010-03-31 16:23:01 +00:00
|
|
|
|
2010-03-08 16:20:19 +00:00
|
|
|
/**
|
2011-03-16 23:57:04 +00:00
|
|
|
* get Smarty property in template context
|
2011-09-16 14:19:56 +00:00
|
|
|
*
|
2010-11-11 21:34:36 +00:00
|
|
|
* @param string $property_name property name
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2015-01-02 09:12:01 +01:00
|
|
|
* @return mixed|Smarty_Template_Cached
|
2014-06-06 02:40:04 +00:00
|
|
|
* @throws SmartyException
|
2010-03-08 16:20:19 +00:00
|
|
|
*/
|
2010-11-11 21:34:36 +00:00
|
|
|
public function __get($property_name)
|
2010-03-08 16:20:19 +00:00
|
|
|
{
|
2015-09-01 00:33:10 +02:00
|
|
|
// object properties of runtime template extensions will start with '_'
|
|
|
|
if ($property_name[0] == '_') {
|
|
|
|
$class = 'Smarty_Internal_Runtime' . $property_name;
|
2015-10-18 04:46:05 +02:00
|
|
|
$class[24] = chr(ord($class[24]) & 0xDF);
|
2015-09-14 23:46:17 +02:00
|
|
|
if (class_exists($class)) {
|
2015-09-01 00:33:10 +02:00
|
|
|
return $this->$property_name = new $class();
|
|
|
|
}
|
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
switch ($property_name) {
|
|
|
|
case 'compiled':
|
2015-05-07 22:57:59 +02:00
|
|
|
$this->loadCompiled();
|
2011-09-16 14:19:56 +00:00
|
|
|
return $this->compiled;
|
|
|
|
|
|
|
|
case 'cached':
|
2015-05-07 22:57:59 +02:00
|
|
|
$this->loadCached();
|
2011-09-16 14:19:56 +00:00
|
|
|
return $this->cached;
|
|
|
|
|
|
|
|
case 'compiler':
|
2015-05-07 22:57:59 +02:00
|
|
|
$this->loadCompiler();
|
2011-09-16 14:19:56 +00:00
|
|
|
return $this->compiler;
|
2015-05-10 12:09:24 +02:00
|
|
|
default:
|
|
|
|
// Smarty property ?
|
2011-09-16 14:19:56 +00:00
|
|
|
if (property_exists($this->smarty, $property_name)) {
|
|
|
|
return $this->smarty->$property_name;
|
|
|
|
}
|
2010-11-11 21:34:36 +00:00
|
|
|
}
|
2011-09-16 14:19:56 +00:00
|
|
|
throw new SmartyException("template property '$property_name' does not exist.");
|
|
|
|
}
|
2010-03-31 16:23:01 +00:00
|
|
|
|
2010-03-08 15:15:41 +00:00
|
|
|
/**
|
2014-06-06 02:40:04 +00:00
|
|
|
* Template data object destructor
|
2010-03-08 15:15:41 +00:00
|
|
|
*/
|
2011-09-16 14:19:56 +00:00
|
|
|
public function __destruct()
|
2010-03-08 15:15:41 +00:00
|
|
|
{
|
2011-09-16 14:19:56 +00:00
|
|
|
if ($this->smarty->cache_locking && isset($this->cached) && $this->cached->is_locked) {
|
|
|
|
$this->cached->handler->releaseLock($this->smarty, $this->cached);
|
|
|
|
}
|
2011-03-16 23:57:04 +00:00
|
|
|
}
|
2010-11-11 21:34:36 +00:00
|
|
|
}
|