From ced3cf376e4a4cb0d741503f941c1ccdce7803cc Mon Sep 17 00:00:00 2001 From: messju Date: Tue, 3 Jun 2003 13:22:41 +0000 Subject: [PATCH] fixed behaviour of start=... for {counter} --- NEWS | 1 + libs/plugins/function.counter.php | 32 ++++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index fd23e769..91844d95 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - fixed behaviour of start=... for {counter} (messju) - fixed assign for {counter} (messju) - added params vdir, hdir and inner to html_table to allow looping over the data in various directions (messju) diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php index 87fcce71..2536c14e 100644 --- a/libs/plugins/function.counter.php +++ b/libs/plugins/function.counter.php @@ -36,44 +36,40 @@ function smarty_function_counter($params, &$smarty) $counters[$name] = array( 'start'=>1, 'skip'=>1, - 'assign'=>null, - 'direction'=>'up' + 'direction'=>'up', + 'count'=>1 ); } $counter =& $counters[$name]; - - if (isset($start)) - $counter['start'] = $start; - else if (!isset($counter['start'])) - $counter['start'] = 1; - - if (!isset($counter['count'])) - $counter['count'] = $counter['start']; + if (isset($start)) { + $counter['start'] = $counter['count'] = $start; + } if (!empty($assign)) { $counter['assign'] = $assign; } - if (!empty($counter['assign'])) { + if (isset($counter['assign'])) { $smarty->assign($counter['assign'], $counter['count']); } - if (!isset($print)) - $print = empty($counter['assign']); - else + if (isset($print)) { $print = (bool)$print; - - if (isset($skip)) { - $counter['skip'] = $skip; + } else { + $print = empty($counter['assign']); } - + if ($print) { $retval = $counter['count']; } else { $retval = null; } + if (isset($skip)) { + $counter['skip'] = $skip; + } + if (isset($direction)) { $counter['direction'] = $direction; }