]> git.joonet.de Git - adminer.git/commitdiff
Add links to documentation
authorJakub Vrana <jakub@vrana.cz>
Wed, 17 Jul 2013 01:37:33 +0000 (18:37 -0700)
committerJakub Vrana <jakub@vrana.cz>
Wed, 17 Jul 2013 04:17:09 +0000 (21:17 -0700)
adminer/create.inc.php
adminer/db.inc.php
adminer/include/editing.inc.php
adminer/processlist.inc.php
adminer/sql.inc.php
adminer/user.inc.php
changes.txt

index cbaa71b77d9a95d3a6d2d24bb991474aa4ab803e..dc099216830c6324380beb0fb63ea06f258d79f5 100644 (file)
@@ -197,7 +197,7 @@ if (support("partitioning")) {
        print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
        ?>
 <p>
-<?php echo html_select("partition_by", array(-1 => "") + $partition_by, $row["partition_by"], "partitionByChange(this);"); ?>
+<?php echo html_select("partition_by", array(-1 => "") + $partition_by, $row["partition_by"], "partitionByChange(this);") . doc_link("partitioning-types.html"); ?>
 (<input name="partition" value="<?php echo h($row["partition"]); ?>">)
 <?php echo lang('Partitions'); ?>: <input type="number" name="partitions" class="size<?php echo ($partition_table || !$row["partition_by"] ? " hidden" : ""); ?>" value="<?php echo h($row["partitions"]); ?>">
 <table cellspacing="0" id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
index 3b58596c01e0f614dab013ac51bb5047a4b883ee..a33adb2b1fdb53d67c092ce416e0dd7248a1fd9d 100644 (file)
@@ -114,11 +114,17 @@ if ($adminer->homepage()) {
                        
                        echo "</table>\n";
                        if (!information_schema(DB)) {
+                               $analyze = "<input type='submit' value='" . lang('Analyze') . "'>";
+                               $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'>";
                                echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>"
-                               . (ereg('^(sql|sqlite|pgsql)$', $jush) ? ($jush != "sqlite" ? "<input type='submit' value='" . lang('Analyze') . "'> " : "") . "<input type='submit' name='optimize' value='" . lang('Optimize') . "'> " : "")
-                               . ($jush == "sql" ? "<input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "")
-                               . (support("table") ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . "> " : "")
-                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
+                               . ($jush == "sqlite" ? $optimize . doc_command("vacuum") . " "
+                               : ($jush == "pgsql" ? $analyze . doc_command("vacuum") . " $optimize" . doc_command("vacuum") . " "
+                               : ($jush == "sql" ? $analyze . doc_command("analyze-table") . " $optimize" . doc_command("optimize-table") . " "
+                                       . "<input type='submit' name='check' value='" . lang('Check') . "'>" . doc_command("check-table") . " "
+                                       . "<input type='submit' name='repair' value='" . lang('Repair') . "'>" . doc_command("repair-table") . " "
+                               : "")))
+                               . (support("table") ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . ">" . doc_command($jush == "sqlite" ? "delete" : "truncate" . ($jush == "pgsql" ? "" : "-table")) . " " : "")
+                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">" . doc_command("drop-table") . "\n";
                                $databases = (support("scheme") ? schemas() : $adminer->databases());
                                if (count($databases) != 1 && $jush != "sqlite") {
                                        $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));
index aa6d8d028ef6ca86ffe6d4cb6c25a7fce3e4a544..af2c445ad0ecf3557e483aef78cc5ef5211906ae 100644 (file)
@@ -2,11 +2,11 @@
 /** Print select result
 * @param Min_Result
 * @param Min_DB connection to examine indexes
-* @param string base link for <th> fields
 * @param array
-* @return null
+* @return array $orgtables
 */
-function select($result, $connection2 = null, $href = "", $orgtables = array()) {
+function select($result, $connection2 = null, $orgtables = array()) {
+       global $jush;
        $links = array(); // colno => orgtable - create links from these columns
        $indexes = array(); // orgtable => array(column => colno) - primary keys
        $columns = array(); // orgtable => array(column => ) - not selected columns in primary key
@@ -24,7 +24,7 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
                                $orgtable = $field->orgtable;
                                $orgname = $field->orgname;
                                $return[$field->table] = $orgtable;
-                               if ($href) { // MySQL EXPLAIN
+                               if ($orgtables && $jush == "sql") { // MySQL EXPLAIN
                                        $links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null));
                                } elseif ($orgtable != "") {
                                        if (!isset($indexes[$orgtable])) {
@@ -48,9 +48,8 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
                                        $blobs[$j] = true;
                                }
                                $types[$j] = $field->type;
-                               $name = h($name);
-                               echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">"
-                                       . ($href ? "<a href='$href" . strtolower($name) . "' target='_blank' rel='noreferrer' class='help'>$name</a>" : $name)
+                               echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($name)
+                                       . ($orgtables && $jush == "sql" ? doc_link("explain-output.html#explain_" . strtolower($name)) : "")
                                ;
                        }
                        echo "</thead>\n";
@@ -70,7 +69,7 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
                                }
                        }
                        if (isset($links[$key]) && !$columns[$links[$key]]) {
-                               if ($href) { // MySQL EXPLAIN
+                               if ($orgtables && $jush == "sql") { // MySQL EXPLAIN
                                        $table = $row[array_search("table=", $links)];
                                        $link = $links[$key] . urlencode($orgtables[$table] != "" ? $orgtables[$table] : $table);
                                } else {
@@ -450,3 +449,44 @@ function ini_bytes($ini) {
        }
        return $val;
 }
+
+/** Create link to database documentation
+* @param string
+* @return string HTML code
+*/
+function doc_link($path) {
+       global $jush, $connection;
+       $urls = array(
+                'sql' => "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/",
+                'sqlite' => "http://www.sqlite.org/",
+                'pgsql' => "http://www.postgresql.org/docs/" . substr($connection->server_info, 0, 3) . "/static/",
+                'mssql' => "http://msdn.microsoft.com/library/",
+                'oracle' => "http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/",
+       );
+       return ($urls[$jush] ? "<a href='$urls[$jush]$path' target='_blank' rel='noreferrer'><sup>?</sup></a>" : "");
+}
+
+/** Create link to documentation of database command
+* @param string lower-case
+* @return string HTML code
+*/
+function doc_command($command) {
+       global $jush;
+       switch ($jush) {
+               case 'sql': return doc_link("$command.html");
+               case 'sqlite': return doc_link("lang_" . str_replace("-", "", $command) . ".html");
+               case 'pgsql': return doc_link("sql-" . str_replace("-", "", $command) . ".html");
+               case 'mssql':
+                       $links = array(
+                               'drop-table' => 'ms173790',
+                               'truncate-table' => 'ms177570',
+                       );
+                       return doc_link("$links[$command].aspx");
+               case 'oracle':
+                       $links = array(
+                               'drop-table' => 'statements_9003.htm',
+                               'truncate-table' => 'statements_10006.htm',
+                       );
+                       return doc_link($links[$command]);
+       }
+}
index b7c3e6a867902a6c1066fd054c81de29090bf523..5d8cb84bd074dc2d5e1e537796f8ce9e3251b542 100644 (file)
@@ -22,10 +22,9 @@ foreach (process_list() as $i => $row) {
        if (!$i) {
                echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "");
                foreach ($row as $key => $val) {
-                       echo "<th>" . ($jush == "sql"
-                               ? "<a href='http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/show-processlist.html#processlist_" . strtolower($key) . "' target='_blank' rel='noreferrer' class='help'>$key</a>"
-                               : $key
-                       );
+                       echo "<th>$key"
+                       . ($jush == "sql" ? doc_link("show-processlist.html#processlist_" . strtolower($key)) : "")
+                       ;
                }
                echo "</thead>\n";
        }
index 1fa96e17292f83be5243c9fc54090b05657949e9..b434e84fef2c226f6c5481a16b5577840148ba51 100644 (file)
@@ -136,7 +136,7 @@ if (!$error && $_POST) {
                                                                                $id = "explain-$commands";
                                                                                echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export";
                                                                                echo "<div id='$id' class='hidden'>\n";
-                                                                               select($explain, $connection2, ($jush == "sql" ? "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/explain-output.html#explain_" : ""), $orgtables);
+                                                                               select($explain, $connection2, $orgtables);
                                                                                echo "</div>\n";
                                                                        } else {
                                                                                echo $export;
index 71e7cf6a475e55ea0c52a6fff7343d632d4ca000..986e8c0c6313a593293db00c36be8842b1569581 100644 (file)
@@ -142,7 +142,7 @@ if ($_POST) {
 <?php
 //! MAX_* limits, REQUIRE
 echo "<table cellspacing='0'>\n";
-echo "<thead><tr><th colspan='2'><a href='http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/grant.html#priv_level' target='_blank' rel='noreferrer' class='help'>" . lang('Privileges') . "</a>";
+echo "<thead><tr><th colspan='2'>" . lang('Privileges') . doc_link("grant.html#priv_level");
 $i = 0;
 foreach ($grants as $object => $grant) {
        echo '<th>' . ($object != "*.*" ? "<input name='objects[$i]' value='" . h($object) . "' size='10' autocapitalize='off'>" : "<input type='hidden' name='objects[$i]' value='*.*' size='10'>*.*"); //! separate db, table, columns, PROCEDURE|FUNCTION, routine
index f026601350d4f13dd408af1e09041ebf26dd4e2c..456426db538f405e067e834287155e4ed058918e 100644 (file)
@@ -6,6 +6,7 @@ Mark length as required for strings
 Add label to database selection
 Add button for dropping an index
 Display number of selected rows
+Add links to documentation
 Disable underlining links
 Improve speed of CSV import
 Don't append newlines to uploaded files, bug since Adminer 3.7.0