From a338f9bf581e561d7c5b8f3a1f18bc7be7e42695 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 19 Jul 2013 10:35:31 -0700 Subject: [PATCH] Display help in tooltip Also rename Analyze to Vacuum outside MySQL --- adminer/db.inc.php | 18 ++++++++--------- adminer/include/adminer.inc.php | 8 ++++---- adminer/include/design.inc.php | 4 +++- adminer/include/editing.inc.php | 32 +++++++++---------------------- adminer/include/functions.inc.php | 5 ++++- adminer/lang/cs.inc.php | 1 + adminer/lang/xx.inc.php | 1 + adminer/processlist.inc.php | 4 +--- adminer/static/default.css | 1 + adminer/static/editing.js | 32 +++++++++++++++++++++++++++++++ 10 files changed, 65 insertions(+), 41 deletions(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index a33adb2b..c5e4c873 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -114,17 +114,17 @@ if ($adminer->homepage()) { echo "\n"; if (!information_schema(DB)) { - $analyze = ""; - $optimize = ""; + $vacuum = " "; + $optimize = " "; echo "
" . lang('Selected') . "
" - . ($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") . " " - . "" . doc_command("check-table") . " " - . "" . doc_command("repair-table") . " " + . ($jush == "sqlite" ? $vacuum + : ($jush == "pgsql" ? $vacuum . $optimize + : ($jush == "sql" ? " " . $optimize + . " " + . " " : ""))) - . (support("table") ? "" . doc_command($jush == "sqlite" ? "delete" : "truncate" . ($jush == "pgsql" ? "" : "-table")) . " " : "") - . "" . doc_command("drop-table") . "\n"; + . (support("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)); diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 04941b02..edadec9a 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -233,14 +233,13 @@ username.form['auth[driver]'].onchange(); print_fieldset("select", lang('Select'), $select); $i = 0; $fun_group = array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)); + $select[""] = array(); foreach ($select as $key => $val) { $val = $_GET["columns"][$key]; - echo "
" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, $val["fun"]); - echo "(" . select_input(" name='columns[$i][col]' onchange='selectFieldChange(this.form);'", $columns, $val["col"]) . ")
\n"; + echo "
" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, $val["fun"], ($key !== "" ? "" : " this.nextSibling.nextSibling.onchange();")); + echo "(" . select_input(" name='columns[$i][col]' onchange='" . ($key !== "" ? "selectFieldChange(this.form)" : "selectAddRow(this)") . ";'", $columns, $val["col"]) . ")
\n"; $i++; } - echo "
" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, "", "this.nextSibling.nextSibling.onchange();"); - echo "(" . select_input(" name='columns[$i][col]' onchange='selectAddRow(this);'", $columns) . ")
\n"; echo "
\n"; } @@ -786,6 +785,7 @@ username.form['auth[driver]'].onchange(); $links[] = preg_quote($table, '/'); } echo " + +
type; echo "name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($name) - . ($orgtables && $jush == "sql" ? doc_link("explain-output.html#explain_" . strtolower($name)) : "") + . ($orgtables ? doc_link("explain-output.html#explain_" . strtolower($name)) : "") ; } echo "\n"; @@ -458,35 +458,21 @@ function doc_link($path) { global $jush, $connection; $urls = array( 'sql' => "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/", + /* not used: '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] ? "?" : ""); } -/** Create link to documentation of database command -* @param string lower-case -* @return string HTML code +/** Return events to display help on mouse over +* @param string +* @param bool +* @return string */ -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]); - } +function on_help($command, $right = 0) { + return " onmouseover=\"helpMouseover(this, '" . js_escape($command) . "', $right);\" onmouseout='helpMouseout();'"; } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index f046ec44..0f9a7ba4 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -799,7 +799,10 @@ function input($field, $value, $function) { } $onchange = ($first ? " onchange=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : ""); $attrs .= $onchange; - echo (count($functions) > 1 ? html_select("function[$name]", $functions, $function === null || in_array($function, $functions) || isset($functions[$function]) ? $function : "", "functionChange(this);") : nbsp(reset($functions))) . ''; + echo (count($functions) > 1 + ? html_select("function[$name]", $functions, $function === null || in_array($function, $functions) || isset($functions[$function]) ? $function : "", "functionChange(this);") + : nbsp(reset($functions)) + ) . ''; $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value); // usage in call is without a table if ($input != "") { echo $input; diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index 721c5efb..1d776e43 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -104,6 +104,7 @@ $translations = array( '%d in total' => '%d celkem', 'Analyze' => 'Analyzovat', 'Optimize' => 'Optimalizovat', + 'Vacuum' => 'Vyčistit', 'Check' => 'Zkontrolovat', 'Repair' => 'Opravit', 'Truncate' => 'Vyprázdnit', diff --git a/adminer/lang/xx.inc.php b/adminer/lang/xx.inc.php index d84bf2a7..05b62853 100644 --- a/adminer/lang/xx.inc.php +++ b/adminer/lang/xx.inc.php @@ -104,6 +104,7 @@ $translations = array( '%d in total' => 'xx', 'Analyze' => 'xx', 'Optimize' => 'xx', + 'Vacuum' => 'xx', 'Check' => 'xx', 'Repair' => 'xx', 'Truncate' => 'xx', diff --git a/adminer/processlist.inc.php b/adminer/processlist.inc.php index 5d8cb84b..da66cfdd 100644 --- a/adminer/processlist.inc.php +++ b/adminer/processlist.inc.php @@ -22,9 +22,7 @@ foreach (process_list() as $i => $row) { if (!$i) { echo "" . (support("kill") ? " " : ""); foreach ($row as $key => $val) { - echo "$key" - . ($jush == "sql" ? doc_link("show-processlist.html#processlist_" . strtolower($key)) : "") - ; + echo "$key" . doc_link("show-processlist.html#processlist_" . strtolower($key)); } echo "\n"; } diff --git a/adminer/static/default.css b/adminer/static/default.css index 9cfde193..d8bd1406 100644 --- a/adminer/static/default.css +++ b/adminer/static/default.css @@ -68,6 +68,7 @@ input.required { box-shadow: 1px 1px 1px red; } #schema { margin-left: 60px; position: relative; -moz-user-select: none; -webkit-user-select: none; } #schema .table { border: 1px solid silver; padding: 0 2px; cursor: move; position: absolute; } #schema .references { position: absolute; } +#help { position: absolute; border: 1px solid #999; background: #eee; padding: 5px; font-family: monospace; z-index: 1; } .rtl h2 { margin: 0 -18px 20px 0; } .rtl p, .rtl table, .rtl .error, .rtl .message { margin: 1em 0 0 20px; } diff --git a/adminer/static/editing.js b/adminer/static/editing.js index 92b053d8..64fbc9c5 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -612,3 +612,35 @@ function schemaMouseup(ev, db) { cookie('adminer_schema-' + db + '=' + s, 30); //! special chars in db } } + +var helpOpen; + +function helpMouseover(el, text, right) { + if (window.jush) { + helpOpen = 1; + var help = document.getElementById('help'); + help.innerHTML = text; + jush.highlight_tag([ help ]); + alterClass(help, 'hidden'); + var top = 0, left = 0, parent = el; + do { + top += parent.offsetTop; + left += parent.offsetLeft; + } while (parent = parent.offsetParent); + help.style.top = (top - (right ? (help.offsetHeight - el.offsetHeight) / 2 : help.offsetHeight)) + 'px'; + help.style.left = (left + (right ? el.offsetWidth : (el.offsetWidth - help.offsetWidth) / 2)) + 'px'; + } +} + +function helpMouseout() { + helpOpen = 0; + setTimeout(function () { + if (!helpOpen) { + helpClose(); + } + }, 200); +} + +function helpClose() { + alterClass(document.getElementById('help'), 'hidden', true); +}