mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
abstracted display_debug_console and assign_smarty_interface to plugin dir as a test
This commit is contained in:
@@ -1136,7 +1136,7 @@ class Smarty
|
|||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = $this->_get_microtime() - $_debug_start_time;
|
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = $this->_get_microtime() - $_debug_start_time;
|
||||||
|
|
||||||
$_smarty_results .= $this->_display_debug_console();
|
$_smarty_results .= $this->_execute_core_function('display_debug_console');
|
||||||
}
|
}
|
||||||
if ($this->cache_modified_check) {
|
if ($this->cache_modified_check) {
|
||||||
$_last_modified_date = substr($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 0, strpos($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
|
$_last_modified_date = substr($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 0, strpos($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
|
||||||
@@ -1209,7 +1209,7 @@ class Smarty
|
|||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $_debug_start_time);
|
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $_debug_start_time);
|
||||||
|
|
||||||
echo $this->_display_debug_console();
|
echo $this->_execute_core_function('display_debug_console');
|
||||||
}
|
}
|
||||||
error_reporting($_smarty_old_error_level);
|
error_reporting($_smarty_old_error_level);
|
||||||
return;
|
return;
|
||||||
@@ -1219,45 +1219,15 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assign $smarty interface variable
|
* execute core function
|
||||||
|
* @return mixed value of function return
|
||||||
*/
|
*/
|
||||||
function _assign_smarty_interface()
|
function _execute_core_function($funcname, $params=null)
|
||||||
{
|
{
|
||||||
if (isset($this->_smarty_vars) && isset($this->_smarty_vars['request'])) {
|
require_once($this->_get_plugin_filepath('core', $funcname));
|
||||||
return;
|
$_core_funcname = 'smarty_core_' . $funcname;
|
||||||
}
|
return $_core_funcname($params, $this);
|
||||||
|
|
||||||
$_globals_map = array('g' => 'HTTP_GET_VARS',
|
|
||||||
'p' => 'HTTP_POST_VARS',
|
|
||||||
'c' => 'HTTP_COOKIE_VARS',
|
|
||||||
's' => 'HTTP_SERVER_VARS',
|
|
||||||
'e' => 'HTTP_ENV_VARS');
|
|
||||||
|
|
||||||
$_smarty_vars_request = array();
|
|
||||||
|
|
||||||
foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c) {
|
|
||||||
if (isset($_globals_map[$c])) {
|
|
||||||
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$c]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
|
|
||||||
|
|
||||||
$this->_smarty_vars['request'] = $_smarty_vars_request;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* display debug console
|
|
||||||
* @return string debug.tpl template output
|
|
||||||
* @uses $debug_tpl debug template, used to display debugging output
|
|
||||||
*/
|
|
||||||
function _display_debug_console()
|
|
||||||
{
|
|
||||||
require_once($this->_get_plugin_filepath('function', 'display_debug_console'));
|
|
||||||
return smarty_function_display_debug_console(null, $this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -352,7 +352,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_init_smarty_vars) {
|
if ($this->_init_smarty_vars) {
|
||||||
$template_header .= "<?php \$this->_assign_smarty_interface(); ?>\n";
|
$template_header .= "<?php \$this->_execute_core_function('assign_smarty_interface'); ?>\n";
|
||||||
$this->_init_smarty_vars = false;
|
$this->_init_smarty_vars = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
libs/plugins/core.assign_smarty_interface.php
Normal file
43
libs/plugins/core.assign_smarty_interface.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage plugins
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Smarty assign_smarty_interface core plugin
|
||||||
|
*
|
||||||
|
* Type: core<br>
|
||||||
|
* Name: assign_smarty_interface<br>
|
||||||
|
* Purpose: assign the $smarty interface variable
|
||||||
|
* @param array Format: null
|
||||||
|
* @param Smarty
|
||||||
|
*/
|
||||||
|
function smarty_core_assign_smarty_interface($params, &$this)
|
||||||
|
{
|
||||||
|
if (isset($this->_smarty_vars) && isset($this->_smarty_vars['request'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$_globals_map = array('g' => 'HTTP_GET_VARS',
|
||||||
|
'p' => 'HTTP_POST_VARS',
|
||||||
|
'c' => 'HTTP_COOKIE_VARS',
|
||||||
|
's' => 'HTTP_SERVER_VARS',
|
||||||
|
'e' => 'HTTP_ENV_VARS');
|
||||||
|
|
||||||
|
$_smarty_vars_request = array();
|
||||||
|
|
||||||
|
foreach (preg_split('!!', strtolower($this->request_vars_order)) as $_c) {
|
||||||
|
if (isset($_globals_map[$_c])) {
|
||||||
|
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
|
||||||
|
|
||||||
|
$this->_smarty_vars['request'] = $_smarty_vars_request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim: set expandtab: */
|
||||||
|
|
||||||
|
?>
|
@@ -8,13 +8,13 @@
|
|||||||
/*
|
/*
|
||||||
* Smarty debug_console function plugin
|
* Smarty debug_console function plugin
|
||||||
*
|
*
|
||||||
* Type: function<br>
|
* Type: core<br>
|
||||||
* Name: display_debug_console<br>
|
* Name: display_debug_console<br>
|
||||||
* Purpose: display the javascript debug console window
|
* Purpose: display the javascript debug console window
|
||||||
* @param array Format: null
|
* @param array Format: null
|
||||||
* @param Smarty
|
* @param Smarty
|
||||||
*/
|
*/
|
||||||
function smarty_function_display_debug_console($params, &$this)
|
function smarty_core_display_debug_console($params, &$this)
|
||||||
{
|
{
|
||||||
// we must force compile the debug template in case the environment
|
// we must force compile the debug template in case the environment
|
||||||
// changed between separate applications.
|
// changed between separate applications.
|
Reference in New Issue
Block a user