r2066 + employ origin highlighting more widely:
[racktables] / inc / pagetitles.php
CommitLineData
b325120a 1<?php
e673ee24
DO
2/*
3*
4* This file is a library of title generation functions for RackTables.
5*
6*/
7
8function dynamic_title_ipaddress ()
9{
10 return array ('name' => $_REQUEST['ip'], 'params' => array ('ip' => $_REQUEST['ip']));
11}
12
13function dynamic_title_iprange ()
14{
15 global $pageno;
16 switch ($pageno)
17 {
18 case 'iprange':
19 $range = getIPRange($_REQUEST['id']);
3cc24579 20 return array ('name' => $range['ip'].'/'.$range['mask'], 'params' => array('id'=>$_REQUEST['id']));
e673ee24
DO
21 break;
22 case 'ipaddress':
23 $range = getRangeByIp($_REQUEST['ip']);
8e700dd1
DO
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 );
e673ee24
DO
33 break;
34 default:
35 return NULL;
36 }
37}
38
39function dynamic_title_row ()
40{
41 global $pageno;
42 $ret = array();
43 switch ($pageno)
44 {
45 case 'rack':
2c6c7645 46 assertUIntArg ('rack_id', __FUNCTION__);
e673ee24
DO
47 $rack = getRackData ($_REQUEST['rack_id']);
48 if ($rack == NULL)
49 {
61e269b5 50 showError ('getRackData() failed', __FUNCTION__);
e673ee24
DO
51 return NULL;
52 }
53 $ret['name'] = $rack['row_name'];
54 $ret['params']['row_id'] = $rack['row_id'];
55 break;
56 case 'row':
2c6c7645 57 assertUIntArg ('row_id', __FUNCTION__);
e673ee24
DO
58 $rowInfo = getRackRowInfo ($_REQUEST['row_id']);
59 if ($rowInfo == NULL)
60 {
61e269b5 61 showError ('getRackRowInfo() failed', __FUNCTION__);
e673ee24
DO
62 return NULL;
63 }
a8ce7234 64 $ret['name'] = $rowInfo['name'];
e673ee24
DO
65 $ret['params']['row_id'] = $_REQUEST['row_id'];
66 break;
67 default:
68 return NULL;
69 }
70 return $ret;
71}
72
73function dynamic_title_rack ()
74{
3cc24579
DO
75 $rack = getRackData ($_REQUEST['rack_id']);
76 return array ('name' => $rack['name'], 'params' => array ('rack_id' => $_REQUEST['rack_id']));
e673ee24
DO
77}
78
79function dynamic_title_object ()
80{
81 global $pageno;
82 $ret = array();
83 switch ($pageno)
84 {
85 case 'object':
2c6c7645 86 assertUIntArg ('object_id', __FUNCTION__);
e673ee24
DO
87 $object = getObjectInfo ($_REQUEST['object_id']);
88 if ($object == NULL)
89 {
61e269b5 90 showError ('getObjectInfo() failed', __FUNCTION__);
e673ee24
DO
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
8d790216
DO
102function dynamic_title_vservice ()
103{
104 global $pageno;
105 $ret = array();
106 switch ($pageno)
107 {
2bb798a3 108 case 'ipv4vs':
49fb2686
DO
109 assertUIntArg ('vs_id', __FUNCTION__);
110 $ret['name'] = buildVServiceName (getVServiceInfo ($_REQUEST['vs_id']));
111 $ret['params']['vs_id'] = $_REQUEST['vs_id'];
8d790216
DO
112 break;
113 default:
114 return NULL;
115 }
116 return $ret;
117}
118
30aaee5a
DO
119function dynamic_title_rspool ()
120{
121 global $pageno;
122 $ret = array();
123 switch ($pageno)
124 {
0e692350 125 case 'ipv4rsp':
2c6c7645 126 assertUIntArg ('pool_id', __FUNCTION__);
6aff02cf 127 $poolInfo = getRSPoolInfo ($_REQUEST['pool_id']);
6ed71e14 128 $ret['name'] = empty ($poolInfo['name']) ? 'ANONYMOUS' : $poolInfo['name'];
6aff02cf 129 $ret['params']['pool_id'] = $_REQUEST['pool_id'];
30aaee5a
DO
130 break;
131 default:
132 return NULL;
133 }
134 return $ret;
135}
136
e673ee24
DO
137function 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
152function dynamic_title_objgroup ()
153{
154 global $pageno;
155 $ret = array();
156 switch ($pageno)
157 {
158 case 'objgroup':
2c6c7645 159 assertUIntArg ('group_id', __FUNCTION__, TRUE);
7cc02fc1
DO
160 $group_id = $_REQUEST['group_id'];
161 $groupInfo = getObjectGroupInfo();
e673ee24
DO
162 if ($groupInfo == NULL)
163 {
61e269b5 164 showError ('getObjectGroupInfo() failed', __FUNCTION__);
e673ee24
DO
165 return NULL;
166 }
7cc02fc1
DO
167 $ret['name'] = $groupInfo[$group_id]['name'];
168 $ret['params']['group_id'] = $group_id;
e673ee24
DO
169 break;
170 case 'object':
2c6c7645 171 assertUIntArg ('object_id', __FUNCTION__);
e673ee24
DO
172 $objectInfo = getObjectInfo ($_REQUEST['object_id']);
173 if ($objectInfo == NULL)
174 {
61e269b5 175 showError ('getObjectInfo() failed', __FUNCTION__);
e673ee24
DO
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
7d9cfed0
DO
187function 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
e673ee24 197?>