Work on management of left menus

This commit is contained in:
Laurent Destailleur 2012-01-03 20:27:10 +01:00
parent f012a52465
commit 6964eaff01
4 changed files with 21 additions and 17 deletions

View File

@ -57,10 +57,11 @@ class Menu
* @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
* @param string $mainmenu Main menu ('home', 'companies', 'products', ...)
* @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...)
* @return void
*/
function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='')
function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='')
{
$i = count($this->liste);
$this->liste[$i]['url'] = $url;
@ -69,12 +70,13 @@ class Menu
$this->liste[$i]['enabled'] = $enabled;
$this->liste[$i]['target'] = $target;
$this->liste[$i]['mainmenu'] = $mainmenu;
$this->liste[$i]['leftmenu'] = $leftmenu;
}
/**
* Remove a menu entry from this->liste
*
* @return voir
* @return void
*/
function remove_last()
{

View File

@ -231,12 +231,12 @@ class Menubase
$sql.= " usertype='".$this->user."'";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("Menubase::update sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Menubase::update ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
@ -275,7 +275,7 @@ class Menubase
$sql.= " FROM ".MAIN_DB_PREFIX."menu as t";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog("Menubase::fetch sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -309,7 +309,7 @@ class Menubase
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Menubase::fetch ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
@ -333,7 +333,7 @@ class Menubase
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Menubase::delete ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
return -1;
}
@ -480,7 +480,7 @@ class Menubase
{
$this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu);
}
//var_dump($tabMenu);
//var_dump($tabMenu); exit;
$menutopid='';
if (is_array($tabMenu))
@ -509,9 +509,11 @@ class Menubase
//var_dump($this->newmenu->liste);exit;
$tabMenu[$key]['fk_menu']=$menutopid;
}
else if ($val['fk_leftmenu'] == $fk_leftmenu)
else if ($val['fk_leftmenu'] == $leftmenu)
{
// TODO
//$tabMenu[$key]['fk_menu']=$menutopid;
// Search higher menu level with this leftmenu
/*
foreach($this->newmenu as $keyparent => $valparent)
{
@ -544,12 +546,12 @@ class Menubase
/**
* Load entries found in database to $tabMenu.
* Load entries found in database into variable $tabMenu. Note that only "database menu entries" are loaded here, hardcoded will not be present into output.
*
* @param string $mymainmenu Value for left that defined mainmenu
* @param string $myleftmenu Value for left that defined leftmenu
* @param int $type_user 0=Internal,1=External,2=All
* @param string $menu_handler Name of menu_handler used (auguria, eldy...)
* @param string $menu_handler Name of menu_handler used ('auguria', 'eldy'...)
* @param array &$tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled)
* @return int >0 if OK, <0 if KO
*/

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -627,7 +627,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
$langs->load("admin");
$langs->load("help");
$newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"));
$newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"), 0, 1, '', $mainmenu, 'setup');
if ($leftmenu=="setup") $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1);
if ($leftmenu=="setup") $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1);
if ($leftmenu=="setup") $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1);
@ -643,7 +643,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after)
if ($leftmenu=="setup") $newmenu->add("/admin/dict.php", $langs->trans("DictionnarySetup"),1);
if ($leftmenu=="setup") $newmenu->add("/admin/const.php", $langs->trans("OtherSetup"),1);
$newmenu->add("/admin/system/index.php?leftmenu=system", $langs->trans("SystemInfo"));
$newmenu->add("/admin/system/index.php?leftmenu=system", $langs->trans("SystemInfo"), 0, 1, '', $mainmenu, 'system');
if ($leftmenu=="system") $newmenu->add("/admin/system/dolibarr.php", $langs->trans("Dolibarr"),1);
if ($leftmenu=="system") $newmenu->add("/admin/system/constall.php", $langs->trans("AllParameters"),2);
if ($leftmenu=="system") $newmenu->add("/admin/system/modules.php", $langs->trans("Modules"),2);

View File

@ -26,7 +26,7 @@ CREATE TABLE llx_menu
entity integer DEFAULT 1 NOT NULL, -- Multi company id
module varchar(64), -- Module name if record is added by a module
type varchar(4) NOT NULL, -- Menu top or left
mainmenu varchar(100) NOT NULL, -- Name family/module (home, companies, ...)
mainmenu varchar(100) NOT NULL, -- Name family/module for top menu (home, companies, ...)
leftmenu varchar(100) NULL, -- Name family/module for left menu (setup, info, ...)
fk_menu integer NOT NULL, -- 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu
fk_mainmenu varchar(16), --