get_menudiv.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/core/get_menudiv.php
  22. * \brief File to return menu into a div tree
  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')) define('NOCSRFCHECK',1);
  29. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
  30. //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
  31. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
  32. if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
  33. if (! defined('DISABLE_JQUERY_TABLEDND')) define('DISABLE_JQUERY_TABLEDND',1);
  34. if (! defined('DISABLE_JQUERY_TIPTIP')) define('DISABLE_JQUERY_TIPTIP',1);
  35. if (! defined('DISABLE_JQUERY_JNOTIFY')) define('DISABLE_JQUERY_JNOTIFY',1);
  36. if (! defined('DISABLE_JQUERY_FLOT')) define('DISABLE_JQUERY_FLOT',1);
  37. if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1);
  38. if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1);
  39. if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1);
  40. if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1);
  41. if (! defined('DISABLE_BROWSER_NOTIF')) define('DISABLE_BROWSER_NOTIF',1);
  42. if (! defined('DISABLE_DATE_PICKER')) define('DISABLE_DATE_PICKER',1);
  43. if (! defined('DISABLE_SELECT2')) define('DISABLE_SELECT2',1);
  44. require_once '../main.inc.php';
  45. $langs->load("main");
  46. $right=($langs->trans("DIRECTION")=='rtl'?'left':'right');
  47. $left=($langs->trans("DIRECTION")=='rtl'?'right':'left');
  48. /*
  49. * View
  50. */
  51. $title=$langs->trans("Menu");
  52. // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests
  53. $head='<!-- Menu -->'."\n";
  54. $arrayofjs=array();
  55. $arrayofcss=array();
  56. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  57. print '<body>'."\n";
  58. // Javascript to make menu active like Jmobile did.
  59. print '
  60. <style>
  61. /*Lets hide the non active LIs by default*/
  62. body {
  63. font-size: 16px;
  64. }
  65. body ul {
  66. margin: 0;
  67. padding-left: 0;
  68. }
  69. body ul li {
  70. list-style: none;
  71. }
  72. body ul ul {
  73. display: none;
  74. }
  75. a.alilevel0 {
  76. background-image: url(\''.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/next.png\') !important;
  77. background-repeat: no-repeat !important;
  78. background-position-x: 10px;
  79. background-position-y: 16px;
  80. padding: 1em 15px 1em 40px;
  81. }
  82. li.lilevel1 {
  83. padding: 1em 15px 0.5em 40px;
  84. border-top: 1px solid #aaa;
  85. margin-right: 20px;
  86. border-right: 0px ! important;
  87. }
  88. li.lilevel1:first-child {
  89. margin-right: 0px;
  90. margin-left: 0px;
  91. }
  92. li.lilevel1 a {
  93. padding-bottom: 5px;
  94. }
  95. li.lilevel1 a, li.lilevel1 {
  96. color: #000;
  97. cursor: pointer;
  98. display: block;
  99. }
  100. li.lilevel2 a {
  101. padding: 0 15px 0.5em 40px;
  102. color: #000;
  103. cursor: pointer;
  104. display: block;
  105. }
  106. li.lilevel3 a {
  107. padding: 0.2em 15px 8px 60px;
  108. color: #000;
  109. cursor: pointer;
  110. display: block;
  111. }
  112. li.lilevel3:last-child {
  113. padding-bottom: 10px;
  114. }
  115. a.alilevel0, li.lilevel1 a {
  116. text-overflow: ellipsis;
  117. overflow: hidden;
  118. white-space: nowrap;
  119. display: block;
  120. }
  121. </style>
  122. <script type="text/javascript">
  123. $(document).ready(function(){
  124. $("body ul").click(function(){
  125. console.log("We click on body ul");
  126. $(this).siblings().find("li ul").slideUp(0);
  127. $(this).find("li ul").slideToggle(200);
  128. target = $(this);
  129. $(\'html, body\').animate({
  130. scrollTop: target.offset().top
  131. }, 300);
  132. })
  133. });
  134. </script>
  135. ';
  136. if (empty($user->societe_id)) // If internal user or not defined
  137. {
  138. $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);
  139. }
  140. else // If external user
  141. {
  142. $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);
  143. }
  144. // Load the menu manager (only if not already done)
  145. $file_menu=$conf->standard_menu;
  146. if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php
  147. if (! class_exists('MenuManager'))
  148. {
  149. $menufound=0;
  150. $dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
  151. foreach($dirmenus as $dirmenu)
  152. {
  153. $menufound=dol_include_once($dirmenu."standard/".$file_menu);
  154. if ($menufound) break;
  155. }
  156. if (! $menufound) // If failed to include, we try with standard
  157. {
  158. dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
  159. $file_menu='eldy_menu.php';
  160. include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
  161. }
  162. }
  163. $menumanager = new MenuManager($db, empty($user->societe_id)?0:1);
  164. $menumanager->loadMenu('all','all');
  165. //var_dump($menumanager->tabMenu);exit;
  166. $menumanager->showmenu('jmobile');
  167. print '</body>';
  168. print '</html>'."\n";
  169. $db->close();