]> git.joonet.de Git - adminer.git/commitdiff
Homepage customization
authorJakub Vrana <jakub@vrana.cz>
Thu, 6 Jan 2011 08:30:07 +0000 (09:30 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 6 Jan 2011 08:30:07 +0000 (09:30 +0100)
adminer/db.inc.php
adminer/include/adminer.inc.php
changes.txt
editor/db.inc.php
editor/include/adminer.inc.php

index eaec1c04d747ff805be4292f342b59bd4a7f997f..4b970a63e9f62bfcbd9bd8930ae5c9ab4ed62f45 100644 (file)
@@ -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 '<p>' . ($_GET["ns"] == "" ? '<a href="' . h(ME) . 'database=">' . lang('Alter database') . "</a>\n" : "");
-if (support("scheme")) {
-       echo "<a href='" . h(ME) . "scheme='>" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . "</a>\n";
-}
-if ($_GET["ns"] !== "") {
-       echo '<a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
-       echo "<h3>" . lang('Tables and views') . "</h3>\n";
-       $tables_list = tables_list();
-       if (!$tables_list) {
-               echo "<p class='message'>" . lang('No tables.') . "\n";
-       } else {
-               echo "<form action='' method='post'>\n";
-               echo "<p>" . lang('Search data in tables') . ": <input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
-               if ($_POST["search"] && $_POST["query"] != "") {
-                       search_tables();
-               }
-               echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
-               echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . (support("comment") ? '<td>' . lang('Comment') : '') . "</thead>\n";
-               foreach ($tables_list as $name => $type) {
-                       $view = (isset($type) && !eregi("table", $type));
-                       echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
-                       echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
-                       if ($view) {
-                               echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '">' . lang('View') . '</a>';
-                               echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '">?</a>';
-                       } else {
-                               echo "<td id='Engine-" . h($name) . "'>&nbsp;<td id='Collation-" . h($name) . "'>&nbsp;";
-                               foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) {
-                                       echo "<td align='right'><a href='" . h(ME . "$link=") . urlencode($name) . "' id='$key-" . h($name) . "'>?</a>";
+
+if ($adminer->homepage()) {
+       if ($_GET["ns"] !== "") {
+               echo '<a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
+               echo "<h3>" . lang('Tables and views') . "</h3>\n";
+               $tables_list = tables_list();
+               if (!$tables_list) {
+                       echo "<p class='message'>" . lang('No tables.') . "\n";
+               } else {
+                       echo "<form action='' method='post'>\n";
+                       echo "<p>" . lang('Search data in tables') . ": <input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
+                       if ($_POST["search"] && $_POST["query"] != "") {
+                               search_tables();
+                       }
+                       echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
+                       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);"><th>' . lang('Table') . '<td>' . lang('Engine') . '<td>' . lang('Collation') . '<td>' . lang('Data Length') . '<td>' . lang('Index Length') . '<td>' . lang('Data Free') . '<td>' . lang('Auto Increment') . '<td>' . lang('Rows') . (support("comment") ? '<td>' . lang('Comment') : '') . "</thead>\n";
+                       foreach ($tables_list as $name => $type) {
+                               $view = (isset($type) && !eregi("table", $type));
+                               echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
+                               echo '<th><a href="' . h(ME) . 'table=' . urlencode($name) . '">' . h($name) . '</a>';
+                               if ($view) {
+                                       echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '">' . lang('View') . '</a>';
+                                       echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '">?</a>';
+                               } else {
+                                       echo "<td id='Engine-" . h($name) . "'>&nbsp;<td id='Collation-" . h($name) . "'>&nbsp;";
+                                       foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "auto_increment=1&create", "Rows" => "select") as $key => $link) {
+                                               echo "<td align='right'><a href='" . h(ME . "$link=") . urlencode($name) . "' id='$key-" . h($name) . "'>?</a>";
+                                       }
                                }
+                               echo (support("comment") ? "<td id='Comment-" . h($name) . "'>&nbsp;" : "");
                        }
-                       echo (support("comment") ? "<td id='Comment-" . h($name) . "'>&nbsp;" : "");
-               }
-               echo "<tr><td>&nbsp;<th>" . lang('%d in total', count($tables_list));
-               echo "<td>" . nbsp($connection->result("SELECT @@storage_engine"));
-               echo "<td>" . nbsp(db_collation(DB, collations()));
-               foreach (array("Data_length", "Index_length", "Data_free") as $key) {
-                       echo "<td align='right' id='sum-$key'>&nbsp;";
-               }
-               echo "</table>\n";
-               if (!information_schema(DB)) {
-                       echo "<p><input type='hidden' name='token' value='$token'>" . ($jush == "sql" ? "<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') . "'" . confirm("formChecked(this, /tables/)") . "> <input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /tables|views/)", 1) . ">\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 "<p>" . lang('Move to other database') . ($databases ? ": " . html_select("target", $databases, $db) : ': <input name="target" value="' . h($db) . '">') . " <input type='submit' name='move' value='" . lang('Move') . "' onclick='eventStop(event);'>\n";
+                       echo "<tr><td>&nbsp;<th>" . lang('%d in total', count($tables_list));
+                       echo "<td>" . nbsp($connection->result("SELECT @@storage_engine"));
+                       echo "<td>" . nbsp(db_collation(DB, collations()));
+                       foreach (array("Data_length", "Index_length", "Data_free") as $key) {
+                               echo "<td align='right' id='sum-$key'>&nbsp;";
                        }
+                       echo "</table>\n";
+                       if (!information_schema(DB)) {
+                               echo "<p><input type='hidden' name='token' value='$token'>" . ($jush == "sql" ? "<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') . "'" . confirm("formChecked(this, /tables/)") . "> <input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /tables|views/)", 1) . ">\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 "<p>" . lang('Move to other database') . ($databases ? ": " . html_select("target", $databases, $db) : ': <input name="target" value="' . h($db) . '">') . " <input type='submit' name='move' value='" . lang('Move') . "' onclick='eventStop(event);'>\n";
+                               }
+                       }
+                       echo "</form>\n";
+               }
+               
+               echo '<p><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
+               if (support("view")) {
+                       echo '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
                }
-               echo "</form>\n";
-       }
        
-       echo '<p><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
-       if (support("view")) {
-               echo '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
-       }
-
-       if (support("routine")) {
-               echo "<h3>" . lang('Routines') . "</h3>\n";
-               $routines = routines();
-               if ($routines) {
-                       echo "<table cellspacing='0'>\n";
-                       echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td>&nbsp;</thead>\n";
-                       odd('');
-                       foreach ($routines as $row) {
-                               echo '<tr' . odd() . '>';
-                               echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
-                               echo '<td>' . h($row["ROUTINE_TYPE"]);
-                               echo '<td>' . h($row["DTD_IDENTIFIER"]);
-                               echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
+               if (support("routine")) {
+                       echo "<h3>" . lang('Routines') . "</h3>\n";
+                       $routines = routines();
+                       if ($routines) {
+                               echo "<table cellspacing='0'>\n";
+                               echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td>&nbsp;</thead>\n";
+                               odd('');
+                               foreach ($routines as $row) {
+                                       echo '<tr' . odd() . '>';
+                                       echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
+                                       echo '<td>' . h($row["ROUTINE_TYPE"]);
+                                       echo '<td>' . h($row["DTD_IDENTIFIER"]);
+                                       echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
+                               }
+                               echo "</table>\n";
                        }
-                       echo "</table>\n";
+                       echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
                }
-               echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
-       }
-       
-       if (support("sequence")) {
-               echo "<h3>" . lang('Sequences') . "</h3>\n";
-               $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");
-               if ($sequences) {
-                       echo "<table cellspacing='0'>\n";
-                       echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
-                       odd('');
-                       foreach ($sequences as $val) {
-                               echo "<tr" . odd() . "><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
+               
+               if (support("sequence")) {
+                       echo "<h3>" . lang('Sequences') . "</h3>\n";
+                       $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");
+                       if ($sequences) {
+                               echo "<table cellspacing='0'>\n";
+                               echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
+                               odd('');
+                               foreach ($sequences as $val) {
+                                       echo "<tr" . odd() . "><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
+                               }
+                               echo "</table>\n";
                        }
-                       echo "</table>\n";
+                       echo "<p><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
                }
-               echo "<p><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
-       }
-       
-       if (support("type")) {
-               echo "<h3>" . lang('User types') . "</h3>\n";
-               $types = types();
-               if ($types) {
-                       echo "<table cellspacing='0'>\n";
-                       echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
-                       odd('');
-                       foreach ($types as $val) {
-                               echo "<tr" . odd() . "><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
+               
+               if (support("type")) {
+                       echo "<h3>" . lang('User types') . "</h3>\n";
+                       $types = types();
+                       if ($types) {
+                               echo "<table cellspacing='0'>\n";
+                               echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
+                               odd('');
+                               foreach ($types as $val) {
+                                       echo "<tr" . odd() . "><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
+                               }
+                               echo "</table>\n";
                        }
-                       echo "</table>\n";
+                       echo "<p><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
                }
-               echo "<p><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
-       }
-       
-       if (support("event")) {
-               echo "<h3>" . lang('Events') . "</h3>\n";
-               $rows = get_rows("SHOW EVENTS");
-               if ($rows) {
-                       echo "<table cellspacing='0'>\n";
-                       echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
-                       foreach ($rows as $row) {
-                               echo "<tr>";
-                               echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
-                               echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
-                               echo "<td>$row[Ends]";
+               
+               if (support("event")) {
+                       echo "<h3>" . lang('Events') . "</h3>\n";
+                       $rows = get_rows("SHOW EVENTS");
+                       if ($rows) {
+                               echo "<table cellspacing='0'>\n";
+                               echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
+                               foreach ($rows as $row) {
+                                       echo "<tr>";
+                                       echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
+                                       echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
+                                       echo "<td>$row[Ends]";
+                               }
+                               echo "</table>\n";
                        }
-                       echo "</table>\n";
+                       echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
+               }
+               
+               if ($tables_list) {
+                       echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
                }
-               echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
-       }
-       
-       if ($tables_list) {
-               echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
        }
 }
index 18fe8896df450c4a101a35f6299d94e22649d667..37faf96a92996abf785293842822f1decf6b312f 100644 (file)
@@ -682,6 +682,17 @@ DROP PROCEDURE adminer_alter;
                return $ext;
        }
        
+       /** Print homepage
+       * @return bool whether to print default homepage
+       */
+       function homepage() {
+               echo '<p>' . ($_GET["ns"] == "" ? '<a href="' . h(ME) . 'database=">' . lang('Alter database') . "</a>\n" : "");
+               if (support("scheme")) {
+                       echo "<a href='" . h(ME) . "scheme='>" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . "</a>\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
index 9cbf81dfb3db2eafd71ca3fc7cfb40411a0b04df..98574d636c520ed781e2571b16cf9a61ac5278fc 100644 (file)
@@ -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
 
index ba8878645146b73dded2a4ce2d02d0d87a72df95..6bf1d2f6ef8b8850cf5181163bde1a6e1f9fe7d2 100644 (file)
@@ -1,21 +1,23 @@
 <?php
 page_header(lang('Server'), "", false);
 
-echo "<form action='' method='post'>\n";
-echo "<p>" . lang('Search data in tables') . ": <input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' value='" . lang('Search') . "'>\n";
-if ($_POST["query"] != "") {
-       search_tables();
-}
-echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
-echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
-foreach (table_status() as $table => $row) {
-       $name = $adminer->tableName($row);
-       if (isset($row["Engine"]) && $name != "") {
-               echo '<tr' . odd() . '><td>' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true), "", "formUncheck('check-all');");
-               echo '<th><a href="' . h(ME) . 'select=' . urlencode($table) . '">' . h($name) . '</a>';
-               $val = number_format($row["Rows"], 0, '.', lang(','));
-               echo "<td align='right'><a href='" . h(ME . "edit=") . urlencode($table) . "'>" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "</a>";
+if ($adminer->homepage()) {
+       echo "<form action='' method='post'>\n";
+       echo "<p>" . lang('Search data in tables') . ": <input name='query' value='" . h($_POST["query"]) . "'> <input type='submit' value='" . lang('Search') . "'>\n";
+       if ($_POST["query"] != "") {
+               search_tables();
+       }
+       echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
+       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
+       foreach (table_status() as $table => $row) {
+               $name = $adminer->tableName($row);
+               if (isset($row["Engine"]) && $name != "") {
+                       echo '<tr' . odd() . '><td>' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true), "", "formUncheck('check-all');");
+                       echo '<th><a href="' . h(ME) . 'select=' . urlencode($table) . '">' . h($name) . '</a>';
+                       $val = number_format($row["Rows"], 0, '.', lang(','));
+                       echo "<td align='right'><a href='" . h(ME . "edit=") . urlencode($table) . "'>" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "</a>";
+               }
        }
+       echo "</table>\n";
+       echo "</form>\n";
 }
-echo "</table>\n";
-echo "</form>\n";
index 9d9b87e5aa03cd1c85f17ab7165f5c110a9cf521..1f5fe4f12e0570e0650c50e1fa5ae2f84ea1ee01 100644 (file)
@@ -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;
                ?>