summaryrefslogtreecommitdiff
path: root/lib/smarty3/sysplugins/smarty_internal_debug.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_internal_debug.php')
-rw-r--r--lib/smarty3/sysplugins/smarty_internal_debug.php73
1 files changed, 34 insertions, 39 deletions
diff --git a/lib/smarty3/sysplugins/smarty_internal_debug.php b/lib/smarty3/sysplugins/smarty_internal_debug.php
index d5cd60d..24b233e 100644
--- a/lib/smarty3/sysplugins/smarty_internal_debug.php
+++ b/lib/smarty3/sysplugins/smarty_internal_debug.php
@@ -52,9 +52,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*/
public function start_template(Smarty_Internal_Template $template, $mode = null)
{
- if (isset($mode)) {
- $this->index ++;
- $this->offset ++;
+ if (isset($mode) && !$template->_isSubTpl()) {
+ $this->index++;
+ $this->offset++;
$this->template_data[ $this->index ] = null;
}
$key = $this->get_key($template);
@@ -117,7 +117,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
if (isset($this->ignore_uid[ $template->source->uid ])) {
return;
}
-
$key = $this->get_key($template);
}
$this->template_data[ $this->index ][ $key ][ 'compile_time' ] +=
@@ -193,42 +192,43 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param Smarty_Internal_Template|Smarty $obj object to debug
* @param bool $full
+ *
+ * @throws \Exception
+ * @throws \SmartyException
*/
public function display_debug($obj, $full = false)
{
if (!$full) {
- $this->offset ++;
+ $this->offset++;
$savedIndex = $this->index;
$this->index = 9999;
}
- if ($obj->_objType == 1) {
- $smarty = $obj;
- } else {
- $smarty = $obj->smarty;
- }
+ $smarty = $obj->_getSmartyObj();
// create fresh instance of smarty for displaying the debug console
// to avoid problems if the application did overload the Smarty class
$debObj = new Smarty();
// copy the working dirs from application
$debObj->setCompileDir($smarty->getCompileDir());
// init properties by hand as user may have edited the original Smarty class
- $debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . '/../plugins' : $smarty->getPluginsDir());
+ $debObj->setPluginsDir(is_dir(dirname(__FILE__) . '/../plugins') ? dirname(__FILE__) .
+ '/../plugins' : $smarty->getPluginsDir());
$debObj->force_compile = false;
- $debObj->compile_check = true;
+ $debObj->compile_check = Smarty::COMPILECHECK_ON;
$debObj->left_delimiter = '{';
$debObj->right_delimiter = '}';
$debObj->security_policy = null;
$debObj->debugging = false;
$debObj->debugging_ctrl = 'NONE';
$debObj->error_reporting = E_ALL & ~E_NOTICE;
- $debObj->debug_tpl = isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
+ $debObj->debug_tpl =
+ isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . dirname(__FILE__) . '/../debug.tpl';
$debObj->registered_plugins = array();
$debObj->registered_resources = array();
$debObj->registered_filters = array();
$debObj->autoload_filters = array();
$debObj->default_modifiers = array();
$debObj->escape_html = true;
- $debObj->caching = false;
+ $debObj->caching = Smarty::CACHING_OFF;
$debObj->compile_id = null;
$debObj->cache_id = null;
// prepare information of assigned variables
@@ -238,12 +238,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$_config_vars = $ptr->config_vars;
ksort($_config_vars);
$debugging = $smarty->debugging;
-
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
- if ($obj->_objType == 2) {
+ if ($obj->_isTplObj()) {
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
}
- if ($obj->_objType == 1 || $full) {
+ if ($obj->_objType === 1 || $full) {
$_template->assign('template_data', $this->template_data[ $this->index ]);
} else {
$_template->assign('template_data', null);
@@ -251,11 +250,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$_template->assign('assigned_vars', $_assigned_vars);
$_template->assign('config_vars', $_config_vars);
$_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', $this->offset * 50);
echo $_template->fetch();
if (isset($full)) {
- $this->index --;
+ $this->index--;
}
if (!$full) {
$this->index = $savedIndex;
@@ -265,7 +264,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
/**
* Recursively gets variables from all template/data scopes
*
- * @param Smarty_Internal_Template|Smarty_Data $obj object to debug
+ * @param Smarty_Internal_Template|Smarty_Data $obj object to debug
*
* @return StdClass
*/
@@ -274,9 +273,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$config_vars = array();
foreach ($obj->config_vars as $key => $var) {
$config_vars[ $key ][ 'value' ] = $var;
- if ($obj->_objType == 2) {
+ if ($obj->_isTplObj()) {
$config_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj->_objType == 4) {
+ } elseif ($obj->_isDataObj()) {
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
} else {
$config_vars[ $key ][ 'scope' ] = 'Smarty object';
@@ -285,29 +284,28 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$tpl_vars = array();
foreach ($obj->tpl_vars as $key => $var) {
foreach ($var as $varkey => $varvalue) {
- if ($varkey == 'value') {
+ if ($varkey === 'value') {
$tpl_vars[ $key ][ $varkey ] = $varvalue;
} else {
- if ($varkey == 'nocache') {
- if ($varvalue == true) {
+ if ($varkey === 'nocache') {
+ if ($varvalue === true) {
$tpl_vars[ $key ][ $varkey ] = $varvalue;
}
} else {
- if ($varkey != 'scope' || $varvalue !== 0) {
+ if ($varkey !== 'scope' || $varvalue !== 0) {
$tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue;
}
}
}
}
- if ($obj->_objType == 2) {
+ if ($obj->_isTplObj()) {
$tpl_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj->_objType == 4) {
+ } elseif ($obj->_isDataObj()) {
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
} else {
$tpl_vars[ $key ][ 'scope' ] = 'Smarty object';
}
}
-
if (isset($obj->parent)) {
$parent = $this->get_debug_vars($obj->parent);
foreach ($parent->tpl_vars as $name => $pvar) {
@@ -316,7 +314,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
}
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
-
foreach ($parent->config_vars as $name => $pvar) {
if (isset($config_vars[ $name ]) && $config_vars[ $name ][ 'value' ] === $pvar[ 'value' ]) {
$config_vars[ $name ][ 'scope' ] = $pvar[ 'scope' ];
@@ -327,15 +324,15 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
foreach (Smarty::$global_tpl_vars as $key => $var) {
if (!array_key_exists($key, $tpl_vars)) {
foreach ($var as $varkey => $varvalue) {
- if ($varkey == 'value') {
+ if ($varkey === 'value') {
$tpl_vars[ $key ][ $varkey ] = $varvalue;
} else {
- if ($varkey == 'nocache') {
- if ($varvalue == true) {
+ if ($varkey === 'nocache') {
+ if ($varvalue === true) {
$tpl_vars[ $key ][ $varkey ] = $varvalue;
}
} else {
- if ($varkey != 'scope' || $varvalue !== 0) {
+ if ($varkey !== 'scope' || $varvalue !== 0) {
$tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue;
}
}
@@ -345,8 +342,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
}
}
-
- return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
+ return (object)array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
}
/**
@@ -360,7 +356,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
{
static $_is_stringy = array('string' => true, 'eval' => true);
// calculate Uid if not already done
- if ($template->source->uid == '') {
+ if ($template->source->uid === '') {
$template->source->filepath;
}
$key = $template->source->uid;
@@ -377,7 +373,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$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;
}
}
@@ -390,7 +385,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
public function ignore(Smarty_Internal_Template $template)
{
// calculate Uid if not already done
- if ($template->source->uid == '') {
+ if ($template->source->uid === '') {
$template->source->filepath;
}
$this->ignore_uid[ $template->source->uid ] = true;