[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/classes/ -> class.menu.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 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  /*
  24  Classe Menu
  25  */
  26  
  27  class menu
  28  {
  29  	function menu($id,$imgSpace='',$itemSpace='')
  30      {
  31          $this->id = $id;
  32          $this->imgSpace = $imgSpace;
  33          $this->itemSpace = $itemSpace;
  34          $this->items = array();
  35      }
  36      
  37  	function addItem($title,$url,$img,$active,$show=true,$id=NULL)
  38      {
  39          if($show)
  40          {
  41              if (is_array($url)) {
  42                  $link = $url[0];
  43                  $ahtml = (!empty($url[1])) ? ' '.$url[1] : '';
  44              } else {
  45                  $link = $url;
  46                  $ahtml = '';
  47              }
  48              
  49              $this->items[] =
  50              '<li'.(($active) ? ' class="actif"' : '').
  51              (($id) ? ' id="'.$id.'"' : '').
  52              '>'.
  53              (($img) ? '<img src="'.$img.'" alt="" />'.$this->imgSpace : '').
  54              '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n";
  55          }
  56      }
  57      
  58  	function draw()
  59      {
  60          $res = '<ul id="'.$this->id.'">'."\n";
  61          
  62          if (count($this->items) > 0) {
  63              for ($i=0; $i<count($this->items); $i++)
  64              {
  65                  if ($i+1 < count($this->items) && $this->itemSpace != '') {
  66                      $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]);
  67                      $res .= "\n";
  68                  } else {
  69                      $res .= $this->items[$i]."\n";
  70                  }
  71              }
  72          } else {
  73              $res .= '<li>&nbsp;</li>';
  74          }
  75          
  76          $res .= '</ul>'."\n";
  77          
  78          return $res;
  79      }
  80  }
  81  ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7