diff options
Diffstat (limited to 'lib/smarty3/plugins/function.counter.php')
-rw-r--r-- | lib/smarty3/plugins/function.counter.php | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/smarty3/plugins/function.counter.php b/lib/smarty3/plugins/function.counter.php index bcc8f49..a4129e7 100644 --- a/lib/smarty3/plugins/function.counter.php +++ b/lib/smarty3/plugins/function.counter.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsFunction */ - /** * Smarty {counter} function plugin - * Type: function<br> - * Name: counter<br> + * Type: function + * Name: counter * Purpose: print out a counter value * * @author Monte Ohrt <monte at ohrt dot com> @@ -24,50 +23,40 @@ function smarty_function_counter($params, $template) { static $counters = array(); - $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; if (!isset($counters[ $name ])) { $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); } $counter =& $counters[ $name ]; - if (isset($params[ 'start' ])) { - $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ]; + $counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ]; } - if (!empty($params[ 'assign' ])) { $counter[ 'assign' ] = $params[ 'assign' ]; } - if (isset($counter[ 'assign' ])) { $template->assign($counter[ 'assign' ], $counter[ 'count' ]); } - if (isset($params[ 'print' ])) { - $print = (bool) $params[ 'print' ]; + $print = (bool)$params[ 'print' ]; } else { $print = empty($counter[ 'assign' ]); } - if ($print) { $retval = $counter[ 'count' ]; } else { $retval = null; } - if (isset($params[ 'skip' ])) { $counter[ 'skip' ] = $params[ 'skip' ]; } - if (isset($params[ 'direction' ])) { $counter[ 'direction' ] = $params[ 'direction' ]; } - - if ($counter[ 'direction' ] == "down") { + if ($counter[ 'direction' ] === 'down') { $counter[ 'count' ] -= $counter[ 'skip' ]; } else { $counter[ 'count' ] += $counter[ 'skip' ]; } - return $retval; } |