dolibarr 24.0.0-beta
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}
38//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
39if (!defined('NOREQUIREMENU')) {
40 define('NOREQUIREMENU', 1);
41}
42if (!defined('NOREQUIREHTML')) {
43 define('NOREQUIREHTML', 1);
44}
45if (!defined('NOBROWSERNOTIF')) {
46 define('NOBROWSERNOTIF', 1);
47}
48
49if (!defined('DISABLE_JQUERY_TABLEDND')) {
50 define('DISABLE_JQUERY_TABLEDND', 1);
51}
52if (!defined('DISABLE_JQUERY_JNOTIFY')) {
53 define('DISABLE_JQUERY_JNOTIFY', 1);
54}
55if (!defined('DISABLE_JQUERY_FLOT')) {
56 define('DISABLE_JQUERY_FLOT', 1);
57}
58if (!defined('DISABLE_JQUERY_JEDITABLE')) {
59 define('DISABLE_JQUERY_JEDITABLE', 1);
60}
61if (!defined('DISABLE_CKEDITOR')) {
62 define('DISABLE_CKEDITOR', 1);
63}
64if (!defined('DISABLE_DATE_PICKER')) {
65 define('DISABLE_DATE_PICKER', 1);
66}
67if (!defined('DISABLE_SELECT2')) {
68 define('DISABLE_SELECT2', 1);
69}
70
71require_once '../main.inc.php';
80if (GETPOST('lang', 'aZ09')) {
81 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
82}
83
84$langs->load("main");
85$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
86$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
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 /* Hide the non active LIs by default*/
119 body {
120 font-size: 16px;
121 }
122 body ul {
123 margin: 0;
124 padding-'.$left.': 0;
125 }
126 body ul li {
127 list-style: none;
128 }
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 {
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 background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
164 background-repeat: no-repeat !important;
165 background-position-y: 18px;';
166if ($langs->trans("DIRECTION") == 'rtl') {
167 print 'background-position: right;';
168 print 'padding: 1em 40px 1em 15px;';
169} else {
170 print 'background-position-x: 10px;';
171 print 'padding: 1em 15px 1em 40px;';
172}
173print '
174 display: block;
175 }
176 li.lilevel0 font.vsmenudisabled {
177 background-repeat: no-repeat !important;
178 background-position-x: 10px;
179 background-position-y: 16px;
180 padding: 1em 15px 1em 40px;
181 background: #f8f8f8;
182 display: block;
183 font-size: 16px !important;
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:first-child {
193 margin-right: 0px;
194 margin-left: 0px;
195 }
196 li.lilevel1 a {
197 padding-bottom: 5px;
198 }
199 li.lilevel1 > a, li.lilevel1 > i {
200 background-repeat: no-repeat !important;';
201if ($langs->trans("DIRECTION") == 'rtl') {
202 print 'background-position: right;';
203} else {
204 print 'background-position-x: 10px;';
205}
206print ' background-position-y: 1px;
207 padding-'.$left.': 20px;
208 }
209 li.lilevel1 a, li.lilevel1 {
210 color: #000;
211 cursor: pointer;
212 display: block;
213 }
214 .fa.fa-does-not-exists {
215 padding: 0px !important;
216 margin: 0px;
217 width: 0px;
218 }
219 li.lilevel2 a {
220 padding: 0.7em 15px 0.7em 40px;
221 color: #000;
222 cursor: pointer;
223 display: block;
224 }
225 li.lilevel3 a {
226 padding: 0.6em 15px 0.6em 60px;
227 color: #000;
228 cursor: pointer;
229 display: block;
230 }
231 li.lilevel4 a {
232 padding: 0.2em 15px 8px 60px;
233 color: #000;
234 cursor: pointer;
235 display: block;
236 }
237 li.lilevel5 a {
238 padding: 0.2em 15px 0.2em 60px;
239 color: #000;
240 cursor: pointer;
241 display: block;
242 }
243 li.lilevel3:last-child {
244 padding-bottom: 10px;
245 }
246 a.alilevel0, li.lilevel1 a {
247 text-overflow: ellipsis;
248 overflow: hidden;
249 white-space: nowrap;
250 display: block;
251 }
252 .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
253 color: #aaa !important;
254 }
255</style>
256
257<script nonce="'.getNonce().'" type="text/javascript">
258$(document).ready(function(){
259 $("body li").click(function(){
260 console.log("We click on a li");
261
262 $(this).siblings().find("ul").slideUp(0);
263
264 $(this).find("ul").slideToggle(200);
265
266 var target = $(this);
267 $(\'html, body\').animate({
268 scrollTop: target.offset().top
269 }, 300);
270
271 })
272});
273</script>
274';
275
276
277if (empty($user->socid)) { // If internal user or not defined
278 $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);
279} else { // If external user
280 $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);
281}
282
283// Load the menu manager (only if not already done)
284$file_menu = $conf->standard_menu;
285if (GETPOST('menu', 'aZ09')) {
286 $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
287}
288if (!class_exists('MenuManager')) {
289 $menufound = 0;
290 $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
291 foreach ($dirmenus as $dirmenu) {
292 $menufound = dol_include_once($dirmenu."standard/".dol_sanitizeFileName($file_menu));
293 if ($menufound) {
294 break;
295 }
296 }
297 if (!$menufound) { // If failed to include, we try with standard
298 dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
299 $file_menu = 'eldy_menu.php';
300 include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".dol_sanitizeFileName($file_menu);
301 }
302}
303// @phan-suppress-next-line PhanRedefinedClassReference
304$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
305// @phan-suppress-next-line PhanRedefinedClassReference
306$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
307
308// @phan-suppress-next-line PhanRedefinedClassReference
309$menumanager->showmenu('jmobile');
310
311print '</body>';
312
313print '</html>'."\n";
314
315$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:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_now($mode='gmt')
Return date for now.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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)
Return value of a param into GET or POST supervariable.
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.