Add new directory structure. Tags will contain current and past releases, and stable will contain any bug fixes to the current stable release so users won't have to get the potentially broken trunk build to fix a screwup in stable.

Trunk updated to 0.9

git-svn-id: http://kusabax.cultnet.net/svn/repo/stable@176 73d99b7e-4f53-4972-b7b7-2ecd3c4d89ee
This commit is contained in:
Sazpaimon committed 2009-05-27 06:37:50 +00:00
commit 88bacfad9c
316 files changed
+79806

No files matched your search

@@ -0,0 +1,69 @@
<?php
/**
* Cycles between several values and returns one of them on each call
* <pre>
* * name : the cycler name, specify if you need to have multiple concurrent cycles running
* * values : an array of values or a string of values delimited by $delimiter
* * print : if false, the pointer will go to the next one but not print anything
* * advance : if false, the pointer will not advance to the next value
* * delimiter : the delimiter used to split values if they are provided as a string
* * assign : if set, the value is saved in that variable instead of being output
* * reset : if true, the pointer is reset to the first value
* </pre>
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://dwoo.org/LICENSE Modified BSD License
* @link http://dwoo.org/
* @version 1.0.1
* @date 2008-12-24
* @package Dwoo
*/
class Dwoo_Plugin_cycle extends Dwoo_Plugin
{
protected $cycles = array();
public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false)
{
if ($values !== null) {
if (is_string($values)) {
$values = explode($delimiter, $values);
}
if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) {
$this->cycles[$name]['index'] = 0;
}
$this->cycles[$name]['values'] = array_values($values);
} elseif (isset($this->cycles[$name])) {
$values = $this->cycles[$name]['values'];
}
if ($reset) {
$this->cycles[$name]['index'] = 0;
}
if ($print) {
$out = $values[$this->cycles[$name]['index']];
} else {
$out = null;
}
if ($advance) {
if ($this->cycles[$name]['index'] >= count($values)-1) {
$this->cycles[$name]['index'] = 0;
} else {
$this->cycles[$name]['index']++;
}
}
if ($assign !== null) {
$this->dwoo->assignInScope($out, $assign);
} else {
return $out;
}
}
}