r1443 + make all functions use buildVServiceName()
[racktables] / inc / pagetitles.php
1 <?php
2 /*
3 *
4 * This file is a library of title generation functions for RackTables.
5 *
6 */
7
8 function dynamic_title_ipaddress ()
9 {
10 return array ('name' => $_REQUEST['ip'], 'params' => array ('ip' => $_REQUEST['ip']));
11 }
12
13 function dynamic_title_iprange ()
14 {
15 global $pageno;
16 switch ($pageno)
17 {
18 case 'iprange':
19 $range = getIPRange($_REQUEST['id']);
20 return array ('name' => $range['ip'].'/'.$range['mask'], 'params' => array('id'=>$_GET['id']));
21 break;
22 case 'ipaddress':
23 $range = getRangeByIp($_REQUEST['ip']);
24 return array ('name' => $range['ip'].'/'.$range['mask'], 'params' => array('id'=>$range['id']));
25 break;
26 default:
27 return NULL;
28 }
29 }
30
31 function dynamic_title_row ()
32 {
33 global $pageno;
34 $ret = array();
35 switch ($pageno)
36 {
37 case 'rack':
38 assertUIntArg ('rack_id');
39 $rack = getRackData ($_REQUEST['rack_id']);
40 if ($rack == NULL)
41 {
42 showError ('getRackData() failed in dynamic_title_row()');
43 return NULL;
44 }
45 $ret['name'] = $rack['row_name'];
46 $ret['params']['row_id'] = $rack['row_id'];
47 break;
48 case 'row':
49 assertUIntArg ('row_id');
50 $rowInfo = getRackRowInfo ($_REQUEST['row_id']);
51 if ($rowInfo == NULL)
52 {
53 showError ('getRackRowInfo() failed in dynamic_title_row()');
54 return NULL;
55 }
56 $ret['name'] = $rowInfo['dict_value'];
57 $ret['params']['row_id'] = $_REQUEST['row_id'];
58 break;
59 default:
60 return NULL;
61 }
62 return $ret;
63 }
64
65 function dynamic_title_rack ()
66 {
67 $rack = getRackData ($_GET['rack_id']);
68 return array ('name' => $rack['name'], 'params' => array ('rack_id' => $_GET['rack_id']));
69 }
70
71 function dynamic_title_object ()
72 {
73 global $pageno;
74 $ret = array();
75 switch ($pageno)
76 {
77 case 'object':
78 assertUIntArg ('object_id');
79 $object = getObjectInfo ($_REQUEST['object_id']);
80 if ($object == NULL)
81 {
82 showError ('getObjectInfo() failed in dynamic_title_object()');
83 return NULL;
84 }
85 $ret['name'] = $object['dname'];
86 $ret['params']['object_id'] = $_REQUEST['object_id'];
87 break;
88 default:
89 return NULL;
90 }
91 return $ret;
92 }
93
94 function dynamic_title_vservice ()
95 {
96 global $pageno;
97 $ret = array();
98 switch ($pageno)
99 {
100 case 'vservice':
101 assertUIntArg ('id');
102 $ret['name'] = buildVServiceName (getVServiceInfo ($_REQUEST['id']));
103 $ret['params']['id'] = $_REQUEST['id'];
104 break;
105 default:
106 return NULL;
107 }
108 return $ret;
109 }
110
111 function dynamic_title_search ()
112 {
113 if (isset ($_REQUEST['q']))
114 {
115 $ret['name'] = "search results for '${_REQUEST['q']}'";
116 $ret['params']['q'] = $_REQUEST['q'];
117 }
118 else
119 {
120 $ret['name'] = "search results";
121 $ret['params'] = array();
122 }
123 return $ret;
124 }
125
126 function dynamic_title_objgroup ()
127 {
128 global $pageno;
129 $ret = array();
130 switch ($pageno)
131 {
132 case 'objgroup':
133 assertUIntArg ('group_id');
134 $groupInfo = getObjectGroupInfo ($_REQUEST['group_id']);
135 if ($groupInfo == NULL)
136 {
137 showError ('getObjectGroupInfo() failed in dynamic_title_objgroup()');
138 return NULL;
139 }
140 $ret['name'] = $groupInfo['name'];
141 $ret['params']['group_id'] = $groupInfo['id'];
142 break;
143 case 'object':
144 assertUIntArg ('object_id');
145 $objectInfo = getObjectInfo ($_REQUEST['object_id']);
146 if ($objectInfo == NULL)
147 {
148 showError ('getObjectInfo() failed in dynamic_title_objgroup()');
149 return NULL;
150 }
151 $ret['name'] = $objectInfo['objtype_name'];
152 $ret['params']['group_id'] = $objectInfo['objtype_id'];
153 break;
154 default:
155 return NULL;
156 }
157 return $ret;
158 }
159
160 function static_title ($pageno)
161 {
162 $ret['params'] = array();
163 switch ($pageno)
164 {
165 case 'index':
166 $ret['name'] = 'Main page';
167 break;
168 case 'ipv4space':
169 $ret['name'] = 'IPv4 space';
170 break;
171 case 'rackspace':
172 $ret['name'] = 'Rackspace';
173 break;
174 case 'objects':
175 $ret['name'] = 'Objects';
176 break;
177 case 'perms':
178 $ret['name'] = 'Permissions';
179 break;
180 case 'config':
181 $ret['name'] = 'Configuration';
182 break;
183 case 'accounts':
184 $ret['name'] = 'Accounts';
185 break;
186 case 'portmap':
187 $ret['name'] = 'Port compatibility map';
188 break;
189 case 'attrs':
190 $ret['name'] = 'Attributes';
191 break;
192 case 'dict':
193 $ret['name'] = 'Dictionary';
194 break;
195 case 'ui':
196 $ret['name'] = 'User interface';
197 break;
198 case 'reports':
199 $ret['name'] = 'Reports';
200 break;
201 case 'help':
202 $ret['name'] = 'Help';
203 break;
204 default:
205 $ret['name'] = 'UNKNOWN';
206 break;
207 }
208 return $ret;
209 }
210
211 ?>