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