get_menudiv.php 8.7 KB

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