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

This class manage menu. More...

Public Member Functions

 m_menu ()
 Constructor menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment. More...
 
 getmenu ()
 
 order_menu ($a, $b)
 
 system_menu ()
 

Detailed Description

This class manage menu.

Definition at line 32 of file m_menu.php.

Member Function Documentation

m_menu::getmenu ( )

Definition at line 42 of file m_menu.php.

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

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

Constructor menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment.

Definition at line 38 of file m_menu.php.

38  {
39 
40  }
m_menu::order_menu (   $a,
  $b 
)

Definition at line 105 of file m_menu.php.

105  {
106  // Use to order the menu with a usort
107  return $a['pos'] > $b['pos'];
108  }
m_menu::system_menu ( )

Definition at line 110 of file m_menu.php.

References $help_baseurl.

Referenced by getmenu().

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

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