Ok, so I changed it a bit for easier integration:
This class extends the Smarty class and adds a new function to it
--------------------------------------------------------
<?php
// load Smarty library
require ( 'includes/Smarty/Smarty.class.php' );
class Template extends Smarty{
function Template(){
$this->Smarty();
$this->template_dir = './templates';
$this->compile_dir = './templates/compiled';
$this->config_dir = './templates/config';
$this->cache_dir = './cache';
//$this->caching = false;
}
function smartyDebugFirePHP(){
//get required debug variables
$assigned_vars = $this->_tpl_vars;
ksort($assigned_vars);
$config_vars = array();
if (@is_array($this->_config[0])) {
$config_vars = $this->_config[0];
ksort($config_vars);
}
$firephp = FirePHP::getInstance(true);
$firephp->group('Smarty Debug Output');
/*Log template files*/
$firephp->group('included templates & config files (load time in seconds)');
foreach($this->_smarty_debug_info as $tml){
$msg = str_repeat('--', $tml['depth']);
$msg .= ($tml['depth'] != 0) ? '>' : '';
$msg .= $tml['filename'] . ' (' . substr($tml['exec_time'], 0, 7) . 's)';
$firephp->log($msg);
}
$firephp->groupEnd();//end group 'included templates &...'
/*Log assigned template variables*/
$firephp->group('assigned template variables');
foreach($assigned_vars as $key => $value){
$firephp->log($value, '{$' . $key . '}');
}
$firephp->groupEnd();//end group 'assigned template variables'
/*Log assigned config file variables (outer template scope)*/
$firephp->group('assigned config file variables (outer template scope)');
/*Check if there is something in the config*/
if(!empty($config_vars)){
foreach($config_vars as $key => $value){
$firephp->log($value, '{#' . $key . '#}');
}
}else{
$firephp->log("No configuration values available");
}
$firephp->groupEnd();//end group 'assigned config file variables (outer template scope)'
$firephp->groupEnd();//end group 'Smarty Debug Output'
}
}
--------------------------------------------------------
Use this class instead of Smarty to consume your templates like below:
--------------------------------------------------------
<?php
$tpl = new Template();
/*Do your Smarty things below*/
/*...*/
/*At the end of your application, call the log function*/
$tpl->smartyDebugFirePHP();
--------------------------------------------------------
Another thing you could do is replace the Smarty debugger (internals/core.display_debug_console.php)
This way, you would simply replace the debugger window of Smarty with the FirePHP output.
I would not recommend this because you are modifying core code of Smarty, and upgrading can remove your code.
If you want to do this, replace the content of the file with the code below:
--------------------------------------------------------
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty debug_console function plugin
*
* Type: core<br>
* Name: display_debug_console<br>
* Purpose: display the javascript debug console window
* @param array Format: null
* @param Smarty
*/
function smarty_core_display_debug_console($params, &$smarty)
{
//get required debug variables
$assigned_vars = $smarty->_tpl_vars;
ksort($assigned_vars);
$config_vars = array();
if(@is_array($smarty->_config[0])){
$config_vars = $smarty->_config[0];
ksort($config_vars);
}
$firephp = FirePHP::getInstance(true);
$firephp->group('Smarty Debug Output');
/*Log template files*/
$firephp->group('included templates & config files (load time in seconds)');
foreach( $smarty->_smarty_debug_info as $tml ){
$msg = str_repeat('--', $tml['depth']);
$msg .= ( $tml['depth'] != 0 ) ? '>' : '';
$msg .= $tml['filename'] . ' (' . substr($tml['exec_time'], 0, 7) . 's)';
$firephp->log($msg);
}
$firephp->groupEnd(); //end group 'included templates &...'
/*Log assigned template variables*/
$firephp->group('assigned template variables');
foreach( $assigned_vars as $key => $value ){
$firephp->log($value, '{$' . $key . '}');
}
$firephp->groupEnd(); //end group 'assigned template variables'
/*Log assigned config file variables (outer template scope)*/
$firephp->group('assigned config file variables (outer template scope)');
/*Check if there is something in the config*/
if(!empty($config_vars)){
foreach( $config_vars as $key => $value ){
$firephp->log($value, '{#' . $key . '#}');
}
} else{
$firephp->log("No configuration values available");
}
$firephp->groupEnd(); //end group 'assigned config file variables (outer template scope)'
$firephp->groupEnd(); //end group 'Smarty Debug Output'
}
/* vim: set expandtab: */
?>
--------------------------------------------------------
(don't forget to enable debugging when using this method!)