diff --git a/adminer/createv.inc.php b/adminer/createv.inc.php deleted file mode 100644 index 2e5a1ef4..00000000 --- a/adminer/createv.inc.php +++ /dev/null @@ -1,31 +0,0 @@ - $_GET["createv"]), $_GET["createv"]); - -$row = array(); -if ($_POST) { - $row = $_POST; -} elseif (strlen($_GET["createv"])) { - $row = view($_GET["createv"]); - $row["name"] = $_GET["createv"]; -} -?> - -
-

-

- - -: " maxlength="64"> - -> -

diff --git a/adminer/db.inc.php b/adminer/db.inc.php index abe08d81..ba068171 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -54,15 +54,16 @@ if (!$table_status) { $name = $row["Name"]; table_comment($row); echo ''; + echo '' . htmlspecialchars($name) . ''; if (isset($row["Rows"])) { - echo '' . htmlspecialchars($name) . "$row[Engine]$row[Collation]"; + echo "$row[Engine]$row[Collation]"; foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) { $val = number_format($row[$key], 0, '.', lang(',')); echo '' . (strlen($row[$key]) ? '' . str_replace(" ", " ", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '' : ' '); } echo "" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " "); } else { - echo '' . htmlspecialchars($name) . '' . lang('View') . ''; + echo '' . lang('View') . ''; } } echo "\n"; @@ -76,7 +77,7 @@ if (!$table_status) { } if ($dbh->server_info >= 5) { - echo '

' . lang('Create view') . "\n"; + echo '

' . lang('Create view') . "\n"; echo "

" . lang('Routines') . "

\n"; $result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $dbh->quote($_GET["db"])); if ($result->num_rows) { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 02d4f584..a3dd2ef3 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -50,8 +50,8 @@ function adminer_login($login, $password) { * @param array result of SHOW TABLE STATUS * @return string */ -function adminer_table_name($row) { - return call_adminer('table_name', htmlspecialchars($row["Name"]), $row); +function adminer_table_name($table_status) { + return call_adminer('table_name', htmlspecialchars($table_status["Name"]), $table_status); } /** Field caption used in select and edit @@ -68,7 +68,7 @@ function adminer_field_name($field) { */ function adminer_select_links($table_status) { global $SELF; - return call_adminer('select_links', '' . lang('Table structure') . '', $table_status); + return call_adminer('select_links', '' . lang('Table structure') . '', $table_status); } /** Find backward keys for table @@ -198,7 +198,7 @@ function adminer_process_input($name, $field) { * @return bool true if default navigation should be printed */ function adminer_navigation($missing) { - global $SELF; + global $SELF, $dbh; if (call_adminer('navigation', true, $missing) && $missing != "auth") { ob_flush(); flush(); @@ -227,16 +227,17 @@ function adminer_navigation($missing) { query("SHOW TABLES"); + if (!$result->num_rows) { echo "

" . lang('No tables.') . "\n"; } else { echo "

\n"; - foreach ($table_status as $row) { - echo '' . lang('select') . ' '; - echo '' . adminer_table_name($row) . "
\n"; + while ($row = $result->fetch_row()) { + echo '' . lang('select') . ' '; + echo '' . adminer_table_name(array("Name" => $row[0])) . "
\n"; //! Adminer::table_name may work with full table status } } + $result->free(); echo '

' . lang('Create new table') . "\n"; } } diff --git a/adminer/index.php b/adminer/index.php index f2c2bc2d..3e445478 100644 --- a/adminer/index.php +++ b/adminer/index.php @@ -15,8 +15,6 @@ if (isset($_GET["download"])) { include "./download.inc.php"; } elseif (isset($_GET["table"])) { include "./table.inc.php"; -} elseif (isset($_GET["view"])) { - include "./view.inc.php"; } elseif (isset($_GET["schema"])) { include "./schema.inc.php"; } elseif (isset($_GET["dump"])) { @@ -51,8 +49,8 @@ if (isset($_GET["download"])) { include "./call.inc.php"; } elseif (isset($_GET["foreign"])) { include "./foreign.inc.php"; - } elseif (isset($_GET["createv"])) { - include "./createv.inc.php"; + } elseif (isset($_GET["view"])) { + include "./view.inc.php"; } elseif (isset($_GET["event"])) { include "./event.inc.php"; } elseif (isset($_GET["procedure"])) { diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 5751e465..0f73572a 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -3,11 +3,12 @@ $result = $dbh->query("SHOW COLUMNS FROM " . idf_escape($_GET["table"])); if (!$result) { $error = htmlspecialchars($dbh->error); } +$table_status = ($result ? table_status($_GET["table"]) : array()); +$is_view = !isset($table_status["Rows"]); -page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"]), $error); +page_header(($result && $is_view ? lang('View') : lang('Table')) . ": " . htmlspecialchars($_GET["table"]), $error); if ($result) { - $table_status = table_status($_GET["table"]); $auto_increment_only = true; echo "\n"; while ($row = $result->fetch_assoc()) { @@ -20,56 +21,62 @@ if ($result) { $result->free(); echo "

"; - echo '' . lang('Alter table') . ''; - echo ($auto_increment_only ? '' : ' ' . lang('Default values') . ''); + if ($is_view) { + echo '' . lang('Alter view') . ''; + } else { + echo '' . lang('Alter table') . ''; + echo ($auto_increment_only ? '' : ' ' . lang('Default values') . ''); + } echo ' ' . lang('Select table') . ''; echo ' ' . lang('New item') . ''; - echo "

" . lang('Indexes') . "

\n"; - $indexes = indexes($_GET["table"]); - if ($indexes) { - echo "
\n"; - foreach ($indexes as $index) { - ksort($index["columns"]); // enforce correct columns order - $print = array(); - foreach ($index["columns"] as $key => $val) { - $print[] = "" . htmlspecialchars($val) . "" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : ""); - } - echo "
$index[type]" . implode(", ", $print) . "\n"; - } - echo "
\n"; - } - echo '

' . lang('Alter indexes') . "\n"; - - if ($table_status["Engine"] == "InnoDB") { - echo "

" . lang('Foreign keys') . "

\n"; - $foreign_keys = foreign_keys($_GET["table"]); - if ($foreign_keys) { + if (!$is_view) { + echo "

" . lang('Indexes') . "

\n"; + $indexes = indexes($_GET["table"]); + if ($indexes) { echo "\n"; - foreach ($foreign_keys as $name => $foreign_key) { - $link = (strlen($foreign_key["db"]) ? "" . htmlspecialchars($foreign_key["db"]) . "." : "") . htmlspecialchars($foreign_key["table"]); - echo ""; - echo "
" . implode(", ", array_map('htmlspecialchars', $foreign_key["source"])) . ""; - echo '$link"; - echo "(" . implode(", ", array_map('htmlspecialchars', $foreign_key["target"])) . ")"; - echo "" . (!strlen($foreign_key["db"]) ? '' . lang('Alter') . '' : ' '); + foreach ($indexes as $index) { + ksort($index["columns"]); // enforce correct columns order + $print = array(); + foreach ($index["columns"] as $key => $val) { + $print[] = "" . htmlspecialchars($val) . "" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : ""); + } + echo "
$index[type]" . implode(", ", $print) . "\n"; } echo "
\n"; } - echo '

' . lang('Add foreign key') . "\n"; - } -} - -if ($dbh->server_info >= 5) { - echo "

" . lang('Triggers') . "

\n"; - $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($_GET["table"], "%_"))); - if ($result->num_rows) { - echo "\n"; - while ($row = $result->fetch_assoc()) { - echo "
$row[Timing]$row[Event]" . htmlspecialchars($row["Trigger"]) . "' . lang('Alter') . "\n"; + echo '

' . lang('Alter indexes') . "\n"; + + if ($table_status["Engine"] == "InnoDB") { + echo "

" . lang('Foreign keys') . "

\n"; + $foreign_keys = foreign_keys($_GET["table"]); + if ($foreign_keys) { + echo "\n"; + foreach ($foreign_keys as $name => $foreign_key) { + $link = (strlen($foreign_key["db"]) ? "" . htmlspecialchars($foreign_key["db"]) . "." : "") . htmlspecialchars($foreign_key["table"]); + echo ""; + echo "
" . implode(", ", array_map('htmlspecialchars', $foreign_key["source"])) . ""; + echo '$link"; + echo "(" . implode(", ", array_map('htmlspecialchars', $foreign_key["target"])) . ")"; + echo "" . (!strlen($foreign_key["db"]) ? '' . lang('Alter') . '' : ' '); + } + echo "
\n"; + } + echo '

' . lang('Add foreign key') . "\n"; + } + + if ($dbh->server_info >= 5) { + echo "

" . lang('Triggers') . "

\n"; + $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($_GET["table"], "%_"))); + if ($result->num_rows) { + echo "\n"; + while ($row = $result->fetch_assoc()) { + echo "
$row[Timing]$row[Event]" . htmlspecialchars($row["Trigger"]) . "' . lang('Alter') . "\n"; + } + echo "
\n"; + } + $result->free(); + echo '

' . lang('Add trigger') . "\n"; } - echo "

\n"; } - $result->free(); - echo '

' . lang('Add trigger') . "\n"; } diff --git a/adminer/view.inc.php b/adminer/view.inc.php index 7540dae5..1b7a77e7 100644 --- a/adminer/view.inc.php +++ b/adminer/view.inc.php @@ -1,6 +1,31 @@ " . htmlspecialchars($view["select"]) . "\n"; -echo '

' . lang('Alter view') . "\n"; +page_header((strlen($_GET["view"]) ? lang('Alter view') : lang('Create view')), $error, array("table" => $_GET["view"]), $_GET["view"]); + +$row = array(); +if ($_POST) { + $row = $_POST; +} elseif (strlen($_GET["view"])) { + $row = view($_GET["view"]); + $row["name"] = $_GET["view"]; +} +?> + +

+

+

+ + +: " maxlength="64"> + +> +

diff --git a/changes.txt b/changes.txt index a3aa5897..2679f4cc 100644 --- a/changes.txt +++ b/changes.txt @@ -10,6 +10,7 @@ Preselect now() for timestamp columns (thanks to paranoiq) Clear history (thanks to paranoiq) Remove Delete button from Edit page - use mass operation for it Faster multiple update, clone and delete +Faster table list in navigation Use HTML Strict instead of XHTML Fix grant ALL PRIVILEGES with GRANT OPTION Fix CSV import diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index b9ae9c3d..acce9c70 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -27,9 +27,9 @@ function adminer_login($login, $password) { return call_adminer('login', true, $login, $password); } -function adminer_table_name($row) { - table_comment($row); - return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row); +function adminer_table_name($table_status) { + table_comment($table_status); + return call_adminer('table_name', htmlspecialchars(strlen($table_status["Comment"]) ? $table_status["Comment"] : $table_status["Name"]), $table_status); } function adminer_field_name($field) { @@ -48,7 +48,7 @@ FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . " AND REFERENCED_TABLE_SCHEMA = " . $dbh->quote(adminer_database()) . " AND REFERENCED_TABLE_NAME = " . $dbh->quote($table) . " -ORDER BY ORDINAL_POSITION"); +ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 if ($result) { while ($row = $result->fetch_assoc()) { $return[$row["TABLE_NAME"]][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];