fixed bug with call $assign

This commit is contained in:
mohrt
2002-06-03 16:13:37 +00:00
parent 51a14712f8
commit c23569b7ca
2 changed files with 16 additions and 16 deletions

View File

@@ -11,12 +11,12 @@
function smarty_function_math($params, &$smarty) function smarty_function_math($params, &$smarty)
{ {
// be sure equation parameter is present // be sure equation parameter is present
if (empty($params["equation"])) { if (empty($params['equation'])) {
$smarty->trigger_error("math: missing equation parameter"); $smarty->trigger_error("math: missing equation parameter");
return; return;
} }
$equation = $params["equation"]; $equation = $params['equation'];
// make sure parenthesis are balanced // make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) { if (substr_count($equation,"(") != substr_count($equation,")")) {
@@ -53,17 +53,17 @@ function smarty_function_math($params, &$smarty)
eval("\$smarty_math_result = ".$equation.";"); eval("\$smarty_math_result = ".$equation.";");
if (empty($params["format"])) { if (empty($params['format'])) {
if (empty($params["assign"])) { if (empty($params['assign'])) {
echo $smarty_math_result; echo $smarty_math_result;
} else { } else {
$smarty->assign($params["assign"],$smarty_math_result); $smarty->assign($params['assign'],$smarty_math_result);
} }
} else { } else {
if (empty($params["assign"])){ if (empty($params['assign'])){
printf($params["format"],$smarty_math_result); printf($params['format'],$smarty_math_result);
} else { } else {
$smarty->assign($assign,sprintf($params["format"],$smarty_math_result)); $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
} }
} }
} }

View File

@@ -11,12 +11,12 @@
function smarty_function_math($params, &$smarty) function smarty_function_math($params, &$smarty)
{ {
// be sure equation parameter is present // be sure equation parameter is present
if (empty($params["equation"])) { if (empty($params['equation'])) {
$smarty->trigger_error("math: missing equation parameter"); $smarty->trigger_error("math: missing equation parameter");
return; return;
} }
$equation = $params["equation"]; $equation = $params['equation'];
// make sure parenthesis are balanced // make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) { if (substr_count($equation,"(") != substr_count($equation,")")) {
@@ -53,17 +53,17 @@ function smarty_function_math($params, &$smarty)
eval("\$smarty_math_result = ".$equation.";"); eval("\$smarty_math_result = ".$equation.";");
if (empty($params["format"])) { if (empty($params['format'])) {
if (empty($params["assign"])) { if (empty($params['assign'])) {
echo $smarty_math_result; echo $smarty_math_result;
} else { } else {
$smarty->assign($params["assign"],$smarty_math_result); $smarty->assign($params['assign'],$smarty_math_result);
} }
} else { } else {
if (empty($params["assign"])){ if (empty($params['assign'])){
printf($params["format"],$smarty_math_result); printf($params['format'],$smarty_math_result);
} else { } else {
$smarty->assign($assign,sprintf($params["format"],$smarty_math_result)); $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
} }
} }
} }