From ffe52be500d50215be10de521e6e454a5678379d Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 20 Feb 2002 22:24:32 +0000 Subject: [PATCH] Fixup some naming. --- Smarty.class.php | 33 +++++++++++---------- libs/Smarty.class.php | 33 +++++++++++---------- libs/plugins/function.assign.php | 13 ++++---- libs/plugins/function.assign_debug_info.php | 20 ++++++------- libs/plugins/function.counter.php | 8 ++--- libs/plugins/function.fetch.php | 16 +++++----- libs/plugins/function.math.php | 32 ++++++++++---------- libs/plugins/function.popup.php | 7 ++--- libs/plugins/function.popup_init.php | 5 ++-- libs/plugins/modifier.escape.php | 10 ++++--- plugins/function.assign.php | 13 ++++---- plugins/function.assign_debug_info.php | 20 ++++++------- plugins/function.counter.php | 8 ++--- plugins/function.fetch.php | 16 +++++----- plugins/function.math.php | 32 ++++++++++---------- plugins/function.popup.php | 7 ++--- plugins/function.popup_init.php | 5 ++-- plugins/modifier.escape.php | 10 ++++--- 18 files changed, 142 insertions(+), 146 deletions(-) diff --git a/Smarty.class.php b/Smarty.class.php index 18041a88..4bc58a9f 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -463,6 +463,16 @@ class Smarty } +/*======================================================================*\ + Function: trigger_error + Purpose: trigger Smarty error +\*======================================================================*/ + function trigger_error($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Smarty error: $error_msg", $error_type); + } + + /*======================================================================*\ Function: display() Purpose: executes & displays the template results @@ -751,7 +761,7 @@ function _generate_debug_output() { if (method_exists($this, '_syntax_error')) { $error_func = '_syntax_error'; } else { - $error_func = '_trigger_error_msg'; + $error_func = 'trigger_error'; } if ($readable) { @@ -916,7 +926,7 @@ function _generate_debug_output() { // see if we can get a template with the default template handler if (!empty($this->default_template_handler_func)) { if (!function_exists($this->default_template_handler_func)) { - $this->_trigger_error_msg("default template handler function \"$this->default_template_handler_func\" doesn't exist."); + $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); $_return = false; } $funcname = $this->default_template_handler_func; @@ -925,9 +935,9 @@ function _generate_debug_output() { } if (!$_return) { - $this->_trigger_error_msg("unable to read template resource: \"$tpl_path\""); + $this->trigger_error("unable to read template resource: \"$tpl_path\""); } else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) { - $this->_trigger_error_msg("(secure mode) accessing \"$tpl_path\" is not allowed"); + $this->trigger_error("(secure mode) accessing \"$tpl_path\" is not allowed"); $template_source = null; $template_timestamp = null; return false; @@ -966,7 +976,7 @@ function _generate_debug_output() { if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) return true; else { - $this->_trigger_error_msg($smarty_compiler->_error_msg); + $this->trigger_error($smarty_compiler->_error_msg); return false; } } @@ -1265,7 +1275,7 @@ function _run_insert_handler($args) $this->_create_dir_structure(dirname($filename)); if (!($fd = @fopen($filename, 'w'))) { - $this->_trigger_error_msg("problem writing '$filename.'"); + $this->trigger_error("problem writing '$filename.'"); return false; } @@ -1359,7 +1369,7 @@ function _run_insert_handler($args) foreach ($dir_parts as $dir_part) { $new_dir .= $dir_part; if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) { - $this->_trigger_error_msg("problem creating directory \"$dir\""); + $this->trigger_error("problem creating directory \"$dir\""); return false; } $new_dir .= '/'; @@ -1664,15 +1674,6 @@ function _run_insert_handler($args) } -/*======================================================================*\ - Function: _trigger_error_msg - Purpose: trigger Smarty error -\*======================================================================*/ - function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) - { - trigger_error("Smarty error: $error_msg", $error_type); - } - /*======================================================================*\ Function: _trigger_plugin_error Purpose: trigger Smarty plugin error diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 18041a88..4bc58a9f 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -463,6 +463,16 @@ class Smarty } +/*======================================================================*\ + Function: trigger_error + Purpose: trigger Smarty error +\*======================================================================*/ + function trigger_error($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Smarty error: $error_msg", $error_type); + } + + /*======================================================================*\ Function: display() Purpose: executes & displays the template results @@ -751,7 +761,7 @@ function _generate_debug_output() { if (method_exists($this, '_syntax_error')) { $error_func = '_syntax_error'; } else { - $error_func = '_trigger_error_msg'; + $error_func = 'trigger_error'; } if ($readable) { @@ -916,7 +926,7 @@ function _generate_debug_output() { // see if we can get a template with the default template handler if (!empty($this->default_template_handler_func)) { if (!function_exists($this->default_template_handler_func)) { - $this->_trigger_error_msg("default template handler function \"$this->default_template_handler_func\" doesn't exist."); + $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); $_return = false; } $funcname = $this->default_template_handler_func; @@ -925,9 +935,9 @@ function _generate_debug_output() { } if (!$_return) { - $this->_trigger_error_msg("unable to read template resource: \"$tpl_path\""); + $this->trigger_error("unable to read template resource: \"$tpl_path\""); } else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) { - $this->_trigger_error_msg("(secure mode) accessing \"$tpl_path\" is not allowed"); + $this->trigger_error("(secure mode) accessing \"$tpl_path\" is not allowed"); $template_source = null; $template_timestamp = null; return false; @@ -966,7 +976,7 @@ function _generate_debug_output() { if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) return true; else { - $this->_trigger_error_msg($smarty_compiler->_error_msg); + $this->trigger_error($smarty_compiler->_error_msg); return false; } } @@ -1265,7 +1275,7 @@ function _run_insert_handler($args) $this->_create_dir_structure(dirname($filename)); if (!($fd = @fopen($filename, 'w'))) { - $this->_trigger_error_msg("problem writing '$filename.'"); + $this->trigger_error("problem writing '$filename.'"); return false; } @@ -1359,7 +1369,7 @@ function _run_insert_handler($args) foreach ($dir_parts as $dir_part) { $new_dir .= $dir_part; if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) { - $this->_trigger_error_msg("problem creating directory \"$dir\""); + $this->trigger_error("problem creating directory \"$dir\""); return false; } $new_dir .= '/'; @@ -1664,15 +1674,6 @@ function _run_insert_handler($args) } -/*======================================================================*\ - Function: _trigger_error_msg - Purpose: trigger Smarty error -\*======================================================================*/ - function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) - { - trigger_error("Smarty error: $error_msg", $error_type); - } - /*======================================================================*\ Function: _trigger_plugin_error Purpose: trigger Smarty plugin error diff --git a/libs/plugins/function.assign.php b/libs/plugins/function.assign.php index a9efcbea..0eb29602 100644 --- a/libs/plugins/function.assign.php +++ b/libs/plugins/function.assign.php @@ -8,22 +8,21 @@ * Purpose: assign a value to a template variable * ------------------------------------------------------------- */ -function smarty_function_assign($args, &$smarty_obj) +function smarty_function_assign($params, &$smarty) { - extract($args); + extract($params); if (empty($var)) { - $smarty_obj->_trigger_error_msg("assign: missing 'var' parameter"); + $smarty->trigger_error("assign: missing 'var' parameter"); return; } - if (!in_array('value', array_keys($args))) { - $smarty_obj->_trigger_error_msg("assign: missing 'value' parameter"); + if (!in_array('value', array_keys($params))) { + $smarty->trigger_error("assign: missing 'value' parameter"); return; } - $smarty_obj->assign($var, $value); - return true; + $smarty->assign($var, $value); } /* vim: set expandtab: */ diff --git a/libs/plugins/function.assign_debug_info.php b/libs/plugins/function.assign_debug_info.php index 87d936a1..e1e31905 100644 --- a/libs/plugins/function.assign_debug_info.php +++ b/libs/plugins/function.assign_debug_info.php @@ -8,23 +8,23 @@ * Purpose: assign debug info to the template * ------------------------------------------------------------- */ -function smarty_function_assign_debug_info($args, &$smarty_obj) +function smarty_function_assign_debug_info($params, &$smarty) { - $assigned_vars = $smarty_obj->_tpl_vars; + $assigned_vars = $smarty->_tpl_vars; ksort($assigned_vars); - if (is_array($smarty_obj->_config[0])) { - $config_vars = $smarty_obj->_config[0]; + if (is_array($smarty->_config[0])) { + $config_vars = $smarty->_config[0]; ksort($config_vars); - $smarty_obj->assign("_debug_config_keys", array_keys($config_vars)); - $smarty_obj->assign("_debug_config_vals", array_values($config_vars)); + $smarty->assign("_debug_config_keys", array_keys($config_vars)); + $smarty->assign("_debug_config_vals", array_values($config_vars)); } - $included_templates = $smarty_obj->_smarty_debug_info; + $included_templates = $smarty->_smarty_debug_info; - $smarty_obj->assign("_debug_keys", array_keys($assigned_vars)); - $smarty_obj->assign("_debug_vals", array_values($assigned_vars)); + $smarty->assign("_debug_keys", array_keys($assigned_vars)); + $smarty->assign("_debug_vals", array_values($assigned_vars)); - $smarty_obj->assign("_debug_tpls", $included_templates); + $smarty->assign("_debug_tpls", $included_templates); } /* vim: set expandtab: */ diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php index 3aa5e1b9..a081b100 100644 --- a/libs/plugins/function.counter.php +++ b/libs/plugins/function.counter.php @@ -8,7 +8,7 @@ * Purpose: print out a counter value * ------------------------------------------------------------- */ -function smarty_function_counter($args, &$smarty_obj) +function smarty_function_counter($params, &$smarty) { static $count = array(); static $skipval = array(); @@ -17,7 +17,7 @@ function smarty_function_counter($args, &$smarty_obj) static $printval = array(); static $assign = ""; - extract($args); + extract($params); if (!isset($id)) $id = "default"; @@ -34,7 +34,7 @@ function smarty_function_counter($args, &$smarty_obj) if (!empty($assign)) { $printval[$id] = false; - $smarty_obj->assign($assign, $count[$id]); + $smarty->assign($assign, $count[$id]); } if ($printval[$id]) @@ -54,8 +54,6 @@ function smarty_function_counter($args, &$smarty_obj) $count[$id] -= $skipval[$id]; else $count[$id] += $skipval[$id]; - - return true; } /* vim: set expandtab: */ diff --git a/libs/plugins/function.fetch.php b/libs/plugins/function.fetch.php index f29a3ed2..e86408c6 100644 --- a/libs/plugins/function.fetch.php +++ b/libs/plugins/function.fetch.php @@ -8,29 +8,29 @@ * Purpose: fetch file, web or ftp data and display results * ------------------------------------------------------------- */ -function smarty_function_fetch($args, &$smarty_obj) +function smarty_function_fetch($params, &$smarty) { - extract($args); + extract($params); if (empty($file)) { - $smarty_obj->_trigger_error_msg("parameter 'file' cannot be empty"); + $smarty->trigger_error("parameter 'file' cannot be empty"); return; } - if ($smarty_obj->security && !preg_match('!^(http|ftp)://!', $file)) { + if ($smarty->security && !preg_match('!^(http|ftp)://!', $file)) { // make sure fetched file comes from secure directory - foreach ($smarty_obj->secure_dir as $curr_dir) { + foreach ($smarty->secure_dir as $curr_dir) { if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $resource_is_secure = true; break; } } if (!$resource_is_secure) { - $smarty_obj->_trigger_error_msg("(secure mode) fetch '$file' is not allowed"); + $smarty->trigger_error("(secure mode) fetch '$file' is not allowed"); return; } if (!@is_readable($file)) { - $smarty_obj->_trigger_error_msg("fetch cannot read file '$file'"); + $smarty->trigger_error("fetch cannot read file '$file'"); return; } } @@ -39,7 +39,7 @@ function smarty_function_fetch($args, &$smarty_obj) if (!empty($assign)) { ob_start(); readfile($file); - $smarty_obj->assign($assign,ob_get_contents()); + $smarty->assign($assign,ob_get_contents()); ob_end_clean(); } else { readfile($file); diff --git a/libs/plugins/function.math.php b/libs/plugins/function.math.php index b25bb2c9..2beef46d 100644 --- a/libs/plugins/function.math.php +++ b/libs/plugins/function.math.php @@ -8,19 +8,19 @@ * Purpose: handle math computations in template * ------------------------------------------------------------- */ -function smarty_function_math($args, &$smarty_obj) +function smarty_function_math($params, &$smarty) { // be sure equation parameter is present - if (empty($args["equation"])) { - $smarty_obj->_trigger_error_msg("math: missing equation parameter"); + if (empty($params["equation"])) { + $smarty->trigger_error("math: missing equation parameter"); return; } - $equation = $args["equation"]; + $equation = $params["equation"]; // make sure parenthesis are balanced if (substr_count($equation,"(") != substr_count($equation,")")) { - $smarty_obj->_trigger_error_msg("math: unbalanced parenthesis"); + $smarty->trigger_error("math: unbalanced parenthesis"); return; } @@ -30,21 +30,21 @@ function smarty_function_math($args, &$smarty_obj) 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); foreach($match[0] as $curr_var) { - if (!in_array($curr_var,array_keys($args)) && !in_array($curr_var, $allowed_funcs)) { - $smarty_obj->_trigger_error_msg("math: parameter $curr_var not passed as argument"); + if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { + $smarty->trigger_error("math: parameter $curr_var not passed as argument"); return; } } - foreach($args as $key => $val) { + foreach($params as $key => $val) { if ($key != "equation" && $key != "format" && $key != "assign") { // make sure value is not empty if (strlen($val)==0) { - $smarty_obj->_trigger_error_msg("math: parameter $key is empty"); + $smarty->trigger_error("math: parameter $key is empty"); return; } if (!is_numeric($val)) { - $smarty_obj->_trigger_error_msg("math: parameter $key: is not numeric"); + $smarty->trigger_error("math: parameter $key: is not numeric"); return; } $equation = preg_replace("/\b$key\b/",$val, $equation); @@ -53,17 +53,17 @@ function smarty_function_math($args, &$smarty_obj) eval("\$smarty_math_result = ".$equation.";"); - if (empty($args["format"])) { - if (empty($args["assign"])) { + if (empty($params["format"])) { + if (empty($params["assign"])) { echo $smarty_math_result; } else { - $smarty_obj->assign($args["assign"],$smarty_math_result); + $smarty->assign($params["assign"],$smarty_math_result); } } else { - if (empty($args["assign"])){ - printf($args["format"],$smarty_math_result); + if (empty($params["assign"])){ + printf($params["format"],$smarty_math_result); } else { - $smarty_obj->assign($assign,sprintf($args["format"],$smarty_math_result)); + $smarty->assign($assign,sprintf($params["format"],$smarty_math_result)); } } } diff --git a/libs/plugins/function.popup.php b/libs/plugins/function.popup.php index 45e87327..3ad24b5d 100644 --- a/libs/plugins/function.popup.php +++ b/libs/plugins/function.popup.php @@ -8,12 +8,12 @@ * Purpose: make text pop up in windows via overlib * ------------------------------------------------------------- */ -function smarty_function_popup($args, &$smarty_obj) +function smarty_function_popup($params, &$smarty) { - extract($args); + extract($params); if (empty($text) && !isset($inarray) && empty($function)) { - $smarty_obj->_trigger_error_msg("overlib: attribute 'text' or 'inarray' or 'function' required"); + $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required"); return false; } @@ -68,7 +68,6 @@ function smarty_function_popup($args, &$smarty_obj) if (!empty($hauto)) { echo ",HAUTO"; } if (!empty($vauto)) { echo ",VAUTO"; } echo ');" onMouseOut="nd();"'; - return; } /* vim: set expandtab: */ diff --git a/libs/plugins/function.popup_init.php b/libs/plugins/function.popup_init.php index 5c120f57..f3ab84d8 100644 --- a/libs/plugins/function.popup_init.php +++ b/libs/plugins/function.popup_init.php @@ -8,11 +8,11 @@ * Purpose: initialize overlib * ------------------------------------------------------------- */ -function smarty_function_popup_init($args, &$smarty_obj) +function smarty_function_popup_init($params, &$smarty) { // be sure to place overlib.js where Smarty can locate it. // overlib.js came with the distribution of Smarty. - extract($args); + extract($params); echo ''."\n"; if (empty($src)) { echo '