Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
m_menu Class Reference

This class manage the left menu of AlternC. More...

Public Member Functions

 getmenu ()
 get all menus to display, uses hooks More...
 
 order_menu ($a, $b)
 utilitary function used by usort() to order menus More...
 
 system_menu ()
 some menus that don't have an attached class More...
 

Detailed Description

This class manage the left menu of AlternC.

Definition at line 26 of file m_menu.php.

Member Function Documentation

m_menu::getmenu ( )

get all menus to display, uses hooks

Definition at line 32 of file m_menu.php.

References $hooks, $mem, s, and system_menu().

32  {
33  global $hooks, $quota, $mem;
34 
35  // Force rebuilding quota, in case of add or edit of the quota and cache not up-to-date
36  $mesq = $quota->getquota("", true); // rebuild quota
37  // Get menu objects
38  $lsto = $hooks->invoke('hook_menu');
39 
40  // Get system menu
41  $sm = $this->system_menu();
42 
43  // Merge it !
44  $lst = array_merge($sm, $lsto);
45 
46  // Sort it
47  uasort($lst, 'm_menu::order_menu');
48 
49  // Get user specific menu visibility options
50  $mop = $mem->session_tempo_params_get('menu_toggle');
51 
52  foreach ($lst as $k => $v) {
53 
54  if (empty($v)) {
55  unset($lst[$k]);
56  continue;
57  }
58 
59  // Set the javascript toggle link for menu asking for it
60  if ($v['link'] == 'toggle') {
61  $lst[$k]['link'] = 'javascript:menu_toggle(\'menu-' . $k . '\');';
62  }
63 
64  // Be sure that the default visibility is true
65  if (!isset($lst[$k]['visibility'])) {
66  $lst[$k]['visibility'] = true;
67  }
68 
69  // Set the user's specific visibility option
70  if (isset($mop["menu-$k"])) {
71  if ($mop["menu-$k"] == "hidden") {
72  $lst[$k]['visibility'] = false;
73  }
74  if ($mop["menu-$k"] == "visible") {
75  $lst[$k]['visibility'] = true;
76  }
77  }
78 
79  if (isset($mesq[$k])) { // if there are some quota for this class
80  // Hide the menu if there are none and not allowed to create
81  if ($mesq[$k]['t'] < 1 && $mesq[$k]['u'] < 1) {
82  unset($lst[$k]);
83  continue;
84  }
85 
86  // Set the quota in the menu object
87  $lst[$k]['quota_used'] = $mesq[$k]['u'];
88  $lst[$k]['quota_total'] = $mesq[$k]['t'];
89  } // end if there are some quota for this class
90  }
91 
92  return $lst;
93  }
$hooks
Definition: bootstrap.php:74
function s
system_menu()
some menus that don't have an attached class
Definition: m_menu.php:105
$mem
Definition: bootstrap.php:71
m_menu::order_menu (   $a,
  $b 
)

utilitary function used by usort() to order menus

Definition at line 98 of file m_menu.php.

98  {
99  return $a['pos'] > $b['pos'];
100  }
m_menu::system_menu ( )

some menus that don't have an attached class

Definition at line 105 of file m_menu.php.

References $help_baseurl.

Referenced by getmenu().

105  {
106  global $help_baseurl, $lang_translation, $locales;
107 
108  $m = array(
109  'home' =>
110  array(
111  'title' => _("Home / Information"),
112  'ico' => 'images/home.png',
113  'link' => 'main.php',
114  'pos' => 0,
115  ),
116  'logout' =>
117  array(
118  'title' => _("Logout"),
119  'ico' => 'images/exit.png',
120  'link' => 'mem_logout.php',
121  'pos' => 170,
122  ),
123  'help' =>
124  array(
125  'title' => _("Online help"),
126  'ico' => 'images/help.png',
127  'target' => 'help',
128  'link' => $help_baseurl,
129  'pos' => 140,
130  ),
131  'lang' =>
132  array(
133  'title' => _("Languages"),
134  'ico' => '/images/lang.png',
135  'visibility' => false,
136  'link' => 'toggle',
137  'links' => array(),
138  'pos' => 150,
139  )
140  );
141  foreach ($locales as $l) {
142  $m['lang']['links'][] = array('txt' => (isset($lang_translation[$l])) ? $lang_translation[$l] : $l, 'url' => "/login.php?setlang=$l");
143  }
144  return $m;
145  }
$help_baseurl
Definition: config.php:68

The documentation for this class was generated from the following file: