*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (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
* along with this program. If not, see .
*/
/**
* \file htdocs/core/menus/standard/empty.php
* \brief This is an example of an empty top menu handler
*/
/**
* Class to manage empty menu
*/
class MenuManager
{
/**
* @var DoliDB Database handler.
*/
public $db;
public $type_user=0; // Put 0 for internal users, 1 for external users
public $atarget=""; // To store default target to use onto links
public $menu;
public $menu_array_after;
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param int $type_user Type of user
*/
public function __construct($db, $type_user)
{
$this->type_user=$type_user;
$this->db=$db;
}
/**
* Load this->tabMenu
*
* @return void
*/
public function loadMenu()
{
}
/**
* Show menu
*
* @param string $mode 'top', 'left', 'jmobile'
* @param array $moredata An array with more data to output
* @return int 0 or nb of top menu entries if $mode = 'topnb'
*/
public function showmenu($mode, $moredata = null)
{
global $user,$conf,$langs,$dolibarr_main_db_name;
$id='mainmenu';
require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php';
$this->menu=new Menu();
$res='ErrorBadParameterForMode';
$noout=0;
//if ($mode == 'jmobile') $noout=1;
if ($mode == 'topnb')
{
return 1;
}
if ($mode == 'top')
{
if (empty($noout)) print_start_menu_array_empty();
$usemenuhider = 1;
// Show/Hide vertical menu
if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$showmode=1;
$classname = 'class="tmenu menuhider"';
$idsel='menu';
$this->menu->add('#', '', 0, $showmode, $atarget, "xxx", '', 0, $id, $idsel, $classname);
}
// Home
$showmode=1;
$classname='class="tmenusel"';
$idsel='home';
$this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname);
// Sort on position
$this->menu->liste = dol_sort_array($this->menu->liste, 'position');
// Output menu entries
foreach($this->menu->liste as $menkey => $menuval)
{
if (empty($noout)) print_start_menu_entry_empty($menuval['idsel'], $menuval['classname'], $menuval['enabled']);
if (empty($noout)) print_text_menu_entry_empty($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget));
if (empty($noout)) print_end_menu_entry_empty($menuval['enabled']);
}
$showmode=1;
if (empty($noout)) print_start_menu_entry_empty('', 'class="tmenuend"', $showmode);
if (empty($noout)) print_end_menu_entry_empty($showmode);
if (empty($noout)) print_end_menu_array_empty();
if ($mode == 'jmobile')
{
$this->topmenu = clone $this->menu;
unset($this->menu->liste);
}
}
if ($mode == 'jmobile') // Used to get menu in xml ul/li
{
// Home
$showmode=1;
$classname='class="tmenusel"';
$idsel='home';
$this->menu->add('/index.php', $langs->trans("Home"), 0, $showmode, $this->atarget, 'home', '', 10, $id, $idsel, $classname);
// $this->menu->liste is top menu
//var_dump($this->menu->liste);exit;
$lastlevel = array();
print ''."\n";
foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
print '
'."\n";
}
}
if ($mode == 'left')
{
// Put here left menu entries
// ***** START *****
$langs->load("admin"); // Load translation file admin.lang
$this->menu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"), 0);
$this->menu->add("/admin/company.php", $langs->trans("MenuCompanySetup"), 1);
$this->menu->add("/admin/modules.php", $langs->trans("Modules"), 1);
$this->menu->add("/admin/menus.php", $langs->trans("Menus"), 1);
$this->menu->add("/admin/ihm.php", $langs->trans("GUISetup"), 1);
$this->menu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"), 1);
$this->menu->add("/admin/defaultvalues.php?mainmenu=home", $langs->trans("DefaultValues"), 1);
$this->menu->add("/admin/boxes.php", $langs->trans("Boxes"), 1);
$this->menu->add("/admin/delais.php", $langs->trans("Alerts"), 1);
$this->menu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"), 1);
$this->menu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1);
$this->menu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1);
$this->menu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"), 1);
$this->menu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1);
$this->menu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionarySetup"), 1);
$this->menu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1);
// ***** END *****
// do not change code after this
if (empty($noout))
{
$alt=0; $altok=0; $blockvmenuopened=false;
$num=count($this->menu->liste);
for ($i = 0; $i < $num; $i++)
{
$alt++;
if (empty($this->menu->liste[$i]['level']))
{
$altok++;
$blockvmenuopened=true;
$lastopened=true;
for($j = ($i + 1); $j < $num; $j++)
{
if (empty($menu_array[$j]['level'])) $lastopened=false;
}
$alt = 0; // For menu manager "empty", we force to not have blockvmenufirst defined
$lastopened = 1; // For menu manager "empty", we force to not have blockvmenulast defined
if (($alt%2==0))
{
print '