[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 class dcMenu 24 { 25 private $id; 26 private $title; 27 28 public function __construct($id,$title,$itemSpace='') 29 { 30 $this->id = $id; 31 $this->title = $title; 32 $this->itemSpace = $itemSpace; 33 $this->items = array(); 34 } 35 36 public function addItem($title,$url,$img,$active,$show=true,$id=NULL) 37 { 38 if($show) 39 { 40 if (is_array($url)) { 41 $link = $url[0]; 42 $ahtml = (!empty($url[1])) ? ' '.$url[1] : ''; 43 } else { 44 $link = $url; 45 $ahtml = ''; 46 } 47 48 $this->items[] = 49 '<li'.(($active) ? ' class="active"' : ''). 50 (($id) ? ' id="'.$id.'"' : ''). 51 (($img) ? ' style="background-image: url('.$img.');"' : ''). 52 '>'. 53 54 '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n"; 55 } 56 } 57 58 public function draw() 59 { 60 if (count($this->items) == 0) { 61 return ''; 62 } 63 64 $res = 65 '<div id="'.$this->id.'">'. 66 '<h3>'.$this->title.'</h3>'. 67 '<ul>'."\n"; 68 69 for ($i=0; $i<count($this->items); $i++) 70 { 71 if ($i+1 < count($this->items) && $this->itemSpace != '') { 72 $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); 73 $res .= "\n"; 74 } else { 75 $res .= $this->items[$i]."\n"; 76 } 77 } 78 79 $res .= '</ul></div>'."\n"; 80 81 return $res; 82 } 83 } 84 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |