Source for file List.class.php
Documentation is available at List.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Template List Class (Special class for saving lists of data)
* This is a Special Template Element designed to hold lists of data. The
* output is formatted specifically by the child class.
* For example, using a string replacement Engine, looping through an array
* of data requires clever programming. However, the List class will hold the
* array of data and perform the loop internally, formatting the desired output.
* If the program requires placing list items 'li' inside an [un]ordered list
* 'ul' or 'ol', simply populate the List_Item class with the data and assign
* a Template Variable. When the Template File is parsed, the List object
* will replace the keyword with a formatted string.
* $tpl = new Gumbo_Template_Engine_[Name] ();
* $tpl_list = new Gumbo_Template_List_Item;
* $tpl_list->add ("some data");
* $tpl->assign ("My_List", $tpl_list);
* // inside template_file.txt
* To extend, create new List classes that work with specific types of elements.
* In HTML, this could be definition lists, table rows, [un]ordered list items,
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Template List Class (Special class for saving lists of data)
gumbo_load ("Interface_Output");
/** @var array $_elements string elements to place inside list item */
* Adds data to the end of the list
* @param arr[] $data data arguments
abstract public function add ($data);
* Places data at the specified location
* @param arr[] $data data arguments
abstract public function place ($position, $data);
* Displays to the browser
* Removes data from a given position (resets the List)
* @throws Gumbo_Exception
public function remove ($position) {
$position = (int)
$position;
throw
new Gumbo_Exception ("Invalid Range: Greater Than Zero, Less Than Total Elements: {$position}");
foreach ($data as $key=>
$val) {
if ($position ==
$key+
1) { continue; }
$e->setFunction (__METHOD__
);
* Returns all the elements