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