dolibarr 21.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 *
5 * This file is a modified version of datepicker.php from phpBSM to fix some
6 * bugs, to add new features and to dramatically increase speed.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
27//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
28//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
29//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
30//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
31if (!defined('NOCSRFCHECK')) {
32 define('NOCSRFCHECK', 1);
33}
34if (!defined('NOTOKENRENEWAL')) {
35 define('NOTOKENRENEWAL', 1);
36}
37//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
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';
71
72if (GETPOST('lang', 'aZ09')) {
73 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
74}
75
76$langs->load("main");
77$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
78$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
79
80
81/*
82 * View
83 */
84
85// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
86if (empty($dolibarr_nocache) && GETPOSTINT('cache')) {
87 header('Cache-Control: max-age='.GETPOSTINT('cache').', public, must-revalidate');
88 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
89 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
90 // HTTP/1.0
91 header('Pragma: token=public');
92} else {
93 // HTTP/1.0
94 header('Cache-Control: no-cache');
95}
96
97$title = $langs->trans("Menu");
98
99// URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests
100$head = '<!-- Menu -->'."\n"; // This is used by DoliDroid to know page is a menu page
101$arrayofjs = array();
102$arrayofcss = array();
103top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
104
105print '<body class="getmenudiv">'."\n";
106
107// JavaScript to make menu active like Jmobile did.
108print '
109<style>
110 /* Hide the non active LIs by default*/
111 body {
112 font-size: 16px;
113 }
114 body ul {
115 margin: 0;
116 padding-left: 0;
117 }
118 body ul li {
119 list-style: none;
120 }
121 body ul ul {
122 display: none;
123 }
124
125 ul li.lilevel2 {
126 padding-left: 40px; /* width = 20 for level0, 20 for level1 */
127 }
128
129 .getmenudiv a:hover {
130 text-decoration: none;
131 }
132
133 .pictofixedwidth {
134 text-align: left;
135 padding-right: 10px !important;
136 }
137
138 li.lilevel1 > a, li.lilevel1 > i {
139 padding-left: 30px !important;
140 }
141 li.lilevel2 a {
142 padding-left: 60px !important;
143 }
144 li.lilevel3 a {
145 padding-left: 90px !important;
146 }
147 li.lilevel4 a {
148 padding-left: 120px !important;
149 }
150
151 a.alilevel0, span.spanlilevel0 {
152 background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
153 background-repeat: no-repeat !important;';
154if ($langs->trans("DIRECTION") == 'rtl') {
155 print 'background-position: right;';
156} else {
157 print 'background-position-x: 10px;';
158}
159print '
160 background-position-y: 18px;
161 padding: 1em 15px 1em 40px;
162 display: block;
163 }
164 li.lilevel0 font.vsmenudisabled {
165 background-repeat: no-repeat !important;
166 background-position-x: 10px;
167 background-position-y: 16px;
168 padding: 1em 15px 1em 40px;
169 background: #f8f8f8;
170 display: block;
171 font-size: 16px !important;
172 }
173 li.lilevel1 {
174 padding: 1em 15px 0.5em 40px;
175 border-top: 1px solid #aaa;
176 margin-right: 0px;
177 margin-left: 0px;
178 border-right: 0px ! important;
179 }
180 li.lilevel1:first-child {
181 margin-right: 0px;
182 margin-left: 0px;
183 }
184 li.lilevel1 a {
185 padding-bottom: 5px;
186 }
187 li.lilevel1 > a, li.lilevel1 > i {
188 /* background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/puce.png\') !important; */
189 background-repeat: no-repeat !important;';
190if ($langs->trans("DIRECTION") == 'rtl') {
191 print 'background-position: right;';
192} else {
193 print 'background-position-x: 10px;';
194}
195print 'background-position-y: 1px;';
196print 'padding-left: 20px;';
197print '
198 }
199 li.lilevel1 a, li.lilevel1 {
200 color: #000;
201 cursor: pointer;
202 display: block;
203 }
204 li.lilevel2 a {
205 padding: 0.7em 15px 0.7em 40px;
206 color: #000;
207 cursor: pointer;
208 display: block;
209 }
210 li.lilevel3 a {
211 padding: 0.6em 15px 0.6em 60px;
212 color: #000;
213 cursor: pointer;
214 display: block;
215 }
216 li.lilevel4 a {
217 padding: 0.2em 15px 8px 60px;
218 color: #000;
219 cursor: pointer;
220 display: block;
221 }
222 li.lilevel5 a {
223 padding: 0.2em 15px 0.2em 60px;
224 color: #000;
225 cursor: pointer;
226 display: block;
227 }
228 li.lilevel3:last-child {
229 padding-bottom: 10px;
230 }
231 a.alilevel0, li.lilevel1 a {
232 text-overflow: ellipsis;
233 overflow: hidden;
234 white-space: nowrap;
235 display: block;
236 }
237 .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
238 color: #aaa !important;
239 }
240</style>
241
242<script nonce="'.getNonce().'" type="text/javascript">
243$(document).ready(function(){
244 $("body ul").click(function(){
245 console.log("We click on body ul");
246
247 $(this).siblings().find("li ul").slideUp(0);
248
249 $(this).find("li ul").slideToggle(200);
250
251 var target = $(this);
252 $(\'html, body\').animate({
253 scrollTop: target.offset().top
254 }, 300);
255
256 })
257});
258</script>
259';
260
261
262if (empty($user->socid)) { // If internal user or not defined
263 $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);
264} else { // If external user
265 $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);
266}
267
268// Load the menu manager (only if not already done)
269$file_menu = $conf->standard_menu;
270if (GETPOST('menu', 'aZ09')) {
271 $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
272}
273if (!class_exists('MenuManager')) {
274 $menufound = 0;
275 $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
276 foreach ($dirmenus as $dirmenu) {
277 $menufound = dol_include_once($dirmenu."standard/".$file_menu);
278 if ($menufound) {
279 break;
280 }
281 }
282 if (!$menufound) { // If failed to include, we try with standard
283 dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
284 $file_menu = 'eldy_menu.php';
285 include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
286 }
287}
288// @phan-suppress-next-line PhanRedefinedClassReference
289$menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
290// @phan-suppress-next-line PhanRedefinedClassReference
291$menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
292//var_dump($menumanager);exit;
293// @phan-suppress-next-line PhanRedefinedClassReference
294$menumanager->showmenu('jmobile');
295
296print '</body>';
297
298print '</html>'."\n";
299
300$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.