Add links to documentation

This commit is contained in:
Jakub Vrana 2013-07-16 18:37:33 -07:00
parent ddd5c7586b
commit 6f6f69a891
7 changed files with 65 additions and 19 deletions

View file

@ -197,7 +197,7 @@ if (support("partitioning")) {
print_fieldset("partition", lang('Partition by'), $row["partition_by"]); print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
?> ?>
<p> <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"]); ?>">) (<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"]); ?>"> <?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'"); ?>> <table cellspacing="0" id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>

View file

@ -114,11 +114,17 @@ if ($adminer->homepage()) {
echo "</table>\n"; echo "</table>\n";
if (!information_schema(DB)) { 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>" 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 == "sqlite" ? $optimize . doc_command("vacuum") . " "
. ($jush == "sql" ? "<input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") : ($jush == "pgsql" ? $analyze . doc_command("vacuum") . " $optimize" . doc_command("vacuum") . " "
. (support("table") ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . "> " : "") : ($jush == "sql" ? $analyze . doc_command("analyze-table") . " $optimize" . doc_command("optimize-table") . " "
. "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n"; . "<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()); $databases = (support("scheme") ? schemas() : $adminer->databases());
if (count($databases) != 1 && $jush != "sqlite") { if (count($databases) != 1 && $jush != "sqlite") {
$db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB)); $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));

View file

@ -2,11 +2,11 @@
/** Print select result /** Print select result
* @param Min_Result * @param Min_Result
* @param Min_DB connection to examine indexes * @param Min_DB connection to examine indexes
* @param string base link for <th> fields
* @param array * @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 $links = array(); // colno => orgtable - create links from these columns
$indexes = array(); // orgtable => array(column => colno) - primary keys $indexes = array(); // orgtable => array(column => colno) - primary keys
$columns = array(); // orgtable => array(column => ) - not selected columns in primary key $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; $orgtable = $field->orgtable;
$orgname = $field->orgname; $orgname = $field->orgname;
$return[$field->table] = $orgtable; $return[$field->table] = $orgtable;
if ($href) { // MySQL EXPLAIN if ($orgtables && $jush == "sql") { // MySQL EXPLAIN
$links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null)); $links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null));
} elseif ($orgtable != "") { } elseif ($orgtable != "") {
if (!isset($indexes[$orgtable])) { if (!isset($indexes[$orgtable])) {
@ -48,9 +48,8 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
$blobs[$j] = true; $blobs[$j] = true;
} }
$types[$j] = $field->type; $types[$j] = $field->type;
$name = h($name); echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($name)
echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . ($orgtables && $jush == "sql" ? doc_link("explain-output.html#explain_" . strtolower($name)) : "")
. ($href ? "<a href='$href" . strtolower($name) . "' target='_blank' rel='noreferrer' class='help'>$name</a>" : $name)
; ;
} }
echo "</thead>\n"; echo "</thead>\n";
@ -70,7 +69,7 @@ function select($result, $connection2 = null, $href = "", $orgtables = array())
} }
} }
if (isset($links[$key]) && !$columns[$links[$key]]) { if (isset($links[$key]) && !$columns[$links[$key]]) {
if ($href) { // MySQL EXPLAIN if ($orgtables && $jush == "sql") { // MySQL EXPLAIN
$table = $row[array_search("table=", $links)]; $table = $row[array_search("table=", $links)];
$link = $links[$key] . urlencode($orgtables[$table] != "" ? $orgtables[$table] : $table); $link = $links[$key] . urlencode($orgtables[$table] != "" ? $orgtables[$table] : $table);
} else { } else {
@ -450,3 +449,44 @@ function ini_bytes($ini) {
} }
return $val; 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]);
}
}

View file

@ -22,10 +22,9 @@ foreach (process_list() as $i => $row) {
if (!$i) { if (!$i) {
echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : ""); echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "");
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
echo "<th>" . ($jush == "sql" echo "<th>$key"
? "<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>" . ($jush == "sql" ? doc_link("show-processlist.html#processlist_" . strtolower($key)) : "")
: $key ;
);
} }
echo "</thead>\n"; echo "</thead>\n";
} }

View file

@ -136,7 +136,7 @@ if (!$error && $_POST) {
$id = "explain-$commands"; $id = "explain-$commands";
echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export"; echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export";
echo "<div id='$id' class='hidden'>\n"; 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"; echo "</div>\n";
} else { } else {
echo $export; echo $export;

View file

@ -142,7 +142,7 @@ if ($_POST) {
<?php <?php
//! MAX_* limits, REQUIRE //! MAX_* limits, REQUIRE
echo "<table cellspacing='0'>\n"; 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; $i = 0;
foreach ($grants as $object => $grant) { 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 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

View file

@ -6,6 +6,7 @@ Mark length as required for strings
Add label to database selection Add label to database selection
Add button for dropping an index Add button for dropping an index
Display number of selected rows Display number of selected rows
Add links to documentation
Disable underlining links Disable underlining links
Improve speed of CSV import Improve speed of CSV import
Don't append newlines to uploaded files, bug since Adminer 3.7.0 Don't append newlines to uploaded files, bug since Adminer 3.7.0