From 9e42d23f88f8c9dc7856174350c8ae288111e5c1 Mon Sep 17 00:00:00 2001 From: mohrt Date: Wed, 7 May 2003 18:54:41 +0000 Subject: [PATCH] abstracted display_debug_console and assign_smarty_interface to plugin dir as a test --- libs/Smarty.class.php | 46 ++++--------------- libs/Smarty_Compiler.class.php | 2 +- libs/plugins/core.assign_smarty_interface.php | 43 +++++++++++++++++ ...ole.php => core.display_debug_console.php} | 4 +- 4 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 libs/plugins/core.assign_smarty_interface.php rename libs/plugins/{function.display_debug_console.php => core.display_debug_console.php} (93%) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index cc142dd6..490d52ac 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1136,7 +1136,7 @@ class Smarty // capture time for debugging info $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) { $_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 $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); return; @@ -1219,45 +1219,15 @@ class Smarty } } - /** - * assign $smarty interface variable - */ - function _assign_smarty_interface() - { - 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; - - } - - - /** - * display debug console - * @return string debug.tpl template output - * @uses $debug_tpl debug template, used to display debugging output + * execute core function + * @return mixed value of function return */ - function _display_debug_console() + function _execute_core_function($funcname, $params=null) { - require_once($this->_get_plugin_filepath('function', 'display_debug_console')); - return smarty_function_display_debug_console(null, $this); + require_once($this->_get_plugin_filepath('core', $funcname)); + $_core_funcname = 'smarty_core_' . $funcname; + return $_core_funcname($params, $this); } /** diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 0fbfda8a..2d174ebd 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -352,7 +352,7 @@ class Smarty_Compiler extends Smarty { } if ($this->_init_smarty_vars) { - $template_header .= "_assign_smarty_interface(); ?>\n"; + $template_header .= "_execute_core_function('assign_smarty_interface'); ?>\n"; $this->_init_smarty_vars = false; } diff --git a/libs/plugins/core.assign_smarty_interface.php b/libs/plugins/core.assign_smarty_interface.php new file mode 100644 index 00000000..49123316 --- /dev/null +++ b/libs/plugins/core.assign_smarty_interface.php @@ -0,0 +1,43 @@ + + * Name: assign_smarty_interface
+ * 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: */ + +?> diff --git a/libs/plugins/function.display_debug_console.php b/libs/plugins/core.display_debug_console.php similarity index 93% rename from libs/plugins/function.display_debug_console.php rename to libs/plugins/core.display_debug_console.php index db94953d..3686bd44 100644 --- a/libs/plugins/function.display_debug_console.php +++ b/libs/plugins/core.display_debug_console.php @@ -8,13 +8,13 @@ /* * Smarty debug_console function plugin * - * Type: function
+ * Type: core
* Name: display_debug_console
* Purpose: display the javascript debug console window * @param array Format: null * @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 // changed between separate applications.