PageRenderTime 58ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/asterix14/dolibarr
PHP | 233 lines | 141 code | 40 blank | 52 comment | 19 complexity | 0c7ab4978e49025a76bc7f6d80854080 MD5 | raw file
Possible License(s): LGPL-2.0
  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 2 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. var $db;
  27. var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler
  28. var $hideifnotallowed=false; // Put 0 for back office menu, 1 for front office menu
  29. var $atarget=""; // To store arget to use in menu links
  30. /**
  31. * Constructor
  32. *
  33. * @param DoliDB $DB Database handler
  34. */
  35. function MenuTop($db)
  36. {
  37. $this->db=$db;
  38. }
  39. /**
  40. * Show menu
  41. */
  42. function showmenu()
  43. {
  44. global $user,$conf,$langs,$dolibarr_main_db_name;;
  45. print_start_menu_array_empty();
  46. $idsel='home';
  47. $classname='class="tmenu"';
  48. print_start_menu_entry_empty($idsel);
  49. print '<a class="tmenuimage" href="'.dol_buildpath('/index.php',1).'?mainmenu=home&amp;leftmenu="'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
  50. print '<div class="mainmenu '.$idsel.'"><span class="mainmenu_'.$idsel.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>';
  51. print '</a>';
  52. print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.DOL_URL_ROOT.'"'.($this->atarget?' target="'.$this->atarget.'"':'').'>';
  53. print_text_menu_entry_empty($langs->trans("Home"));
  54. print '</a>';
  55. print_end_menu_entry_empty();
  56. print_end_menu_array_empty();
  57. }
  58. }
  59. function print_start_menu_array_empty()
  60. {
  61. global $conf;
  62. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<table class="tmenu" summary="topmenu"><tr class="tmenu">';
  63. else print '<ul class="tmenu">';
  64. }
  65. function print_start_menu_entry_empty($idsel)
  66. {
  67. global $conf;
  68. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '<td class="tmenu" id="mainmenutd_'.$idsel.'">';
  69. else print '<li class="tmenu" id="mainmenutd_'.$idsel.'">';
  70. }
  71. function print_text_menu_entry_empty($text)
  72. {
  73. global $conf;
  74. print '<span class="mainmenuaspan">';
  75. print $text;
  76. print '</span>';
  77. }
  78. function print_end_menu_entry_empty()
  79. {
  80. global $conf;
  81. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</td>';
  82. else print '</li>';
  83. print "\n";
  84. }
  85. function print_end_menu_array_empty()
  86. {
  87. global $conf;
  88. if (preg_match('/bluelagoon|eldy|freelug|rodolphe|yellow|dev/',$conf->css)) print '</tr></table>';
  89. else print '</ul>';
  90. print "\n";
  91. }
  92. /**
  93. * \class MenuLeft
  94. * \brief Class for left empty menu
  95. */
  96. class MenuLeft {
  97. var $db;
  98. var $menu_array;
  99. var $menu_array_after;
  100. /**
  101. * Constructor
  102. *
  103. * @param db Database handler
  104. * @param menu_array Table of menu entries to show before entries of menu handler
  105. * @param menu_array_after Table of menu entries to show after entries of menu handler
  106. */
  107. function MenuLeft($db,&$menu_array,&$menu_array_after)
  108. {
  109. $this->db=$db;
  110. $this->menu_array=$menu_array;
  111. $this->menu_array_after=$menu_array_after;
  112. }
  113. /**
  114. * Show menu
  115. */
  116. function showmenu()
  117. {
  118. global $user,$conf,$langs,$dolibarr_main_db_name;
  119. $newmenu = new Menu();
  120. // Put here left menu entries
  121. // ***** START *****
  122. $langs->load("admin"); // Load translation file admin.lang
  123. $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0);
  124. $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1);
  125. $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1);
  126. $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1);
  127. $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1);
  128. $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1);
  129. $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1);
  130. $newmenu->add("/admin/perms.php", $langs->trans("Security"),1);
  131. $newmenu->add("/admin/mails.php", $langs->trans("EMails"),1);
  132. $newmenu->add("/admin/limits.php", $langs->trans("Limits"),1);
  133. $newmenu->add("/admin/dict.php", $langs->trans("DictionnarySetup"),1);
  134. $newmenu->add("/admin/const.php", $langs->trans("OtherSetup"),1);
  135. // ***** END *****
  136. // do not change code after this
  137. // override menu_array by value array in $newmenu
  138. $this->menu_array=$newmenu->liste;
  139. $alt=0;
  140. $num=count($this->menu_array);
  141. for ($i = 0; $i < $num; $i++)
  142. {
  143. $alt++;
  144. if (empty($this->menu_array[$i]['level']))
  145. {
  146. if (($alt%2==0))
  147. {
  148. print '<div class="blockvmenuimpair">'."\n";
  149. }
  150. else
  151. {
  152. print '<div class="blockvmenupair">'."\n";
  153. }
  154. }
  155. // Place tabulation
  156. $tabstring='';
  157. $tabul=($this->menu_array[$i]['level'] - 1);
  158. if ($tabul > 0)
  159. {
  160. for ($j=0; $j < $tabul; $j++)
  161. {
  162. $tabstring.='&nbsp; &nbsp;';
  163. }
  164. }
  165. if ($this->menu_array[$i]['level'] == 0) {
  166. if ($this->menu_array[$i]['enabled'])
  167. {
  168. 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";
  169. }
  170. else
  171. {
  172. print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu_array[$i]['titre'].'</font></div>'."\n";
  173. }
  174. print '<div class="menu_top"></div>'."\n";
  175. }
  176. if ($this->menu_array[$i]['level'] > 0) {
  177. print '<div class="menu_contenu">';
  178. if ($this->menu_array[$i]['enabled'])
  179. print $tabstring.'<a class="vsmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'">'.$this->menu_array[$i]['titre'].'</a><br>';
  180. else
  181. print $tabstring.'<font class="vsmenudisabled">'.$this->menu_array[$i]['titre'].'</font><br>';
  182. print '</div>'."\n";
  183. }
  184. // If next is a new block or end
  185. if (empty($this->menu_array[$i+1]['level']))
  186. {
  187. print '<div class="menu_end"></div>'."\n";
  188. print "</div>\n";
  189. }
  190. }
  191. }
  192. }
  193. ?>