get_menudiv.php 8.2 KB

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