From f2ed2379bdb2e198966d3f4e00d6b98278bb1e45 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Sun, 20 Sep 2009 07:31:46 +0000 Subject: [PATCH] Display table links above table structure Move body_load back to git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1119 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/include/adminer.inc.php | 24 ++++++++++++++++-------- adminer/include/design.inc.php | 2 +- adminer/select.inc.php | 5 ++--- adminer/table.inc.php | 13 ++----------- editor/editing.js | 2 ++ editor/include/adminer.inc.php | 8 +++++--- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 793fc770..da2e2a0b 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -66,12 +66,24 @@ class Adminer { return '' . h($field["field"]) . ''; } - /** 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 '' . lang('Table structure') . ''; + function selectLinks($tableStatus, $set = "") { + $TABLE = $tableStatus["Name"]; + echo '

' . lang('Select table') . ''; + echo ' ' . lang('Table structure') . ''; + if (isset($tableStatus["Rows"])) { + echo ' ' . lang('Alter table') . ''; + } else { + echo ' ' . lang('Alter view') . ''; + } + if (isset($set)) { + echo ' ' . lang('New item') . ''; + } + echo "\n"; } /** Find backward keys for table @@ -421,10 +433,6 @@ class Adminer { - - +"> diff --git a/adminer/select.inc.php b/adminer/select.inc.php index b7e08ac9..ffeee302 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -122,7 +122,7 @@ if ($_POST && !$error) { $table_name = $adminer->tableName($table_status); page_header(lang('Select') . ": $table_name", $error); -echo "

"; +$set = null; if (isset($rights["insert"])) { $set = ""; foreach ((array) $_GET["where"] as $val) { @@ -132,9 +132,8 @@ if (isset($rights["insert"])) { $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]); } } - echo '' . lang('New item') . ' '; } -echo $adminer->selectLinks($table_status); +$adminer->selectLinks($table_status, $set); if (!$columns) { echo "

" . lang('Unable to select the table') . ($fields ? "" : ": " . h($dbh->error)) . ".\n"; diff --git a/adminer/table.inc.php b/adminer/table.inc.php index acb210ad..f608c681 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -5,9 +5,9 @@ if (!$result) { $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 "\n"; @@ -20,16 +20,7 @@ if ($result) { } echo "
\n"; - echo "

"; - if ($is_view) { - echo '' . lang('Alter view') . ''; - } else { - echo '' . lang('Alter table') . ''; - } - echo ' ' . lang('Select table') . ''; - echo ' ' . lang('New item') . ''; - - if (!$is_view) { + if (isset($table_status["Rows"])) { echo "

" . lang('Indexes') . "

\n"; $indexes = indexes($TABLE); if ($indexes) { diff --git a/editor/editing.js b/editor/editing.js index fc73e71b..6cf53070 100644 --- a/editor/editing.js +++ b/editor/editing.js @@ -1,2 +1,4 @@ // Editor specific functions +function body_load() { +} diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 5b45a315..12ca0ef9 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -39,8 +39,11 @@ class Adminer { return h(strlen($field["comment"]) ? $field["comment"] : $field["field"]); } - function selectLinks($tableStatus) { - return ""; + function selectLinks($tableStatus, $set = "") { + $TABLE = $tableStatus["Name"]; + if (isset($set)) { + echo '

' . lang('New item') . "\n"; + } } function backwardKeys($table) { @@ -356,7 +359,6 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 verify_version();\n"); if ($missing != "auth") { ?>