mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- convert debug console processing to object
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
- introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop
|
- introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop
|
||||||
- load seldom used Smarty API methods dynamically to reduce memory footprint
|
- load seldom used Smarty API methods dynamically to reduce memory footprint
|
||||||
- cache template object of {include} if same template is included several times
|
- cache template object of {include} if same template is included several times
|
||||||
|
- convert debug console processing to object
|
||||||
|
|
||||||
06.08.2015
|
06.08.2015
|
||||||
- avoid possible circular object references caused by parser/lexer objects
|
- avoid possible circular object references caused by parser/lexer objects
|
||||||
|
@@ -741,6 +741,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public $_objType = 1;
|
public $_objType = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug object
|
||||||
|
*
|
||||||
|
* @var Smarty_Internal_Debug
|
||||||
|
*/
|
||||||
|
public $_debug = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removed properties
|
* removed properties
|
||||||
*
|
*
|
||||||
@@ -1190,6 +1197,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
} else {
|
} else {
|
||||||
$data = null;
|
$data = null;
|
||||||
}
|
}
|
||||||
|
/* var Smarty $tpl */
|
||||||
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
|
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
|
||||||
if ($do_clone) {
|
if ($do_clone) {
|
||||||
$tpl->smarty = clone $tpl->smarty;
|
$tpl->smarty = clone $tpl->smarty;
|
||||||
@@ -1202,7 +1210,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
Smarty_Internal_Debug::register_template($tpl);
|
$tpl->smarty->_debug = new Smarty_Internal_Debug();
|
||||||
}
|
}
|
||||||
return $tpl;
|
return $tpl;
|
||||||
}
|
}
|
||||||
|
@@ -160,7 +160,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
|
|||||||
$_tpl = new Smarty_Internal_template('string:' .
|
$_tpl = new Smarty_Internal_template('string:' .
|
||||||
$compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime);
|
$compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime);
|
||||||
if ($compiler->smarty->debugging) {
|
if ($compiler->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::ignore($_tpl);
|
$compiler->smarty->_debug->ignore($_tpl);
|
||||||
}
|
}
|
||||||
$_tpl->tpl_vars = $compiler->template->tpl_vars;
|
$_tpl->tpl_vars = $compiler->template->tpl_vars;
|
||||||
$_tpl->variable_filters = $compiler->template->variable_filters;
|
$_tpl->variable_filters = $compiler->template->variable_filters;
|
||||||
|
@@ -34,8 +34,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
|||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
|
|
||||||
// display debug template
|
// display debug template
|
||||||
$_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>";
|
$_output = "<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
|
||||||
|
$_output .= "unset(\$_smarty_debug);\n?>";
|
||||||
return $_output;
|
return $_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
$this->template->source->getTimeStamp(),
|
$this->template->source->getTimeStamp(),
|
||||||
$this->template->source->type);
|
$this->template->source->type);
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
// init the lexer/parser to compile the config file
|
// init the lexer/parser to compile the config file
|
||||||
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) .
|
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) .
|
||||||
@@ -136,7 +136,7 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
mb_internal_encoding($mbEncoding);
|
mb_internal_encoding($mbEncoding);
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_compile($this->template);
|
$this->smarty->_debug->end_compile($this->template);
|
||||||
}
|
}
|
||||||
// template header code
|
// template header code
|
||||||
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " .
|
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " .
|
||||||
|
@@ -21,28 +21,32 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $template_data = array();
|
public $template_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of uid's which shall be ignored
|
* List of uid's which shall be ignored
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $ignore_uid = array();
|
public $ignore_uid = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of display() and fetch() calls
|
* Index of display() and fetch() calls
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public static $index = 0;
|
public $index = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counter for window offset
|
* Counter for window offset
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public static $offset = 0;
|
public $offset = 0;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start logging template
|
* Start logging template
|
||||||
@@ -50,15 +54,15 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
* @param \Smarty_Internal_Template $template template
|
* @param \Smarty_Internal_Template $template template
|
||||||
* @param null $mode true: display false: fetch null: subtemolate
|
* @param null $mode true: display false: fetch null: subtemolate
|
||||||
*/
|
*/
|
||||||
public static function start_template(Smarty_Internal_Template $template, $mode = null)
|
public function start_template(Smarty_Internal_Template $template, $mode = null)
|
||||||
{
|
{
|
||||||
if (isset($mode)) {
|
if (isset($mode)) {
|
||||||
self::$index ++;
|
$this->index ++;
|
||||||
self::$offset ++;
|
$this->offset ++;
|
||||||
self::$template_data[self::$index] = null;
|
$this->template_data[$this->index] = null;
|
||||||
}
|
}
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['start_template_time'] = microtime(true);
|
$this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,11 +70,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template cached template
|
* @param \Smarty_Internal_Template $template cached template
|
||||||
*/
|
*/
|
||||||
public static function end_template(Smarty_Internal_Template $template)
|
public function end_template(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['total_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_template_time'];
|
$this->template_data[$this->index][$key]['total_time'] += microtime(true) - $this->template_data[$this->index][$key]['start_template_time'];
|
||||||
//self::$template_data[self::$index][$key]['properties'] = $template->properties;
|
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,28 +82,28 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*/
|
*/
|
||||||
public static function start_compile(Smarty_Internal_Template $template)
|
public function start_compile(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||||
if (!empty($template->compiler->trace_uid)) {
|
if (!empty($template->compiler->trace_uid)) {
|
||||||
$key = $template->compiler->trace_uid;
|
$key = $template->compiler->trace_uid;
|
||||||
if (!isset(self::$template_data[self::$index][$key])) {
|
if (!isset($this->template_data[$this->index][$key])) {
|
||||||
if (isset($_is_stringy[$template->source->type])) {
|
if (isset($_is_stringy[$template->source->type])) {
|
||||||
self::$template_data[self::$index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
|
$this->template_data[$this->index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||||
} else {
|
} else {
|
||||||
self::$template_data[self::$index][$key]['name'] = $template->source->filepath;
|
$this->template_data[$this->index][$key]['name'] = $template->source->filepath;
|
||||||
}
|
}
|
||||||
self::$template_data[self::$index][$key]['compile_time'] = 0;
|
$this->template_data[$this->index][$key]['compile_time'] = 0;
|
||||||
self::$template_data[self::$index][$key]['render_time'] = 0;
|
$this->template_data[$this->index][$key]['render_time'] = 0;
|
||||||
self::$template_data[self::$index][$key]['cache_time'] = 0;
|
$this->template_data[$this->index][$key]['cache_time'] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isset(self::$ignore_uid[$template->source->uid])) {
|
if (isset($this->ignore_uid[$template->source->uid])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
}
|
}
|
||||||
self::$template_data[self::$index][$key]['start_time'] = microtime(true);
|
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,18 +111,18 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*/
|
*/
|
||||||
public static function end_compile(Smarty_Internal_Template $template)
|
public function end_compile(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
if (!empty($template->compiler->trace_uid)) {
|
if (!empty($template->compiler->trace_uid)) {
|
||||||
$key = $template->compiler->trace_uid;
|
$key = $template->compiler->trace_uid;
|
||||||
} else {
|
} else {
|
||||||
if (isset(self::$ignore_uid[$template->source->uid])) {
|
if (isset($this->ignore_uid[$template->source->uid])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
}
|
}
|
||||||
self::$template_data[self::$index][$key]['compile_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
|
$this->template_data[$this->index][$key]['compile_time'] += microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,10 +130,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*/
|
*/
|
||||||
public static function start_render(Smarty_Internal_Template $template)
|
public function start_render(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['start_time'] = microtime(true);
|
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,10 +141,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*/
|
*/
|
||||||
public static function end_render(Smarty_Internal_Template $template)
|
public function end_render(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['render_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
|
$this->template_data[$this->index][$key]['render_time'] += microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,10 +152,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template cached template
|
* @param \Smarty_Internal_Template $template cached template
|
||||||
*/
|
*/
|
||||||
public static function start_cache(Smarty_Internal_Template $template)
|
public function start_cache(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['start_time'] = microtime(true);
|
$this->template_data[$this->index][$key]['start_time'] = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,10 +163,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template cached template
|
* @param \Smarty_Internal_Template $template cached template
|
||||||
*/
|
*/
|
||||||
public static function end_cache(Smarty_Internal_Template $template)
|
public function end_cache(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$key = self::get_key($template);
|
$key = $this->get_key($template);
|
||||||
self::$template_data[self::$index][$key]['cache_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
|
$this->template_data[$this->index][$key]['cache_time'] += microtime(true) - $this->template_data[$this->index][$key]['start_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +174,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template cached template
|
* @param \Smarty_Internal_Template $template cached template
|
||||||
*/
|
*/
|
||||||
public static function register_template(Smarty_Internal_Template $template)
|
public function register_template(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,12 +193,12 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
* @param Smarty_Internal_Template|Smarty $obj object to debug
|
* @param Smarty_Internal_Template|Smarty $obj object to debug
|
||||||
* @param bool $full
|
* @param bool $full
|
||||||
*/
|
*/
|
||||||
public static function display_debug($obj, $full = false)
|
public function display_debug($obj, $full = false)
|
||||||
{
|
{
|
||||||
if (!$full) {
|
if (!$full) {
|
||||||
self::$offset ++;
|
$this->offset ++;
|
||||||
$savedIndex = self::$index;
|
$savedIndex = $this->index;
|
||||||
self::$index = 9999;
|
$this->index = 9999;
|
||||||
}
|
}
|
||||||
if ($obj instanceof Smarty) {
|
if ($obj instanceof Smarty) {
|
||||||
$smarty = $obj;
|
$smarty = $obj;
|
||||||
@@ -227,7 +231,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
$debObj->compile_id = null;
|
$debObj->compile_id = null;
|
||||||
$debObj->cache_id = null;
|
$debObj->cache_id = null;
|
||||||
// prepare information of assigned variables
|
// prepare information of assigned variables
|
||||||
$ptr = self::get_debug_vars($obj);
|
$ptr = $this->get_debug_vars($obj);
|
||||||
$_assigned_vars = $ptr->tpl_vars;
|
$_assigned_vars = $ptr->tpl_vars;
|
||||||
ksort($_assigned_vars);
|
ksort($_assigned_vars);
|
||||||
$_config_vars = $ptr->config_vars;
|
$_config_vars = $ptr->config_vars;
|
||||||
@@ -239,7 +243,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
||||||
}
|
}
|
||||||
if ($obj instanceof Smarty || $full) {
|
if ($obj instanceof Smarty || $full) {
|
||||||
$_template->assign('template_data', self::$template_data[self::$index]);
|
$_template->assign('template_data', $this->template_data[$this->index]);
|
||||||
} else {
|
} else {
|
||||||
$_template->assign('template_data', null);
|
$_template->assign('template_data', null);
|
||||||
}
|
}
|
||||||
@@ -247,13 +251,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
$_template->assign('config_vars', $_config_vars);
|
$_template->assign('config_vars', $_config_vars);
|
||||||
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
|
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
|
||||||
$_template->assign('display_mode', $debugging == 2 || !$full);
|
$_template->assign('display_mode', $debugging == 2 || !$full);
|
||||||
$_template->assign('offset', self::$offset * 50);
|
$_template->assign('offset', $this->offset * 50);
|
||||||
echo $_template->fetch();
|
echo $_template->fetch();
|
||||||
if (isset($full)) {
|
if (isset($full)) {
|
||||||
self::$index --;
|
$this->index --;
|
||||||
}
|
}
|
||||||
if (!$full) {
|
if (!$full) {
|
||||||
self::$index = $savedIndex;
|
$this->index = $savedIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +268,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @return StdClass
|
* @return StdClass
|
||||||
*/
|
*/
|
||||||
public static function get_debug_vars($obj)
|
public function get_debug_vars($obj)
|
||||||
{
|
{
|
||||||
$config_vars = array();
|
$config_vars = array();
|
||||||
foreach ($obj->config_vars as $key => $var) {
|
foreach ($obj->config_vars as $key => $var) {
|
||||||
@@ -304,7 +308,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($obj->parent)) {
|
if (isset($obj->parent)) {
|
||||||
$parent = self::get_debug_vars($obj->parent);
|
$parent = $this->get_debug_vars($obj->parent);
|
||||||
foreach ($parent->tpl_vars as $name => $pvar) {
|
foreach ($parent->tpl_vars as $name => $pvar) {
|
||||||
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
|
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
|
||||||
$tpl_vars[$name]['scope'] = $pvar['scope'];
|
$tpl_vars[$name]['scope'] = $pvar['scope'];
|
||||||
@@ -351,7 +355,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @return string key into $template_data
|
* @return string key into $template_data
|
||||||
*/
|
*/
|
||||||
private static function get_key(Smarty_Internal_Template $template)
|
private function get_key(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||||
// calculate Uid if not already done
|
// calculate Uid if not already done
|
||||||
@@ -359,18 +363,18 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
$template->source->filepath;
|
$template->source->filepath;
|
||||||
}
|
}
|
||||||
$key = $template->source->uid;
|
$key = $template->source->uid;
|
||||||
if (isset(self::$template_data[self::$index][$key])) {
|
if (isset($this->template_data[$this->index][$key])) {
|
||||||
return $key;
|
return $key;
|
||||||
} else {
|
} else {
|
||||||
if (isset($_is_stringy[$template->source->type])) {
|
if (isset($_is_stringy[$template->source->type])) {
|
||||||
self::$template_data[self::$index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
|
$this->template_data[$this->index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
|
||||||
} else {
|
} else {
|
||||||
self::$template_data[self::$index][$key]['name'] = $template->source->filepath;
|
$this->template_data[$this->index][$key]['name'] = $template->source->filepath;
|
||||||
}
|
}
|
||||||
self::$template_data[self::$index][$key]['compile_time'] = 0;
|
$this->template_data[$this->index][$key]['compile_time'] = 0;
|
||||||
self::$template_data[self::$index][$key]['render_time'] = 0;
|
$this->template_data[$this->index][$key]['render_time'] = 0;
|
||||||
self::$template_data[self::$index][$key]['cache_time'] = 0;
|
$this->template_data[$this->index][$key]['cache_time'] = 0;
|
||||||
self::$template_data[self::$index][$key]['total_time'] = 0;
|
$this->template_data[$this->index][$key]['total_time'] = 0;
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
@@ -381,13 +385,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*/
|
*/
|
||||||
public static function ignore(Smarty_Internal_Template $template)
|
public function ignore(Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
// calculate Uid if not already done
|
// calculate Uid if not already done
|
||||||
if ($template->source->uid == '') {
|
if ($template->source->uid == '') {
|
||||||
$template->source->filepath;
|
$template->source->filepath;
|
||||||
}
|
}
|
||||||
self::$ignore_uid[$template->source->uid] = true;
|
$this->ignore_uid[$template->source->uid] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,7 +399,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template
|
* @param Smarty_Internal_Template $_template
|
||||||
*/
|
*/
|
||||||
public static function debugUrl(Smarty_Internal_Template $_template)
|
public function debugUrl(Smarty_Internal_Template $_template)
|
||||||
{
|
{
|
||||||
if (isset($_SERVER['QUERY_STRING'])) {
|
if (isset($_SERVER['QUERY_STRING'])) {
|
||||||
$_query_string = $_SERVER['QUERY_STRING'];
|
$_query_string = $_SERVER['QUERY_STRING'];
|
||||||
|
@@ -46,11 +46,11 @@ class Smarty_Internal_Method_ConfigLoad
|
|||||||
$confObj->source->scope = $scope;
|
$confObj->source->scope = $scope;
|
||||||
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
|
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
|
||||||
if ($confObj->smarty->debugging) {
|
if ($confObj->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_render($confObj);
|
$confObj->smarty->_debug->start_render($confObj);
|
||||||
}
|
}
|
||||||
$confObj->compiled->render($confObj);
|
$confObj->compiled->render($confObj);
|
||||||
if ($confObj->smarty->debugging) {
|
if ($confObj->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_render($confObj);
|
$confObj->smarty->_debug->end_render($confObj);
|
||||||
}
|
}
|
||||||
if ($data instanceof Smarty_Internal_Template) {
|
if ($data instanceof Smarty_Internal_Template) {
|
||||||
$data->compiled->file_dependency[$confObj->source->uid] = array($confObj->source->filepath,
|
$data->compiled->file_dependency[$confObj->source->uid] = array($confObj->source->filepath,
|
||||||
|
@@ -173,7 +173,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
|
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
|
||||||
{
|
{
|
||||||
return isset($template) ? $this->smarty->fetch($template, $cache_id, $compile_id, $parent, true) : $this->render(true, false, true);
|
$this->fetch($template, $cache_id, $compile_id, $parent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +191,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
{
|
{
|
||||||
$parentIsTpl = $this->parent instanceof Smarty_Internal_Template;
|
$parentIsTpl = $this->parent instanceof Smarty_Internal_Template;
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_template($this, $display);
|
$this->smarty->_debug->start_template($this, $display);
|
||||||
}
|
}
|
||||||
// checks if template exists
|
// checks if template exists
|
||||||
if (!$this->source->exists) {
|
if (!$this->source->exists) {
|
||||||
@@ -235,7 +235,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$_smarty_old_error_level = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
|
$_smarty_old_error_level = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
|
||||||
// check URL debugging control
|
// check URL debugging control
|
||||||
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
|
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
|
||||||
Smarty_Internal_Debug::debugUrl($this);
|
$this->smarty->_debug->debugUrl($this);
|
||||||
}
|
}
|
||||||
// disable caching for evaluated code
|
// disable caching for evaluated code
|
||||||
if ($this->source->recompiled) {
|
if ($this->source->recompiled) {
|
||||||
@@ -253,7 +253,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
if (!($isCacheTpl) || !$this->cached->valid) {
|
if (!($isCacheTpl) || !$this->cached->valid) {
|
||||||
// render template (not loaded and not in cache)
|
// render template (not loaded and not in cache)
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_render($this);
|
$this->smarty->_debug->start_render($this);
|
||||||
}
|
}
|
||||||
if (!$this->source->uncompiled) {
|
if (!$this->source->uncompiled) {
|
||||||
// render compiled code
|
// render compiled code
|
||||||
@@ -268,12 +268,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$this->parent->tpl_function = array_merge($this->parent->tpl_function, $this->tpl_function);
|
$this->parent->tpl_function = array_merge($this->parent->tpl_function, $this->tpl_function);
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_render($this);
|
$this->smarty->_debug->end_render($this);
|
||||||
}
|
}
|
||||||
// write to cache when necessary
|
// write to cache when necessary
|
||||||
if (!$this->source->recompiled && $isCacheTpl) {
|
if (!$this->source->recompiled && $isCacheTpl) {
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_cache($this);
|
$this->smarty->_debug->start_cache($this);
|
||||||
}
|
}
|
||||||
$this->cached->updateCache($this, $content, $no_output_filter);
|
$this->cached->updateCache($this, $content, $no_output_filter);
|
||||||
$compile_check = $this->smarty->compile_check;
|
$compile_check = $this->smarty->compile_check;
|
||||||
@@ -287,7 +287,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$this->smarty->compile_check = $compile_check;
|
$this->smarty->compile_check = $compile_check;
|
||||||
$content = $this->getRenderedTemplateCode($this->cached->unifunc);
|
$content = $this->getRenderedTemplateCode($this->cached->unifunc);
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_cache($this);
|
$this->smarty->_debug->end_cache($this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->parent instanceof Smarty_Internal_Template && !empty($this->compiled->nocache_hash) &&
|
if ($this->parent instanceof Smarty_Internal_Template && !empty($this->compiled->nocache_hash) &&
|
||||||
@@ -301,11 +301,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_cache($this);
|
$this->smarty->_debug->start_cache($this);
|
||||||
}
|
}
|
||||||
$content = $this->cached->render($this);
|
$content = $this->cached->render($this);
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_cache($this);
|
$this->smarty->_debug->end_cache($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->recompiled) && !$no_output_filter &&
|
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->recompiled) && !$no_output_filter &&
|
||||||
@@ -324,11 +324,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
echo $content;
|
echo $content;
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_template($this);
|
$this->smarty->_debug->end_template($this);
|
||||||
}
|
}
|
||||||
// debug output
|
// debug output
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::display_debug($this, true);
|
$this->smarty->_debug->display_debug($this, true);
|
||||||
}
|
}
|
||||||
if ($merge_tpl_vars) {
|
if ($merge_tpl_vars) {
|
||||||
// restore local variables
|
// restore local variables
|
||||||
@@ -343,11 +343,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$this->config_vars = $save_config_vars;
|
$this->config_vars = $save_config_vars;
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_template($this);
|
$this->smarty->_debug->end_template($this);
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging == 2 and $display === false) {
|
if ($this->smarty->debugging == 2 and $display === false) {
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::display_debug($this, true);
|
$this->smarty->_debug->display_debug($this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($parentIsTpl) {
|
if ($parentIsTpl) {
|
||||||
@@ -491,6 +491,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
{
|
{
|
||||||
$_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
|
$_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
|
||||||
// already in template cache?
|
// already in template cache?
|
||||||
|
/* @var Smarty_Internal_Template $tpl */
|
||||||
if (isset($this->smarty->template_objects[$_templateId])) {
|
if (isset($this->smarty->template_objects[$_templateId])) {
|
||||||
// clone cached template object because of possible recursive call
|
// clone cached template object because of possible recursive call
|
||||||
$tpl = clone $this->smarty->template_objects[$_templateId];
|
$tpl = clone $this->smarty->template_objects[$_templateId];
|
||||||
@@ -559,13 +560,13 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$tpl->compiled = $this->compiled;
|
$tpl->compiled = $this->compiled;
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_template($tpl);
|
$this->smarty->_debug->start_template($tpl);
|
||||||
Smarty_Internal_Debug::start_render($tpl);
|
$this->smarty->_debug->start_render($tpl);
|
||||||
}
|
}
|
||||||
$output = $tpl->getRenderedTemplateCode($content_func);
|
$output = $tpl->getRenderedTemplateCode($content_func);
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_template($tpl);
|
$this->smarty->_debug->end_template($tpl);
|
||||||
Smarty_Internal_Debug::end_render($tpl);
|
$this->smarty->_debug->end_render($tpl);
|
||||||
}
|
}
|
||||||
return str_replace($tpl->compiled->nocache_hash, $this->compiled->nocache_hash, $output);
|
return str_replace($tpl->compiled->nocache_hash, $this->compiled->nocache_hash, $output);
|
||||||
}
|
}
|
||||||
@@ -660,7 +661,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
} else {
|
} else {
|
||||||
$this->mustCompile = !$is_valid;
|
$this->mustCompile = !$is_valid;
|
||||||
$resource = $this->compiled;
|
$resource = $this->compiled;
|
||||||
$resource->includes = $properties['includes'];
|
$resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
|
||||||
}
|
}
|
||||||
if ($is_valid) {
|
if ($is_valid) {
|
||||||
$resource->unifunc = $properties['unifunc'];
|
$resource->unifunc = $properties['unifunc'];
|
||||||
|
@@ -399,7 +399,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
while ($this->template->source = array_shift($this->sources)) {
|
while ($this->template->source = array_shift($this->sources)) {
|
||||||
$this->smarty->_current_file = $this->template->source->filepath;
|
$this->smarty->_current_file = $this->template->source->filepath;
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
$no_sources = count($this->sources);
|
$no_sources = count($this->sources);
|
||||||
$this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath,
|
$this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath,
|
||||||
@@ -431,7 +431,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
$_compiled_code = $this->doCompile($_content, true);
|
$_compiled_code = $this->doCompile($_content, true);
|
||||||
}
|
}
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_compile($this->template);
|
$this->smarty->_debug->end_compile($this->template);
|
||||||
}
|
}
|
||||||
// free memory
|
// free memory
|
||||||
$this->parser = null;
|
$this->parser = null;
|
||||||
@@ -1067,7 +1067,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
public function pushTrace($file, $uid, $line, $debug = true)
|
public function pushTrace($file, $uid, $line, $debug = true)
|
||||||
{
|
{
|
||||||
if ($this->smarty->debugging && $debug) {
|
if ($this->smarty->debugging && $debug) {
|
||||||
Smarty_Internal_Debug::end_compile($this->template);
|
$this->smarty->_debug->end_compile($this->template);
|
||||||
}
|
}
|
||||||
array_push($this->trace_stack, array($this->smarty->_current_file, $this->trace_filepath, $this->trace_uid,
|
array_push($this->trace_stack, array($this->smarty->_current_file, $this->trace_filepath, $this->trace_uid,
|
||||||
$this->trace_line_offset));
|
$this->trace_line_offset));
|
||||||
@@ -1075,7 +1075,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
$this->trace_uid = $uid;
|
$this->trace_uid = $uid;
|
||||||
$this->trace_line_offset = $line;
|
$this->trace_line_offset = $line;
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,7 +1085,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
public function popTrace()
|
public function popTrace()
|
||||||
{
|
{
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_compile($this->template);
|
$this->smarty->_debug->end_compile($this->template);
|
||||||
}
|
}
|
||||||
$r = array_pop($this->trace_stack);
|
$r = array_pop($this->trace_stack);
|
||||||
$this->smarty->_current_file = $r[0];
|
$this->smarty->_current_file = $r[0];
|
||||||
@@ -1093,7 +1093,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
$this->trace_uid = $r[2];
|
$this->trace_uid = $r[2];
|
||||||
$this->trace_line_offset = $r[3];
|
$this->trace_line_offset = $r[3];
|
||||||
if ($this->smarty->debugging) {
|
if ($this->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -142,7 +142,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
|||||||
if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
|
if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
|
||||||
// load cache file for the following checks
|
// load cache file for the following checks
|
||||||
if ($_template->smarty->debugging) {
|
if ($_template->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::start_cache($_template);
|
$_template->smarty->_debug->start_cache($_template);
|
||||||
}
|
}
|
||||||
if ($this->handler->process($_template, $this) === false) {
|
if ($this->handler->process($_template, $this) === false) {
|
||||||
$this->valid = false;
|
$this->valid = false;
|
||||||
@@ -150,7 +150,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
|||||||
$this->processed = true;
|
$this->processed = true;
|
||||||
}
|
}
|
||||||
if ($_template->smarty->debugging) {
|
if ($_template->smarty->debugging) {
|
||||||
Smarty_Internal_Debug::end_cache($_template);
|
$_template->smarty->_debug->end_cache($_template);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->is_locked = true;
|
$this->is_locked = true;
|
||||||
|
Reference in New Issue
Block a user