get_menudiv.php 7.0 KB

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