- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.menu.php
r3075 r2566 22 22 $this->title = $title; 23 23 $this->itemSpace = $itemSpace; 24 $this->pinned = array();25 24 $this->items = array(); 26 25 } 27 26 28 public function addItem($title,$url,$img,$active,$show=true,$id=null,$class=null ,$pinned=false)27 public function addItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 29 28 { 30 29 if($show) { 31 $item = $this->itemDef($title,$url,$img,$active,$id,$class); 32 if ($pinned) { 33 $this->pinned[] = $item; 34 } else { 35 $this->items[$title] = $item; 36 } 30 $this->items[] = $this->itemDef($title,$url,$img,$active,$id,$class); 37 31 } 38 32 } 39 33 40 public function prependItem($title,$url,$img,$active,$show=true,$id=null,$class=null ,$pinned=false)34 public function prependItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 41 35 { 42 36 if ($show) { 43 $item = $this->itemDef($title,$url,$img,$active,$id,$class); 44 if ($pinned) { 45 array_unshift($this->pinned,$item); 46 } else { 47 $this->items[$title] = $item; 48 } 37 array_unshift($this->items,$this->itemDef($title,$url,$img,$active,$id,$class)); 49 38 } 50 39 } … … 52 41 public function draw() 53 42 { 54 if (count($this->items) + count($this->pinned)== 0) {43 if (count($this->items) == 0) { 55 44 return ''; 56 45 } … … 61 50 '<ul>'."\n"; 62 51 63 // 1. Display pinned items (unsorted) 64 for ($i=0; $i<count($this->pinned); $i++) 52 for ($i=0; $i<count($this->items); $i++) 65 53 { 66 if ($i+1 < count($this-> pinned) && $this->itemSpace != '') {67 $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this-> pinned[$i]);54 if ($i+1 < count($this->items) && $this->itemSpace != '') { 55 $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); 68 56 $res .= "\n"; 69 57 } else { 70 $res .= $this-> pinned[$i]."\n";58 $res .= $this->items[$i]."\n"; 71 59 } 72 }73 74 // 2. Display unpinned itmes (sorted)75 $i = 0;76 dcUtils::lexicalKeySort($this->items);77 foreach ($this->items as $title => $item)78 {79 if ($i+1 < count($this->items) && $this->itemSpace != '') {80 $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$item);81 $res .= "\n";82 } else {83 $res .= $item."\n";84 }85 $i++;86 60 } 87 61
Note: See TracChangeset
for help on using the changeset viewer.