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