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
87
88/*
89 * View
90 */
91
92// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
93if (GETPOSTINT('cache')) {
94 header('Cache-Control: max-age='.GETPOSTINT('cache').', public, must-revalidate');
95 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
96 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
97 // HTTP/1.0
98 header('Pragma: token=public');
99} else {
100 // HTTP/1.0
101 header('Cache-Control: no-cache');
102}
103
104$title = $langs->trans("Menu");
105
106// URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests
107$head = '<!-- Menu -->'."\n"; // This is used by DoliDroid to know page is a menu page
108$arrayofjs = array();
109$arrayofcss = array();
110top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
111
112print '<body class="getmenudiv">'."\n";
113
114// JavaScript to make menu active like Jmobile did.
115print '
116<style>
117 /* Hide the non active LIs by default*/
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 body ul ul {
129 display: none;
130 }
131
132 .getmenudiv a:hover {
133 text-decoration: none;
134 }
135
136 .ulmenu li.lilevel0 {
137 border-bottom: 1px solid #ccc;
138 }
139
140 .pictofixedwidth {
141 text-align: left;
142 padding-'.$right.': 8px !important;
143 }
144
145 li.lilevel1 > a, li.lilevel1 > i {
146 padding-'.$left.': 30px !important;
147 }
148 li.lilevel2 a {
149 padding-'.$left.': 60px !important;
150 }
151 li.lilevel3 a {
152 padding-'.$left.': 40px !important;
153 }
154 li.lilevel4 a {
155 padding-'.$left.': 0px !important;
156 }
157 li.lilevel5 a {
158 padding-'.$left.': 0px !important;
159 }
160
161 a.alilevel0, span.spanlilevel0 {
162 background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
163 background-repeat: no-repeat !important;
164 background-position-y: 18px;';
165if ($langs->trans("DIRECTION") == 'rtl') {
166 print 'background-position: right;';
167 print 'padding: 1em 40px 1em 15px;';
168} else {
169 print 'background-position-x: 10px;';
170 print 'padding: 1em 15px 1em 40px;';
171}
172print '
173 display: block;
174 }
175 li.lilevel0 font.vsmenudisabled {
176 background-repeat: no-repeat !important;
177 background-position-x: 10px;
178 background-position-y: 16px;
179 padding: 1em 15px 1em 40px;
180 background: #f8f8f8;
181 display: block;
182 font-size: 16px !important;
183 }
184 li.lilevel1 {
185 padding: 1em 15px 0.5em 40px;
186 border-top: 1px solid #aaa;
187 margin-right: 0px;
188 margin-left: 0px;
189 border-right: 0px ! important;
190 }
191 li.lilevel1:first-child {
192 margin-right: 0px;
193 margin-left: 0px;
194 }
195 li.lilevel1 a {
196 padding-bottom: 5px;
197 }
198 li.lilevel1 > a, li.lilevel1 > i {
199 background-repeat: no-repeat !important;';
200if ($langs->trans("DIRECTION") == 'rtl') {
201 print 'background-position: right;';
202} else {
203 print 'background-position-x: 10px;';
204}
205print ' background-position-y: 1px;
206 padding-'.$left.': 20px;
207 }
208 li.lilevel1 a, li.lilevel1 {
209 color: #000;
210 cursor: pointer;
211 display: block;
212 }
213 .fa.fa-does-not-exists {
214 padding: 0px !important;
215 margin: 0px;
216 width: 0px;
217 }
218 li.lilevel2 a {
219 padding: 0.7em 15px 0.7em 40px;
220 color: #000;
221 cursor: pointer;
222 display: block;
223 }
224 li.lilevel3 a {
225 padding: 0.6em 15px 0.6em 60px;
226 color: #000;
227 cursor: pointer;
228 display: block;
229 }
230 li.lilevel4 a {
231 padding: 0.2em 15px 8px 60px;
232 color: #000;
233 cursor: pointer;
234 display: block;
235 }
236 li.lilevel5 a {
237 padding: 0.2em 15px 0.2em 60px;
238 color: #000;
239 cursor: pointer;
240 display: block;
241 }
242 li.lilevel3:last-child {
243 padding-bottom: 10px;
244 }
245 a.alilevel0, li.lilevel1 a {
246 text-overflow: ellipsis;
247 overflow: hidden;
248 white-space: nowrap;
249 display: block;
250 }
251 .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
252 color: #aaa !important;
253 }
254</style>
255
256<script nonce="'.getNonce().'" type="text/javascript">
257$(document).ready(function(){
258 $("body li").click(function(){
259 console.log("We click on a li");
260
261 $(this).siblings().find("ul").slideUp(0);
262
263 $(this).find("ul").slideToggle(200);
264
265 var target = $(this);
266 $(\'html, body\').animate({
267 scrollTop: target.offset().top
268 }, 300);
269
270 })
271});
272</script>
273';
274
275
276if (empty($user->socid)) { // If internal user or not defined
277 $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);
278} else { // If external user
279 $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);
280}
281
282// Load the menu manager (only if not already done)
283$file_menu = $conf->standard_menu;
284if (GETPOST('menu', 'aZ09')) {
285 $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
286}
287if (!class_exists('MenuManager')) {
288 $menufound = 0;
289 $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
290 foreach ($dirmenus as $dirmenu) {
291 $menufound = dol_include_once($dirmenu."standard/".dol_sanitizeFileName($file_menu));
292 if ($menufound) {
293 break;
294 }
295 }
296 if (!$menufound) { // If failed to include, we try with standard
297 dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
298 $file_menu = 'eldy_menu.php';
299 include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".dol_sanitizeFileName($file_menu);
300 }
301}
302// @phan-suppress-next-line PhanRedefinedClassReference
303$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
304// @phan-suppress-next-line PhanRedefinedClassReference
305$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
306
307// @phan-suppress-next-line PhanRedefinedClassReference
308$menumanager->showmenu('jmobile');
309
310print '</body>';
311
312print '</html>'."\n";
313
314$db->close();
Class to manage menu Auguria.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
getNonce()
Return a random string to be used as a nonce value for js.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.