108 global $user,
$conf, $langs, $dolibarr_main_db_name;
112 require_once DOL_DOCUMENT_ROOT.
'/core/class/menu.class.php';
113 $this->menu =
new Menu();
115 $res =
'ErrorBadParameterForMode';
120 if ($mode ==
'topnb') {
124 if ($mode ==
'top') {
132 if ($mode !=
'jmobile' && $mode !=
'topnb' && $usemenuhider && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
134 $classname =
'class="tmenu menuhider nohover"';
137 $this->menu->add(
'#',
'', 0, $showmode, $this->atarget,
"xxx",
'', 0,
$id, $idsel, $classname);
142 $classname =
'class="tmenusel"';
145 $this->menu->add(
'/index.php', $langs->trans(
"Home"), 0, $showmode, $this->atarget,
'home',
'', 10,
$id, $idsel, $classname);
149 $this->menu->liste =
dol_sort_array($this->menu->liste,
'position');
152 foreach ($this->menu->liste as $menkey => $menuval) {
157 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));
175 if ($mode ==
'jmobile') {
176 $this->topmenu = clone $this->menu;
177 unset($this->menu->liste);
181 if ($mode ==
'jmobile') {
184 $classname =
'class="tmenusel"';
187 $this->menu->add(
'/index.php', $langs->trans(
"Home"), 0, $showmode, $this->atarget,
'home',
'', 10,
$id, $idsel, $classname);
193 $lastlevel = array();
195 print
'<!-- Generate menu list from menu handler '.$this->name.
' -->'.
"\n";
196 foreach ($this->menu->liste as $key => $val) {
197 print
'<ul class="ulmenu" data-inset="true">';
198 print
'<li class="lilevel0">';
202 if ($val[
'enabled'] == 1) {
204 $canonurl = preg_replace(
'/\?.*$/',
'', $val[
'url']);
206 print
'<a class="alilevel0" href="#">';
209 if ($val[
'level'] == 0 && $val[
'mainmenu'] ==
'home') {
210 print
'<span class="fas fa-home fa-fw paddingright" aria-hidden="true"></span>';
217 $tmpmainmenu = $val[
'mainmenu'];
218 $tmpleftmenu =
'all';
219 $submenu =
new Menu();
221 $langs->load(
"admin");
222 $submenu->add(
"/admin/index.php?leftmenu=setup", $langs->trans(
"Setup"), 0);
223 $submenu->add(
"/admin/company.php", $langs->trans(
"MenuCompanySetup"), 1);
224 $submenu->add(
"/admin/modules.php", $langs->trans(
"Modules"), 1);
225 $submenu->add(
"/admin/menus.php", $langs->trans(
"Menus"), 1);
226 $submenu->add(
"/admin/ihm.php", $langs->trans(
"GUISetup"), 1);
227 $submenu->add(
"/admin/translation.php?mainmenu=home", $langs->trans(
"Translation"), 1);
228 $submenu->add(
"/admin/defaultvalues.php?mainmenu=home", $langs->trans(
"DefaultValues"), 1);
230 $submenu->add(
"/admin/boxes.php?mainmenu=home", $langs->trans(
"Boxes"), 1);
231 $submenu->add(
"/admin/delais.php?mainmenu=home", $langs->trans(
"Alerts"), 1);
232 $submenu->add(
"/admin/proxy.php?mainmenu=home", $langs->trans(
"Security"), 1);
233 $submenu->add(
"/admin/limits.php?mainmenu=home", $langs->trans(
"MenuLimits"), 1);
234 $submenu->add(
"/admin/pdf.php?mainmenu=home", $langs->trans(
"PDF"), 1);
235 $submenu->add(
"/admin/mails.php?mainmenu=home", $langs->trans(
"Emails"), 1);
236 $submenu->add(
"/admin/sms.php?mainmenu=home", $langs->trans(
"SMS"), 1);
237 $submenu->add(
"/admin/dict.php?mainmenu=home", $langs->trans(
"DictionarySetup"), 1);
238 $submenu->add(
"/admin/const.php?mainmenu=home", $langs->trans(
"OtherSetup"), 1);
248 $canonrelurl = preg_replace(
'/\?.*$/',
'', $relurl);
249 $canonnexturl = preg_replace(
'/\?.*$/',
'', $nexturl);
252 if (($canonrelurl != $canonnexturl && !in_array($val[
'mainmenu'], array(
'tools')))
253 || (strpos($canonrelurl,
'/product/index.php') !==
false || strpos($canonrelurl,
'/compta/bank/list.php') !==
false)) {
255 print str_pad(
'', 1).
'<li class="lilevel1 ui-btn-icon-right ui-btn">';
256 print
'<a href="'.$relurl.
'">';
257 if ($langs->trans(ucfirst($val[
'mainmenu']).
"Dashboard") == ucfirst($val[
'mainmenu']).
"Dashboard") {
258 if (in_array($val[
'mainmenu'], array(
'cashdesk',
'websites'))) {
259 print $langs->trans(
"Access");
261 print $langs->trans(
"Dashboard");
264 print $langs->trans(ucfirst($val[
'mainmenu']).
"Dashboard");
270 if ($val[
'level'] == 0) {
271 if ($val[
'enabled']) {
272 $lastlevel[0] =
'enabled';
273 } elseif ($showmenu) {
274 $lastlevel[0] =
'greyed';
276 $lastlevel[0] =
'hidden';
280 $lastlevel2 = array();
281 foreach ($submenu->liste as $key2 => $val2) {
288 if ($val2[
'level'] > 0) {
289 $levelcursor = $val2[
'level'] - 1;
290 while ($levelcursor >= 0) {
292 if ($lastlevel2[$levelcursor] !=
'enabled') {
303 $canonurl2 = preg_replace(
'/\?.*$/',
'', $val2[
'url']);
305 if (in_array($canonurl2, array(
'/admin/index.php',
'/admin/tools/index.php',
'/core/tools.php'))) {
310 if (!$val2[
'enabled']) {
311 $disabled =
" vsmenudisabled";
315 print str_pad(
'', $val2[
'level'] + 1);
316 print
'<li class="lilevel'.($val2[
'level'] + 1);
317 if ($val2[
'level'] == 0) {
318 print
' ui-btn-icon-right ui-btn';
320 print $disabled.
'">';
322 if ($val2[
'enabled']) {
324 print
'<a href="'.$relurl2.
'">';
325 $lastlevel2[$val2[
'level']] =
'enabled';
328 print
'<a href="#" class="vsmenudisabled">';
329 $lastlevel2[$val2[
'level']] =
'greyed';
332 if ($val2[
'enabled']) {
333 $lastlevel2[$val2[
'level']] =
'enabled';
335 $lastlevel2[$val2[
'level']] =
'greyed';
338 print $val2[
'titre'];
347 if ($val[
'enabled'] == 2) {
348 print
'<span class="vsmenudisabled">'.$val[
'titre'].
'</span>';
355 if ($mode ==
'left') {
359 $langs->load(
"admin");
360 $this->menu->add(
"/admin/index.php?leftmenu=setup", $langs->trans(
"Setup"), 0);
361 $this->menu->add(
"/admin/company.php", $langs->trans(
"MenuCompanySetup"), 1);
362 $this->menu->add(
"/admin/modules.php", $langs->trans(
"Modules"), 1);
363 $this->menu->add(
"/admin/menus.php", $langs->trans(
"Menus"), 1);
364 $this->menu->add(
"/admin/ihm.php", $langs->trans(
"GUISetup"), 1);
365 $this->menu->add(
"/admin/translation.php?mainmenu=home", $langs->trans(
"Translation"), 1);
366 $this->menu->add(
"/admin/defaultvalues.php?mainmenu=home", $langs->trans(
"DefaultValues"), 1);
368 $this->menu->add(
"/admin/boxes.php?mainmenu=home", $langs->trans(
"Boxes"), 1);
369 $this->menu->add(
"/admin/delais.php?mainmenu=home", $langs->trans(
"Alerts"), 1);
370 $this->menu->add(
"/admin/proxy.php?mainmenu=home", $langs->trans(
"Security"), 1);
371 $this->menu->add(
"/admin/limits.php?mainmenu=home", $langs->trans(
"MenuLimits"), 1);
372 $this->menu->add(
"/admin/pdf.php?mainmenu=home", $langs->trans(
"PDF"), 1);
373 $this->menu->add(
"/admin/mails.php?mainmenu=home", $langs->trans(
"Emails"), 1);
374 $this->menu->add(
"/admin/sms.php?mainmenu=home", $langs->trans(
"SMS"), 1);
375 $this->menu->add(
"/admin/dict.php?mainmenu=home", $langs->trans(
"DictionarySetup"), 1);
376 $this->menu->add(
"/admin/const.php?mainmenu=home", $langs->trans(
"OtherSetup"), 1);
380 $menu_array_before = array();
381 $menu_array_after = array();
385 $menu_array = $this->menu->liste;
386 if (is_array($menu_array_before)) {
387 $menu_array = array_merge($menu_array_before, $menu_array);
389 if (is_array($menu_array_after)) {
390 $menu_array = array_merge($menu_array, $menu_array_after);
393 if (!is_array($menu_array)) {
397 '@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';
402 $blockvmenuopened =
false;
403 $num = count($menu_array);
404 foreach (array_keys($menu_array) as $i) {
406 if (empty($menu_array[$i][
'level'])) {
408 $blockvmenuopened =
true;
410 for ($j = ($i + 1); $j < $num; $j++) {
411 if (empty($menu_array[$j][
'level'])) {
417 if (($alt % 2 == 0)) {
418 print
'<div class="blockvmenub lockvmenuimpair blockvmenuunique'.($lastopened ?
' blockvmenulast' :
'').($alt == 1 ?
' blockvmenufirst' :
'').
'">'.
"\n";
420 print
'<div class="blockvmenu blockvmenupair blockvmenuunique'.($lastopened ?
' blockvmenulast' :
'').($alt == 1 ?
' blockvmenufirst' :
'').
'">'.
"\n";
426 $tabul = ($menu_array[$i][
'level'] - 1);
428 for ($j = 0; $j < $tabul; $j++) {
429 $tabstring .=
' ';
433 if ($menu_array[$i][
'level'] == 0) {
434 if ($menu_array[$i][
'enabled']) {
435 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";
437 print
'<div class="menu_titre">'.$tabstring.
'<span class="vmenudisabled">'.$menu_array[$i][
'titre'].
'</span></div>'.
"\n";
439 print
'<div class="menu_top"></div>'.
"\n";
442 if ($menu_array[$i][
'level'] > 0) {
444 if ($menu_array[$i][
'url']) {
445 $cssmenu =
' menu_contenu'.dol_string_nospecial(preg_replace(
'/\.php.*$/',
'', $menu_array[$i][
'url']));
448 print
'<div class="menu_contenu'.$cssmenu.
'">';
450 if ($menu_array[$i][
'enabled']) {
452 if ($menu_array[$i][
'url']) {
453 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'].
'"' :
'').
'>';
455 print
'<span class="vsmenu" title="'.dol_escape_htmltag($menu_array[$i][
'titre']).
'">';
457 if ($menu_array[$i][
'url']) {
458 print $menu_array[$i][
'titre'].
'</a>';
463 print $tabstring.
'<span class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i][
'titre'].
'</span>';
467 if (!strstr($menu_array[$i][
'titre'],
'<table')) {
474 if (empty($menu_array[$i + 1][
'level'])) {
475 print
'<div class="menu_end"></div>'.
"\n";
481 print
'<div class="blockvmenuend"></div>';
485 if ($mode ==
'jmobile') {
486 $this->leftmenu = clone $this->menu;
print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval=array())
Output menu entry.
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
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...