", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['streditrow']}\n"; $misc->printMsg($msg); $attrs = &$data->getTableAttributes($_REQUEST['table']); $rs = &$data->browseRow($_REQUEST['table'], $key); echo "
\n"; $error = true; if ($rs->recordCount() == 1 && $attrs->recordCount() > 0) { echo "\n"; // Output table header echo ""; echo "\n"; echo ""; $i = 0; while (!$attrs->EOF) { $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']); $id = (($i % 2) == 0 ? '1' : '2'); // Initialise variables if (!isset($_REQUEST['format'][$attrs->f['attname']])) $_REQUEST['format'][$attrs->f['attname']] = 'VALUE'; echo "\n"; echo ""; echo ""; echo "\n"; echo ""; } else echo " "; echo ""; echo "\n"; $i++; $attrs->moveNext(); } echo "
{$lang['strfield']}{$lang['strtype']}{$lang['strformat']}{$lang['strnull']}{$lang['strvalue']}
", $misc->printVal($attrs->f['attname']), "\n"; echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])); echo "f['attname']), "]\" value=\"", htmlspecialchars($attrs->f['type']), "\" />\n"; echo "\n"; // Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS) if (!$attrs->f['attnotnull']) { // Set initial null values if ($_REQUEST['action'] == 'confeditrow' && $rs->f[$attrs->f['attname']] === null) { $_REQUEST['nulls'][$attrs->f['attname']] = 'on'; } echo "f['attname']}]\"", isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " />", $data->printField("values[{$attrs->f['attname']}]", $rs->f[$attrs->f['attname']], $attrs->f['type']), "

\n"; $error = false; } elseif ($rs->recordCount() != 1) { echo "

{$lang['strrownotunique']}

\n"; } else { echo "

{$lang['strinvalidparam']}

\n"; } echo "\n"; echo $misc->form; if (isset($_REQUEST['table'])) echo "\n"; if (isset($_REQUEST['query'])) echo "\n"; if (isset($_REQUEST['count'])) echo "\n"; if (isset($_REQUEST['return_url'])) echo "\n"; if (isset($_REQUEST['return_desc'])) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

"; if (!$error) echo "\n"; echo "

\n"; echo "
\n"; } else { if (!isset($_POST['values'])) $_POST['values'] = array(); if (!isset($_POST['nulls'])) $_POST['nulls'] = array(); $status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], $_POST['format'], $_POST['types'], unserialize($_POST['key'])); if ($status == 0) doBrowse($lang['strrowupdated']); elseif ($status == -2) doEditRow(true, $lang['strrownotunique']); else doEditRow(true, $lang['strrowupdatedbad']); } } /** * Show confirmation of drop and perform actual drop */ function doDelRow($confirm) { global $data, $misc; global $lang; global $PHP_SELF; if ($confirm) { echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strdeleterow']}

\n"; echo "

{$lang['strconfdeleterow']}

\n"; echo "
\n"; echo "\n"; echo $misc->form; if (isset($_REQUEST['table'])) echo "\n"; if (isset($_REQUEST['query'])) echo "\n"; if (isset($_REQUEST['count'])) echo "\n"; if (isset($_REQUEST['return_url'])) echo "\n"; if (isset($_REQUEST['return_desc'])) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } else { $status = $data->deleteRow($_POST['table'], unserialize($_POST['key'])); if ($status == 0) doBrowse($lang['strrowdeleted']); elseif ($status == -2) doBrowse($lang['strrownotunique']); else doBrowse($lang['strrowdeletedbad']); } } /** * Displays requested data */ function doBrowse() { global $data, $conf, $misc, $lang; // If current page is not set, default to first page if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1; // If 'table' is not set, default to '' and set type if (isset($_REQUEST['table']) && isset($_REQUEST['query'])) { echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strselect']}

\n"; $type = 'SELECT'; } elseif (isset($_REQUEST['table'])) { echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strbrowse']}

\n"; $type = 'TABLE'; } else { echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strqueryresults']}

\n"; $type = 'QUERY'; } // If 'sortkey' is not set, default to '' if (!isset($_REQUEST['sortkey'])) $_REQUEST['sortkey'] = ''; // If 'sortdir' is not set, default to '' if (!isset($_REQUEST['sortdir'])) $_REQUEST['sortdir'] = ''; // If 'strings' is not set, default to collapsed if (!isset($_REQUEST['strings'])) $_REQUEST['strings'] = 'collapsed'; // Fetch unique row identifier, if this is a table browse request. if (isset($_REQUEST['table'])) $key = $data->getRowIdentifier($_REQUEST['table']); else $key = array(); // Retrieve page from query. $max_pages is returned by reference. $rs = &$data->browseQuery($type, isset($_REQUEST['table']) ? $_REQUEST['table'] : null, isset($_REQUEST['query']) ? $_REQUEST['query'] : null, $_REQUEST['sortkey'], $_REQUEST['sortdir'], $_REQUEST['page'], $conf['max_rows'], $max_pages); // Build strings for GETs $str = $misc->href; // . "&page=" . urlencode($_REQUEST['page']); if (isset($_REQUEST['table'])) $str .= "&table=" . urlencode($_REQUEST['table']); if (isset($_REQUEST['query'])) $str .= "&query=" . urlencode($_REQUEST['query']); if (isset($_REQUEST['count'])) $str .= "&count=" . urlencode($_REQUEST['count']); if (isset($_REQUEST['return_url'])) $str .= "&return_url=" . urlencode($_REQUEST['return_url']); if (isset($_REQUEST['return_desc'])) $str .= "&return_desc=" . urlencode($_REQUEST['return_desc']); // This string just contains sort info $str2 = "sortkey=" . urlencode($_REQUEST['sortkey']) . "&sortdir=" . urlencode($_REQUEST['sortdir']); if (is_object($rs) && $rs->recordCount() > 0) { // Show page navigation $misc->printPages($_REQUEST['page'], $max_pages, "display.php?page=%s&{$str}&{$str2}"); echo "\n"; // Check that the key is actually in the result set. This can occur for select // operations where the key fields aren't part of the select. XXX: We should // be able to support this, somehow. foreach ($key as $v) { // If a key column is not found in the record set, then we // can't use the key. if (!in_array($v, array_keys($rs->f))) { $key = array(); break; } } // Display edit and delete actions if we have a key if (sizeof($key) > 0) echo "\n"; $j = 0; foreach ($rs->f as $k => $v) { if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) { $j++; continue; } $finfo = $rs->fetchField($j); // Display column headers with sorting options, unless we're PostgreSQL // 7.0 and it's a non-TABLE mode if (!$data->hasFullSubqueries() && $type != 'TABLE') { echo "\n"; } else { echo "\n"; } $j++; } echo "\n"; $i = 0; reset($rs->f); while (!$rs->EOF) { $id = (($i % 2) == 0 ? '1' : '2'); echo "\n"; // Display edit and delete links if we have a key if (sizeof($key) > 0) { $key_str = ''; $has_nulls = false; foreach ($key as $v) { if ($rs->f[$v] === null) { $has_nulls = true; break; } if ($key_str != '') $key_str .= '&'; $key_str .= urlencode("key[{$v}]") . '=' . urlencode($rs->f[$v]); } if ($has_nulls) { echo "\n"; } else { echo "\n"; echo "\n"; } } $j = 0; foreach ($rs->f as $k => $v) { $finfo = $rs->fetchField($j++); if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) continue; elseif ($v !== null && $v == '') echo ""; else { // Trim strings if over length if ($_REQUEST['strings'] == 'collapsed' && strlen($v) > $conf['max_chars']) { $v = substr($v, 0, $conf['max_chars'] - 1) . $lang['strellipsis']; } echo ""; } } echo "\n"; $rs->moveNext(); $i++; } echo "
{$lang['stractions']}", $misc->printVal($finfo->name), "", $misc->printVal($finfo->name), "
 {$lang['stredit']}{$lang['strdelete']} ", $misc->printVal($v, true, $finfo->type), "
\n"; echo "

", $rs->recordCount(), " {$lang['strrows']}

\n"; } else echo "

{$lang['strnodata']}

\n"; // Navigation links echo "

"; // Return if (isset($_REQUEST['return_url']) && isset($_REQUEST['return_desc'])) { echo "{$_REQUEST['return_desc']} |\n"; } // Edit SQL link if (isset($_REQUEST['query'])) { echo "href}&action=sql&paginate=on&query=" . urlencode($_REQUEST['query']), "\">{$lang['streditsql']} |\n"; } // Expand/Collapse if ($_REQUEST['strings'] == 'expanded') echo "{$lang['strcollapse']}\n"; else echo "{$lang['strexpand']}\n"; // Create report if (isset($_REQUEST['query']) && $conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) { echo " | {$lang['strcreatereport']}\n"; } // Create view and download if (isset($_REQUEST['query']) && isset($rs) && is_object($rs) && $rs->recordCount() > 0) { // Report views don't set a schema, so we need to disable create view in that case if (isset($_REQUEST['schema'])) echo " | href}\">{$lang['strcreateview']}\n"; echo " | href}\">{$lang['strdownload']}\n"; } // Refresh echo "| {$lang['strrefresh']}

\n"; echo "

\n"; } // If a table is specified, then set the title differently if (isset($_REQUEST['table'])) $misc->printHeader($lang['strtables']); else $misc->printHeader($lang['strqueryresults']); $misc->printBody(); switch ($action) { case 'editrow': if (isset($_POST['save'])) doEditRow(false); else doBrowse(); break; case 'confeditrow': doEditRow(true); break; case 'delrow': if (isset($_POST['yes'])) doDelRow(false); else doBrowse(); break; case 'confdelrow': doDelRow(true); break; default: doBrowse(); break; } $misc->printFooter(); ?>