r1421 + testing the new tabhandler array
[racktables] / inc / navigation.php
CommitLineData
b325120a 1<?php
e673ee24
DO
2/*
3*
4* This file implements generic navigation for RackTables.
5*
6*/
7
83dd1b15
DO
8$page = array();
9$tab = array();
10$helptab = array();
11$trigger = array();
12$ophandler = array();
13
e673ee24
DO
14$page['index']['title'] = 'static_title';
15$page['index']['handler'] = 'renderIndex';
16
17$page['rackspace']['title'] = 'static_title';
18$page['rackspace']['handler'] = 'handler_rackspace';
19$page['rackspace']['parent'] = 'index';
20$tab['rackspace']['default'] = 'Browse';
21$tab['rackspace']['history'] = 'History';
9b0cf84f
DO
22$tab['rackspace']['firstrow'] = 'Click me!';
23$trigger['rackspace']['firstrow'] = 'trigger_emptyRackspace';
e673ee24
DO
24
25$page['objects']['title'] = 'static_title';
26$page['objects']['handler'] = 'handler_objects';
27$page['objects']['parent'] = 'index';
28$tab['objects']['default'] = 'View';
29$tab['objects']['newobj'] = 'Add an object';
30$tab['objects']['newmulti'] = 'Add multiple objects';
31
32$page['row']['title'] = 'dynamic_title_row';
33$page['row']['handler'] = 'handler_row';
34$page['row']['bypass'] = 'row_id';
35$page['row']['parent'] = 'rackspace';
36$tab['row']['default'] = 'View';
37$tab['row']['newrack'] = 'Add new rack';
38
39$page['rack']['title'] = 'dynamic_title_rack';
40$page['rack']['handler'] = 'handler_rack';
41$page['rack']['bypass'] = 'rack_id';
42$page['rack']['parent'] = 'row';
43$tab['rack']['default'] = 'View';
44$tab['rack']['edit'] = 'Properties';
45$tab['rack']['design'] = 'Design';
46$tab['rack']['problems'] = 'Problems';
beee6141
DO
47$helptab['rack']['design'] = 'rackspace';
48$helptab['rack']['problems'] = 'rackspace';
e673ee24
DO
49
50$page['objgroup']['title'] = 'dynamic_title_objgroup';
51$page['objgroup']['handler'] = 'handler_objgroup';
52$page['objgroup']['bypass'] = 'group_id';
53$page['objgroup']['parent'] = 'objects';
54
55$page['object']['title'] = 'dynamic_title_object';
e673ee24
DO
56$page['object']['bypass'] = 'object_id';
57$page['object']['parent'] = 'objgroup';
58$tab['object']['default'] = 'View';
59$tab['object']['edit'] = 'Properties';
60$tab['object']['rackspace'] = 'Rackspace';
61$tab['object']['ports'] = 'Ports';
62$tab['object']['network'] = 'IPv4';
737f9ac1 63$tab['object']['portfwrd'] = 'NATv4';
a684aa6f 64$tab['object']['switchvlans'] = 'Live VLANs';
9c67f713 65$tab['object']['snmpportfinder'] = 'SNMP port finder';
e45a78d7
DO
66$tabhandler['object']['default'] = 'renderRackObject';
67$tabhandler['object']['edit'] = 'renderEditObjectForm';
68$tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
69$tabhandler['object']['ports'] = 'renderPortsForObject';
70$tabhandler['object']['network'] = 'renderNetworkForObject';
71$tabhandler['object']['portfwrd'] = 'renderIPAddressPortForwarding';
72$tabhandler['object']['switchvlans'] = 'renderVLANMembership';
73$tabhandler['object']['snmpportfinder'] = 'renderSNMPPortFinder';
bdd05c5d 74$helptab['object']['network'] = 'nets';
150fdd66 75$helptab['object']['ports'] = 'ports';
bdd05c5d
DO
76$helptab['object']['portfwrd'] = 'nets';
77$helptab['object']['rackspace'] = 'rackspace';
641fe9b0 78$trigger['object']['switchvlans'] = 'trigger_switchvlans';
9c67f713 79$trigger['object']['snmpportfinder'] = 'trigger_snmpportfinder';
e673ee24
DO
80$ophandler['object']['ports']['addPort'] = 'addPortForObject';
81$ophandler['object']['ports']['delPort'] = 'delPortFromObject';
82$ophandler['object']['ports']['editPort'] = 'editPortForObject';
83$ophandler['object']['ports']['linkPort'] = 'linkPortForObject';
84$ophandler['object']['ports']['unlinkPort'] = 'unlinkPortForObject';
85$ophandler['object']['ports']['addMultiPorts'] = 'addMultiPorts';
86$ophandler['object']['ports']['useup'] = 'useupPort';
87$ophandler['object']['network']['editAddressFromObject'] = 'editAddressFromObject';
88$ophandler['object']['network']['addAddrFObj'] = 'addAddressToObject';
89$ophandler['object']['network']['delAddrFObj'] = 'delAddressFromObject';
90$ophandler['object']['edit']['del'] = 'resetAttrValue';
0dfb8a2a 91$ophandler['object']['edit']['upd'] = 'updateAttrValues';
e673ee24
DO
92$ophandler['object']['portfwrd']['forwardPorts'] = 'addPortForwarding';
93$ophandler['object']['portfwrd']['delPortForwarding'] = 'delPortForwarding';
94$ophandler['object']['portfwrd']['updPortForwarding'] = 'updPortForwarding';
641fe9b0 95$ophandler['object']['switchvlans']['submit'] = 'updateVLANMembership';
e673ee24
DO
96
97$page['ipv4space']['title'] = 'static_title';
98$page['ipv4space']['handler'] = 'handler_ipv4space';
99$page['ipv4space']['parent'] = 'index';
100$tab['ipv4space']['default'] = 'Browse';
101$tab['ipv4space']['newrange'] = 'Manage ranges';
bdd05c5d
DO
102$helptab['ipv4space']['default'] = 'nets';
103$helptab['ipv4space']['newrange'] = 'nets';
e673ee24
DO
104$ophandler['ipv4space']['newrange']['addRange'] = 'addNewrange';
105$ophandler['ipv4space']['newrange']['delRange'] = 'delRange';
106
107$page['iprange']['title'] = 'dynamic_title_iprange';
108$page['iprange']['handler'] = 'handler_iprange';
109$page['iprange']['parent'] = 'ipv4space';
110$page['iprange']['bypass'] = 'id';
111$tab['iprange']['default'] = 'Browse';
112$tab['iprange']['properties'] = 'Properties';
bdd05c5d
DO
113$helptab['iprange']['default'] = 'nets';
114$helptab['iprange']['properties'] = 'nets';
e673ee24
DO
115$ophandler['iprange']['properties']['editRange'] = 'editRange';
116
117$page['ipaddress']['title'] = 'dynamic_title_ipaddress';
118$page['ipaddress']['handler'] = 'handler_ipaddress';
119$page['ipaddress']['parent'] = 'iprange';
120$page['ipaddress']['bypass'] = 'ip';
121$tab['ipaddress']['default'] = 'Browse';
122$tab['ipaddress']['properties'] = 'Properties';
123$tab['ipaddress']['assignment'] = 'Allocation';
bdd05c5d
DO
124$helptab['ipaddress']['default'] = 'nets';
125$helptab['ipaddress']['properties'] = 'nets';
126$helptab['ipaddress']['assignment'] = 'nets';
e673ee24
DO
127$ophandler['ipaddress']['properties']['editAddress'] = 'editAddress';
128$ophandler['ipaddress']['assignment']['delIpAssignment'] = 'delIpAssignment';
129$ophandler['ipaddress']['assignment']['editBondForAddress'] = 'editIpAssignment';
130$ophandler['ipaddress']['assignment']['bindObjectToIp'] = 'addIpAssignment';
131
132$page['search']['title'] = 'dynamic_title_search';
133$page['search']['handler'] = 'handler_search';
134$page['search']['parent'] = 'index';
135$page['search']['bypass'] = 'q';
136
137$page['config']['title'] = 'static_title';
138$page['config']['handler'] = 'handler_config';
139$page['config']['parent'] = 'index';
140
141$page['accounts']['title'] = 'static_title';
142$page['accounts']['handler'] = 'handler_accounts';
143$page['accounts']['parent'] = 'config';
144$tab['accounts']['default'] = 'View';
145$tab['accounts']['edit'] = 'Change';
146$ophandler['accounts']['edit']['updateAccount'] = 'updateUserAccount';
147$ophandler['accounts']['edit']['createAccount'] = 'createUserAccount';
148$ophandler['accounts']['edit']['disableAccount'] = 'disableUserAccount';
149$ophandler['accounts']['edit']['enableAccount'] = 'enableUserAccount';
150
151$page['perms']['title'] = 'static_title';
152$page['perms']['handler'] = 'handler_perms';
153$page['perms']['parent'] = 'config';
154$tab['perms']['default'] = 'View';
155$tab['perms']['edit'] = 'Change';
156$ophandler['perms']['edit']['revoke'] = 'revokePermission';
157$ophandler['perms']['edit']['grant'] = 'grantPermission';
158
159$page['portmap']['title'] = 'static_title';
160$page['portmap']['handler'] = 'handler_portmap';
161$page['portmap']['parent'] = 'config';
162$tab['portmap']['default'] = 'View';
163$tab['portmap']['edit'] = 'Change';
164$ophandler['portmap']['edit']['save'] = 'savePortMap';
165
166$page['attrs']['title'] = 'static_title';
167$page['attrs']['handler'] = 'handler_attrs';
168$page['attrs']['parent'] = 'config';
169$tab['attrs']['default'] = 'View';
170$tab['attrs']['editattrs'] = 'Edit attributes';
171$tab['attrs']['editmap'] = 'Edit map';
172$ophandler['attrs']['editattrs']['add'] = 'createAttribute';
173$ophandler['attrs']['editattrs']['upd'] = 'changeAttribute';
174$ophandler['attrs']['editattrs']['del'] = 'deleteAttribute';
175$ophandler['attrs']['editmap']['add'] = 'supplementAttrMap';
176$ophandler['attrs']['editmap']['del'] = 'reduceAttrMap';
177
178$page['dict']['title'] = 'static_title';
179$page['dict']['handler'] = 'handler_dict';
180$page['dict']['parent'] = 'config';
181$tab['dict']['default'] = 'View';
182$tab['dict']['edit'] = 'Edit words';
183$tab['dict']['chapters'] = 'Manage chapters';
184$ophandler['dict']['edit']['del'] = 'reduceDictionary';
185$ophandler['dict']['edit']['upd'] = 'updateDictionary';
186$ophandler['dict']['edit']['add'] = 'supplementDictionary';
187$ophandler['dict']['chapters']['del'] = 'delChapter';
188$ophandler['dict']['chapters']['upd'] = 'updateChapter';
189$ophandler['dict']['chapters']['add'] = 'addChapter';
190
191$page['ui']['title'] = 'static_title';
192$page['ui']['handler'] = 'handler_ui';
193$page['ui']['parent'] = 'config';
0a1b1268 194$tab['ui']['default'] = 'View';
4fe32e78 195$tab['ui']['edit'] = 'Change';
b07f617c 196$tab['ui']['reset'] = 'Reset';
4fe32e78 197$ophandler['ui']['edit']['upd'] = 'updateUI';
b07f617c 198$ophandler['ui']['reset']['go'] = 'resetUIConfig';
e673ee24
DO
199
200$page['reports']['title'] = 'static_title';
201$page['reports']['handler'] = 'handler_reports';
202$page['reports']['parent'] = 'index';
203$tab['reports']['default'] = 'View';
204
ae545907
DO
205$page['help']['title'] = 'static_title';
206$page['help']['handler'] = 'handler_help';
207$page['help']['parent'] = 'index';
beee6141 208$tab['help']['default'] = 'Welcome';
51ef5041 209$tab['help']['quickstart'] = 'Quick start';
beee6141
DO
210$tab['help']['workflow'] = 'Workflow';
211$tab['help']['rackspace'] = 'Rackspace';
212$tab['help']['objects'] = 'Objects';
bdd05c5d 213$tab['help']['nets'] = 'Networking';
0a1b1268
DO
214$tab['help']['auth'] = '[ User accounts & permissions ]';
215$tab['help']['dict'] = '[ Dictionary ]';
beee6141 216$tab['help']['ports'] = 'Ports and links';
0a1b1268 217$tab['help']['hacking'] = '[ Hacker\'s guide ]';
ae545907 218
e673ee24
DO
219// This function returns array if page numbers leading to the target page
220// plus page number of target page itself. The first element is the target
221// page number and the last element is the index page number.
222function getPath ($targetno)
223{
224 global $page;
225 $path = array();
226 // Recursion breaks at first parentless page.
227 if (!isset ($page[$targetno]['parent']))
228 $path = array ($targetno);
229 else
230 {
231 $path = getPath ($page[$targetno]['parent']);
232 $path[] = $targetno;
233 }
234 return $path;
235}
236
237function showPathAndSearch ($pageno)
238{
9c0b0016 239 global $root, $page;
e673ee24 240 // Path.
73635d32 241 echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
e673ee24
DO
242 if (isset ($page[$pageno]['title']))
243 {
244 $path = getPath ($pageno);
245 foreach ($path as $dummy => $no)
246 {
247 $title = $page[$no]['title']($no);
248 echo ": <a href='${root}?page=${no}";
249 foreach ($title['params'] as $param_name => $param_value)
250 echo "&${param_name}=${param_value}";
251 echo "'>" .$title['name'] . "</a>";
252 }
253 }
254 echo "</td>";
255 // Search form.
256 echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
257 echo "<form method=get action='${root}'><td>";
258 echo '<input type=hidden name=page value=search>';
259 // This input will be the first, if we don't add ports or addresses.
260 echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
261}
262
263function getTitle ($pageno, $tabno)
264{
9c0b0016
DO
265 global $page;
266 if (!isset ($page[$pageno]['title']))
267 return getConfigVar ('enterprise');
268 $tmp = $page[$pageno]['title']($pageno);
269 return $tmp['name'];
e673ee24
DO
270}
271
272function showTabs ($pageno, $tabno)
273{
641fe9b0 274 global $tab, $root, $page, $remote_username, $trigger;
e673ee24
DO
275 if (!isset ($tab[$pageno]['default']))
276 return;
277 echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
278 foreach ($tab[$pageno] as $tabidx => $tabtitle)
279 {
280 // Hide forbidden tabs.
281 if (authorized ($remote_username, $pageno, $tabidx) == FALSE)
282 continue;
641fe9b0
DO
283 // Dynamic tabs should only be shown in certain cases (trigger exists and returns true).
284 if
285 (
286 isset ($trigger[$pageno][$tabidx]) &&
287 $trigger[$pageno][$tabidx] () != TRUE
288 )
289 continue;
e673ee24
DO
290 echo '<li><a' . (($tabidx == $tabno) ? ' class=current' : '');
291 echo " href='${root}?page=${pageno}&tab=${tabidx}";
292 if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
293 {
294 $bpname = $page[$pageno]['bypass'];
295 $bpval = $_REQUEST[$bpname];
296 echo "&${bpname}=${bpval}";
297 }
298 echo "'>${tabtitle}</a></li>\n";
299 }
ae9a3784 300 lookupHelpTopic ($pageno, $tabno);
e673ee24
DO
301 echo "</ul></div></td>\n";
302}
303
304// This function returns pages, which are direct children of the requested
305// page and are accessible by the current user.
306function getDirectChildPages ($pageno)
307{
308 global $page, $remote_username;
309 $children = array();
310 foreach ($page as $cpageno => $cpage)
311 if
312 (
313 isset ($cpage['parent']) and
314 $cpage['parent'] == $pageno and
315 authorized ($remote_username, $cpageno, 'default') == TRUE
316 )
317 $children[$cpageno] = $cpage;
318 return $children;
319}
320
321function getAllChildPages ($parent)
322{
323 global $page;
324 // Array pointer is global, so if we don't create local copies of
325 // the global array, we can't advance any more after nested call
326 // of getAllChildPages returns.
327 $mypage = $page;
328 $mykids = array();
329 foreach ($mypage as $ctitle => $cpage)
330 if (isset ($cpage['parent']) and $cpage['parent'] == $parent)
331 $mykids[] = array ('title' => $ctitle, 'kids' => getAllChildPages ($ctitle));
332 return $mykids;
333}
334
335?>