Alternc  latest
Alternc logiel libre pour l'hébergement
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

◆ getmenu()

m_menu::getmenu ( )

get all menus to display, uses hooks

Definition at line 32 of file m_menu.php.

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
$mem
Definition: bootstrap.php:71
system_menu()
some menus that don't have an attached class
Definition: m_menu.php:105

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

◆ order_menu()

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  }

◆ system_menu()

m_menu::system_menu ( )

some menus that don't have an attached class

Definition at line 105 of file m_menu.php.

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

References $help_baseurl.

Referenced by getmenu().


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