From 541e03660e7d70736cd3a6c1c3495d3738c7dc21 Mon Sep 17 00:00:00 2001 From: mohrt Date: Fri, 3 May 2002 18:22:41 +0000 Subject: [PATCH] update counter to use name instead of id (id still works though) --- docs/designers.sgml | 8 +++--- libs/plugins/function.counter.php | 47 +++++++++++++++++-------------- plugins/function.counter.php | 47 +++++++++++++++++-------------- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/docs/designers.sgml b/docs/designers.sgml index ca43444b..3b712fe1 100644 --- a/docs/designers.sgml +++ b/docs/designers.sgml @@ -2649,11 +2649,11 @@ The value of $name is Bob. - id + name string No default - The id of the counter + The name of the counter start @@ -2699,8 +2699,8 @@ The value of $name is Bob. count on each iteration. You can adjust the number, the interval and the direction of the count, as well as determine whether or not to print the value. You can run multiple counters concurrently by - supplying a unique id for each one. If you do not supply an id, the - default id will be used. counter was added to Smarty 1.4.0. + supplying a unique id for each one. If you do not supply a name, the + name 'default' will be used. counter was added to Smarty 1.4.0. If you supply the special "assign" attribute, the output of the diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php index a081b100..08db6a55 100644 --- a/libs/plugins/function.counter.php +++ b/libs/plugins/function.counter.php @@ -13,47 +13,52 @@ function smarty_function_counter($params, &$smarty) static $count = array(); static $skipval = array(); static $dir = array(); - static $id = "default"; + static $name = "default"; static $printval = array(); static $assign = ""; extract($params); - if (!isset($id)) - $id = "default"; + if (!isset($name)) { + if(isset($id)) { + $name = $id; + } else { + $name = "default"; + } + } if (isset($start)) - $count[$id] = $start; - else if (!isset($count[$id])) - $count[$id]=1; + $count[$name] = $start; + else if (!isset($count[$name])) + $count[$name]=1; if (!isset($print)) - $printval[$id]=true; + $printval[$name]=true; else - $printval[$id]=$print; + $printval[$name]=$print; if (!empty($assign)) { - $printval[$id] = false; - $smarty->assign($assign, $count[$id]); + $printval[$name] = false; + $smarty->assign($assign, $count[$name]); } - if ($printval[$id]) - echo $count[$id]; + if ($printval[$name]) + echo $count[$name]; if (isset($skip)) - $skipval[$id] = $skip; - else if (empty($skipval[$id])) - $skipval[$id] = 1; + $skipval[$name] = $skip; + else if (empty($skipval[$name])) + $skipval[$name] = 1; if (isset($direction)) - $dir[$id] = $direction; - else if (!isset($dir[$id])) - $dir[$id] = "up"; + $dir[$name] = $direction; + else if (!isset($dir[$name])) + $dir[$name] = "up"; - if ($dir[$id] == "down") - $count[$id] -= $skipval[$id]; + if ($dir[$name] == "down") + $count[$name] -= $skipval[$name]; else - $count[$id] += $skipval[$id]; + $count[$name] += $skipval[$name]; } /* vim: set expandtab: */ diff --git a/plugins/function.counter.php b/plugins/function.counter.php index a081b100..08db6a55 100644 --- a/plugins/function.counter.php +++ b/plugins/function.counter.php @@ -13,47 +13,52 @@ function smarty_function_counter($params, &$smarty) static $count = array(); static $skipval = array(); static $dir = array(); - static $id = "default"; + static $name = "default"; static $printval = array(); static $assign = ""; extract($params); - if (!isset($id)) - $id = "default"; + if (!isset($name)) { + if(isset($id)) { + $name = $id; + } else { + $name = "default"; + } + } if (isset($start)) - $count[$id] = $start; - else if (!isset($count[$id])) - $count[$id]=1; + $count[$name] = $start; + else if (!isset($count[$name])) + $count[$name]=1; if (!isset($print)) - $printval[$id]=true; + $printval[$name]=true; else - $printval[$id]=$print; + $printval[$name]=$print; if (!empty($assign)) { - $printval[$id] = false; - $smarty->assign($assign, $count[$id]); + $printval[$name] = false; + $smarty->assign($assign, $count[$name]); } - if ($printval[$id]) - echo $count[$id]; + if ($printval[$name]) + echo $count[$name]; if (isset($skip)) - $skipval[$id] = $skip; - else if (empty($skipval[$id])) - $skipval[$id] = 1; + $skipval[$name] = $skip; + else if (empty($skipval[$name])) + $skipval[$name] = 1; if (isset($direction)) - $dir[$id] = $direction; - else if (!isset($dir[$id])) - $dir[$id] = "up"; + $dir[$name] = $direction; + else if (!isset($dir[$name])) + $dir[$name] = "up"; - if ($dir[$id] == "down") - $count[$id] -= $skipval[$id]; + if ($dir[$name] == "down") + $count[$name] -= $skipval[$name]; else - $count[$id] += $skipval[$id]; + $count[$name] += $skipval[$name]; } /* vim: set expandtab: */