get_menudiv.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. $title = $langs->trans("Menu");
  76. // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests
  77. $head = '<!-- Menu -->'."\n";
  78. $arrayofjs = array();
  79. $arrayofcss = array();
  80. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  81. print '<body>'."\n";
  82. // Javascript to make menu active like Jmobile did.
  83. print '
  84. <style>
  85. /*Lets hide the non active LIs by default*/
  86. body {
  87. font-size: 16px;
  88. }
  89. body ul {
  90. margin: 0;
  91. padding-left: 0;
  92. }
  93. body ul li {
  94. list-style: none;
  95. }
  96. body ul ul {
  97. display: none;
  98. }
  99. a.alilevel0 {
  100. background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important;
  101. background-repeat: no-repeat !important;
  102. background-position-x: 10px;
  103. background-position-y: 16px;
  104. padding: 1em 15px 1em 40px;
  105. }
  106. li.lilevel0 font.vsmenudisabled {
  107. background-repeat: no-repeat !important;
  108. background-position-x: 10px;
  109. background-position-y: 16px;
  110. padding: 1em 15px 1em 40px;
  111. background: #f8f8f8;
  112. display: block;
  113. font-size: 16px !important;
  114. }
  115. li.lilevel1 {
  116. padding: 1em 15px 0.5em 40px;
  117. border-top: 1px solid #aaa;
  118. margin-right: 0px;
  119. margin-left: 0px;
  120. border-right: 0px ! important;
  121. }
  122. li.lilevel1:first-child {
  123. margin-right: 0px;
  124. margin-left: 0px;
  125. }
  126. li.lilevel1 a {
  127. padding-bottom: 5px;
  128. }
  129. li.lilevel1 a, li.lilevel1 {
  130. color: #000;
  131. cursor: pointer;
  132. display: block;
  133. }
  134. li.lilevel2 a {
  135. padding: 0.7em 15px 0.7em 40px;
  136. color: #000;
  137. cursor: pointer;
  138. display: block;
  139. }
  140. li.lilevel3 a {
  141. padding: 0.6em 15px 0.6em 60px;
  142. color: #000;
  143. cursor: pointer;
  144. display: block;
  145. }
  146. li.lilevel4 a {
  147. padding: 0.2em 15px 8px 60px;
  148. color: #000;
  149. cursor: pointer;
  150. display: block;
  151. }
  152. li.lilevel5 a {
  153. padding: 0.2em 15px 0.2em 60px;
  154. color: #000;
  155. cursor: pointer;
  156. display: block;
  157. }
  158. li.lilevel3:last-child {
  159. padding-bottom: 10px;
  160. }
  161. a.alilevel0, li.lilevel1 a {
  162. text-overflow: ellipsis;
  163. overflow: hidden;
  164. white-space: nowrap;
  165. display: block;
  166. }
  167. .vsmenudisabled .fa, .vsmenudisabled .fas, .vsmenudisabled .far {
  168. color: #aaa !important;
  169. }
  170. </style>
  171. <script type="text/javascript">
  172. $(document).ready(function(){
  173. $("body ul").click(function(){
  174. console.log("We click on body ul");
  175. $(this).siblings().find("li ul").slideUp(0);
  176. $(this).find("li ul").slideToggle(200);
  177. target = $(this);
  178. $(\'html, body\').animate({
  179. scrollTop: target.offset().top
  180. }, 300);
  181. })
  182. });
  183. </script>
  184. ';
  185. if (empty($user->socid)) { // If internal user or not defined
  186. $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);
  187. } else // If external user
  188. {
  189. $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);
  190. }
  191. // Load the menu manager (only if not already done)
  192. $file_menu = $conf->standard_menu;
  193. if (GETPOST('menu', 'aZ09')) {
  194. $file_menu = GETPOST('menu', 'aZ09'); // example: menu=eldy_menu.php
  195. }
  196. if (!class_exists('MenuManager')) {
  197. $menufound = 0;
  198. $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
  199. foreach ($dirmenus as $dirmenu) {
  200. $menufound = dol_include_once($dirmenu."standard/".$file_menu);
  201. if ($menufound) {
  202. break;
  203. }
  204. }
  205. if (!$menufound) { // If failed to include, we try with standard
  206. dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
  207. $file_menu = 'eldy_menu.php';
  208. include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
  209. }
  210. }
  211. $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1);
  212. $menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries
  213. //var_dump($menumanager);exit;
  214. $menumanager->showmenu('jmobile');
  215. print '</body>';
  216. print '</html>'."\n";
  217. $db->close();