r2066 + employ origin highlighting more widely:
[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'=>$_REQUEST['id']));
21 break;
22 case 'ipaddress':
23 $range = getRangeByIp($_REQUEST['ip']);
24 return array
25 (
26 'name' => $range['ip'] . '/' . $range['mask'],
27 'params' => array
28 (
29 'id' => $range['id'],
30 'hl_ipv4_addr' => $_REQUEST['ip']
31 )
32 );
33 break;
34 default:
35 return NULL;
36 }
37 }
38
39 function dynamic_title_row ()
40 {
41 global $pageno;
42 $ret = array();
43 switch ($pageno)
44 {
45 case 'rack':
46 assertUIntArg ('rack_id', __FUNCTION__);
47 $rack = getRackData ($_REQUEST['rack_id']);
48 if ($rack == NULL)
49 {
50 showError ('getRackData() failed', __FUNCTION__);
51 return NULL;
52 }
53 $ret['name'] = $rack['row_name'];
54 $ret['params']['row_id'] = $rack['row_id'];
55 break;
56 case 'row':
57 assertUIntArg ('row_id', __FUNCTION__);
58 $rowInfo = getRackRowInfo ($_REQUEST['row_id']);
59 if ($rowInfo == NULL)
60 {
61 showError ('getRackRowInfo() failed', __FUNCTION__);
62 return NULL;
63 }
64 $ret['name'] = $rowInfo['name'];
65 $ret['params']['row_id'] = $_REQUEST['row_id'];
66 break;
67 default:
68 return NULL;
69 }
70 return $ret;
71 }
72
73 function dynamic_title_rack ()
74 {
75 $rack = getRackData ($_REQUEST['rack_id']);
76 return array ('name' => $rack['name'], 'params' => array ('rack_id' => $_REQUEST['rack_id']));
77 }
78
79 function dynamic_title_object ()
80 {
81 global $pageno;
82 $ret = array();
83 switch ($pageno)
84 {
85 case 'object':
86 assertUIntArg ('object_id', __FUNCTION__);
87 $object = getObjectInfo ($_REQUEST['object_id']);
88 if ($object == NULL)
89 {
90 showError ('getObjectInfo() failed', __FUNCTION__);
91 return NULL;
92 }
93 $ret['name'] = $object['dname'];
94 $ret['params']['object_id'] = $_REQUEST['object_id'];
95 break;
96 default:
97 return NULL;
98 }
99 return $ret;
100 }
101
102 function dynamic_title_vservice ()
103 {
104 global $pageno;
105 $ret = array();
106 switch ($pageno)
107 {
108 case 'ipv4vs':
109 assertUIntArg ('vs_id', __FUNCTION__);
110 $ret['name'] = buildVServiceName (getVServiceInfo ($_REQUEST['vs_id']));
111 $ret['params']['vs_id'] = $_REQUEST['vs_id'];
112 break;
113 default:
114 return NULL;
115 }
116 return $ret;
117 }
118
119 function dynamic_title_rspool ()
120 {
121 global $pageno;
122 $ret = array();
123 switch ($pageno)
124 {
125 case 'ipv4rsp':
126 assertUIntArg ('pool_id', __FUNCTION__);
127 $poolInfo = getRSPoolInfo ($_REQUEST['pool_id']);
128 $ret['name'] = empty ($poolInfo['name']) ? 'ANONYMOUS' : $poolInfo['name'];
129 $ret['params']['pool_id'] = $_REQUEST['pool_id'];
130 break;
131 default:
132 return NULL;
133 }
134 return $ret;
135 }
136
137 function dynamic_title_search ()
138 {
139 if (isset ($_REQUEST['q']))
140 {
141 $ret['name'] = "search results for '${_REQUEST['q']}'";
142 $ret['params']['q'] = $_REQUEST['q'];
143 }
144 else
145 {
146 $ret['name'] = "search results";
147 $ret['params'] = array();
148 }
149 return $ret;
150 }
151
152 function dynamic_title_objgroup ()
153 {
154 global $pageno;
155 $ret = array();
156 switch ($pageno)
157 {
158 case 'objgroup':
159 assertUIntArg ('group_id', __FUNCTION__, TRUE);
160 $group_id = $_REQUEST['group_id'];
161 $groupInfo = getObjectGroupInfo();
162 if ($groupInfo == NULL)
163 {
164 showError ('getObjectGroupInfo() failed', __FUNCTION__);
165 return NULL;
166 }
167 $ret['name'] = $groupInfo[$group_id]['name'];
168 $ret['params']['group_id'] = $group_id;
169 break;
170 case 'object':
171 assertUIntArg ('object_id', __FUNCTION__);
172 $objectInfo = getObjectInfo ($_REQUEST['object_id']);
173 if ($objectInfo == NULL)
174 {
175 showError ('getObjectInfo() failed', __FUNCTION__);
176 return NULL;
177 }
178 $ret['name'] = $objectInfo['objtype_name'];
179 $ret['params']['group_id'] = $objectInfo['objtype_id'];
180 break;
181 default:
182 return NULL;
183 }
184 return $ret;
185 }
186
187 function dynamic_title_user ()
188 {
189 global $accounts;
190 return array
191 (
192 'name' => "User '" . $accounts[getUsernameByID ($_REQUEST['user_id'])]['user_name'] . "'",
193 'params' => array ('user_id' => $_REQUEST['user_id'])
194 );
195 }
196
197 ?>