diff --git a/adminer/db.inc.php b/adminer/db.inc.php index eaec1c04..4b970a63 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -32,129 +32,128 @@ if ($tables_views && !$error && !$_POST["search"]) { } page_header(($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"])), $error, true); -echo '

' . ($_GET["ns"] == "" ? '' . lang('Alter database') . "\n" : ""); -if (support("scheme")) { - echo "" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . "\n"; -} -if ($_GET["ns"] !== "") { - echo '' . lang('Database schema') . "\n"; - echo "

" . lang('Tables and views') . "

\n"; - $tables_list = tables_list(); - if (!$tables_list) { - echo "

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

\n"; - echo "

" . lang('Search data in tables') . ": \n"; - if ($_POST["search"] && $_POST["query"] != "") { - search_tables(); - } - echo "\n"; - echo '\n"; - foreach ($tables_list as $name => $type) { - $view = (isset($type) && !eregi("table", $type)); - echo '
' . lang('Table') . '' . lang('Engine') . '' . lang('Collation') . '' . lang('Data Length') . '' . lang('Index Length') . '' . lang('Data Free') . '' . lang('Auto Increment') . '' . lang('Rows') . (support("comment") ? '' . lang('Comment') : '') . "
' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');"); - echo '' . h($name) . ''; - if ($view) { - echo '' . lang('View') . ''; - echo '?'; - } else { - echo "  "; - foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) { - echo "?"; + +if ($adminer->homepage()) { + if ($_GET["ns"] !== "") { + echo '' . lang('Database schema') . "\n"; + echo "

" . lang('Tables and views') . "

\n"; + $tables_list = tables_list(); + if (!$tables_list) { + echo "

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

" . lang('Search data in tables') . ": \n"; + if ($_POST["search"] && $_POST["query"] != "") { + search_tables(); + } + echo "\n"; + echo '\n"; + foreach ($tables_list as $name => $type) { + $view = (isset($type) && !eregi("table", $type)); + echo '
' . lang('Table') . '' . lang('Engine') . '' . lang('Collation') . '' . lang('Data Length') . '' . lang('Index Length') . '' . lang('Data Free') . '' . lang('Auto Increment') . '' . lang('Rows') . (support("comment") ? '' . lang('Comment') : '') . "
' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');"); + echo '' . h($name) . ''; + if ($view) { + echo '' . lang('View') . ''; + echo '?'; + } else { + echo "  "; + foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) { + echo "?"; + } + } + echo (support("comment") ? " " : ""); + } + echo "
 " . lang('%d in total', count($tables_list)); + echo "" . nbsp($connection->result("SELECT @@storage_engine")); + echo "" . nbsp(db_collation(DB, collations())); + foreach (array("Data_length", "Index_length", "Data_free") as $key) { + echo " "; + } + echo "
\n"; + if (!information_schema(DB)) { + echo "

" . ($jush == "sql" ? " " : "") . " \n"; // 1 - eventStop + $databases = (support("scheme") ? schemas() : get_databases()); + if (count($databases) != 1 && $jush != "sqlite") { + $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB)); + echo "

" . lang('Move to other database') . ($databases ? ": " . html_select("target", $databases, $db) : ': ') . " \n"; } } - echo (support("comment") ? "

 " : ""); + echo "\n"; } - echo "
 " . lang('%d in total', count($tables_list)); - echo "" . nbsp($connection->result("SELECT @@storage_engine")); - echo "" . nbsp(db_collation(DB, collations())); - foreach (array("Data_length", "Index_length", "Data_free") as $key) { - echo " "; + + echo '

' . lang('Create table') . "\n"; + if (support("view")) { + echo '' . lang('Create view') . "\n"; } - echo "

\n"; - if (!information_schema(DB)) { - echo "

" . ($jush == "sql" ? " " : "") . " \n"; // 1 - eventStop - $databases = (support("scheme") ? schemas() : get_databases()); - if (count($databases) != 1 && $jush != "sqlite") { - $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB)); - echo "

" . lang('Move to other database') . ($databases ? ": " . html_select("target", $databases, $db) : ': ') . " \n"; - } - } - echo "\n"; - } - echo '

' . lang('Create table') . "\n"; - if (support("view")) { - echo '' . lang('Create view') . "\n"; - } - - if (support("routine")) { - echo "

" . lang('Routines') . "

\n"; - $routines = routines(); - if ($routines) { - echo "\n"; - echo '\n"; - odd(''); - foreach ($routines as $row) { - echo ''; - echo '
' . lang('Name') . '' . lang('Type') . '' . lang('Return type') . " 
' . h($row["ROUTINE_NAME"]) . ''; - echo '' . h($row["ROUTINE_TYPE"]); - echo '' . h($row["DTD_IDENTIFIER"]); - echo '' . lang('Alter') . ""; + if (support("routine")) { + echo "

" . lang('Routines') . "

\n"; + $routines = routines(); + if ($routines) { + echo "\n"; + echo '\n"; + odd(''); + foreach ($routines as $row) { + echo ''; + echo '
' . lang('Name') . '' . lang('Type') . '' . lang('Return type') . " 
' . h($row["ROUTINE_NAME"]) . ''; + echo '' . h($row["ROUTINE_TYPE"]); + echo '' . h($row["DTD_IDENTIFIER"]); + echo '' . lang('Alter') . ""; + } + echo "
\n"; } - echo "
\n"; + echo '

' . lang('Create procedure') . ' ' . lang('Create function') . "\n"; } - echo '

' . lang('Create procedure') . ' ' . lang('Create function') . "\n"; - } - - if (support("sequence")) { - echo "

" . lang('Sequences') . "

\n"; - $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()"); - if ($sequences) { - echo "\n"; - echo "\n"; - odd(''); - foreach ($sequences as $val) { - echo "
" . lang('Name') . "
" . h($val) . "\n"; + + if (support("sequence")) { + echo "

" . lang('Sequences') . "

\n"; + $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()"); + if ($sequences) { + echo "\n"; + echo "\n"; + odd(''); + foreach ($sequences as $val) { + echo "
" . lang('Name') . "
" . h($val) . "\n"; + } + echo "
\n"; } - echo "
\n"; + echo "

" . lang('Create sequence') . "\n"; } - echo "

" . lang('Create sequence') . "\n"; - } - - if (support("type")) { - echo "

" . lang('User types') . "

\n"; - $types = types(); - if ($types) { - echo "\n"; - echo "\n"; - odd(''); - foreach ($types as $val) { - echo "
" . lang('Name') . "
" . h($val) . "\n"; + + if (support("type")) { + echo "

" . lang('User types') . "

\n"; + $types = types(); + if ($types) { + echo "\n"; + echo "\n"; + odd(''); + foreach ($types as $val) { + echo "
" . lang('Name') . "
" . h($val) . "\n"; + } + echo "
\n"; } - echo "
\n"; + echo "

" . lang('Create type') . "\n"; } - echo "

" . lang('Create type') . "\n"; - } - - if (support("event")) { - echo "

" . lang('Events') . "

\n"; - $rows = get_rows("SHOW EVENTS"); - if ($rows) { - echo "\n"; - echo "\n"; - foreach ($rows as $row) { - echo ""; - echo '
" . lang('Name') . "" . lang('Schedule') . "" . lang('Start') . "" . lang('End') . "
' . h($row["Name"]) . ""; - echo "" . ($row["Execute at"] ? lang('At given time') . "" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "$row[Starts]"); - echo "$row[Ends]"; + + if (support("event")) { + echo "

" . lang('Events') . "

\n"; + $rows = get_rows("SHOW EVENTS"); + if ($rows) { + echo "\n"; + echo "\n"; + foreach ($rows as $row) { + echo ""; + echo '
" . lang('Name') . "" . lang('Schedule') . "" . lang('Start') . "" . lang('End') . "
' . h($row["Name"]) . ""; + echo "" . ($row["Execute at"] ? lang('At given time') . "" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "$row[Starts]"); + echo "$row[Ends]"; + } + echo "
\n"; } - echo "
\n"; + echo '

' . lang('Create event') . "\n"; + } + + if ($tables_list) { + echo "\n"; } - echo '

' . lang('Create event') . "\n"; - } - - if ($tables_list) { - echo "\n"; } } diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 18fe8896..37faf96a 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -682,6 +682,17 @@ DROP PROCEDURE adminer_alter; return $ext; } + /** Print homepage + * @return bool whether to print default homepage + */ + function homepage() { + echo '

' . ($_GET["ns"] == "" ? '' . lang('Alter database') . "\n" : ""); + if (support("scheme")) { + echo "" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . "\n"; + } + return true; + } + /** Prints navigation after Adminer title * @param string can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema * @return null diff --git a/changes.txt b/changes.txt index 9cbf81df..98574d63 100644 --- a/changes.txt +++ b/changes.txt @@ -7,6 +7,7 @@ History: edit all MS SQL: auto primary and foreign key SQLite: display 0 Create table default data type: int +Homepage customization Work without session.use_cookies (bug #3138640) Portuguese translation diff --git a/editor/db.inc.php b/editor/db.inc.php index ba887864..6bf1d2f6 100644 --- a/editor/db.inc.php +++ b/editor/db.inc.php @@ -1,21 +1,23 @@ \n"; -echo "

" . lang('Search data in tables') . ": \n"; -if ($_POST["query"] != "") { - search_tables(); -} -echo "\n"; -echo '\n"; -foreach (table_status() as $table => $row) { - $name = $adminer->tableName($row); - if (isset($row["Engine"]) && $name != "") { - echo '
' . lang('Table') . '' . lang('Rows') . "
' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true), "", "formUncheck('check-all');"); - echo '' . h($name) . ''; - $val = number_format($row["Rows"], 0, '.', lang(',')); - echo "" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . ""; +if ($adminer->homepage()) { + echo "
\n"; + echo "

" . lang('Search data in tables') . ": \n"; + if ($_POST["query"] != "") { + search_tables(); } + echo "\n"; + echo '\n"; + foreach (table_status() as $table => $row) { + $name = $adminer->tableName($row); + if (isset($row["Engine"]) && $name != "") { + echo '
' . lang('Table') . '' . lang('Rows') . "
' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true), "", "formUncheck('check-all');"); + echo '' . h($name) . ''; + $val = number_format($row["Rows"], 0, '.', lang(',')); + echo "" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . ""; + } + } + echo "
\n"; + echo "

\n"; } -echo "
\n"; -echo "\n"; diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 9d9b87e5..1f5fe4f1 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -465,6 +465,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 return $ext; } + function homepage() { + return true; + } + function navigation($missing) { global $VERSION, $token; ?>