You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

photocopiesmenu.php 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. /* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007-2009 Regis Houssin <regis.houssin@capnetworks.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/core/menus/standard/eldy_menu.php
  20. * \brief Menu eldy manager
  21. */
  22. /**
  23. * Class to manage menu Eldy
  24. */
  25. class MenuManager
  26. {
  27. var $db;
  28. var $type_user; // Put 0 for internal users, 1 for external users
  29. var $atarget=""; // To store default target to use onto links
  30. var $name="eldy";
  31. var $menu_array;
  32. var $menu_array_after;
  33. var $tabMenu;
  34. /**
  35. * Constructor
  36. *
  37. * @param DoliDB $db Database handler
  38. * @param int $type_user Type of user
  39. */
  40. function __construct($db, $type_user)
  41. {
  42. $this->type_user=$type_user;
  43. $this->db=$db;
  44. }
  45. /**
  46. * Load this->tabMenu
  47. *
  48. * @param string $forcemainmenu To force mainmenu to load
  49. * @param string $forceleftmenu To force leftmenu to load
  50. * @return void
  51. */
  52. function loadMenu($forcemainmenu='',$forceleftmenu='')
  53. {
  54. // On sauve en session le menu principal choisi
  55. if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"];
  56. if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"];
  57. // Read mainmenu and leftmenu that define which menu to show
  58. if (isset($_GET["mainmenu"]))
  59. {
  60. // On sauve en session le menu principal choisi
  61. $mainmenu=$_GET["mainmenu"];
  62. $_SESSION["mainmenu"]=$mainmenu;
  63. $_SESSION["leftmenuopened"]="";
  64. }
  65. else
  66. {
  67. // On va le chercher en session si non defini par le lien
  68. $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
  69. }
  70. if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu;
  71. if (isset($_GET["leftmenu"]))
  72. {
  73. // On sauve en session le menu principal choisi
  74. $leftmenu=$_GET["leftmenu"];
  75. $_SESSION["leftmenu"]=$leftmenu;
  76. if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse
  77. {
  78. //$leftmenu="";
  79. $_SESSION["leftmenuopened"]="";
  80. }
  81. else
  82. {
  83. $_SESSION["leftmenuopened"]=$leftmenu;
  84. }
  85. } else {
  86. // On va le chercher en session si non defini par le lien
  87. $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:'';
  88. }
  89. if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu;
  90. require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
  91. $tabMenu=array();
  92. $menuArbo = new Menubase($this->db,'eldy');
  93. $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu);
  94. $this->tabMenu=$tabMenu;
  95. }
  96. /**
  97. * Show menu
  98. *
  99. * @param string $mode 'top', 'left', 'jmobile'
  100. * @return int Number of menu entries shown
  101. */
  102. function showmenu($mode)
  103. {
  104. global $conf, $langs, $user;
  105. require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
  106. if ($this->type_user == 1)
  107. {
  108. $conf->global->MAIN_SEARCHFORM_SOCIETE=0;
  109. $conf->global->MAIN_SEARCHFORM_CONTACT=0;
  110. }
  111. $res='ErrorBadParameterForMode';
  112. require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php';
  113. $this->menu=new Menu();
  114. if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0);
  115. if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0);
  116. if ($mode == 'jmobile')
  117. {
  118. $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1);
  119. print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n";
  120. foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
  121. {
  122. print '<ul class="ulmenu" data-role="listview" data-inset="true">';
  123. print '<li data-role="list-divider">';
  124. if ($val['enabled'] == 1)
  125. {
  126. $relurl=dol_buildpath($val['url'],1);
  127. $relurl=preg_replace('/__LOGIN__/',$user->login,$relurl);
  128. $relurl=preg_replace('/__USERID__/',$user->id,$relurl);
  129. print '<a href="#">'.$val['titre'].'</a>'."\n";
  130. // Search submenu fot this entry
  131. $tmpmainmenu=$val['mainmenu'];
  132. $tmpleftmenu='all';
  133. $submenu=new Menu();
  134. $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu);
  135. $nexturl=dol_buildpath($submenu->liste[0]['url'],1);
  136. $canonrelurl=preg_replace('/\?.*$/','',$relurl);
  137. $canonnexturl=preg_replace('/\?.*$/','',$nexturl);
  138. //var_dump($canonrelurl);
  139. //var_dump($canonnexturl);
  140. print '<ul>'."\n";
  141. if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools')))
  142. || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/index.php') !== false))
  143. {
  144. // We add sub entry
  145. print str_pad('',1).'<li data-role="list-divider" class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
  146. print '<a href="'.$relurl.'">';
  147. print str_pad('',12,'&nbsp;');
  148. print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
  149. print '</a>';
  150. print '</li>'."\n";
  151. }
  152. foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
  153. {
  154. $relurl2=dol_buildpath($val2['url'],1);
  155. $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2);
  156. $relurl2=preg_replace('/__USERID__/',$user->id,$relurl2);
  157. $canonurl2=preg_replace('/\?.*$/','',$val2['url']);
  158. //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']);
  159. if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2='';
  160. if ($val2['level']==0) print str_pad('',$val2['level']+1).'<li'.($val2['level']==0?' data-role="list-divider"':'').' class="lilevel'.($val2['level']+1).' ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
  161. else print str_pad('',$val2['level']+1).'<li class="lilevel'.($val2['level']+1).'">'; // ui-btn to highlight on clic
  162. if ($relurl2) print '<a href="'.$relurl2.'">';
  163. print str_pad('',($val2['level']+1)*12,'&nbsp;');
  164. print $val2['titre'];
  165. if ($relurl2) print '</a>';
  166. print '</li>'."\n";
  167. }
  168. //var_dump($submenu);
  169. print '</ul>';
  170. }
  171. if ($val['enabled'] == 2)
  172. {
  173. print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
  174. }
  175. print '</li>';
  176. print '</ul>'."\n";
  177. }
  178. }
  179. unset($this->menu);
  180. //print 'xx'.$mode;
  181. return $res;
  182. }
  183. }
  184. ?>