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