2004-10-20 21:06:45 +00:00
|
|
|
<?php
|
2006-12-04 18:31:18 +00:00
|
|
|
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2012-01-04 18:31:46 +00:00
|
|
|
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2009-07-27 22:48:05 +00:00
|
|
|
*
|
2002-05-09 14:57:48 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-05-09 14:57:48 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-07-31 23:45:11 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-05-09 14:57:48 +00:00
|
|
|
*/
|
|
|
|
|
|
2005-03-28 12:08:19 +00:00
|
|
|
/**
|
2010-04-28 10:02:54 +00:00
|
|
|
* \file htdocs/core/class/menu.class.php
|
2010-11-22 09:18:53 +00:00
|
|
|
* \ingroup core
|
2009-07-27 22:48:05 +00:00
|
|
|
* \brief Fichier de la classe de gestion du menu gauche
|
|
|
|
|
*/
|
2004-10-28 22:15:31 +00:00
|
|
|
|
|
|
|
|
|
2005-01-19 22:50:56 +00:00
|
|
|
/**
|
2012-01-27 15:12:11 +00:00
|
|
|
* Class to manage left menus
|
2009-07-27 22:48:05 +00:00
|
|
|
*/
|
2011-10-15 23:59:12 +00:00
|
|
|
class Menu
|
|
|
|
|
{
|
2005-01-19 22:50:56 +00:00
|
|
|
var $liste;
|
2002-05-09 14:57:48 +00:00
|
|
|
|
2005-01-19 22:50:56 +00:00
|
|
|
/**
|
2011-09-11 18:35:38 +00:00
|
|
|
* Constructor
|
2005-01-19 22:50:56 +00:00
|
|
|
*/
|
2012-07-30 15:17:33 +00:00
|
|
|
function __construct()
|
2005-01-19 22:50:56 +00:00
|
|
|
{
|
2009-07-27 22:48:05 +00:00
|
|
|
$this->liste = array();
|
2005-01-19 22:50:56 +00:00
|
|
|
}
|
2002-05-09 14:57:48 +00:00
|
|
|
|
2005-01-19 22:50:56 +00:00
|
|
|
/**
|
2011-10-15 23:59:12 +00:00
|
|
|
* Clear property ->liste
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2005-01-19 22:50:56 +00:00
|
|
|
*/
|
|
|
|
|
function clear()
|
|
|
|
|
{
|
|
|
|
|
$this->liste = array();
|
|
|
|
|
}
|
2002-05-09 14:57:48 +00:00
|
|
|
|
2005-01-19 22:50:56 +00:00
|
|
|
/**
|
2012-01-04 18:31:46 +00:00
|
|
|
* Add a menu entry into this->liste (at end)
|
2011-10-15 23:59:12 +00:00
|
|
|
*
|
|
|
|
|
* @param string $url Url to follow on click
|
|
|
|
|
* @param string $titre Label of menu to add
|
|
|
|
|
* @param string $level Level of menu to add
|
2013-03-05 14:42:26 +00:00
|
|
|
* @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey)
|
2011-10-15 23:59:12 +00:00
|
|
|
* @param string $target Target lien
|
2012-01-03 19:27:10 +00:00
|
|
|
* @param string $mainmenu Main menu ('home', 'companies', 'products', ...)
|
|
|
|
|
* @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...)
|
2011-10-15 23:59:12 +00:00
|
|
|
* @return void
|
2005-01-19 22:50:56 +00:00
|
|
|
*/
|
2012-01-03 19:27:10 +00:00
|
|
|
function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='')
|
2005-01-19 22:50:56 +00:00
|
|
|
{
|
2012-01-04 18:31:46 +00:00
|
|
|
$this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert a menu entry into this->liste
|
|
|
|
|
*
|
|
|
|
|
* @param int $idafter Array key after which inserting new entry
|
|
|
|
|
* @param string $url Url to follow on click
|
|
|
|
|
* @param string $titre Label of menu to add
|
|
|
|
|
* @param string $level Level of menu to add
|
|
|
|
|
* @param int $enabled Menu active or not
|
|
|
|
|
* @param string $target Target lien
|
|
|
|
|
* @param string $mainmenu Main menu ('home', 'companies', 'products', ...)
|
|
|
|
|
* @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...)
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='')
|
|
|
|
|
{
|
|
|
|
|
$array_start = array_slice($this->liste,0,($idafter+1));
|
|
|
|
|
$array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu));
|
|
|
|
|
$array_end = array_slice($this->liste,($idafter+1));
|
|
|
|
|
$this->liste=array_merge($array_start,$array_new,$array_end);
|
2005-01-19 22:50:56 +00:00
|
|
|
}
|
2002-05-09 14:57:48 +00:00
|
|
|
|
2006-12-04 17:50:54 +00:00
|
|
|
/**
|
2011-10-15 23:59:12 +00:00
|
|
|
* Remove a menu entry from this->liste
|
|
|
|
|
*
|
2012-01-03 19:27:10 +00:00
|
|
|
* @return void
|
2006-12-04 17:50:54 +00:00
|
|
|
*/
|
|
|
|
|
function remove_last()
|
2009-07-27 22:48:05 +00:00
|
|
|
{
|
2011-09-17 19:49:50 +00:00
|
|
|
if (count($this->liste) > 1) array_pop($this->liste);
|
2006-12-04 17:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-09 14:57:48 +00:00
|
|
|
}
|