update cycle function to handle array as input, update files to 2.1.1

This commit is contained in:
mohrt
2002-05-07 14:16:34 +00:00
parent 7ee4e41e17
commit 5b70385282
10 changed files with 39 additions and 15 deletions

View File

@@ -13,8 +13,10 @@
* Jason Sweat <jsweat_php@yahoo.com>
* Purpose: cycle through given values
* Input: name = name of cycle (optional)
* values = comma separated list of values to cycle
* values = comma separated list of values to cycle,
* or an array of values to cycle
* (this can be left out for subsequent calls)
*
* reset = boolean - resets given var to true
* print = boolean - print var or not. default is true
* advance = boolean - whether or not to advance the cycle
@@ -62,7 +64,11 @@ function smarty_function_cycle($params, &$smarty)
$cycle_vars[$name]['values'] = $values;
}
$cycle_array = explode($delimiter,$cycle_vars[$name]['values']);
if(!is_array($cycle_vars[$name]['values'])) {
$cycle_array = explode($delimiter,$cycle_vars[$name]['values']);
} else {
$cycle_array = $cycle_vars[$name]['values'];
}
if(!isset($cycle_vars[$name]['index']) || $reset ) {
$cycle_vars[$name]['index'] = 0;