dolibarr  7.0.0-beta
menu.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
29 class Menu
30 {
31  var $liste;
32 
36  function __construct()
37  {
38  $this->liste = array();
39  }
40 
46  function clear()
47  {
48  $this->liste = array();
49  }
50 
68  function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='', $prefix='')
69  {
70  $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix);
71  }
72 
91  function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='', $prefix='')
92  {
93  $array_start = array_slice($this->liste,0,($idafter+1));
94  $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix));
95  $array_end = array_slice($this->liste,($idafter+1));
96  $this->liste=array_merge($array_start,$array_new,$array_end);
97  }
98 
104  function remove_last()
105  {
106  if (count($this->liste) > 1) array_pop($this->liste);
107  }
108 
115  {
116  $nb=0;
117  foreach($this->liste as $val)
118  {
119  if (! empty($val['enabled'])) $nb++;
120  }
121  return $nb;
122  }
123 }
insert($idafter, $url, $titre, $level=0, $enabled=1, $target='', $mainmenu='', $leftmenu='', $position=0, $id='', $idsel='', $classname='', $prefix='')
Insert a menu entry into this->liste.
Definition: menu.class.php:91
add($url, $titre, $level=0, $enabled=1, $target='', $mainmenu='', $leftmenu='', $position=0, $id='', $idsel='', $classname='', $prefix='')
Add a menu entry into this->liste (at end)
Definition: menu.class.php:68
__construct()
Constructor.
Definition: menu.class.php:36
Class to manage left menus.
Definition: menu.class.php:29
remove_last()
Remove a menu entry from this->liste.
Definition: menu.class.php:104
getNbOfVisibleMenuEntries()
Return number of visible entries (gray or not)
Definition: menu.class.php:114
clear()
Clear property ->liste.
Definition: menu.class.php:46