dolibarr  19.0.0-dev
get_menudiv.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2015 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
30 if (!defined('NOCSRFCHECK')) {
31  define('NOCSRFCHECK', 1);
32 }
33 if (!defined('NOTOKENRENEWAL')) {
34  define('NOTOKENRENEWAL', 1);
35 }
36 //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
37 if (!defined('NOREQUIREMENU')) {
38  define('NOREQUIREMENU', 1);
39 }
40 if (!defined('NOREQUIREHTML')) {
41  define('NOREQUIREHTML', 1);
42 }
43 if (!defined('NOBROWSERNOTIF')) {
44  define('NOBROWSERNOTIF', 1);
45 }
46 
47 if (!defined('DISABLE_JQUERY_TABLEDND')) {
48  define('DISABLE_JQUERY_TABLEDND', 1);
49 }
50 if (!defined('DISABLE_JQUERY_JNOTIFY')) {
51  define('DISABLE_JQUERY_JNOTIFY', 1);
52 }
53 if (!defined('DISABLE_JQUERY_FLOT')) {
54  define('DISABLE_JQUERY_FLOT', 1);
55 }
56 if (!defined('DISABLE_JQUERY_JEDITABLE')) {
57  define('DISABLE_JQUERY_JEDITABLE', 1);
58 }
59 if (!defined('DISABLE_CKEDITOR')) {
60  define('DISABLE_CKEDITOR', 1);
61 }
62 if (!defined('DISABLE_DATE_PICKER')) {
63  define('DISABLE_DATE_PICKER', 1);
64 }
65 if (!defined('DISABLE_SELECT2')) {
66  define('DISABLE_SELECT2', 1);
67 }
68 
69 require_once '../main.inc.php';
70 
71 if (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.
85 if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) {
86  header('Cache-Control: max-age='.GETPOST('cache', 'int').', 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') + GETPOST('cache', 'int')).' 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();
102 top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
103 
104 print '<body>'."\n";
105 
106 // Javascript to make menu active like Jmobile did.
107 print '
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: 42px;
126  }
127 
128  a.alilevel0, span.spanlilevel0 {
129  background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
130  background-repeat: no-repeat !important;';
131 if ($langs->trans("DIRECTION") == 'rtl') {
132  print 'background-position: right;';
133 } else {
134  print 'background-position-x: 10px;';
135 }
136  print '
137  background-position-y: 16px;
138  padding: 1em 15px 1em 40px;
139  display: block;
140  }
141  li.lilevel0 font.vsmenudisabled {
142  background-repeat: no-repeat !important;
143  background-position-x: 10px;
144  background-position-y: 16px;
145  padding: 1em 15px 1em 40px;
146  background: #f8f8f8;
147  display: block;
148  font-size: 16px !important;
149  }
150  li.lilevel1 {
151  padding: 1em 15px 0.5em 40px;
152  border-top: 1px solid #aaa;
153  margin-right: 0px;
154  margin-left: 0px;
155  border-right: 0px ! important;
156  }
157  li.lilevel1:first-child {
158  margin-right: 0px;
159  margin-left: 0px;
160  }
161  li.lilevel1 a {
162  padding-bottom: 5px;
163  }
164  li.lilevel1 > a, li.lilevel1 > i {
165  /* background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/puce.png\') !important; */
166  background-repeat: no-repeat !important;';
167 if ($langs->trans("DIRECTION") == 'rtl') {
168  print 'background-position: right;';
169 } else {
170  print 'background-position-x: 10px;';
171 }
172  print 'background-position-y: 1px;';
173  print 'padding-left: 20px;';
174  print '
175  }
176  li.lilevel1 a, li.lilevel1 {
177  color: #000;
178  cursor: pointer;
179  display: block;
180  }
181  li.lilevel2 a {
182  padding: 0.7em 15px 0.7em 40px;
183  color: #000;
184  cursor: pointer;
185  display: block;
186  }
187  li.lilevel3 a {
188  padding: 0.6em 15px 0.6em 60px;
189  color: #000;
190  cursor: pointer;
191  display: block;
192  }
193  li.lilevel4 a {
194  padding: 0.2em 15px 8px 60px;
195  color: #000;
196  cursor: pointer;
197  display: block;
198  }
199  li.lilevel5 a {
200  padding: 0.2em 15px 0.2em 60px;
201  color: #000;
202  cursor: pointer;
203  display: block;
204  }
205  li.lilevel3:last-child {
206  padding-bottom: 10px;
207  }
208  a.alilevel0, li.lilevel1 a {
209  text-overflow: ellipsis;
210  overflow: hidden;
211  white-space: nowrap;
212  display: block;
213  }
214  .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
215  color: #aaa !important;
216  }
217 </style>
218 
219 <script nonce="'.getNonce().'" type="text/javascript">
220 $(document).ready(function(){
221  $("body ul").click(function(){
222  console.log("We click on body ul");
223 
224  $(this).siblings().find("li ul").slideUp(0);
225 
226  $(this).find("li ul").slideToggle(200);
227 
228  var target = $(this);
229  $(\'html, body\').animate({
230  scrollTop: target.offset().top
231  }, 300);
232 
233  })
234 });
235 </script>
236 ';
237 
238 
239 if (empty($user->socid)) { // If internal user or not defined
240  $conf->standard_menu = (empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENU_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENU_STANDARD) : $conf->global->MAIN_MENU_STANDARD_FORCED);
241 } else // If external user
242 {
243  $conf->standard_menu = (empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? (empty($conf->global->MAIN_MENUFRONT_STANDARD) ? 'eldy_menu.php' : $conf->global->MAIN_MENUFRONT_STANDARD) : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED);
244 }
245 
246 // Load the menu manager (only if not already done)
247 $file_menu = $conf->standard_menu;
248 if (GETPOST('menu', 'aZ09')) {
249  $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
250 }
251 if (!class_exists('MenuManager')) {
252  $menufound = 0;
253  $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
254  foreach ($dirmenus as $dirmenu) {
255  $menufound = dol_include_once($dirmenu."standard/".$file_menu);
256  if ($menufound) {
257  break;
258  }
259  }
260  if (!$menufound) { // If failed to include, we try with standard
261  dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
262  $file_menu = 'eldy_menu.php';
263  include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
264  }
265 }
266 $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
267 $menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
268 //var_dump($menumanager);exit;
269 $menumanager->showmenu('jmobile');
270 
271 print '</body>';
272 
273 print '</html>'."\n";
274 
275 $db->close();
Class to manage menu Auguria.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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='', $arrayofcss='', $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Ouput html header of a page.
Definition: main.inc.php:1625