mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
rename id to name for cycle function
This commit is contained in:
@@ -2746,11 +2746,11 @@ OUTPUT:
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<row>
|
<row>
|
||||||
<entry>id</entry>
|
<entry>name</entry>
|
||||||
<entry>string</entry>
|
<entry>string</entry>
|
||||||
<entry>No</entry>
|
<entry>No</entry>
|
||||||
<entry><emphasis>default</emphasis></entry>
|
<entry><emphasis>default</emphasis></entry>
|
||||||
<entry>The id of the cycle</entry>
|
<entry>The name of the cycle</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>values</entry>
|
<entry>values</entry>
|
||||||
@@ -2798,8 +2798,8 @@ OUTPUT:
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
{* initialize the count *}
|
{* initialize the count *}
|
||||||
{cycle values="#eeeeee,#d0d0d0"}
|
{cycle values="#eeeeee,#d0d0d0"}
|
||||||
{cycle values="#eeeeee,#d0d0d0"}
|
{cycle}
|
||||||
{cycle values="#eeeeee,#d0d0d0"}
|
{cycle}
|
||||||
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
@@ -10,8 +10,9 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Credits: Mark Priatel <mpriatel@rogers.com>
|
* Credits: Mark Priatel <mpriatel@rogers.com>
|
||||||
* Gerard <gerard@interfold.com>
|
* Gerard <gerard@interfold.com>
|
||||||
|
* Jason Sweat <jsweat_php@yahoo.com>
|
||||||
* Purpose: cycle through given values
|
* Purpose: cycle through given values
|
||||||
* Input: id = id of cycle (optional)
|
* Input: name = name of cycle (optional)
|
||||||
* values = comma separated list of values to cycle
|
* values = comma separated list of values to cycle
|
||||||
* (this can be left out for subsequent calls)
|
* (this can be left out for subsequent calls)
|
||||||
* reset = boolean - resets given var to true
|
* reset = boolean - resets given var to true
|
||||||
@@ -22,8 +23,8 @@
|
|||||||
* printed.
|
* printed.
|
||||||
*
|
*
|
||||||
* Examples: {cycle values="#eeeeee,#d0d0d0d"}
|
* Examples: {cycle values="#eeeeee,#d0d0d0d"}
|
||||||
* {cycle id=row values="one,two,three" reset=true}
|
* {cycle name=row values="one,two,three" reset=true}
|
||||||
* {cycle id=row}
|
* {cycle name=row}
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_cycle($params, &$smarty)
|
function smarty_function_cycle($params, &$smarty)
|
||||||
@@ -32,8 +33,8 @@ function smarty_function_cycle($params, &$smarty)
|
|||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($name)) {
|
||||||
$id = 'default';
|
$name = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($print)) {
|
if (!isset($print)) {
|
||||||
@@ -49,38 +50,38 @@ function smarty_function_cycle($params, &$smarty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('values', array_keys($params))) {
|
if (!in_array('values', array_keys($params))) {
|
||||||
if(!isset($cycle_vars[$id]['values'])) {
|
if(!isset($cycle_vars[$name]['values'])) {
|
||||||
$smarty->trigger_error("cycle: missing 'values' parameter");
|
$smarty->trigger_error("cycle: missing 'values' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(isset($cycle_vars[$id]['values'])
|
if(isset($cycle_vars[$name]['values'])
|
||||||
&& $cycle_vars[$id]['values'] != $values ) {
|
&& $cycle_vars[$name]['values'] != $values ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
}
|
}
|
||||||
$cycle_vars[$id]['values'] = $values;
|
$cycle_vars[$name]['values'] = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cycle_array = explode($delimiter,$cycle_vars[$id]['values']);
|
$cycle_array = explode($delimiter,$cycle_vars[$name]['values']);
|
||||||
|
|
||||||
if(!isset($cycle_vars[$id]['index']) || $reset ) {
|
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($assign)) {
|
if (isset($assign)) {
|
||||||
$print = false;
|
$print = false;
|
||||||
$smarty->assign($assign, $cycle_array[$cycle_vars[$id]['index']]);
|
$smarty->assign($assign, $cycle_array[$cycle_vars[$name]['index']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($print) {
|
if($print) {
|
||||||
echo $cycle_array[$cycle_vars[$id]['index']]."\n";
|
echo $cycle_array[$cycle_vars[$name]['index']]."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($advance) {
|
if($advance) {
|
||||||
if ( $cycle_vars[$id]['index'] >= count($cycle_array) -1 ) {
|
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
} else {
|
} else {
|
||||||
$cycle_vars[$id]['index']++;
|
$cycle_vars[$name]['index']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,9 @@
|
|||||||
* Author: Monte Ohrt <monte@ispi.net>
|
* Author: Monte Ohrt <monte@ispi.net>
|
||||||
* Credits: Mark Priatel <mpriatel@rogers.com>
|
* Credits: Mark Priatel <mpriatel@rogers.com>
|
||||||
* Gerard <gerard@interfold.com>
|
* Gerard <gerard@interfold.com>
|
||||||
|
* Jason Sweat <jsweat_php@yahoo.com>
|
||||||
* Purpose: cycle through given values
|
* Purpose: cycle through given values
|
||||||
* Input: id = id of cycle (optional)
|
* Input: name = name of cycle (optional)
|
||||||
* values = comma separated list of values to cycle
|
* values = comma separated list of values to cycle
|
||||||
* (this can be left out for subsequent calls)
|
* (this can be left out for subsequent calls)
|
||||||
* reset = boolean - resets given var to true
|
* reset = boolean - resets given var to true
|
||||||
@@ -22,8 +23,8 @@
|
|||||||
* printed.
|
* printed.
|
||||||
*
|
*
|
||||||
* Examples: {cycle values="#eeeeee,#d0d0d0d"}
|
* Examples: {cycle values="#eeeeee,#d0d0d0d"}
|
||||||
* {cycle id=row values="one,two,three" reset=true}
|
* {cycle name=row values="one,two,three" reset=true}
|
||||||
* {cycle id=row}
|
* {cycle name=row}
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_cycle($params, &$smarty)
|
function smarty_function_cycle($params, &$smarty)
|
||||||
@@ -32,8 +33,8 @@ function smarty_function_cycle($params, &$smarty)
|
|||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($name)) {
|
||||||
$id = 'default';
|
$name = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($print)) {
|
if (!isset($print)) {
|
||||||
@@ -49,38 +50,38 @@ function smarty_function_cycle($params, &$smarty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('values', array_keys($params))) {
|
if (!in_array('values', array_keys($params))) {
|
||||||
if(!isset($cycle_vars[$id]['values'])) {
|
if(!isset($cycle_vars[$name]['values'])) {
|
||||||
$smarty->trigger_error("cycle: missing 'values' parameter");
|
$smarty->trigger_error("cycle: missing 'values' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(isset($cycle_vars[$id]['values'])
|
if(isset($cycle_vars[$name]['values'])
|
||||||
&& $cycle_vars[$id]['values'] != $values ) {
|
&& $cycle_vars[$name]['values'] != $values ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
}
|
}
|
||||||
$cycle_vars[$id]['values'] = $values;
|
$cycle_vars[$name]['values'] = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cycle_array = explode($delimiter,$cycle_vars[$id]['values']);
|
$cycle_array = explode($delimiter,$cycle_vars[$name]['values']);
|
||||||
|
|
||||||
if(!isset($cycle_vars[$id]['index']) || $reset ) {
|
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($assign)) {
|
if (isset($assign)) {
|
||||||
$print = false;
|
$print = false;
|
||||||
$smarty->assign($assign, $cycle_array[$cycle_vars[$id]['index']]);
|
$smarty->assign($assign, $cycle_array[$cycle_vars[$name]['index']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($print) {
|
if($print) {
|
||||||
echo $cycle_array[$cycle_vars[$id]['index']]."\n";
|
echo $cycle_array[$cycle_vars[$name]['index']]."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($advance) {
|
if($advance) {
|
||||||
if ( $cycle_vars[$id]['index'] >= count($cycle_array) -1 ) {
|
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||||
$cycle_vars[$id]['index'] = 0;
|
$cycle_vars[$name]['index'] = 0;
|
||||||
} else {
|
} else {
|
||||||
$cycle_vars[$id]['index']++;
|
$cycle_vars[$name]['index']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user