r1492 + learn to list RS pools
[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']);
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
31function 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 {
61e269b5 42 showError ('getRackData() failed', __FUNCTION__);
e673ee24
DO
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 {
61e269b5 53 showError ('getRackRowInfo() failed', __FUNCTION__);
e673ee24
DO
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
65function 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
71function 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 {
61e269b5 82 showError ('getObjectInfo() failed', __FUNCTION__);
e673ee24
DO
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
8d790216
DO
94function 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
30aaee5a
DO
111function dynamic_title_rspool ()
112{
113 global $pageno;
114 $ret = array();
115 switch ($pageno)
116 {
117 case 'rspool':
118 assertUIntArg ('id');
119 $poolInfo = getRSPoolInfo ($_REQUEST['id']);
9a81d416 120 $ret['name'] = empty ($poolInfo['name']) ? '' : 'ANONYMOUS' . $poolInfo['name'];
30aaee5a
DO
121 $ret['params']['id'] = $_REQUEST['id'];
122 break;
123 default:
124 return NULL;
125 }
126 return $ret;
127}
128
e673ee24
DO
129function dynamic_title_search ()
130{
131 if (isset ($_REQUEST['q']))
132 {
133 $ret['name'] = "search results for '${_REQUEST['q']}'";
134 $ret['params']['q'] = $_REQUEST['q'];
135 }
136 else
137 {
138 $ret['name'] = "search results";
139 $ret['params'] = array();
140 }
141 return $ret;
142}
143
144function dynamic_title_objgroup ()
145{
146 global $pageno;
147 $ret = array();
148 switch ($pageno)
149 {
150 case 'objgroup':
151 assertUIntArg ('group_id');
152 $groupInfo = getObjectGroupInfo ($_REQUEST['group_id']);
153 if ($groupInfo == NULL)
154 {
61e269b5 155 showError ('getObjectGroupInfo() failed', __FUNCTION__);
e673ee24
DO
156 return NULL;
157 }
158 $ret['name'] = $groupInfo['name'];
159 $ret['params']['group_id'] = $groupInfo['id'];
160 break;
161 case 'object':
162 assertUIntArg ('object_id');
163 $objectInfo = getObjectInfo ($_REQUEST['object_id']);
164 if ($objectInfo == NULL)
165 {
61e269b5 166 showError ('getObjectInfo() failed', __FUNCTION__);
e673ee24
DO
167 return NULL;
168 }
169 $ret['name'] = $objectInfo['objtype_name'];
170 $ret['params']['group_id'] = $objectInfo['objtype_id'];
171 break;
172 default:
173 return NULL;
174 }
175 return $ret;
176}
177
e673ee24 178?>