root/freepbx/branches/2.10/amp_conf/htdocs/admin/views/menu.php

Revision 12728, 6.2 kB (checked in by p_lindheimer, 2 years ago)

allows menu tabs with only a single module to be a direct link, removes User Panel link which will be replaced by a module

Line 
1 <?php
2 global $amp_conf;
3 global $_item_sort;
4
5 $out = '';
6 $out .= '<div id="header">';
7 $out .= '<div class="menubar ui-widget-header ui-corner-all">';
8 //left hand logo
9 $out .= '<img src="' . $amp_conf['BRAND_IMAGE_FREEPBX_LEFT']
10         . '" alt="FreePBX" title="FreePBX" id="BRAND_IMAGE_FREEPBX_LEFT" '
11         . 'data-BRAND_IMAGE_FREEPBX_LINK_LEFT="' . $amp_conf['BRAND_IMAGE_FREEPBX_LINK_LEFT'] . '"/ />';
12         
13 // If freepbx_menu.conf exists then use it to define/redefine categories
14 //
15 $fd = $amp_conf['ASTETCDIR'].'/freepbx_menu.conf';
16 if (file_exists($fd)) {
17   $favorites = parse_ini_file($fd,true);
18   if ($favorites !== false) foreach ($favorites as $menuitem => $setting) {
19     if (isset($fpbx_menu[$menuitem])) {
20       foreach($setting as $key => $value) {
21         switch ($key) {
22           case 'category':
23           case 'name':
24             $fpbx_menu[$menuitem][$key] = htmlspecialchars($value);
25           break;
26           case 'type':
27             // this is really deprecated but ???
28             if (strtolower($value)=='setup' || strtolower($value)=='tool') {
29               $fpbx_menu[$menuitem][$key] = strtolower($value);
30             }
31           break;
32           case 'sort':
33             if (is_numeric($value) && $value > -10 && $value < 10) {
34               $fpbx_menu[$menuitem][$key] = $value;
35             }
36           break;
37           case 'remove':
38             // parse_ini_file sets all forms of yes/true to 1 and no/false to nothing
39             if ($value == '1') {
40               unset($fpbx_menu[$menuitem]);
41             }
42           break;
43         }
44       }
45     }
46   }
47 }
48
49
50 // TODO: these categories are not localizable
51 //
52 if (isset($fpbx_menu) && is_array($fpbx_menu)) {    // && freepbx_menu.conf not defined
53     if (empty($favorites)) foreach ($fpbx_menu as $mod => $deets) {
54         switch(strtolower($deets['category'])) {
55             case 'admin':
56             case 'applications':
57             case 'connectivity':
58             case 'reports':
59             case 'settings':
60             case 'user panel':
61                 $menu[strtolower($deets['category'])][] = $deets;
62                 break;
63             default:
64                 $menu['other'][] = $deets;
65                 break;
66         }
67   } else {
68       foreach ($fpbx_menu as $mod => $deets) {
69             $menu[$deets['category']][] = $deets;
70         }
71   }
72     
73     $count = 0;
74     foreach($menu as $t => $cat) { //catagories
75     //TODO: this is broken, not getting translation from modules
76     //      see old code from freepbx_admin as to how to get it, requires a lot of hoops
77     //      first checking in the module owner's i18n, then in the core i18n
78     //
79
80     if (count($cat) == 1) {
81             if (isset($cat[0]['hidden']) && $cat[0]['hidden'] == 'true') {
82                 continue;
83             }
84       $href = isset($cat[0]['href']) ? $cat[0]['href'] : 'config.php?display=' . $cat[0]['display'];
85       $target = isset($cat[0]['target']) ? ' target="' . $cat[0]['target'] . '"'  : '';
86       $class = $cat[0]['display'] == $display ? 'class="ui-state-highlight"' : '';
87       $mods[$t] = '<a href="' . $href . '" ' . $target . $class . '>' . _(ucwords($t)) . '</a>';
88       continue;
89     }
90         $mods[$t] = '<a href="#">'
91                 . _(ucwords($t))
92                 . '</a><ul>';
93         foreach ($cat as $c => $mod) { //modules
94             if (isset($mod['hidden']) && $mod['hidden'] == 'true') {
95                 continue;
96             }
97             $classes = array();
98                 
99             //build defualt module url
100             $href = isset($mod['href'])
101                     ? $mod['href']
102                     : "config.php?display=" . $mod['display'];
103
104       $target = isset($mod['target'])
105           ? ' target="' . $cat[0]['target'] . '" '  : '';
106
107             //highlight currently in-use module
108             if ($display == $mod['display']) {
109                 $classes[] = 'ui-state-highlight';
110                 $classes[] = 'ui-corner-all';
111             }
112
113             //highlight disabled modules
114             if (isset($mod['disabled']) && $mod['disabled']) {
115                 $classes[] = 'ui-state-disabled';
116                 $classes[] = 'ui-corner-all';
117             }
118
119             $items[$mod['name']] = '<li><a href="' . $href . '"'
120           . $target
121                     . 'class="' . implode(' ', $classes) . '">'
122                     . _(ucwords($mod['name']))
123                     . '</a></li>';
124
125        $_item_sort[$mod['name']] = $mod['sort'];
126         }
127         uksort($items,'_item_sort');
128         $mods[$t] .= implode($items) . '</ul>';
129         unset($items);
130         unset($_item_sort);
131     }
132     uksort($mods,'_menu_sort');
133     $out .= implode($mods);
134 }
135 $out .= '<a id="language-menu-button" class="button-right ui-widget-content ui-state-default">' . _('Language') . '</a>';
136 $out .= '<ul id="fpbx_lang" style="display:none;">';
137     $out .= '<li data-lang="en_US"><a href="#">'. _('English') . '</a></li>';
138     $out .= '<li data-lang="bg_BG"><a href="#">' . _('Bulgarian') . '</a></li>';
139     $out .= '<li data-lang="zh_CN"><a href="#">' . _('Chinese') . '</a></li>';
140     $out .= '<li data-lang="de_DE"><a href="#">' . _('German') . '</a></li>';
141     $out .= '<li data-lang="fr_FR"><a href="#">' . _('French') . '</a></li>';
142     $out .= '<li data-lang="he_IL"><a href="#">' . _('Hebrew') . '</a></li>';
143     $out .= '<li data-lang="hu_HU"><a href="#">' . _('Hungarian') . '</a></li>';
144     $out .= '<li data-lang="it_IT"><a href="#">' . _('Italian') . '</a></li>';
145     $out .= '<li data-lang="pt_PT"><a href="#">' . _('Portuguese') . '</a></li>';
146     $out .= '<li data-lang="pt_BR"><a href="#">' . _('Portuguese (Brasil)') . '</a></li>';
147     $out .= '<li data-lang="ru_RU"><a href="#">' . _('Russian') . '</a></li>';
148     $out .= '<li data-lang="sv_SE"><a href="#">' . _('Swedish') . '</a></li>';
149     $out .= '<li data-lang="es_ES"><a href="#">' . _('Spanish') . '</a></li>';
150 $out .= '</ul>';
151
152 if ( isset($_SESSION['AMP_user']) && ($authtype != 'none')) {
153     $out .= '<a id="user_logout" href="#"'
154             . ' class="button-right ui-widget-content ui-state-default" title="logout">'
155             . _('Logout') . ': ' . (isset($_SESSION['AMP_user']->username) ? $_SESSION['AMP_user']->username : 'ERROR')
156             . '</a>';
157 }
158
159 $out .= '<a id="button_reload" href="#" data-button-icon-primary="ui-icon-gear" class="ui-state-error ">'
160         . _("Apply Config") .'</a>';
161
162 $out .= '</div>';
163 $out .= '</div>';//header
164 $out .= '<div id="page_body">';
165 echo $out;
166
167 // key sort but keep Favorites on the far left, Other on the far right
168 //
169 function _menu_sort($a, $b) {
170   if ($a == 'favorites')
171     return false;
172   else if ($b == 'favorites')
173     return true;
174   else if ($a == 'other')
175     return true;
176   else if ($b == 'other')
177     return false;
178   else
179     return $a > $b;
180 }
181
182 function _item_sort($a, $b) {
183   global $_item_sort;
184
185   if ($_item_sort[$a] != $_item_sort[$b])
186     return $_item_sort[$a] > $_item_sort[$b];
187   else
188     return $a > $b;
189 }
190 ?>
191
Note: See TracBrowser for help on using the browser.