return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>';
}
- /** Links after select heading
+ /** Print links after select heading
* @param array result of SHOW TABLE STATUS
- * @return string
+ * @param strin new item options, NULL for no new item
+ * @return null
*/
- function selectLinks($tableStatus) {
- return '<a href="' . h(ME) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
+ function selectLinks($tableStatus, $set = "") {
+ $TABLE = $tableStatus["Name"];
+ echo '<p><a href="' . h(ME) . 'select=' . urlencode($TABLE) . '">' . lang('Select table') . '</a>';
+ echo ' <a href="' . h(ME) . 'table=' . urlencode($TABLE) . '">' . lang('Table structure') . '</a>';
+ if (isset($tableStatus["Rows"])) {
+ echo ' <a href="' . h(ME) . 'create=' . urlencode($TABLE) . '">' . lang('Alter table') . '</a>';
+ } else {
+ echo ' <a href="' . h(ME) . 'view=' . urlencode($TABLE) . '">' . lang('Alter view') . '</a>';
+ }
+ if (isset($set)) {
+ echo ' <a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . '</a>';
+ }
+ echo "\n";
}
/** Find backward keys for table
<span class="version"><?php echo $VERSION; ?></span>
<a href="http://www.adminer.org/#download" id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
</h1>
-<script type="text/javascript">
-body_load();
-<?php echo (isset($_COOKIE["adminer_version"]) ? "" : "verify_version();"); ?>
-</script>
<?php
if ($missing != "auth") {
$databases = get_databases();
<link rel="stylesheet" type="text/css" href="adminer.css">
<?php } ?>
-<body>
+<body onload="body_load();<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verify_version();"); ?>">
<script type="text/javascript" src="../adminer/functions.js"></script>
<script type="text/javascript" src="editing.js"></script>
$table_name = $adminer->tableName($table_status);
page_header(lang('Select') . ": $table_name", $error);
-echo "<p>";
+$set = null;
if (isset($rights["insert"])) {
$set = "";
foreach ((array) $_GET["where"] as $val) {
$set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
}
}
- echo '<a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . '</a> ';
}
-echo $adminer->selectLinks($table_status);
+$adminer->selectLinks($table_status, $set);
if (!$columns) {
echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . h($dbh->error)) . ".\n";
$error = h($dbh->error);
}
$table_status = ($result ? table_status($TABLE) : array());
-$is_view = !isset($table_status["Rows"]);
page_header(($result && $is_view ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
+$adminer->selectLinks($table_status);
if ($result) {
echo "<table cellspacing='0'>\n";
}
echo "</table>\n";
- echo "<p>";
- if ($is_view) {
- echo '<a href="' . h(ME) . 'view=' . urlencode($TABLE) . '">' . lang('Alter view') . '</a>';
- } else {
- echo '<a href="' . h(ME) . 'create=' . urlencode($TABLE) . '">' . lang('Alter table') . '</a>';
- }
- echo ' <a href="' . h(ME) . 'select=' . urlencode($TABLE) . '">' . lang('Select table') . '</a>';
- echo ' <a href="' . h(ME) . 'edit=' . urlencode($TABLE) . '">' . lang('New item') . '</a>';
-
- if (!$is_view) {
+ if (isset($table_status["Rows"])) {
echo "<h3>" . lang('Indexes') . "</h3>\n";
$indexes = indexes($TABLE);
if ($indexes) {
// Editor specific functions
+function body_load() {
+}
return h(strlen($field["comment"]) ? $field["comment"] : $field["field"]);
}
- function selectLinks($tableStatus) {
- return "";
+ function selectLinks($tableStatus, $set = "") {
+ $TABLE = $tableStatus["Name"];
+ if (isset($set)) {
+ echo '<p><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
+ }
}
function backwardKeys($table) {
<a href="http://www.adminer.org/editor/#download" id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
</h1>
<?php
- echo (isset($_COOKIE["adminer_version"]) ? "" : "<script type='text/javascript'>verify_version();</script>\n");
if ($missing != "auth") {
?>
<form action="" method="post">