dolibarr 25.0.0-alpha
get_menudiv.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This file is a modified version of datepicker.php from phpBSM to fix some
7 * bugs, to add new features and to dramatically increase speed.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
29//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
30//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
31//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
32if (!defined('NOCSRFCHECK')) {
33 define('NOCSRFCHECK', 1);
34}
35if (!defined('NOTOKENRENEWAL')) {
36 define('NOTOKENRENEWAL', 1);
37}
38if (!defined('NOREQUIREMENU')) {
39 define('NOREQUIREMENU', 1);
40}
41if (!defined('NOREQUIREHTML')) {
42 define('NOREQUIREHTML', 1);
43}
44if (!defined('NOBROWSERNOTIF')) {
45 define('NOBROWSERNOTIF', 1);
46}
47
48if (!defined('DISABLE_JQUERY_TABLEDND')) {
49 define('DISABLE_JQUERY_TABLEDND', 1);
50}
51if (!defined('DISABLE_JQUERY_JNOTIFY')) {
52 define('DISABLE_JQUERY_JNOTIFY', 1);
53}
54if (!defined('DISABLE_JQUERY_FLOT')) {
55 define('DISABLE_JQUERY_FLOT', 1);
56}
57if (!defined('DISABLE_JQUERY_JEDITABLE')) {
58 define('DISABLE_JQUERY_JEDITABLE', 1);
59}
60if (!defined('DISABLE_CKEDITOR')) {
61 define('DISABLE_CKEDITOR', 1);
62}
63if (!defined('DISABLE_DATE_PICKER')) {
64 define('DISABLE_DATE_PICKER', 1);
65}
66if (!defined('DISABLE_SELECT2')) {
67 define('DISABLE_SELECT2', 1);
68}
69
70require_once '../main.inc.php';
79if (GETPOST('lang', 'aZ09')) {
80 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
81}
82
83$langs->load("main");
84$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
85$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
86$urlarrow = DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png';
87
88
89/*
90 * View
91 */
92
93// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
94if (GETPOSTINT('cache')) {
95 header('Cache-Control: max-age='.GETPOSTINT('cache').', public, must-revalidate');
96 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
97 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
98 // HTTP/1.0
99 header('Pragma: token=public');
100} else {
101 // HTTP/1.0
102 header('Cache-Control: no-cache');
103}
104
105$title = $langs->trans("Menu");
106
107// URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests
108$head = '<!-- Menu -->'."\n"; // This is used by DoliDroid to know page is a menu page
109$arrayofjs = array();
110$arrayofcss = array();
111top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
112
113print '<body class="getmenudiv">'."\n";
114
115// JavaScript to make menu active like Jmobile did.
116print '
117<style>
118 body {
119 font-size: 16px;
120 }
121 body ul {
122 margin: 0;
123 padding-'.$left.': 0;
124 }
125 body ul li {
126 list-style: none;
127 }
128 /* Hide the non active LIs by default */
129 body ul ul {
130 display: none;
131 }
132
133 .getmenudiv a:hover {
134 text-decoration: none;
135 }
136
137 .ulmenu li.lilevel0 {
138 border-bottom: 1px solid #ccc;
139 }
140
141 .pictofixedwidth {
142 text-align: left;
143 padding-'.$right.': 8px !important;
144 }
145
146 li.lilevel1 > a, li.lilevel1 > i, li.lilevel1 > span {
147 padding-'.$left.': 30px !important;
148 }
149 li.lilevel2 a {
150 padding-'.$left.': 60px !important;
151 }
152 li.lilevel3 a {
153 padding-'.$left.': 40px !important;
154 }
155 li.lilevel4 a {
156 padding-'.$left.': 0px !important;
157 }
158 li.lilevel5 a {
159 padding-'.$left.': 0px !important;
160 }
161
162 a.alilevel0, span.spanlilevel0 {
163 position: relative;
164 display: block;
165 padding-top: 1em;
166 padding-bottom: 1em;
167 padding-'.$left.': 40px;
168 padding-'.$right.': 15px;
169 }
170 /* Arrow of level 1 entries: points to the right when closed, to the bottom when open */
171 a.alilevel0::before, span.spanlilevel0::before {
172 content: "";
173 position: absolute;
174 top: 18px;
175 '.$left.': 10px;
176 width: 18px;
177 height: 18px;
178 background-image: url(\''.$urlarrow.'\');
179 background-repeat: no-repeat;
180 transition: transform 0.2s;
181 }
182 li.lilevel0.menuopen > a.alilevel0::before {
183 transform: rotate(90deg);
184 }
185 li.lilevel1 {
186 padding: 1em 15px 0.5em 40px;
187 border-top: 1px solid #aaa;
188 margin-right: 0px;
189 margin-left: 0px;
190 border-right: 0px ! important;
191 }
192 li.lilevel1 a, li.lilevel1 > span {
193 padding-bottom: 5px;
194 }
195 li.lilevel1 a, li.lilevel1 > span, li.lilevel1 {
196 color: #000;
197 cursor: pointer;
198 display: block;
199 }
200 .fa.fa-does-not-exists {
201 padding: 0px !important;
202 margin: 0px;
203 width: 0px;
204 }
205 li.lilevel2 a {
206 padding: 0.7em 15px 0.7em 40px;
207 color: #000;
208 cursor: pointer;
209 display: block;
210 }
211 li.lilevel3 a {
212 padding: 0.6em 15px 0.6em 60px;
213 color: #000;
214 cursor: pointer;
215 display: block;
216 }
217 li.lilevel4 a {
218 padding: 0.2em 15px 8px 60px;
219 color: #000;
220 cursor: pointer;
221 display: block;
222 }
223 li.lilevel5 a {
224 padding: 0.2em 15px 0.2em 60px;
225 color: #000;
226 cursor: pointer;
227 display: block;
228 }
229 li.lilevel3:last-child {
230 padding-bottom: 10px;
231 }
232 a.alilevel0, li.lilevel1 a, li.lilevel1 > span {
233 text-overflow: ellipsis;
234 overflow: hidden;
235 white-space: nowrap;
236 display: block;
237 }
238 .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
239 color: #aaa !important;
240 }
241</style>
242
243<script nonce="'.getNonce().'" type="text/javascript">
244$(document).ready(function(){
245 /* A click on a disabled (greyed) entry must do nothing (and not follow the link "#" that scrolls to top) */
246 $("a.vsmenudisabled").click(function(event){
247 event.preventDefault();
248 });
249
250 /* Only entries of level 1 (lilevel0) and level 2 (lilevel1) can be toggled */
251 $("li.lilevel0, li.lilevel1").click(function(event){
252 /* Ignore clicks coming from an entry of a submenu */
253 if ($(event.target).closest("li")[0] !== this) {
254 return;
255 }
256
257 console.log("We click on a li");
258
259 var target = $(this);
260 var childul = target.children("ul");
261
262 if (childul.length == 0) {
263 return;
264 }
265
266 /* The entry has a submenu: a click on it only toggles the submenu, the link of the entry is not followed */
267 event.preventDefault();
268
269 target.siblings().find("ul").slideUp(0);
270 target.siblings().removeClass("menuopen");
271
272 if (childul.is(":visible")) {
273 target.find("ul").slideUp(200);
274 target.removeClass("menuopen");
275 } else if (target.hasClass("lilevel0")) {
276 /* Click on level 1: show only the level 2, or all levels if there is only one entry of level 2 */
277 if (childul.children("li").length == 1) {
278 target.find("ul").slideDown(200);
279 } else {
280 target.find("ul ul").hide();
281 childul.slideDown(200);
282 }
283 target.addClass("menuopen");
284 } else {
285 /* Click on level 2: show all levels under it */
286 target.find("ul").slideDown(200);
287 }
288
289 $(\'html, body\').animate({
290 scrollTop: target.offset().top
291 }, 300);
292
293 })
294});
295</script>
296';
297
298
299if (empty($user->socid)) { // If internal user or not defined
300 $conf->standard_menu = (!getDolGlobalString('MAIN_MENU_STANDARD_FORCED') ? (!getDolGlobalString('MAIN_MENU_STANDARD') ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED);
301} else { // If external user
302 $conf->standard_menu = (!getDolGlobalString('MAIN_MENUFRONT_STANDARD_FORCED') ? (!getDolGlobalString('MAIN_MENUFRONT_STANDARD') ? 'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
303}
304
305// Load the menu manager (only if not already done)
306$file_menu = $conf->standard_menu;
307if (GETPOST('menu', 'aZ09')) {
308 $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
309}
310if (!class_exists('MenuManager')) {
311 $menufound = 0;
312 $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
313 foreach ($dirmenus as $dirmenu) {
314 $menufound = dol_include_once($dirmenu."standard/".dol_sanitizeFileName($file_menu));
315 if ($menufound) {
316 break;
317 }
318 }
319 if (!$menufound) { // If failed to include, we try with standard
320 dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
321 $file_menu = 'eldy_menu.php';
322 include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".dol_sanitizeFileName($file_menu);
323 }
324}
325// @phan-suppress-next-line PhanRedefinedClassReference
326$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
327// @phan-suppress-next-line PhanRedefinedClassReference
328$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
329
330// @phan-suppress-next-line PhanRedefinedClassReference
331$menumanager->showmenu('jmobile');
332
333print '</body>';
334
335print '</html>'."\n";
336
337$db->close();
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage menu Auguria.
dol_now($mode='gmt')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.