get_menudiv.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. /**
  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>'."\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. a.alilevel0, span.spanlilevel0 {
  111. background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
  112. background-repeat: no-repeat !important;
  113. background-position-x: 10px;
  114. background-position-y: 16px;
  115. padding: 1em 15px 1em 40px;
  116. display: block;
  117. }
  118. li.lilevel0 font.vsmenudisabled {
  119. background-repeat: no-repeat !important;
  120. background-position-x: 10px;
  121. background-position-y: 16px;
  122. padding: 1em 15px 1em 40px;
  123. background: #f8f8f8;
  124. display: block;
  125. font-size: 16px !important;
  126. }
  127. li.lilevel1 {
  128. padding: 1em 15px 0.5em 40px;
  129. border-top: 1px solid #aaa;
  130. margin-right: 0px;
  131. margin-left: 0px;
  132. border-right: 0px ! important;
  133. }
  134. li.lilevel1:first-child {
  135. margin-right: 0px;
  136. margin-left: 0px;
  137. }
  138. li.lilevel1 a {
  139. padding-bottom: 5px;
  140. }
  141. li.lilevel1 a, li.lilevel1 {
  142. color: #000;
  143. cursor: pointer;
  144. display: block;
  145. }
  146. li.lilevel2 a {
  147. padding: 0.7em 15px 0.7em 40px;
  148. color: #000;
  149. cursor: pointer;
  150. display: block;
  151. }
  152. li.lilevel3 a {
  153. padding: 0.6em 15px 0.6em 60px;
  154. color: #000;
  155. cursor: pointer;
  156. display: block;
  157. }
  158. li.lilevel4 a {
  159. padding: 0.2em 15px 8px 60px;
  160. color: #000;
  161. cursor: pointer;
  162. display: block;
  163. }
  164. li.lilevel5 a {
  165. padding: 0.2em 15px 0.2em 60px;
  166. color: #000;
  167. cursor: pointer;
  168. display: block;
  169. }
  170. li.lilevel3:last-child {
  171. padding-bottom: 10px;
  172. }
  173. a.alilevel0, li.lilevel1 a {
  174. text-overflow: ellipsis;
  175. overflow: hidden;
  176. white-space: nowrap;
  177. display: block;
  178. }
  179. .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
  180. color: #aaa !important;
  181. }
  182. </style>
  183. <script type="text/javascript">
  184. $(document).ready(function(){
  185. $("body ul").click(function(){
  186. console.log("We click on body ul");
  187. $(this).siblings().find("li ul").slideUp(0);
  188. $(this).find("li ul").slideToggle(200);
  189. target = $(this);
  190. $(\'html, body\').animate({
  191. scrollTop: target.offset().top
  192. }, 300);
  193. })
  194. });
  195. </script>
  196. ';
  197. if (empty($user->socid)) { // If internal user or not defined
  198. $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);
  199. } else // If external user
  200. {
  201. $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);
  202. }
  203. // Load the menu manager (only if not already done)
  204. $file_menu = $conf->standard_menu;
  205. if (GETPOST('menu', 'aZ09')) {
  206. $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
  207. }
  208. if (!class_exists('MenuManager')) {
  209. $menufound = 0;
  210. $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
  211. foreach ($dirmenus as $dirmenu) {
  212. $menufound = dol_include_once($dirmenu."standard/".$file_menu);
  213. if ($menufound) {
  214. break;
  215. }
  216. }
  217. if (!$menufound) { // If failed to include, we try with standard
  218. dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
  219. $file_menu = 'eldy_menu.php';
  220. include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
  221. }
  222. }
  223. $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
  224. $menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
  225. //var_dump($menumanager);exit;
  226. $menumanager->showmenu('jmobile');
  227. print '</body>';
  228. print '</html>'."\n";
  229. $db->close();