]> git.joonet.de Git - adminer.git/commitdiff
Display table links above table structure
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 20 Sep 2009 07:31:46 +0000 (07:31 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sun, 20 Sep 2009 07:31:46 +0000 (07:31 +0000)
Move body_load back to <body onload>

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1119 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/adminer.inc.php
adminer/include/design.inc.php
adminer/select.inc.php
adminer/table.inc.php
editor/editing.js
editor/include/adminer.inc.php

index 793fc770efc26aa4309234298cd67c4d58551dac..da2e2a0b140a16a53f027d83a35931eb4d7432d2 100644 (file)
@@ -66,12 +66,24 @@ class Adminer {
                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
@@ -421,10 +433,6 @@ class Adminer {
 <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();
index 43661de44ab4e468c33ff89b83625ba1d3f8635b..5e0c3f25e2f44015b88478a8cac5bec0fca154c8 100644 (file)
@@ -15,7 +15,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 <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>
 
index b7e08ac9775ad6530b5a91f9ffaa0a85ef9a99fc..ffeee302a443ca5780ad40c5020d96050ce9359a 100644 (file)
@@ -122,7 +122,7 @@ if ($_POST && !$error) {
 $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) {
@@ -132,9 +132,8 @@ if (isset($rights["insert"])) {
                        $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";
index acb210ad6bfcf4a501b1dc76ab1ac68360be5f57..f608c681b6ee1b5ecdbe04a2310bd9486444fa1b 100644 (file)
@@ -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 "<table cellspacing='0'>\n";
@@ -20,16 +20,7 @@ if ($result) {
        }
        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) {
index fc73e71bc756a2d8d2138240dcfe0503c31236d0..6cf5307084df7713b2db5a160046e05143fbd490 100644 (file)
@@ -1,2 +1,4 @@
 // Editor specific functions
 
+function body_load() {
+}
index 5b45a3157d8e1d8598f5ed24d5673ab7d191eafd..12ca0ef99821a54fa4909110c63d0df7a13a125f 100644 (file)
@@ -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 '<p><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
+               }
        }
        
        function backwardKeys($table) {
@@ -356,7 +359,6 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
 <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">