83 public function showmenu($mode, $moredata =
null)
85 global $user, $conf, $langs, $dolibarr_main_db_name;
89 require_once DOL_DOCUMENT_ROOT.
'/core/class/menu.class.php';
90 $this->menu =
new Menu();
92 $res =
'ErrorBadParameterForMode';
97 if ($mode ==
'topnb') {
101 if ($mode ==
'top') {
109 if ($mode !=
'jmobile' && $mode !=
'topnb' && $usemenuhider && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
111 $classname =
'class="tmenu menuhider nohover"';
114 $this->menu->add(
'#',
'', 0, $showmode, $this->atarget,
"xxx",
'', 0, $id, $idsel, $classname);
119 $classname =
'class="tmenusel"';
122 $this->menu->add(
'/index.php', $langs->trans(
"Home"), 0, $showmode, $this->atarget,
'home',
'', 10, $id, $idsel, $classname);
126 $this->menu->liste =
dol_sort_array($this->menu->liste,
'position');
129 foreach ($this->menu->liste as $menkey => $menuval) {
134 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'] : $this->atarget));
152 if ($mode ==
'jmobile') {
153 $this->topmenu = clone $this->menu;
154 unset($this->menu->liste);
158 if ($mode ==
'jmobile') {
161 $classname =
'class="tmenusel"';
164 $this->menu->add(
'/index.php', $langs->trans(
"Home"), 0, $showmode, $this->atarget,
'home',
'', 10, $id, $idsel, $classname);
170 $lastlevel = array();
172 print
'<!-- Generate menu list from menu handler '.$this->name.
' -->'.
"\n";
173 foreach ($this->menu->liste as $key => $val) {
174 print
'<ul class="ulmenu" data-inset="true">';
175 print
'<li class="lilevel0">';
179 if ($val[
'enabled'] == 1) {
181 $canonurl = preg_replace(
'/\?.*$/',
'', $val[
'url']);
183 print
'<a class="alilevel0" href="#">';
186 if ($val[
'level'] == 0 && $val[
'mainmenu'] ==
'home') {
187 print
'<span class="fas fa-home fa-fw paddingright" aria-hidden="true"></span>';
194 $tmpmainmenu = $val[
'mainmenu'];
195 $tmpleftmenu =
'all';
196 $submenu =
new Menu();
198 $langs->load(
"admin");
199 $submenu->add(
"/admin/index.php?leftmenu=setup", $langs->trans(
"Setup"), 0);
200 $submenu->add(
"/admin/company.php", $langs->trans(
"MenuCompanySetup"), 1);
201 $submenu->add(
"/admin/modules.php", $langs->trans(
"Modules"), 1);
202 $submenu->add(
"/admin/menus.php", $langs->trans(
"Menus"), 1);
203 $submenu->add(
"/admin/ihm.php", $langs->trans(
"GUISetup"), 1);
204 $submenu->add(
"/admin/translation.php?mainmenu=home", $langs->trans(
"Translation"), 1);
205 $submenu->add(
"/admin/defaultvalues.php?mainmenu=home", $langs->trans(
"DefaultValues"), 1);
207 $submenu->add(
"/admin/boxes.php?mainmenu=home", $langs->trans(
"Boxes"), 1);
208 $submenu->add(
"/admin/delais.php?mainmenu=home", $langs->trans(
"Alerts"), 1);
209 $submenu->add(
"/admin/proxy.php?mainmenu=home", $langs->trans(
"Security"), 1);
210 $submenu->add(
"/admin/limits.php?mainmenu=home", $langs->trans(
"MenuLimits"), 1);
211 $submenu->add(
"/admin/pdf.php?mainmenu=home", $langs->trans(
"PDF"), 1);
212 $submenu->add(
"/admin/mails.php?mainmenu=home", $langs->trans(
"Emails"), 1);
213 $submenu->add(
"/admin/sms.php?mainmenu=home", $langs->trans(
"SMS"), 1);
214 $submenu->add(
"/admin/dict.php?mainmenu=home", $langs->trans(
"DictionarySetup"), 1);
215 $submenu->add(
"/admin/const.php?mainmenu=home", $langs->trans(
"OtherSetup"), 1);
225 $canonrelurl = preg_replace(
'/\?.*$/',
'', $relurl);
226 $canonnexturl = preg_replace(
'/\?.*$/',
'', $nexturl);
229 if (($canonrelurl != $canonnexturl && !in_array($val[
'mainmenu'], array(
'tools')))
230 || (strpos($canonrelurl,
'/product/index.php') !==
false || strpos($canonrelurl,
'/compta/bank/list.php') !==
false)) {
232 print str_pad(
'', 1).
'<li class="lilevel1 ui-btn-icon-right ui-btn">';
233 print
'<a href="'.$relurl.
'">';
234 if ($langs->trans(ucfirst($val[
'mainmenu']).
"Dashboard") == ucfirst($val[
'mainmenu']).
"Dashboard") {
235 if (in_array($val[
'mainmenu'], array(
'cashdesk',
'websites'))) {
236 print $langs->trans(
"Access");
238 print $langs->trans(
"Dashboard");
241 print $langs->trans(ucfirst($val[
'mainmenu']).
"Dashboard");
247 if ($val[
'level'] == 0) {
248 if ($val[
'enabled']) {
249 $lastlevel[0] =
'enabled';
250 } elseif ($showmenu) {
251 $lastlevel[0] =
'greyed';
253 $lastlevel[0] =
'hidden';
257 $lastlevel2 = array();
258 foreach ($submenu->liste as $key2 => $val2) {
265 if ($val2[
'level'] > 0) {
266 $levelcursor = $val2[
'level'] - 1;
267 while ($levelcursor >= 0) {
268 if ($lastlevel2[$levelcursor] !=
'enabled') {
279 $canonurl2 = preg_replace(
'/\?.*$/',
'', $val2[
'url']);
281 if (in_array($canonurl2, array(
'/admin/index.php',
'/admin/tools/index.php',
'/core/tools.php'))) {
286 if (!$val2[
'enabled']) {
287 $disabled =
" vsmenudisabled";
291 print str_pad(
'', $val2[
'level'] + 1);
292 print
'<li class="lilevel'.($val2[
'level'] + 1);
293 if ($val2[
'level'] == 0) {
294 print
' ui-btn-icon-right ui-btn';
296 print $disabled.
'">';
298 if ($val2[
'enabled']) {
300 print
'<a href="'.$relurl2.
'">';
301 $lastlevel2[$val2[
'level']] =
'enabled';
304 print
'<a href="#" class="vsmenudisabled">';
305 $lastlevel2[$val2[
'level']] =
'greyed';
308 if ($val2[
'enabled']) {
309 $lastlevel2[$val2[
'level']] =
'enabled';
311 $lastlevel2[$val2[
'level']] =
'greyed';
314 print $val2[
'titre'];
323 if ($val[
'enabled'] == 2) {
324 print
'<span class="vsmenudisabled">'.$val[
'titre'].
'</span>';
331 if ($mode ==
'left') {
335 $langs->load(
"admin");
336 $this->menu->add(
"/admin/index.php?leftmenu=setup", $langs->trans(
"Setup"), 0);
337 $this->menu->add(
"/admin/company.php", $langs->trans(
"MenuCompanySetup"), 1);
338 $this->menu->add(
"/admin/modules.php", $langs->trans(
"Modules"), 1);
339 $this->menu->add(
"/admin/menus.php", $langs->trans(
"Menus"), 1);
340 $this->menu->add(
"/admin/ihm.php", $langs->trans(
"GUISetup"), 1);
341 $this->menu->add(
"/admin/translation.php?mainmenu=home", $langs->trans(
"Translation"), 1);
342 $this->menu->add(
"/admin/defaultvalues.php?mainmenu=home", $langs->trans(
"DefaultValues"), 1);
344 $this->menu->add(
"/admin/boxes.php?mainmenu=home", $langs->trans(
"Boxes"), 1);
345 $this->menu->add(
"/admin/delais.php?mainmenu=home", $langs->trans(
"Alerts"), 1);
346 $this->menu->add(
"/admin/proxy.php?mainmenu=home", $langs->trans(
"Security"), 1);
347 $this->menu->add(
"/admin/limits.php?mainmenu=home", $langs->trans(
"MenuLimits"), 1);
348 $this->menu->add(
"/admin/pdf.php?mainmenu=home", $langs->trans(
"PDF"), 1);
349 $this->menu->add(
"/admin/mails.php?mainmenu=home", $langs->trans(
"Emails"), 1);
350 $this->menu->add(
"/admin/sms.php?mainmenu=home", $langs->trans(
"SMS"), 1);
351 $this->menu->add(
"/admin/dict.php?mainmenu=home", $langs->trans(
"DictionarySetup"), 1);
352 $this->menu->add(
"/admin/const.php?mainmenu=home", $langs->trans(
"OtherSetup"), 1);
356 $menu_array_before = array();
357 $menu_array_after = array();
361 $menu_array = $this->menu->liste;
362 if (is_array($menu_array_before)) {
363 $menu_array = array_merge($menu_array_before, $menu_array);
365 if (is_array($menu_array_after)) {
366 $menu_array = array_merge($menu_array, $menu_array_after);
369 if (!is_array($menu_array)) {
373 '@phan-var-force array<array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}> $menu_array';
378 $blockvmenuopened =
false;
379 $num = count($menu_array);
380 foreach (array_keys($menu_array) as $i) {
382 if (empty($menu_array[$i][
'level'])) {
384 $blockvmenuopened =
true;
386 for ($j = ($i + 1); $j < $num; $j++) {
387 if (empty($menu_array[$j][
'level'])) {
393 if (($alt % 2 == 0)) {
394 print
'<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened ?
' blockvmenulast' :
'').($alt == 1 ?
' blockvmenufirst' :
'').
'">'.
"\n";
396 print
'<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened ?
' blockvmenulast' :
'').($alt == 1 ?
' blockvmenufirst' :
'').
'">'.
"\n";
402 $tabul = ($menu_array[$i][
'level'] - 1);
404 for ($j = 0; $j < $tabul; $j++) {
405 $tabstring .=
' ';
409 if ($menu_array[$i][
'level'] == 0) {
410 if ($menu_array[$i][
'enabled']) {
411 print
'<div class="menu_titre">'.$tabstring.
'<a class="vmenu" href="'.
dol_buildpath($menu_array[$i][
'url'], 1).
'"'.($menu_array[$i][
'target'] ?
' target="'.$menu_array[$i][
'target'].
'"' :
'').
'>'.$menu_array[$i][
'titre'].
'</a></div>'.
"\n";
413 print
'<div class="menu_titre">'.$tabstring.
'<span class="vmenudisabled">'.$menu_array[$i][
'titre'].
'</span></div>'.
"\n";
415 print
'<div class="menu_top"></div>'.
"\n";
418 if ($menu_array[$i][
'level'] > 0) {
420 if ($menu_array[$i][
'url']) {
421 $cssmenu =
' menu_contenu'.dol_string_nospecial(preg_replace(
'/\.php.*$/',
'', $menu_array[$i][
'url']));
424 print
'<div class="menu_contenu'.$cssmenu.
'">';
426 if ($menu_array[$i][
'enabled']) {
428 if ($menu_array[$i][
'url']) {
429 print
'<a class="vsmenu" itle="'.dol_escape_htmltag($menu_array[$i][
'titre']).
'" href="'.
dol_buildpath($menu_array[$i][
'url'], 1).
'"'.($menu_array[$i][
'target'] ?
' target="'.$menu_array[$i][
'target'].
'"' :
'').
'>';
431 print
'<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i][
'titre']).
'">';
433 if ($menu_array[$i][
'url']) {
434 print $menu_array[$i][
'titre'].
'</a>';
439 print $tabstring.
'<span class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i][
'titre'].
'</span>';
443 if (!strstr($menu_array[$i][
'titre'],
'<table')) {
450 if (empty($menu_array[$i + 1][
'level'])) {
451 print
'<div class="menu_end"></div>'.
"\n";
457 print
'<div class="blockvmenuend"></div>';
461 if ($mode ==
'jmobile') {
462 $this->leftmenu = clone $this->menu;
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...