Merge pull request #15653 from frederic34/typeusermenuleft

fix type_user not defined in left menu
This commit is contained in:
Laurent Destailleur 2020-12-04 22:03:54 +01:00 committed by GitHub
commit a05021a344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 508 additions and 539 deletions

File diff suppressed because it is too large Load Diff

View File

@ -67,12 +67,15 @@ class MenuManager
global $conf, $user, $langs;
// We save into session the main menu selected
if (GETPOSTISSET("mainmenu")) $_SESSION["mainmenu"] = GETPOST("mainmenu", 'aZ09');
if (GETPOSTISSET("idmenu")) $_SESSION["idmenu"] = GETPOST("idmenu", 'int');
if (GETPOSTISSET("mainmenu")) {
$_SESSION["mainmenu"] = GETPOST("mainmenu", 'aZ09');
}
if (GETPOSTISSET("idmenu")) {
$_SESSION["idmenu"] = GETPOST("idmenu", 'int');
}
// Read now mainmenu and leftmenu that define which menu to show
if (GETPOSTISSET("mainmenu"))
{
if (GETPOSTISSET("mainmenu")) {
// On sauve en session le menu principal choisi
$mainmenu = GETPOST("mainmenu", 'aZ09');
$_SESSION["mainmenu"] = $mainmenu;
@ -81,16 +84,16 @@ class MenuManager
// On va le chercher en session si non defini par le lien
$mainmenu = isset($_SESSION["mainmenu"]) ? $_SESSION["mainmenu"] : '';
}
if (!empty($forcemainmenu)) $mainmenu = $forcemainmenu;
if (!empty($forcemainmenu)) {
$mainmenu = $forcemainmenu;
}
if (GETPOSTISSET("leftmenu"))
{
if (GETPOSTISSET("leftmenu")) {
// On sauve en session le menu principal choisi
$leftmenu = GETPOST("leftmenu", 'aZ09');
$_SESSION["leftmenu"] = $leftmenu;
if ($_SESSION["leftmenuopened"] == $leftmenu) // To collapse
{
if ($_SESSION["leftmenuopened"] == $leftmenu) { // To collapse
//$leftmenu="";
$_SESSION["leftmenuopened"] = "";
} else {
@ -100,7 +103,9 @@ class MenuManager
// On va le chercher en session si non defini par le lien
$leftmenu = isset($_SESSION["leftmenu"]) ? $_SESSION["leftmenu"] : '';
}
if (!empty($forceleftmenu)) $leftmenu = $forceleftmenu;
if (!empty($forceleftmenu)) {
$leftmenu = $forceleftmenu;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
$tabMenu = array();
@ -129,8 +134,7 @@ class MenuManager
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
if ($this->type_user == 1)
{
if ($this->type_user == 1) {
$conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1;
$conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1;
}
@ -138,36 +142,39 @@ class MenuManager
require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php';
$this->menu = new Menu();
if (empty($conf->global->MAIN_MENU_INVERT))
{
if ($mode == 'top') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode);
if ($mode == 'left') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata);
if (empty($conf->global->MAIN_MENU_INVERT)) {
if ($mode == 'top') {
print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode);
}
if ($mode == 'left') {
print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata, $this->type_user);
}
} else {
$conf->global->MAIN_SHOW_LOGO = 0;
if ($mode == 'top') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0);
if ($mode == 'left') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode);
if ($mode == 'top') {
print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata, $this->type_user);
}
if ($mode == 'left') {
print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode);
}
}
if ($mode == 'topnb')
{
if ($mode == 'topnb') {
print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output
return $this->menu->getNbOfVisibleMenuEntries();
}
if ($mode == 'jmobile') // Used to get menu in xml ul/li
{
if ($mode == 'jmobile') { // Used to get menu in xml ul/li
print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // Fill this->menu that is empty with top menu
// $this->menu->liste is top menu
//var_dump($this->menu->liste);exit;
$lastlevel = array();
print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n";
foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
foreach ($this->menu->liste as $key => $val) { // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
print '<ul class="ulmenu" data-inset="true">';
print '<li class="lilevel0">';
if ($val['enabled'] == 1)
{
if ($val['enabled'] == 1) {
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
$substitarray['__USERID__'] = $user->id; // For backward compatibility
$val['url'] = make_substitutions($val['url'], $substitarray);
@ -178,7 +185,9 @@ class MenuManager
print '<a class="alilevel0" href="#">';
// Add font-awesome
if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>';
if ($val['level'] == 0 && $val['mainmenu'] == 'home') {
print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>';
}
print $val['titre'];
print '</a>'."\n";
@ -187,7 +196,7 @@ class MenuManager
$tmpmainmenu = $val['mainmenu'];
$tmpleftmenu = 'all';
$submenu = new Menu();
print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu, null, $this->type_user); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
// Note: $submenu contains menu entry with substitution not yet done
//if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; }
//if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; }
@ -199,27 +208,27 @@ class MenuManager
//var_dump($canonnexturl);
print '<ul>'."\n";
if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools')))
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false))
{
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) {
// We add sub entry
print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print '<a href="'.$relurl.'">';
if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation
{
if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) print $langs->trans("Access");
else print $langs->trans("Dashboard");
} else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { // No translation
if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) {
print $langs->trans("Access");
} else {
print $langs->trans("Dashboard");
}
} else {
print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
}
print '</a>';
print '</li>'."\n";
}
if ($val['level'] == 0)
{
if ($val['enabled'])
{
if ($val['level'] == 0) {
if ($val['enabled']) {
$lastlevel[0] = 'enabled';
} elseif ($showmenu) // Not enabled but visible (so greyed)
{
} elseif ($showmenu) { // Not enabled but visible (so greyed)
$lastlevel[0] = 'greyed';
} else {
$lastlevel[0] = 'hidden';
@ -227,52 +236,52 @@ class MenuManager
}
$lastlevel2 = array();
foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
foreach ($submenu->liste as $key2 => $val2) { // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
$showmenu = true;
if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false;
if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) {
$showmenu = false;
}
// If at least one parent is not enabled, we do not show any menu of all children
if ($val2['level'] > 0)
{
if ($val2['level'] > 0) {
$levelcursor = $val2['level'] - 1;
while ($levelcursor >= 0)
{
if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false;
while ($levelcursor >= 0) {
if ($lastlevel2[$levelcursor] != 'enabled') {
$showmenu = false;
}
$levelcursor--;
}
}
if ($showmenu) // Visible (option to hide when not allowed is off or allowed)
{
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
$substitarray['__USERID__'] = $user->id; // For backward compatibility
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
if ($showmenu) { // Visible (option to hide when not allowed is off or allowed)
$substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
$substitarray['__USERID__'] = $user->id; // For backward compatibility
$val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
if (!preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url']))
{
$relurl2 = dol_buildpath($val2['url'], 1);
} else {
$relurl2 = $val2['url'];
}
if (!preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) {
$relurl2 = dol_buildpath($val2['url'], 1);
} else {
$relurl2 = $val2['url'];
}
$canonurl2 = preg_replace('/\?.*$/', '', $val2['url']);
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = '';
if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) {
$relurl2 = '';
}
$disabled = '';
if (!$val2['enabled'])
{
if (!$val2['enabled']) {
$disabled = " vsmenudisabled";
}
print str_pad('', $val2['level'] + 1);
print '<li class="lilevel'.($val2['level'] + 1);
if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
if ($val2['level'] == 0) {
print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
}
print $disabled.'">'; // ui-btn to highlight on clic
if ($relurl2)
{
if ($val2['enabled']) // Allowed
{
if ($relurl2) {
if ($val2['enabled']) { // Allowed
print '<a href="'.$relurl2.'"';
//print ' data-ajax="false"';
print '>';
@ -283,28 +292,27 @@ class MenuManager
$lastlevel2[$val2['level']] = 'greyed';
}
} else {
if ($val2['enabled']) // Allowed
{
if ($val2['enabled']) { // Allowed
$lastlevel2[$val2['level']] = 'enabled';
} else {
$lastlevel2[$val2['level']] = 'greyed';
}
}
print $val2['titre'];
if ($relurl2)
{
if ($val2['enabled']) // Allowed
if ($relurl2) {
if ($val2['enabled']) { // Allowed
print '</a>';
else print '</a>';
} else {
print '</a>';
}
}
print '</li>'."\n";
}
}
}
}
//var_dump($submenu);
print '</ul>';
}
if ($val['enabled'] == 2)
{
if ($val['enabled'] == 2) {
print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
}
print '</li>';

View File

@ -84,20 +84,19 @@ class MenuManager
$noout = 0;
//if ($mode == 'jmobile') $noout=1;
if ($mode == 'topnb')
{
if ($mode == 'topnb') {
return 1;
}
if ($mode == 'top')
{
if (empty($noout)) print_start_menu_array_empty();
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))
{
if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$showmode = 1;
$classname = 'class="tmenu menuhider"';
$idsel = 'menu';
@ -117,28 +116,37 @@ class MenuManager
$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']);
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_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 (empty($noout)) {
print_end_menu_array_empty();
}
if ($mode == 'jmobile')
{
if ($mode == 'jmobile') {
$this->topmenu = clone $this->menu;
unset($this->menu->liste);
}
}
if ($mode == 'jmobile') // Used to get menu in xml ul/li
{
if ($mode == 'jmobile') { // Used to get menu in xml ul/li
// Home
$showmode = 1;
$classname = 'class="tmenusel"';
@ -152,22 +160,22 @@ class MenuManager
//var_dump($this->menu->liste);exit;
$lastlevel = array();
print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n";
foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
foreach ($this->menu->liste as $key => $val) { // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
print '<ul class="ulmenu" data-inset="true">';
print '<li class="lilevel0">';
$val['url'] = make_substitutions($val['url'], $substitarray);
if ($val['enabled'] == 1)
{
if ($val['enabled'] == 1) {
$relurl = dol_buildpath($val['url'], 1);
$canonurl = preg_replace('/\?.*$/', '', $val['url']);
print '<a class="alilevel0" href="#">';
// Add font-awesome
if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>';
if ($val['level'] == 0 && $val['mainmenu'] == 'home') {
print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>';
}
print $val['titre'];
print '</a>'."\n";
@ -206,27 +214,27 @@ class MenuManager
//var_dump($canonnexturl);
print '<ul>'."\n";
if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools')))
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false))
{
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) {
// We add sub entry
print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print '<a href="'.$relurl.'">';
if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation
{
if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) print $langs->trans("Access");
else print $langs->trans("Dashboard");
} else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { // No translation
if (in_array($val['mainmenu'], array('cashdesk', 'websites'))) {
print $langs->trans("Access");
} else {
print $langs->trans("Dashboard");
}
} else {
print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
}
print '</a>';
print '</li>'."\n";
}
if ($val['level'] == 0)
{
if ($val['enabled'])
{
if ($val['level'] == 0) {
if ($val['enabled']) {
$lastlevel[0] = 'enabled';
} elseif ($showmenu) // Not enabled but visible (so greyed)
{
} elseif ($showmenu) { // Not enabled but visible (so greyed)
$lastlevel[0] = 'greyed';
} else {
$lastlevel[0] = 'hidden';
@ -234,45 +242,46 @@ class MenuManager
}
$lastlevel2 = array();
foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
foreach ($submenu->liste as $key2 => $val2) { // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
$showmenu = true;
if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false;
if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) {
$showmenu = false;
}
// If at least one parent is not enabled, we do not show any menu of all children
if ($val2['level'] > 0)
{
if ($val2['level'] > 0) {
$levelcursor = $val2['level'] - 1;
while ($levelcursor >= 0)
{
if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false;
while ($levelcursor >= 0) {
if ($lastlevel2[$levelcursor] != 'enabled') {
$showmenu = false;
}
$levelcursor--;
}
}
if ($showmenu) // Visible (option to hide when not allowed is off or allowed)
{
if ($showmenu) { // Visible (option to hide when not allowed is off or allowed)
$val2['url'] = make_substitutions($val2['url'], $substitarray);
$relurl2 = dol_buildpath($val2['url'], 1);
$canonurl2 = preg_replace('/\?.*$/', '', $val2['url']);
//var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = '';
if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) {
$relurl2 = '';
}
$disabled = '';
if (!$val2['enabled'])
{
if (!$val2['enabled']) {
$disabled = " vsmenudisabled";
}
print str_pad('', $val2['level'] + 1);
print '<li class="lilevel'.($val2['level'] + 1);
if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
if ($val2['level'] == 0) {
print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
}
print $disabled.'">'; // ui-btn to highlight on clic
if ($relurl2)
{
if ($val2['enabled']) // Allowed
{
if ($relurl2) {
if ($val2['enabled']) { // Allowed
print '<a href="'.$relurl2.'"';
//print ' data-ajax="false"';
print '>';
@ -283,8 +292,7 @@ class MenuManager
$lastlevel2[$val2['level']] = 'greyed';
}
} else {
if ($val2['enabled']) // Allowed
{
if ($val2['enabled']) { // Allowed
$lastlevel2[$val2['level']] = 'enabled';
} else {
$lastlevel2[$val2['level']] = 'greyed';
@ -293,8 +301,7 @@ class MenuManager
//var_dump($val2['level']);
//var_dump($lastlevel2);
print $val2['titre'];
if ($relurl2)
{
if ($relurl2) {
if ($val2['enabled']) {
// Allowed
print '</a>';
@ -308,8 +315,7 @@ class MenuManager
//var_dump($submenu);
print '</ul>';
}
if ($val['enabled'] == 2)
{
if ($val['enabled'] == 2) {
print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
}
print '</li>';
@ -317,8 +323,7 @@ class MenuManager
}
}
if ($mode == 'left')
{
if ($mode == 'left') {
// Put here left menu entries
// ***** START *****
@ -345,26 +350,23 @@ class MenuManager
// do not change code after this
if (empty($noout))
{
if (empty($noout)) {
$alt = 0; $altok = 0; $blockvmenuopened = false;
$num = count($this->menu->liste);
for ($i = 0; $i < $num; $i++)
{
for ($i = 0; $i < $num; $i++) {
$alt++;
if (empty($this->menu->liste[$i]['level']))
{
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;
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))
{
if (($alt % 2 == 0)) {
print '<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened ? ' blockvmenulast' : '').($alt == 1 ? ' blockvmenufirst' : '').'">'."\n";
} else {
print '<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened ? ' blockvmenulast' : '').($alt == 1 ? ' blockvmenufirst' : '').'">'."\n";
@ -374,17 +376,14 @@ class MenuManager
// Add tabulation
$tabstring = '';
$tabul = ($this->menu->liste[$i]['level'] - 1);
if ($tabul > 0)
{
for ($j = 0; $j < $tabul; $j++)
{
if ($tabul > 0) {
for ($j = 0; $j < $tabul; $j++) {
$tabstring .= '&nbsp; &nbsp;';
}
}
if ($this->menu->liste[$i]['level'] == 0) {
if ($this->menu->liste[$i]['enabled'])
{
if ($this->menu->liste[$i]['enabled']) {
print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu->liste[$i]['url'], 1).'"'.($this->menu->liste[$i]['target'] ? ' target="'.$this->menu->liste[$i]['target'].'"' : '').'>'.$this->menu->liste[$i]['titre'].'</a></div>'."\n";
} else {
print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu->liste[$i]['titre'].'</font></div>'."\n";
@ -392,42 +391,50 @@ class MenuManager
print '<div class="menu_top"></div>'."\n";
}
if ($this->menu->liste[$i]['level'] > 0)
{
if ($this->menu->liste[$i]['level'] > 0) {
$cssmenu = '';
if ($this->menu->liste[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $this->menu->liste[$i]['url']));
if ($this->menu->liste[$i]['url']) {
$cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $this->menu->liste[$i]['url']));
}
print '<div class="menu_contenu'.$cssmenu.'">';
if ($this->menu->liste[$i]['enabled'])
{
if ($this->menu->liste[$i]['enabled']) {
print $tabstring;
if ($this->menu->liste[$i]['url']) print '<a class="vsmenu" itle="'.dol_escape_htmltag($this->menu->liste[$i]['titre']).'" href="'.dol_buildpath($this->menu->liste[$i]['url'], 1).'"'.($this->menu->liste[$i]['target'] ? ' target="'.$this->menu->liste[$i]['target'].'"' : '').'>';
else print '<span class="vsmenu" title="'.dol_escape_htmltag($this->menu->liste[$i]['titre']).'">';
if ($this->menu->liste[$i]['url']) print $this->menu->liste[$i]['titre'].'</a>';
else print '</span>';
if ($this->menu->liste[$i]['url']) {
print '<a class="vsmenu" itle="'.dol_escape_htmltag($this->menu->liste[$i]['titre']).'" href="'.dol_buildpath($this->menu->liste[$i]['url'], 1).'"'.($this->menu->liste[$i]['target'] ? ' target="'.$this->menu->liste[$i]['target'].'"' : '').'>';
} else {
print '<span class="vsmenu" title="'.dol_escape_htmltag($this->menu->liste[$i]['titre']).'">';
}
if ($this->menu->liste[$i]['url']) {
print $this->menu->liste[$i]['titre'].'</a>';
} else {
print '</span>';
}
} else {
print $tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$this->menu->liste[$i]['titre'].'</font>';
}
// If title is not pure text and contains a table, no carriage return added
if (!strstr($this->menu->liste[$i]['titre'], '<table')) print '<br>';
if (!strstr($this->menu->liste[$i]['titre'], '<table')) {
print '<br>';
}
print '</div>'."\n";
}
// If next is a new block or end
if (empty($this->menu->liste[$i + 1]['level']))
{
if (empty($this->menu->liste[$i + 1]['level'])) {
print '<div class="menu_end"></div>'."\n";
print "</div>\n";
}
}
if ($altok) print '<div class="blockvmenuend"></div>';
if ($altok) {
print '<div class="blockvmenuend"></div>';
}
}
if ($mode == 'jmobile')
{
if ($mode == 'jmobile') {
$this->leftmenu = clone $this->menu;
unset($this->menu->liste);
}
@ -442,7 +449,7 @@ class MenuManager
print '<ul class="ulmenu" data-inset="true">';
print '<li class="lilevel0">';
$val['url'] = make_substitutions($val['url'], $substitarray);
$val['url'] = make_substitutions($val['url'], $substitarray);
if ($val['enabled'] == 1)
{
@ -453,7 +460,7 @@ class MenuManager
$tmpmainmenu=$val['mainmenu'];
$tmpleftmenu='all';
//$submenu=new Menu();
//$res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu);
//$res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu, null, $this->type_user);
//$nexturl=dol_buildpath($submenu->liste[0]['url'],1);
$submenu=$this->leftmenu;
@ -462,14 +469,14 @@ class MenuManager
//var_dump($canonrelurl);
//var_dump($canonnexturl);
print '<ul>';
if ($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('home','tools')))
if ($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('home','tools')))
{
// We add sub entry
print '<li><a href="'.$relurl.'">'.$langs->trans("MainArea").'-'.$val['titre'].'</a></li>'."\n";
}
foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
{
$val2['url'] = make_substitutions($val2['url'], $substitarray);
$val2['url'] = make_substitutions($val2['url'], $substitarray);
$relurl2=dol_buildpath($val2['url'],1);
//var_dump($val2);
@ -488,7 +495,7 @@ class MenuManager
break; // Only first menu entry (so home)
}
}
*/
*/
unset($this->menu);
return $res;
@ -519,8 +526,7 @@ function print_start_menu_array_empty()
*/
function print_start_menu_entry_empty($idsel, $classname, $showmode)
{
if ($showmode)
{
if ($showmode) {
print '<li '.$classname.' id="mainmenutd_'.$idsel.'">';
//print '<div class="tmenuleft tmenusep"></div>';
print '<div class="tmenucenter">';
@ -543,8 +549,7 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class
{
global $conf, $langs;
if ($showmode == 1)
{
if ($showmode == 1) {
print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>';
print '<div class="'.$id.' '.$idsel.'"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
print '</a>';
@ -554,8 +559,7 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class
print '</span>';
print '</a>';
}
if ($showmode == 2)
{
if ($showmode == 2) {
print '<div class="'.$id.' '.$idsel.' tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>';
print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
}
@ -569,8 +573,7 @@ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $class
*/
function print_end_menu_entry_empty($showmode)
{
if ($showmode)
{
if ($showmode) {
print '</div></li>';
print "\n";
}