Simplify tablesPrint

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1135 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-09-23 15:01:17 +00:00
parent 09e93ded96
commit df0c4bba95
2 changed files with 30 additions and 31 deletions

View 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
}
}

View 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";
}
}
}