1 |
6daefa8c
|
Petr Lukašík
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Common relation browsing function that can be used for views,
|
5 |
|
|
* tables, reports, arbitrary queries, etc. to avoid code duplication.
|
6 |
|
|
* @param $query The SQL SELECT string to execute
|
7 |
|
|
* @param $count The same SQL query, but only retrieves the count of the rows (AS total)
|
8 |
|
|
* @param $return_url The return URL
|
9 |
|
|
* @param $return_desc The return link name
|
10 |
|
|
* @param $page The current page
|
11 |
|
|
*
|
12 |
|
|
* $Id: display.php,v 1.52.2.1 2005/11/20 03:07:26 chriskl Exp $
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
// Prevent timeouts on large exports (non-safe mode only)
|
16 |
|
|
if (!ini_get('safe_mode')) set_time_limit(0);
|
17 |
|
|
|
18 |
|
|
// Include application functions
|
19 |
|
|
include_once('./libraries/lib.inc.php');
|
20 |
|
|
|
21 |
|
|
global $conf, $lang;
|
22 |
|
|
|
23 |
|
|
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
|
24 |
|
|
$PHP_SELF = $_SERVER['PHP_SELF'];
|
25 |
|
|
|
26 |
|
|
/**
|
27 |
|
|
* Show confirmation of edit and perform actual update
|
28 |
|
|
*/
|
29 |
|
|
function doEditRow($confirm, $msg = '') {
|
30 |
|
|
global $data, $misc;
|
31 |
|
|
global $lang;
|
32 |
|
|
global $PHP_SELF;
|
33 |
|
|
|
34 |
|
|
$key = $_REQUEST['key'];
|
35 |
|
|
|
36 |
|
|
if ($confirm) {
|
37 |
|
|
$misc->printTrail($_REQUEST['subject']);
|
38 |
|
|
$misc->printTitle($lang['streditrow']);
|
39 |
|
|
$misc->printMsg($msg);
|
40 |
|
|
|
41 |
|
|
$attrs = $data->getTableAttributes($_REQUEST['table']);
|
42 |
|
|
$rs = $data->browseRow($_REQUEST['table'], $key);
|
43 |
|
|
|
44 |
|
|
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
|
45 |
|
|
$elements = 0;
|
46 |
|
|
$error = true;
|
47 |
|
|
if ($rs->recordCount() == 1 && $attrs->recordCount() > 0) {
|
48 |
|
|
echo "<table>\n<tr>";
|
49 |
|
|
|
50 |
|
|
// Output table header
|
51 |
|
|
echo "<tr><th class=\"data\">{$lang['strcolumn']}</th><th class=\"data\">{$lang['strtype']}</th>";
|
52 |
|
|
echo "<th class=\"data\">{$lang['strformat']}</th>\n";
|
53 |
|
|
echo "<th class=\"data\">{$lang['strnull']}</th><th class=\"data\">{$lang['strvalue']}</th></tr>";
|
54 |
|
|
|
55 |
|
|
$i = 0;
|
56 |
|
|
while (!$attrs->EOF) {
|
57 |
|
|
$attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
|
58 |
|
|
$id = (($i % 2) == 0 ? '1' : '2');
|
59 |
|
|
|
60 |
|
|
// Initialise variables
|
61 |
|
|
if (!isset($_REQUEST['format'][$attrs->f['attname']]))
|
62 |
|
|
$_REQUEST['format'][$attrs->f['attname']] = 'VALUE';
|
63 |
|
|
|
64 |
|
|
echo "<tr>\n";
|
65 |
|
|
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
|
66 |
|
|
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
|
67 |
|
|
echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod']));
|
68 |
|
|
echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->f['attname']), "]\" value=\"",
|
69 |
|
|
htmlspecialchars($attrs->f['type']), "\" /></td>";
|
70 |
|
|
$elements++;
|
71 |
|
|
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
|
72 |
|
|
echo "<select name=\"format[", htmlspecialchars($attrs->f['attname']), "]\">\n";
|
73 |
|
|
echo "<option value=\"VALUE\"", ($_REQUEST['format'][$attrs->f['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$lang['strvalue']}</option>\n";
|
74 |
|
|
echo "<option value=\"EXPRESSION\"", ($_REQUEST['format'][$attrs->f['attname']] == 'EXPRESSION') ? ' selected="selected"' : '', ">{$lang['strexpression']}</option>\n";
|
75 |
|
|
echo "</select>\n</td>\n";
|
76 |
|
|
$elements++;
|
77 |
|
|
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">";
|
78 |
|
|
// Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS)
|
79 |
|
|
if (!$attrs->f['attnotnull']) {
|
80 |
|
|
// Set initial null values
|
81 |
|
|
if ($_REQUEST['action'] == 'confeditrow' && $rs->f[$attrs->f['attname']] === null) {
|
82 |
|
|
$_REQUEST['nulls'][$attrs->f['attname']] = 'on';
|
83 |
|
|
}
|
84 |
|
|
echo "<input type=\"checkbox\" name=\"nulls[{$attrs->f['attname']}]\"",
|
85 |
|
|
isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>\n";
|
86 |
|
|
$elements++;
|
87 |
|
|
}
|
88 |
|
|
else
|
89 |
|
|
echo " </td>";
|
90 |
|
|
|
91 |
|
|
echo "<td class=\"data{$id}\" nowrap>";
|
92 |
|
|
// If the column allows nulls, then we put a JavaScript action on the data field to unset the
|
93 |
|
|
// NULL checkbox as soon as anything is entered in the field. We use the $elements variable to
|
94 |
|
|
// keep track of which element offset we're up to. We can't refer to the null checkbox by name
|
95 |
|
|
// as it contains '[' and ']' characters.
|
96 |
|
|
if (!$attrs->f['attnotnull'])
|
97 |
|
|
echo $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type'],
|
98 |
|
|
array('onChange' => 'elements[' . ($elements - 1) . '].checked = false;'));
|
99 |
|
|
else
|
100 |
|
|
echo $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type']);
|
101 |
|
|
echo "</td>";
|
102 |
|
|
$elements++;
|
103 |
|
|
echo "</tr>\n";
|
104 |
|
|
$i++;
|
105 |
|
|
$attrs->moveNext();
|
106 |
|
|
}
|
107 |
|
|
echo "</table></p>\n";
|
108 |
|
|
$error = false;
|
109 |
|
|
}
|
110 |
|
|
elseif ($rs->recordCount() != 1) {
|
111 |
|
|
echo "<p>{$lang['strrownotunique']}</p>\n";
|
112 |
|
|
}
|
113 |
|
|
else {
|
114 |
|
|
echo "<p>{$lang['strinvalidparam']}</p>\n";
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"editrow\" />\n";
|
118 |
|
|
echo $misc->form;
|
119 |
|
|
if (isset($_REQUEST['table']))
|
120 |
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
|
121 |
|
|
if (isset($_REQUEST['subject']))
|
122 |
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"", htmlspecialchars($_REQUEST['subject']), "\" />\n";
|
123 |
|
|
if (isset($_REQUEST['query']))
|
124 |
|
|
echo "<input type=\"hidden\" name=\"query\" value=\"", htmlspecialchars($_REQUEST['query']), "\" />\n";
|
125 |
|
|
if (isset($_REQUEST['count']))
|
126 |
|
|
echo "<input type=\"hidden\" name=\"count\" value=\"", htmlspecialchars($_REQUEST['count']), "\" />\n";
|
127 |
|
|
if (isset($_REQUEST['return_url']))
|
128 |
|
|
echo "<input type=\"hidden\" name=\"return_url\" value=\"", htmlspecialchars($_REQUEST['return_url']), "\" />\n";
|
129 |
|
|
if (isset($_REQUEST['return_desc']))
|
130 |
|
|
echo "<input type=\"hidden\" name=\"return_desc\" value=\"", htmlspecialchars($_REQUEST['return_desc']), "\" />\n";
|
131 |
|
|
echo "<input type=\"hidden\" name=\"page\" value=\"", htmlspecialchars($_REQUEST['page']), "\" />\n";
|
132 |
|
|
echo "<input type=\"hidden\" name=\"sortkey\" value=\"", htmlspecialchars($_REQUEST['sortkey']), "\" />\n";
|
133 |
|
|
echo "<input type=\"hidden\" name=\"sortdir\" value=\"", htmlspecialchars($_REQUEST['sortdir']), "\" />\n";
|
134 |
|
|
echo "<input type=\"hidden\" name=\"strings\" value=\"", htmlspecialchars($_REQUEST['strings']), "\" />\n";
|
135 |
|
|
echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($key)), "\" />\n";
|
136 |
|
|
echo "<p>";
|
137 |
|
|
if (!$error) echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n";
|
138 |
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
|
139 |
|
|
echo "</form>\n";
|
140 |
|
|
}
|
141 |
|
|
else {
|
142 |
|
|
if (!isset($_POST['values'])) $_POST['values'] = array();
|
143 |
|
|
if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
|
144 |
|
|
|
145 |
|
|
$status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'],
|
146 |
|
|
$_POST['format'], $_POST['types'], unserialize($_POST['key']));
|
147 |
|
|
if ($status == 0)
|
148 |
|
|
doBrowse($lang['strrowupdated']);
|
149 |
|
|
elseif ($status == -2)
|
150 |
|
|
doEditRow(true, $lang['strrownotunique']);
|
151 |
|
|
else
|
152 |
|
|
doEditRow(true, $lang['strrowupdatedbad']);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
/**
|
158 |
|
|
* Show confirmation of drop and perform actual drop
|
159 |
|
|
*/
|
160 |
|
|
function doDelRow($confirm) {
|
161 |
|
|
global $data, $misc;
|
162 |
|
|
global $lang;
|
163 |
|
|
global $PHP_SELF;
|
164 |
|
|
|
165 |
|
|
if ($confirm) {
|
166 |
|
|
$misc->printTrail($_REQUEST['subject']);
|
167 |
|
|
$misc->printTitle($lang['strdeleterow']);
|
168 |
|
|
|
169 |
|
|
echo "<p>{$lang['strconfdeleterow']}</p>\n";
|
170 |
|
|
|
171 |
|
|
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
|
172 |
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"delrow\" />\n";
|
173 |
|
|
echo $misc->form;
|
174 |
|
|
if (isset($_REQUEST['table']))
|
175 |
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
|
176 |
|
|
if (isset($_REQUEST['subject']))
|
177 |
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"", htmlspecialchars($_REQUEST['subject']), "\" />\n";
|
178 |
|
|
if (isset($_REQUEST['query']))
|
179 |
|
|
echo "<input type=\"hidden\" name=\"query\" value=\"", htmlspecialchars($_REQUEST['query']), "\" />\n";
|
180 |
|
|
if (isset($_REQUEST['count']))
|
181 |
|
|
echo "<input type=\"hidden\" name=\"count\" value=\"", htmlspecialchars($_REQUEST['count']), "\" />\n";
|
182 |
|
|
if (isset($_REQUEST['return_url']))
|
183 |
|
|
echo "<input type=\"hidden\" name=\"return_url\" value=\"", htmlspecialchars($_REQUEST['return_url']), "\" />\n";
|
184 |
|
|
if (isset($_REQUEST['return_desc']))
|
185 |
|
|
echo "<input type=\"hidden\" name=\"return_desc\" value=\"", htmlspecialchars($_REQUEST['return_desc']), "\" />\n";
|
186 |
|
|
echo "<input type=\"hidden\" name=\"page\" value=\"", htmlspecialchars($_REQUEST['page']), "\" />\n";
|
187 |
|
|
echo "<input type=\"hidden\" name=\"sortkey\" value=\"", htmlspecialchars($_REQUEST['sortkey']), "\" />\n";
|
188 |
|
|
echo "<input type=\"hidden\" name=\"sortdir\" value=\"", htmlspecialchars($_REQUEST['sortdir']), "\" />\n";
|
189 |
|
|
echo "<input type=\"hidden\" name=\"strings\" value=\"", htmlspecialchars($_REQUEST['strings']), "\" />\n";
|
190 |
|
|
echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($_REQUEST['key'])), "\" />\n";
|
191 |
|
|
echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
|
192 |
|
|
echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
|
193 |
|
|
echo "</form>\n";
|
194 |
|
|
}
|
195 |
|
|
else {
|
196 |
|
|
$status = $data->deleteRow($_POST['table'], unserialize($_POST['key']));
|
197 |
|
|
if ($status == 0)
|
198 |
|
|
doBrowse($lang['strrowdeleted']);
|
199 |
|
|
elseif ($status == -2)
|
200 |
|
|
doBrowse($lang['strrownotunique']);
|
201 |
|
|
else
|
202 |
|
|
doBrowse($lang['strrowdeletedbad']);
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
/**
|
208 |
|
|
* Displays requested data
|
209 |
|
|
*/
|
210 |
|
|
function doBrowse() {
|
211 |
|
|
global $data, $conf, $misc, $lang;
|
212 |
|
|
|
213 |
|
|
// If current page is not set, default to first page
|
214 |
|
|
if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
|
215 |
|
|
|
216 |
|
|
if (isset($_REQUEST['subject'])) {
|
217 |
|
|
$subject = $_REQUEST['subject'];
|
218 |
|
|
if (isset($_REQUEST[$subject])) $object = $_REQUEST[$subject];
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
$misc->printTrail(isset($subject) ? $subject : 'database');
|
222 |
|
|
|
223 |
|
|
if (isset($object)) {
|
224 |
|
|
if (isset($_REQUEST['query'])) {
|
225 |
|
|
$misc->printTitle($lang['strselect']);
|
226 |
|
|
$type = 'SELECT';
|
227 |
|
|
} else {
|
228 |
|
|
$misc->printTitle($lang['strbrowse']);
|
229 |
|
|
$type = 'TABLE';
|
230 |
|
|
}
|
231 |
|
|
} else {
|
232 |
|
|
$misc->printTitle($lang['strqueryresults']);
|
233 |
|
|
$type = 'QUERY';
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
// If 'sortkey' is not set, default to ''
|
237 |
|
|
if (!isset($_REQUEST['sortkey'])) $_REQUEST['sortkey'] = '';
|
238 |
|
|
|
239 |
|
|
// If 'sortdir' is not set, default to ''
|
240 |
|
|
if (!isset($_REQUEST['sortdir'])) $_REQUEST['sortdir'] = '';
|
241 |
|
|
|
242 |
|
|
// If 'strings' is not set, default to collapsed
|
243 |
|
|
if (!isset($_REQUEST['strings'])) $_REQUEST['strings'] = 'collapsed';
|
244 |
|
|
|
245 |
|
|
// Fetch unique row identifier, if this is a table browse request.
|
246 |
|
|
if (isset($object))
|
247 |
|
|
$key = $data->getRowIdentifier($object);
|
248 |
|
|
else
|
249 |
|
|
$key = array();
|
250 |
|
|
|
251 |
|
|
// Set the schema search path
|
252 |
|
|
if ($data->hasSchemas() && isset($_REQUEST['search_path'])) {
|
253 |
|
|
if ($data->setSearchPath(array_map('trim',explode(',',$_REQUEST['search_path']))) != 0) {
|
254 |
|
|
return;
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
// Retrieve page from query. $max_pages is returned by reference.
|
259 |
|
|
$rs = $data->browseQuery($type,
|
260 |
|
|
isset($object) ? $object : null,
|
261 |
|
|
isset($_REQUEST['query']) ? $_REQUEST['query'] : null,
|
262 |
|
|
$_REQUEST['sortkey'], $_REQUEST['sortdir'], $_REQUEST['page'],
|
263 |
|
|
$conf['max_rows'], $max_pages);
|
264 |
|
|
|
265 |
|
|
// Build strings for GETs
|
266 |
|
|
$str = $misc->href; // . "&page=" . urlencode($_REQUEST['page']);
|
267 |
|
|
if (isset($object)) $str .= "&" . urlencode($subject) . '=' . urlencode($object);
|
268 |
|
|
if (isset($subject)) $str .= "&subject=" . urlencode($subject);
|
269 |
|
|
if (isset($_REQUEST['query'])) $str .= "&query=" . urlencode($_REQUEST['query']);
|
270 |
|
|
if (isset($_REQUEST['count'])) $str .= "&count=" . urlencode($_REQUEST['count']);
|
271 |
|
|
if (isset($_REQUEST['return_url'])) $str .= "&return_url=" . urlencode($_REQUEST['return_url']);
|
272 |
|
|
if (isset($_REQUEST['return_desc'])) $str .= "&return_desc=" . urlencode($_REQUEST['return_desc']);
|
273 |
|
|
if (isset($_REQUEST['search_path'])) $str .= "&search_path=" . urlencode($_REQUEST['search_path']);
|
274 |
|
|
|
275 |
|
|
// This string just contains sort info
|
276 |
|
|
$str2 = "sortkey=" . urlencode($_REQUEST['sortkey']) .
|
277 |
|
|
"&sortdir=" . urlencode($_REQUEST['sortdir']);
|
278 |
|
|
|
279 |
|
|
if (is_object($rs) && $rs->recordCount() > 0) {
|
280 |
|
|
// Show page navigation
|
281 |
|
|
$misc->printPages($_REQUEST['page'], $max_pages, "display.php?page=%s&{$str}&{$str2}&strings=" . urlencode($_REQUEST['strings']));
|
282 |
|
|
echo "<table>\n<tr>";
|
283 |
|
|
|
284 |
|
|
// Check that the key is actually in the result set. This can occur for select
|
285 |
|
|
// operations where the key fields aren't part of the select. XXX: We should
|
286 |
|
|
// be able to support this, somehow.
|
287 |
|
|
foreach ($key as $v) {
|
288 |
|
|
// If a key column is not found in the record set, then we
|
289 |
|
|
// can't use the key.
|
290 |
|
|
if (!in_array($v, array_keys($rs->f))) {
|
291 |
|
|
$key = array();
|
292 |
|
|
break;
|
293 |
|
|
}
|
294 |
|
|
}
|
295 |
|
|
// Display edit and delete actions if we have a key
|
296 |
|
|
if (sizeof($key) > 0)
|
297 |
|
|
echo "<th colspan=\"2\" class=\"data\">{$lang['stractions']}</th>\n";
|
298 |
|
|
|
299 |
|
|
$j = 0;
|
300 |
|
|
foreach ($rs->f as $k => $v) {
|
301 |
|
|
if (isset($object) && $k == $data->id && !$conf['show_oids']) {
|
302 |
|
|
$j++;
|
303 |
|
|
continue;
|
304 |
|
|
}
|
305 |
|
|
$finfo = $rs->fetchField($j);
|
306 |
|
|
// Display column headers with sorting options, unless we're PostgreSQL
|
307 |
|
|
// 7.0 and it's a non-TABLE mode
|
308 |
|
|
if (!$data->hasFullSubqueries() && $type != 'TABLE') {
|
309 |
|
|
echo "<th class=\"data\">", $misc->printVal($finfo->name), "</th>\n";
|
310 |
|
|
}
|
311 |
|
|
else {
|
312 |
|
|
echo "<th class=\"data\"><a href=\"display.php?{$str}&sortkey=", ($j + 1), "&sortdir=";
|
313 |
|
|
// Sort direction opposite to current direction, unless it's currently ''
|
314 |
|
|
echo ($_REQUEST['sortdir'] == 'asc' && $_REQUEST['sortkey'] == ($j + 1)) ? 'desc' : 'asc';
|
315 |
|
|
echo "&strings=", urlencode($_REQUEST['strings']),
|
316 |
|
|
"&page=" . urlencode($_REQUEST['page']), "\">",
|
317 |
|
|
$misc->printVal($finfo->name), "</a></th>\n";
|
318 |
|
|
}
|
319 |
|
|
$j++;
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
echo "</tr>\n";
|
323 |
|
|
|
324 |
|
|
$i = 0;
|
325 |
|
|
reset($rs->f);
|
326 |
|
|
while (!$rs->EOF) {
|
327 |
|
|
$id = (($i % 2) == 0 ? '1' : '2');
|
328 |
|
|
echo "<tr>\n";
|
329 |
|
|
// Display edit and delete links if we have a key
|
330 |
|
|
if (sizeof($key) > 0) {
|
331 |
|
|
$key_str = '';
|
332 |
|
|
$has_nulls = false;
|
333 |
|
|
foreach ($key as $v) {
|
334 |
|
|
if ($rs->f[$v] === null) {
|
335 |
|
|
$has_nulls = true;
|
336 |
|
|
break;
|
337 |
|
|
}
|
338 |
|
|
if ($key_str != '') $key_str .= '&';
|
339 |
|
|
$key_str .= urlencode("key[{$v}]") . '=' . urlencode($rs->f[$v]);
|
340 |
|
|
}
|
341 |
|
|
if ($has_nulls) {
|
342 |
|
|
echo "<td class=\"data{$id}\" colspan=\"2\"> </td>\n";
|
343 |
|
|
} else {
|
344 |
|
|
echo "<td class=\"opbutton{$id}\"><a href=\"display.php?action=confeditrow&strings=",
|
345 |
|
|
urlencode($_REQUEST['strings']), "&page=",
|
346 |
|
|
urlencode($_REQUEST['page']), "&{$key_str}&{$str}&{$str2}\">{$lang['stredit']}</a></td>\n";
|
347 |
|
|
echo "<td class=\"opbutton{$id}\"><a href=\"display.php?action=confdelrow&strings=",
|
348 |
|
|
urlencode($_REQUEST['strings']), "&page=",
|
349 |
|
|
urlencode($_REQUEST['page']), "&{$key_str}&{$str}&{$str2}\">{$lang['strdelete']}</a></td>\n";
|
350 |
|
|
}
|
351 |
|
|
}
|
352 |
|
|
$j = 0;
|
353 |
|
|
foreach ($rs->f as $k => $v) {
|
354 |
|
|
$finfo = $rs->fetchField($j++);
|
355 |
|
|
if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) continue;
|
356 |
|
|
elseif ($v !== null && $v == '') echo "<td class=\"data{$id}\"> </td>";
|
357 |
|
|
else {
|
358 |
|
|
echo "<td class=\"data{$id}\" nowrap=\"nowrap\">",
|
359 |
|
|
$misc->printVal($v, $finfo->type, array('null' => true, 'clip' => ($_REQUEST['strings']=='collapsed'))), "</td>";
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
echo "</tr>\n";
|
363 |
|
|
$rs->moveNext();
|
364 |
|
|
$i++;
|
365 |
|
|
}
|
366 |
|
|
echo "</table>\n";
|
367 |
|
|
echo "<p>", $rs->recordCount(), " {$lang['strrows']}</p>\n";
|
368 |
|
|
// Show page navigation
|
369 |
|
|
$misc->printPages($_REQUEST['page'], $max_pages, "display.php?page=%s&{$str}&{$str2}&strings=" . urlencode($_REQUEST['strings']));
|
370 |
|
|
}
|
371 |
|
|
else echo "<p>{$lang['strnodata']}</p>\n";
|
372 |
|
|
|
373 |
|
|
// Navigation links
|
374 |
|
|
echo "<p>";
|
375 |
|
|
// Return
|
376 |
|
|
if (isset($_REQUEST['return_url']) && isset($_REQUEST['return_desc'])) {
|
377 |
|
|
echo "<a class=\"navlink\" href=\"{$_REQUEST['return_url']}\">{$_REQUEST['return_desc']}</a> |\n";
|
378 |
|
|
}
|
379 |
|
|
// Edit SQL link
|
380 |
|
|
if (isset($_REQUEST['query'])) {
|
381 |
|
|
echo "<a class=\"navlink\" href=\"database.php?{$misc->href}&action=sql&paginate=on&query=" . urlencode($_REQUEST['query']), "\">{$lang['streditsql']}</a> |\n";
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
// Expand/Collapse
|
385 |
|
|
if ($_REQUEST['strings'] == 'expanded')
|
386 |
|
|
echo "<a class=\"navlink\" href=\"display.php?{$str}&{$str2}&strings=collapsed&page=",
|
387 |
|
|
urlencode($_REQUEST['page']), "\">{$lang['strcollapse']}</a>\n";
|
388 |
|
|
else
|
389 |
|
|
echo "<a class=\"navlink\" href=\"display.php?{$str}&{$str2}&strings=expanded&page=",
|
390 |
|
|
urlencode($_REQUEST['page']), "\">{$lang['strexpand']}</a>\n";
|
391 |
|
|
// Create report
|
392 |
|
|
if (isset($_REQUEST['query']) && $conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
|
393 |
|
|
echo " | <a class=\"navlink\" href=\"reports.php?{$misc->href}&action=create&report_sql=",
|
394 |
|
|
urlencode($_REQUEST['query']), "\">{$lang['strcreatereport']}</a>\n";
|
395 |
|
|
}
|
396 |
|
|
// Create view and download
|
397 |
|
|
if (isset($_REQUEST['query']) && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
|
398 |
|
|
// Report views don't set a schema, so we need to disable create view in that case
|
399 |
|
|
if (isset($_REQUEST['schema'])) echo " | <a class=\"navlink\" href=\"views.php?action=create&formDefinition=",
|
400 |
|
|
urlencode($_REQUEST['query']), "&{$misc->href}\">{$lang['strcreateview']}</a>\n";
|
401 |
|
|
echo " | <a class=\"navlink\" href=\"dataexport.php?query=", urlencode($_REQUEST['query']);
|
402 |
|
|
if (isset($_REQUEST['search_path']))
|
403 |
|
|
echo "&search_path=", urlencode($_REQUEST['search_path']);
|
404 |
|
|
echo "&{$misc->href}\">{$lang['strdownload']}</a>\n";
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
// Insert
|
408 |
|
|
if (isset($object) && (isset($subject) && $subject == 'table')) {
|
409 |
|
|
echo " | <a class=\"navlink\" href=\"tables.php?action=confinsertrow&table=",
|
410 |
|
|
urlencode($object), "&{$misc->href}\">{$lang['strinsert']}</a>\n";
|
411 |
|
|
}
|
412 |
|
|
|
413 |
|
|
// Refresh
|
414 |
|
|
echo "| <a class=\"navlink\" href=\"display.php?{$str}&{$str2}&strings=", urlencode($_REQUEST['strings']),
|
415 |
|
|
"&page=" . urlencode($_REQUEST['page']),
|
416 |
|
|
"\">{$lang['strrefresh']}</a>\n";
|
417 |
|
|
echo "</p>\n";
|
418 |
|
|
}
|
419 |
|
|
|
420 |
|
|
// If a table is specified, then set the title differently
|
421 |
|
|
if (isset($_REQUEST['subject']) && isset($_REQUEST[$_REQUEST['subject']]))
|
422 |
|
|
$misc->printHeader($lang['strtables']);
|
423 |
|
|
else
|
424 |
|
|
$misc->printHeader($lang['strqueryresults']);
|
425 |
|
|
|
426 |
|
|
$misc->printBody();
|
427 |
|
|
|
428 |
|
|
switch ($action) {
|
429 |
|
|
case 'editrow':
|
430 |
|
|
if (isset($_POST['save'])) doEditRow(false);
|
431 |
|
|
else doBrowse();
|
432 |
|
|
break;
|
433 |
|
|
case 'confeditrow':
|
434 |
|
|
doEditRow(true);
|
435 |
|
|
break;
|
436 |
|
|
case 'delrow':
|
437 |
|
|
if (isset($_POST['yes'])) doDelRow(false);
|
438 |
|
|
else doBrowse();
|
439 |
|
|
break;
|
440 |
|
|
case 'confdelrow':
|
441 |
|
|
doDelRow(true);
|
442 |
|
|
break;
|
443 |
|
|
default:
|
444 |
|
|
doBrowse();
|
445 |
|
|
break;
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
$misc->printFooter();
|
449 |
|
|
?>
|