aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_debug.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_debug.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_debug.php148
1 files changed, 77 insertions, 71 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_debug.php b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
index 89eb9f3ab..e330a35c1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_debug.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
@@ -21,44 +21,44 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @var array
*/
- public static $template_data = array();
+ public $template_data = array();
/**
* List of uid's which shall be ignored
*
* @var array
*/
- public static $ignore_uid = array();
+ public $ignore_uid = array();
/**
* Index of display() and fetch() calls
*
* @var int
*/
- public static $index = 0;
+ public $index = 0;
/**
* Counter for window offset
*
* @var int
*/
- public static $offset = 0;
+ public $offset = 0;
/**
* Start logging template
*
* @param \Smarty_Internal_Template $template template
- * @param null $mode true: display false: fetch null: subtemolate
+ * @param null $mode true: display false: fetch null: subtemplate
*/
- public static function start_template(Smarty_Internal_Template $template, $mode = null)
+ public function start_template(Smarty_Internal_Template $template, $mode = null)
{
if (isset($mode)) {
- self::$index ++;
- self::$offset ++;
- self::$template_data[self::$index] = null;
+ $this->index ++;
+ $this->offset ++;
+ $this->template_data[$this->index] = null;
}
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['start_template_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
}
/**
@@ -66,11 +66,12 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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);
- self::$template_data[self::$index][$key]['total_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_template_time'];
- self::$template_data[self::$index][$key]['properties'] = $template->properties;
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['total_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_template_time'];
+ //$this->template_data[$this->index][$key]['properties'] = $template->properties;
}
/**
@@ -78,28 +79,29 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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);
if (!empty($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])) {
- 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 {
- 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;
- self::$template_data[self::$index][$key]['render_time'] = 0;
- self::$template_data[self::$index][$key]['cache_time'] = 0;
+ $this->template_data[$this->index][$key]['compile_time'] = 0;
+ $this->template_data[$this->index][$key]['render_time'] = 0;
+ $this->template_data[$this->index][$key]['cache_time'] = 0;
}
} else {
- if (isset(self::$ignore_uid[$template->source->uid])) {
+ if (isset($this->ignore_uid[$template->source->uid])) {
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 +109,19 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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)) {
$key = $template->compiler->trace_uid;
} else {
- if (isset(self::$ignore_uid[$template->source->uid])) {
+ if (isset($this->ignore_uid[$template->source->uid])) {
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 +129,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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);
- self::$template_data[self::$index][$key]['start_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_time'] = microtime(true);
}
/**
@@ -137,10 +140,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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);
- self::$template_data[self::$index][$key]['render_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
+ $key = $this->get_key($template);
+ $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
*/
- public static function start_cache(Smarty_Internal_Template $template)
+ public function start_cache(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['start_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_time'] = microtime(true);
}
/**
@@ -159,10 +163,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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);
- self::$template_data[self::$index][$key]['cache_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['cache_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_time'];
}
/**
@@ -170,7 +175,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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,14 +194,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
* @param Smarty_Internal_Template|Smarty $obj object to debug
* @param bool $full
*/
- public static function display_debug($obj, $full = false)
+ public function display_debug($obj, $full = false)
{
if (!$full) {
- self::$offset ++;
- $savedIndex = self::$index;
- self::$index = 9999;
+ $this->offset ++;
+ $savedIndex = $this->index;
+ $this->index = 9999;
}
- if ($obj instanceof Smarty) {
+ if ($obj->_objType == 1) {
$smarty = $obj;
} else {
$smarty = $obj->smarty;
@@ -227,7 +232,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debObj->compile_id = null;
$debObj->cache_id = null;
// prepare information of assigned variables
- $ptr = self::get_debug_vars($obj);
+ $ptr = $this->get_debug_vars($obj);
$_assigned_vars = $ptr->tpl_vars;
ksort($_assigned_vars);
$_config_vars = $ptr->config_vars;
@@ -235,11 +240,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debugging = $smarty->debugging;
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
}
- if ($obj instanceof Smarty || $full) {
- $_template->assign('template_data', self::$template_data[self::$index]);
+ if ($obj->_objType == 1 || $full) {
+ $_template->assign('template_data', $this->template_data[$this->index]);
} else {
$_template->assign('template_data', null);
}
@@ -247,13 +252,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$_template->assign('config_vars', $_config_vars);
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
$_template->assign('display_mode', $debugging == 2 || !$full);
- $_template->assign('offset', self::$offset * 50);
+ $_template->assign('offset', $this->offset * 50);
echo $_template->fetch();
if (isset($full)) {
- self::$index --;
+ $this->index --;
}
if (!$full) {
- self::$index = $savedIndex;
+ $this->index = $savedIndex;
}
}
@@ -264,14 +269,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @return StdClass
*/
- public static function get_debug_vars($obj)
+ public function get_debug_vars($obj)
{
$config_vars = array();
foreach ($obj->config_vars as $key => $var) {
$config_vars[$key]['value'] = $var;
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj instanceof Smarty_Data) {
+ } elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$config_vars[$key]['scope'] = 'Smarty object';
@@ -294,9 +299,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
}
}
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj instanceof Smarty_Data) {
+ } elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$tpl_vars[$key]['scope'] = 'Smarty object';
@@ -304,7 +309,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
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) {
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
$tpl_vars[$name]['scope'] = $pvar['scope'];
@@ -351,7 +356,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_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);
// calculate Uid if not already done
@@ -359,18 +364,19 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$template->source->filepath;
}
$key = $template->source->uid;
- if (isset(self::$template_data[self::$index][$key])) {
+ if (isset($this->template_data[$this->index][$key])) {
return $key;
} else {
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 {
- 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;
- self::$template_data[self::$index][$key]['render_time'] = 0;
- self::$template_data[self::$index][$key]['cache_time'] = 0;
- self::$template_data[self::$index][$key]['total_time'] = 0;
+ $this->template_data[$this->index][$key]['compile_time'] = 0;
+ $this->template_data[$this->index][$key]['render_time'] = 0;
+ $this->template_data[$this->index][$key]['cache_time'] = 0;
+ $this->template_data[$this->index][$key]['total_time'] = 0;
return $key;
}
@@ -381,13 +387,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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
if ($template->source->uid == '') {
$template->source->filepath;
}
- self::$ignore_uid[$template->source->uid] = true;
+ $this->ignore_uid[$template->source->uid] = true;
}
/**
@@ -395,7 +401,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @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'])) {
$_query_string = $_SERVER['QUERY_STRING'];