]> git.joonet.de Git - adminer.git/commitdiff
Simplify tablesPrint
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 23 Sep 2009 15:01:17 +0000 (15:01 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 23 Sep 2009 15:01:17 +0000 (15:01 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1135 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/adminer.inc.php
editor/include/adminer.inc.php

index ebe8969d8541e9132ce53f826a2d93238cd2c6cc..6896a7cf6f8d41ffbb6f5f3530093094f7857929 100644 (file)
@@ -435,7 +435,7 @@ class Adminer {
        * @return null
        */
        function navigation($missing) {
-               global $VERSION;
+               global $VERSION, $connection;
                ?>
 <h1>
 <a href="http://www.adminer.org/" id="h1"><?php echo $this->name(); ?></a>
@@ -470,28 +470,27 @@ class Adminer {
 </p>
 </form>
 <?php
-                       $this->tablesPrint($missing);
+                       if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
+                               $tables = get_vals("SHOW TABLES");
+                               if (!$tables) {
+                                       echo "<p class='message'>" . lang('No tables.') . "\n";
+                               } else {
+                                       $this->tablesPrint($tables);
+                               }
+                               echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
+                       }
                }
        }
        
        /** Prints table list in menu
-       * @param string can be "db" if there is no database selected
+       * @param array
        * @return null
        */
-       function tablesPrint($missing) {
-               global $connection;
-               if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
-                       $result = $connection->query("SHOW TABLES");
-                       if (!$result->num_rows) {
-                               echo "<p class='message'>" . lang('No tables.') . "\n";
-                       } else {
-                               echo "<p id='tables'>\n";
-                               while ($row = $result->fetch_row()) {
-                                       echo '<a href="' . h(ME) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
-                                       echo '<a href="' . h(ME) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status
-                               }
-                       }
-                       echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
+       function tablesPrint($tables) {
+               echo "<p id='tables'>\n";
+               foreach ($tables as $table) {
+                       echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '">' . lang('select') . '</a> ';
+                       echo '<a href="' . h(ME) . 'table=' . urlencode($table) . '">' . $this->tableName(array("Name" => $table)) . "</a><br>\n"; //! Adminer::tableName may work with full table status
                }
        }
        
index 52e0d5703fd62259d3aedb69c0038299cee7a0f0..97fc74da16b5ba8b0916e28f1b476824234deda9 100644 (file)
@@ -415,23 +415,23 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
 </p>
 </form>
 <?php
-                       $this->tablesPrint($missing);
+                       if ($missing != "db") {
+                               $table_status = table_status();
+                               if (!$table_status) {
+                                       echo "<p class='message'>" . lang('No tables.') . "\n";
+                               } else {
+                                       $this->tablesPrint($table_status);
+                               }
+                       }
                }
        }
        
-       function tablesPrint($missing) {
-               if ($missing != "db") {
-                       $table_status = table_status();
-                       if (!$table_status) {
-                               echo "<p class='message'>" . lang('No tables.') . "\n";
-                       } else {
-                               echo "<p id='tables'>\n";
-                               foreach ($table_status as $row) {
-                                       $name = $this->tableName($row);
-                                       if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name
-                                               echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n";
-                                       }
-                               }
+       function tablesPrint($tables) {
+               echo "<p id='tables'>\n";
+               foreach ($tables as $row) {
+                       $name = $this->tableName($row);
+                       if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name
+                               echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n";
                        }
                }
        }