dolibarr 21.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 (empty($dolibarr_nocache) && 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 ul li.lilevel2 {
134 padding-left: 40px; /* width = 20 for level0, 20 for level1 */
135 }
136
137 .getmenudiv a:hover {
138 text-decoration: none;
139 }
140
141 .pictofixedwidth {
142 text-align: left;
143 padding-right: 10px !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: 90px !important;
154 }
155 li.lilevel4 a {
156 padding-left: 120px !important;
157 }
158
159 a.alilevel0, span.spanlilevel0 {
160 background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
161 background-repeat: no-repeat !important;';
162if ($langs->trans("DIRECTION") == 'rtl') {
163 print 'background-position: right;';
164} else {
165 print 'background-position-x: 10px;';
166}
167print '
168 background-position-y: 18px;
169 padding: 1em 15px 1em 40px;
170 display: block;
171 }
172 li.lilevel0 font.vsmenudisabled {
173 background-repeat: no-repeat !important;
174 background-position-x: 10px;
175 background-position-y: 16px;
176 padding: 1em 15px 1em 40px;
177 background: #f8f8f8;
178 display: block;
179 font-size: 16px !important;
180 }
181 li.lilevel1 {
182 padding: 1em 15px 0.5em 40px;
183 border-top: 1px solid #aaa;
184 margin-right: 0px;
185 margin-left: 0px;
186 border-right: 0px ! important;
187 }
188 li.lilevel1:first-child {
189 margin-right: 0px;
190 margin-left: 0px;
191 }
192 li.lilevel1 a {
193 padding-bottom: 5px;
194 }
195 li.lilevel1 > a, li.lilevel1 > i {
196 /* background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/puce.png\') !important; */
197 background-repeat: no-repeat !important;';
198if ($langs->trans("DIRECTION") == 'rtl') {
199 print 'background-position: right;';
200} else {
201 print 'background-position-x: 10px;';
202}
203print 'background-position-y: 1px;';
204print 'padding-left: 20px;';
205print '
206 }
207 li.lilevel1 a, li.lilevel1 {
208 color: #000;
209 cursor: pointer;
210 display: block;
211 }
212 li.lilevel2 a {
213 padding: 0.7em 15px 0.7em 40px;
214 color: #000;
215 cursor: pointer;
216 display: block;
217 }
218 li.lilevel3 a {
219 padding: 0.6em 15px 0.6em 60px;
220 color: #000;
221 cursor: pointer;
222 display: block;
223 }
224 li.lilevel4 a {
225 padding: 0.2em 15px 8px 60px;
226 color: #000;
227 cursor: pointer;
228 display: block;
229 }
230 li.lilevel5 a {
231 padding: 0.2em 15px 0.2em 60px;
232 color: #000;
233 cursor: pointer;
234 display: block;
235 }
236 li.lilevel3:last-child {
237 padding-bottom: 10px;
238 }
239 a.alilevel0, li.lilevel1 a {
240 text-overflow: ellipsis;
241 overflow: hidden;
242 white-space: nowrap;
243 display: block;
244 }
245 .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
246 color: #aaa !important;
247 }
248</style>
249
250<script nonce="'.getNonce().'" type="text/javascript">
251$(document).ready(function(){
252 $("body ul").click(function(){
253 console.log("We click on body ul");
254
255 $(this).siblings().find("li ul").slideUp(0);
256
257 $(this).find("li ul").slideToggle(200);
258
259 var target = $(this);
260 $(\'html, body\').animate({
261 scrollTop: target.offset().top
262 }, 300);
263
264 })
265});
266</script>
267';
268
269
270if (empty($user->socid)) { // If internal user or not defined
271 $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);
272} else { // If external user
273 $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);
274}
275
276// Load the menu manager (only if not already done)
277$file_menu = $conf->standard_menu;
278if (GETPOST('menu', 'aZ09')) {
279 $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
280}
281if (!class_exists('MenuManager')) {
282 $menufound = 0;
283 $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
284 foreach ($dirmenus as $dirmenu) {
285 $menufound = dol_include_once($dirmenu."standard/".$file_menu);
286 if ($menufound) {
287 break;
288 }
289 }
290 if (!$menufound) { // If failed to include, we try with standard
291 dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
292 $file_menu = 'eldy_menu.php';
293 include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
294 }
295}
296// @phan-suppress-next-line PhanRedefinedClassReference
297$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
298// @phan-suppress-next-line PhanRedefinedClassReference
299$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
300//var_dump($menumanager);exit;
301// @phan-suppress-next-line PhanRedefinedClassReference
302$menumanager->showmenu('jmobile');
303
304print '</body>';
305
306print '</html>'."\n";
307
308$db->close();
Class to manage menu Auguria.
loadMenu($forcemainmenu='', $forceleftmenu='')
Load this->tabMenu.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79