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