mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Fixup some naming.
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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: */
|
||||
|
@@ -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: */
|
||||
|
@@ -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: */
|
||||
|
@@ -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);
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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: */
|
||||
|
@@ -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 '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
||||
if (empty($src)) {
|
||||
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
||||
@@ -21,7 +21,6 @@ function smarty_function_popup_init($args, &$smarty_obj)
|
||||
} else {
|
||||
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
@@ -27,11 +27,13 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
||||
$return .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
return $return;
|
||||
|
||||
case 'hexentity':
|
||||
for ($x=0; $x < strlen($string); $x++) {
|
||||
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||
}
|
||||
return $return;
|
||||
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
|
@@ -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: */
|
||||
|
@@ -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: */
|
||||
|
@@ -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: */
|
||||
|
@@ -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);
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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: */
|
||||
|
@@ -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 '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
||||
if (empty($src)) {
|
||||
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
||||
@@ -21,7 +21,6 @@ function smarty_function_popup_init($args, &$smarty_obj)
|
||||
} else {
|
||||
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
@@ -27,11 +27,13 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
||||
$return .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
return $return;
|
||||
|
||||
case 'hexentity':
|
||||
for ($x=0; $x < strlen($string); $x++) {
|
||||
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||
}
|
||||
return $return;
|
||||
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user