]> git.joonet.de Git - adminer.git/commitdiff
Invent get_databases()
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 25 Sep 2008 20:50:08 +0000 (20:50 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 25 Sep 2008 20:50:08 +0000 (20:50 +0000)
Discover nowrap class

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

default.css
design.inc.php
dump.inc.php
editing.inc.php
functions.inc.php
index.php
select.inc.php

index 01c8e6df56b89844423b46d992d4fb14d6e668fd..6c5a2fda0ceded1419fa0e9e853c7915e5f55621 100644 (file)
@@ -14,6 +14,7 @@ p { margin: 0 20px 1em 0; }
 img { vertical-align: middle; }
 code { background-color: #eee; }
 .js .hidden { display: none; }
+.nowrap { white-space: nowrap; }
 .error { color: red; background: #fee; padding: .5em .8em; }
 .message { color: green; background: #efe; padding: .5em .8em; }
 .char { color: #007F00; }
index b73784fc738a3ffc40ff474ef850eea983910650..433d36a52a1cf4ae5e13d069b8563cb8387c28f9 100644 (file)
@@ -78,11 +78,7 @@ function page_footer($missing = false) {
 <p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>" /><?php } ?>
 <select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)</option>
 <?php
-               if (!isset($_SESSION["databases"][$_GET["server"]])) {
-                       flush();
-                       $_SESSION["databases"][$_GET["server"]] = get_vals("SHOW DATABASES");
-               }
-               echo optionlist($_SESSION["databases"][$_GET["server"]], $_GET["db"]);
+               echo optionlist(get_databases(), $_GET["db"]);
                ?>
 </select>
 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value="" /><?php } ?>
index ff4e4e00c5066f88494cc9192ab01f0824c82032..bad01177f88fa318fa8ef16248b69f1d9b22647c 100644 (file)
@@ -151,10 +151,7 @@ foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) {
        echo "<th onclick=\"check(this, /^databases/, '$val');\" style='cursor: pointer;'>" . ($val ? $val : lang('skip')) . "</th>";
 }
 echo "</tr></thead>\n";
-if (!strlen($_GET["db"]) && !isset($_SESSION["databases"][$_GET["server"]])) {
-       $_SESSION["databases"][$_GET["server"]] = get_vals("SHOW DATABASES");
-}
-foreach ((strlen($_GET["db"]) ? array($_GET["db"]) : $_SESSION["databases"][$_GET["server"]]) as $db) {
+foreach ((strlen($_GET["db"]) ? array($_GET["db"]) : get_databases()) as $db) {
        if ($db != "information_schema" || $mysql->server_info < 5) {
                echo "<tr><td>" . htmlspecialchars($db) . "</td>";
                foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) {
index 34693169ff68c822894a16927309b81431f781b1..265e64b6450b667186fc0143cac6f53d3f2ab802 100644 (file)
@@ -111,7 +111,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
 <td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
 <td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
 <?php } ?>
-<td style="white-space: nowrap;">
+<td class="nowrap">
 <input type="image" name="add[<?php echo $i; ?>]" src="plus.gif" title="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" />
 <input type="image" name="drop_col[<?php echo $i; ?>]" src="minus.gif" title="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" />
 <input type="image" name="up[<?php echo $i; ?>]" src="up.gif" title="<?php echo lang('Move up'); ?>" />
index de714cd8aa92b73e7efb862f48f779565527e6eb..a30a754699f2cd2235b7726d6f344d77824080da 100644 (file)
@@ -40,6 +40,15 @@ function get_vals($query) {
        return $return;
 }
 
+function get_databases() {
+       $return = &$_SESSION["databases"][$_GET["server"]];
+       if (!isset($return)) {
+               flush();
+               $return = get_vals("SHOW DATABASES");
+       }
+       return $return;
+}
+
 function table_status($table) {
        global $mysql;
        $result = $mysql->query("SHOW TABLE STATUS LIKE '" . $mysql->escape_string(addcslashes($table, "%_")) . "'");
index 84cbb37967c8cbcb2a17248c9b3e89d8fdacb3d6..d957900aa95f1f2baa2762fac6c9748c9af91895 100644 (file)
--- a/index.php
+++ b/index.php
@@ -129,6 +129,13 @@ if (isset($_GET["download"])) {
                                                }
                                        }
                                        $message = lang('Tables have been truncated.');
+                               } elseif (isset($_POST["move"])) {
+                                       $rename = array();
+                                       foreach ($_POST["tables"] as $table) {
+                                               $rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table);
+                                       }
+                                       $result = queries("RENAME TABLE " . implode(", ", $rename));
+                                       $message = lang('Tables have been moved.');
                                } elseif ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) {
                                        while ($row = $result->fetch_assoc()) {
                                                $message .= htmlspecialchars("$row[Table]: $row[Msg_text]") . "<br />";
@@ -148,12 +155,23 @@ if (isset($_GET["download"])) {
                        } else {
                                echo "<form action='' method='post'>\n";
                                echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
-                               echo '<thead><tr><th>' . lang('Table') . '</th><td><label><input type="checkbox" onclick="var elems = this.form.elements; for (var i=0; elems.length > i; i++) if (elems[i].name == \'tables[]\') elems[i].checked = this.checked;" /> Engine</label></td><td>' . lang('Data Length') . "</td><td>" . lang('Index Length') . "</td><td>" . lang('Data Free') . "</td><td>" . lang('Collation') . "</td><td>" . lang('Auto Increment') . "</td><td>Rows</td></tr></tdead>\n";
+                               echo '<thead><tr><td><input type="checkbox" onclick="var elems = this.form.elements; for (var i=0; elems.length > i; i++) if (elems[i].name == \'tables[]\') elems[i].checked = this.checked;" /></td><th>' . lang('Table') . '</th><td>' . lang('Engine') . '</td><td>' . lang('Collation') . '</td><td>' . lang('Data Length') . '</td><td>' . lang('Index Length') . '</td><td>' . lang('Data Free') . '</td><td>' . lang('Auto Increment') . '</td><td>' . lang('Rows') . "</td></tr></tdead>\n";
                                while ($row = $result->fetch_assoc()) {
-                                       echo '<tr><th><a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th>" . (isset($row["Rows"]) ? '<td><label><input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '" /> ' . $row["Engine"] . "</label></td><td>$row[Data_length]</td><td>$row[Index_length]</td><td>$row[Data_free]</td><td>$row[Collation]</td><td>$row[Auto_increment]</td><td>" . $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))) : '<td colspan="7">' . lang('View')) . "</td></tr>\n";
+                                       echo '<tr class="nowrap"><td>';
+                                       if (isset($row["Rows"])) {
+                                               echo '<input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '"' . (in_array($row["Name"], (array) $_POST["tables"], true) ? ' checked="checked"' : '') . ' /></td><th><a href="' . htmlspecialchars($SELF) . 'create=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th><td align='left'>$row[Engine]</td><td align='left'>$row[Collation]</td>";
+                                               $row["count"] = $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"])));
+                                               foreach (array("Data_length", "Index_length", "Data_free", "Auto_increment", "count") as $val) {
+                                                       echo '<td align="right">' . (strlen($row[$val]) ? number_format($row[$val], 0, '.', lang(',')) : '') . '</td>';
+                                               }
+                                       } else {
+                                               echo '&nbsp;</td><th><a href="' . htmlspecialchars($SELF) . 'createv=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . '</a></th><td colspan="8">' . lang('View');
+                                       }
+                                       echo "</td></tr>\n";
                                }
                                echo "</table>\n";
                                echo "<p><input type='hidden' name='token' value='$token' /><input type='submit' value='" . lang('Analyze') . "' /> <input type='submit' name='optimize' value='" . lang('Optimize') . "' /> <input type='submit' name='check' value='" . lang('Check') . "' /> <input type='submit' name='repair' value='" . lang('Repair') . "' /> <input type='submit' name='truncate' value='" . lang('Truncate') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\" /> <input type='submit' name='drop' value='" . lang('Drop') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\" /></p>\n";
+                               echo "<p>" . lang('Move to other database') . ": <select name='target'>" . optionlist(get_databases(), (isset($_POST["target"]) ? $_POST["target"] : $_GET["db"])) . "</select> <input type='submit' name='move' value='" . lang('Move') . "' /></p>\n";
                                echo "</form>\n";
                        }
                        $result->free();
index bfa413043e68e8d8db6b65826c46bd34593f70b3..c38a46d4713b00533912960e948eed4773d9dc5d 100644 (file)
@@ -236,7 +236,7 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
                                        echo "</tr></thead>\n";
                                }
                                $unique_idf = implode('&amp;', unique_idf($row, $indexes));
-                               echo '<tr style="white-space: nowrap;">' . (count($select) == count($group) ? '<td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
+                               echo '<tr class="nowrap">' . (count($select) == count($group) ? '<td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
                                foreach ($row as $key => $val) {
                                        if (!isset($val)) {
                                                $val = "<i>NULL</i>";