mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +02:00
- improvement of {debug} tag output
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== SVN trunk =====
|
===== SVN trunk =====
|
||||||
|
01/12/2010
|
||||||
|
- improvement of {debug} tag output
|
||||||
|
|
||||||
27/11/2010
|
27/11/2010
|
||||||
-change run output filter before cache file is written. (same as in Smarty2)
|
-change run output filter before cache file is written. (same as in Smarty2)
|
||||||
|
|
||||||
|
@@ -86,8 +86,9 @@ td {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>Smarty Debug Console - Total Time {$execution_time|string_format:"%.5f"}</h1>
|
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||||
|
|
||||||
|
{if !empty($template_data)}
|
||||||
<h2>included templates & config files (load time in seconds)</h2>
|
<h2>included templates & config files (load time in seconds)</h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -99,6 +100,7 @@ td {
|
|||||||
<br>
|
<br>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<h2>assigned template variables</h2>
|
<h2>assigned template variables</h2>
|
||||||
|
|
||||||
@@ -124,13 +126,14 @@ td {
|
|||||||
</html>
|
</html>
|
||||||
{/capture}
|
{/capture}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{literal} if ( self.name == '' ) {
|
{$id = $template_name|default:''|md5}
|
||||||
var title = 'Console';
|
if ( self.name == '' ) {
|
||||||
|
var title = 'Console{$id}';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var title = 'Console_' + self.name;
|
var title = 'Console_{$id}' + self.name;
|
||||||
}{/literal}
|
}
|
||||||
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
|
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
|
||||||
_smarty_console.document.write("{$debug_output|escape:'javascript'}");
|
_smarty_console.document.write("{$debug_output|escape:'javascript'}");
|
||||||
_smarty_console.document.close();
|
_smarty_console.document.close();
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Debug
|
* Smarty Internal Plugin Debug
|
||||||
*
|
*
|
||||||
* Class to collect data for the Smarty Debugging Consol
|
* Class to collect data for the Smarty Debugging Consol
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Debug
|
* @subpackage Debug
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Debug Class
|
* Smarty Internal Plugin Debug Class
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||||
// template data
|
// template data
|
||||||
static $template_data = array();
|
static $template_data = array();
|
||||||
@@ -76,10 +76,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
|||||||
public static function display_debug($obj)
|
public static function display_debug($obj)
|
||||||
{
|
{
|
||||||
// prepare information of assigned variables
|
// prepare information of assigned variables
|
||||||
$ptr = $obj;
|
$ptr = self::get_debug_vars($obj);
|
||||||
while (isset($ptr->parent)) {
|
|
||||||
$ptr = $ptr->parent;
|
|
||||||
}
|
|
||||||
if ($obj instanceof Smarty) {
|
if ($obj instanceof Smarty) {
|
||||||
$smarty = $obj;
|
$smarty = $obj;
|
||||||
} else {
|
} else {
|
||||||
@@ -99,7 +96,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
|||||||
$_template->disableSecurity();
|
$_template->disableSecurity();
|
||||||
$_template->cache_id = null;
|
$_template->cache_id = null;
|
||||||
$_template->compile_id = null;
|
$_template->compile_id = null;
|
||||||
|
if ($obj instanceof Smarty_Internal_Template) {
|
||||||
|
$_template->assign('template_name',$obj->resource_type.':'.$obj->resource_name);
|
||||||
|
}
|
||||||
|
if ($obj instanceof Smarty) {
|
||||||
$_template->assign('template_data', self::$template_data);
|
$_template->assign('template_data', self::$template_data);
|
||||||
|
} else {
|
||||||
|
$_template->assign('template_data', null);
|
||||||
|
}
|
||||||
$_template->assign('assigned_vars', $_assigned_vars);
|
$_template->assign('assigned_vars', $_assigned_vars);
|
||||||
$_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);
|
||||||
@@ -107,6 +111,43 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
|||||||
$smarty->left_delimiter = $ldelim;
|
$smarty->left_delimiter = $ldelim;
|
||||||
$smarty->right_delimiter = $rdelim;
|
$smarty->right_delimiter = $rdelim;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Recursively gets variables from all template/data scopes
|
||||||
|
*/
|
||||||
|
public static function get_debug_vars($obj, $is_parent = false)
|
||||||
|
{
|
||||||
|
$config_vars = $obj->config_vars;
|
||||||
|
$tpl_vars = array();
|
||||||
|
foreach ($obj->tpl_vars as $key => $var) {
|
||||||
|
$tpl_vars[$key] = clone $var;
|
||||||
|
if (true) {
|
||||||
|
if ($obj instanceof Smarty_Internal_Template) {
|
||||||
|
$tpl_vars[$key]->scope = $obj->resource_type.':'.$obj->resource_name;
|
||||||
|
} elseif ($obj instanceof Smarty_Data) {
|
||||||
|
$tpl_vars[$key]->scope = 'Data object';
|
||||||
|
} else {
|
||||||
|
$tpl_vars[$key]->scope = 'Smarty root';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$tpl_vars[$key]->scope = 'local';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($obj->parent)) {
|
||||||
|
$parent = self::get_debug_vars($obj->parent, true);
|
||||||
|
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
|
||||||
|
$config_vars = array_merge($parent->config_vars, $config_vars);
|
||||||
|
} else {
|
||||||
|
foreach (Smarty::$global_tpl_vars as $name => $var) {
|
||||||
|
if (!array_key_exists($name, $tpl_vars)) {
|
||||||
|
$clone = clone $var;
|
||||||
|
$clone->scope = 'Global';
|
||||||
|
$tpl_vars[$name] = $clone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_key
|
* get_key
|
||||||
|
Reference in New Issue
Block a user