PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/menus/standard/empty.php

https://bitbucket.org/speedealing/speedealing
PHP | 262 lines | 143 code | 37 blank | 82 comment | 19 complexity | 6beb64a1e3475f185cb193ae47b6c841 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/core/menus/standard/empty.php
  19. * \brief This is an example of an empty top menu handler
  20. */
  21. /**
  22. * \class MenuTop
  23. * \brief Class for top empty menu
  24. */
  25. class MenuTop
  26. {
  27. var $db;
  28. var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler
  29. var $hideifnotallowed=false; // Put 0 for back office menu, 1 for front office menu
  30. var $atarget=""; // To store arget to use in menu links
  31. /**
  32. * Constructor
  33. *
  34. * @param DoliDB $db Database handler
  35. */
  36. function __construct($db = '')
  37. {
  38. $this->db=$db;
  39. }
  40. /**
  41. * Show menu
  42. *
  43. * @return void
  44. */
  45. function showmenu()
  46. {
  47. global $user,$conf,$langs,$dolibarr_main_db_name;;
  48. print_start_menu_array_empty();
  49. $idsel='home';
  50. $classname='class="tmenu"';
  51. print_start_menu_entry_empty($idsel);
  52. print '<a class="tmenuimage" href="'.dol_buildpath('/index.php',1).'?mainmenu=home&amp;leftmenu="'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
  53. print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  54. print '</a>';
  55. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'"'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
  56. print_text_menu_entry_empty($langs->trans("Home"));
  57. print '</a>';
  58. print_end_menu_entry_empty();
  59. print_end_menu_array_empty();
  60. }
  61. }
  62. /**
  63. * Output menu entry
  64. *
  65. * @return void
  66. */
  67. function print_start_menu_array_empty()
  68. {
  69. global $conf;
  70. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
  71. else print '<ul class="tmenu">';
  72. }
  73. /**
  74. * Output start menu entry
  75. *
  76. * @param string $idsel Text
  77. * @return void
  78. */
  79. function print_start_menu_entry_empty($idsel)
  80. {
  81. global $conf;
  82. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<td class="tmenu" id="mainmenutd_'.$idsel.'">';
  83. else print '<li class="tmenu" id="mainmenutd_'.$idsel.'">';
  84. }
  85. /**
  86. * Output menu entry
  87. *
  88. * @param string $text Text
  89. * @return void
  90. */
  91. function print_text_menu_entry_empty($text)
  92. {
  93. global $conf;
  94. print '<span class="mainmenuaspan">';
  95. print $text;
  96. print '</span>';
  97. }
  98. /**
  99. * Output end menu entry
  100. *
  101. * @return void
  102. */
  103. function print_end_menu_entry_empty()
  104. {
  105. global $conf;
  106. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</td>';
  107. else print '</li>';
  108. print "\n";
  109. }
  110. /**
  111. * Output menu array
  112. *
  113. * @return void
  114. */
  115. function print_end_menu_array_empty()
  116. {
  117. global $conf;
  118. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</tr></table>';
  119. else print '</ul>';
  120. print "\n";
  121. }
  122. /**
  123. * Class for left empty menu
  124. */
  125. class MenuLeft
  126. {
  127. var $db;
  128. var $menu_array;
  129. var $menu_array_after;
  130. /**
  131. * Constructor
  132. *
  133. * @param DoliDB $db Database handler
  134. * @param array &$menu_array Table of menu entries to show before entries of menu handler
  135. * @param array &$menu_array_after Table of menu entries to show after entries of menu handler
  136. */
  137. function __construct($db,&$menu_array,&$menu_array_after)
  138. {
  139. $this->db=$db;
  140. $this->menu_array=$menu_array;
  141. $this->menu_array_after=$menu_array_after;
  142. }
  143. /**
  144. * Show menu
  145. *
  146. * @return void
  147. */
  148. function showmenu()
  149. {
  150. global $user,$conf,$langs,$dolibarr_main_db_name;
  151. $newmenu = new Menu();
  152. // Put here left menu entries
  153. // ***** START *****
  154. $langs->load("admin"); // Load translation file admin.lang
  155. $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0);
  156. $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1);
  157. $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1);
  158. $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1);
  159. $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1);
  160. $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1);
  161. $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1);
  162. $newmenu->add("/admin/perms.php", $langs->trans("Security"),1);
  163. $newmenu->add("/admin/mails.php", $langs->trans("EMails"),1);
  164. $newmenu->add("/admin/limits.php", $langs->trans("Limits"),1);
  165. $newmenu->add("/admin/dict.php", $langs->trans("DictionnarySetup"),1);
  166. $newmenu->add("/admin/const.php", $langs->trans("OtherSetup"),1);
  167. // ***** END *****
  168. // do not change code after this
  169. // override menu_array by value array in $newmenu
  170. $this->menu_array=$newmenu->liste;
  171. $alt=0;
  172. $num=count($this->menu_array);
  173. for ($i = 0; $i < $num; $i++)
  174. {
  175. $alt++;
  176. if (empty($this->menu_array[$i]['level']))
  177. {
  178. if (($alt%2==0))
  179. {
  180. print '<div class="blockvmenuimpair">'."\n";
  181. }
  182. else
  183. {
  184. print '<div class="blockvmenupair">'."\n";
  185. }
  186. }
  187. // Place tabulation
  188. $tabstring='';
  189. $tabul=($this->menu_array[$i]['level'] - 1);
  190. if ($tabul > 0)
  191. {
  192. for ($j=0; $j < $tabul; $j++)
  193. {
  194. $tabstring.='&nbsp; &nbsp;';
  195. }
  196. }
  197. if ($this->menu_array[$i]['level'] == 0) {
  198. if ($this->menu_array[$i]['enabled'])
  199. {
  200. print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'"'.($this->menu_array[$i]['target']?' target="'.$this->menu_array[$i]['target'].'"':'').'>'.$this->menu_array[$i]['titre'].'</a></div>'."\n";
  201. }
  202. else
  203. {
  204. print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu_array[$i]['titre'].'</font></div>'."\n";
  205. }
  206. print '<div class="menu_top"></div>'."\n";
  207. }
  208. if ($this->menu_array[$i]['level'] > 0) {
  209. print '<div class="menu_contenu">';
  210. if ($this->menu_array[$i]['enabled'])
  211. print $tabstring.'<a class="vsmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'">'.$this->menu_array[$i]['titre'].'</a><br>';
  212. else
  213. print $tabstring.'<font class="vsmenudisabled">'.$this->menu_array[$i]['titre'].'</font><br>';
  214. print '</div>'."\n";
  215. }
  216. // If next is a new block or end
  217. if (empty($this->menu_array[$i+1]['level']))
  218. {
  219. print '<div class="menu_end"></div>'."\n";
  220. print "</div>\n";
  221. }
  222. }
  223. }
  224. }
  225. ?>