| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/tree/src/lmbTreeHelper.class.php'); 10 11 /** 12 * class lmbTreeSortedCollection. 13 * 14 * @package tree 15 * @version $Id: lmbTreeSortedCollection.class.php 5945 2007-06-06 08:31:43Z pachanga $ 16 */ 17 class lmbTreeSortedCollection extends lmbCollectionDecorator 18 { 19 protected $node_field = 'id'; 20 protected $parent_field = 'parent_id'; 21 protected $order_pairs = array(); 22 23 function setNodeField($name) 24 { 25 $this->node_field = $name; 26 } 27 28 function setParentField($name) 29 { 30 $this->parent_field = $name; 31 } 32 33 function setOrder($order_string) 34 { 35 $order_items = explode(',', $order_string); 36 foreach($order_items as $order_pair) 37 { 38 $arr = explode('=', $order_pair); 39 40 if(isset($arr[1])) 41 { 42 if(strtolower($arr[1]) == 'asc' || strtolower($arr[1]) == 'desc' 43 || strtolower($arr[1]) == 'rand()') 44 $this->order_pairs[$arr[0]] = strtoupper($arr[1]); 45 else 46 throw new lmbException('Wrong order type', array('order' => $arr[1])); 47 } 48 else 49 $this->order_pairs[$arr[0]] = 'ASC'; 50 } 51 } 52 53 function rewind() 54 { 55 parent :: rewind(); 56 57 if($this->iterator->valid()) 58 { 59 $nested_array = array(); 60 61 $iterator = lmbTreeHelper :: sort($this->iterator, $this->order_pairs, $this->node_field, $this->parent_field); 62 } 63 else 64 $iterator = new lmbCollection(); 65 66 $this->iterator = $iterator; 67 68 return $this->iterator->rewind(); 69 } 70 } 71 72 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Dec 2 03:54:09 2008 | Cross-referenced by PHPXref 0.7 |