Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
m_menu.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2000-2012 by the AlternC Development Team.
6  https://alternc.org/
7  ----------------------------------------------------------------------
8  LICENSE
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License (GPL)
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  To read the license please visit http://www.gnu.org/copyleft/gpl.html
21  ----------------------------------------------------------------------
22  Purpose of file: Manage hook system.
23  ----------------------------------------------------------------------
24 */
25 
26 /**
27  * This class manage menu.
28  *
29  * @copyright AlternC-Team 2002-2005 http://alternc.org/
30  */
31 class m_menu {
32 
33  /*---------------------------------------------------------------------------*/
34  /** Constructor
35  * menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment
36  */
37  function m_menu() {
38  }
39 
40  function getmenu() {
41  global $hooks, $quota, $mem;
42 
43  // Force rebuilding quota, in case of add or edit of the quota and cache not up-to-date
44  $mesq = $quota->getquota("",true); // rebuild quota
45 
46  // Get menu objects
47  $lsto = $hooks->invoke('hook_menu');
48 
49  // Get system menu
50  $sm = $this->system_menu();
51 
52  // Merge it !
53  $lst = array_merge($sm,$lsto);
54 
55  // Sort it
56  uasort($lst, 'm_menu::order_menu');
57 
58  // Get user specific menu visibility options
59  $mop = $mem->session_tempo_params_get('menu_toggle') ;
60 
61  foreach( $lst as $k => $v ) {
62 
63  if (empty($v)) {
64  unset($lst[$k]);
65  continue;
66  }
67 
68  // Set the javascript toggle link for menu asking for it
69  if ($v['link'] == 'toggle') {
70  $lst[$k]['link'] = 'javascript:menu_toggle(\'menu-'.$k.'\');';
71  }
72 
73  // Be sure that the default visibility is true
74  if (! isset($lst[$k]['visibility'])) $lst[$k]['visibility'] = true;
75 
76  // Set the user's specific visibility option
77  if (isset($mop["menu-$k"])) {
78  if ($mop["menu-$k"] == "hidden") $lst[$k]['visibility'] = false;
79  if ($mop["menu-$k"] == "visible") $lst[$k]['visibility'] = true;
80  }
81 
82  if ( isset($mesq[$k])) { // if there are some quota for this class
83  // Hide the menu if there are none and not allowed to create
84  if ( $mesq[$k]['t'] < 1 && $mesq[$k]['u'] < 1 ) {
85  unset($lst[$k]);
86  continue;
87  }
88 
89  // Set the quota in the menu object
90  $lst[$k]['quota_used'] = $mesq[$k]['u'] ;
91  $lst[$k]['quota_total'] = $mesq[$k]['t'] ;
92 
93  } // end if there are some quota for this class
94 
95  }
96 
97  return $lst;
98  } //getmenu
99 
100  function order_menu($a, $b) {
101  // Use to order the menu with a usort
102  return $a['pos'] > $b['pos'];
103  }
104 
105  function system_menu() {
106  // Here some needed menu who don't have a class
107  global $help_baseurl, $lang_translation, $locales;
108 
109  $m =
110  array(
111  'home' =>
112  array(
113  'title' => _("Home / Information"),
114  'ico' => 'images/home.png',
115  'link' => 'main.php',
116  'pos' => 0,
117  ),
118  'logout' =>
119  array(
120  'title' => _("Logout"),
121  'ico' => 'images/exit.png',
122  'link' => 'mem_logout.php',
123  'pos' => 170,
124  ),
125  'help' =>
126  array(
127  'title' => _("Online help"),
128  'ico' => 'images/help.png',
129  'target' => 'help',
130  'link' => $help_baseurl,
131  'pos' => 140,
132  ),
133  'lang' =>
134  array(
135  'title' => _("Languages"),
136  'ico' => '/images/lang.png',
137  'visibility' => false,
138  'link' => 'toggle',
139  'links' => array(),
140  'pos' => 150,
141  )
142  ) ;
143  foreach($locales as $l) {
144  $m['lang']['links'][] = array ( 'txt' => (isset($lang_translation[$l]))?$lang_translation[$l]:$l, 'url' => "/login.php?setlang=$l");
145  }
146  return $m;
147 
148 
149 /*
150 
151 <div class="menu-box">
152  <a href="javascript:menu_toggle('menu-lang');">
153  <div class="menu-title">
154  <img src="/images/lang.png" alt="<?php __("Languages"); ?>" />&nbsp;<?php __("Languages"); ?>
155  <img src="/images/menu_moins.png" alt="" style="float:right;" id="menu-lang-img"/>
156  </div>
157  </a>
158  <div class="menu-content" id="menu-lang">
159  <ul>
160  <?php foreach($locales as $l) { ?>
161  <li><a href="/login.php?setlang=<?php echo $l; ?>" target="_top"><?php if (isset($lang_translation[$l])) echo $lang_translation[$l]; else echo $l; ?></a></li>
162  <?php } ?>
163  </ul>
164  </div>
165 </div>
166 
167 
168 
169 
170 
171 */
172  } //system_menu
173 
174 } /* Class menu */
175