Revert Displaying SQL edit form on Ctrl+click on the select query

This commit is contained in:
Jakub Vrana 2013-07-24 13:00:37 -07:00
parent cbd690dd71
commit 34349f1482
3 changed files with 60 additions and 83 deletions

View file

@ -4,21 +4,21 @@
class Adminer { class Adminer {
/** @var array operators used in select, null for all operators */ /** @var array operators used in select, null for all operators */
var $operators; var $operators;
/** Name in title and navigation /** Name in title and navigation
* @return string HTML code * @return string HTML code
*/ */
function name() { function name() {
return "<a href='http://www.adminer.org/' id='h1'>Adminer</a>"; return "<a href='http://www.adminer.org/' id='h1'>Adminer</a>";
} }
/** Connection parameters /** Connection parameters
* @return array ($server, $username, $password) * @return array ($server, $username, $password)
*/ */
function credentials() { function credentials() {
return array(SERVER, $_GET["username"], get_session("pwds")); return array(SERVER, $_GET["username"], get_session("pwds"));
} }
/** Get key used for permanent login /** Get key used for permanent login
* @param bool * @param bool
* @return string cryptic string which gets combined with password or false in case of an error * @return string cryptic string which gets combined with password or false in case of an error
@ -26,7 +26,7 @@ class Adminer {
function permanentLogin($create = false) { function permanentLogin($create = false) {
return password_file($create); return password_file($create);
} }
/** Identifier of selected database /** Identifier of selected database
* @return string * @return string
*/ */
@ -34,7 +34,7 @@ class Adminer {
// should be used everywhere instead of DB // should be used everywhere instead of DB
return DB; return DB;
} }
/** Get cached list of databases /** Get cached list of databases
* @param bool * @param bool
* @return array * @return array
@ -42,28 +42,28 @@ class Adminer {
function databases($flush = true) { function databases($flush = true) {
return get_databases($flush); return get_databases($flush);
} }
/** Specify limit for waiting on some slow queries like DB list /** Specify limit for waiting on some slow queries like DB list
* @return float number of seconds * @return float number of seconds
*/ */
function queryTimeout() { function queryTimeout() {
return 5; return 5;
} }
/** Headers to send before HTML output /** Headers to send before HTML output
* @return bool true to send security headers * @return bool true to send security headers
*/ */
function headers() { function headers() {
return true; return true;
} }
/** Print HTML code inside <head> /** Print HTML code inside <head>
* @return bool true to link adminer.css if exists * @return bool true to link adminer.css if exists
*/ */
function head() { function head() {
return true; return true;
} }
/** Print login form /** Print login form
* @return null * @return null
*/ */
@ -86,7 +86,7 @@ username.form['auth[driver]'].onchange();
echo "<p><input type='submit' value='" . lang('Login') . "'>\n"; echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n"; echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
} }
/** Authorize the user /** Authorize the user
* @param string * @param string
* @param string * @param string
@ -95,7 +95,7 @@ username.form['auth[driver]'].onchange();
function login($login, $password) { function login($login, $password) {
return true; return true;
} }
/** Table caption used in navigation and headings /** Table caption used in navigation and headings
* @param array result of SHOW TABLE STATUS * @param array result of SHOW TABLE STATUS
* @return string HTML code, "" to ignore table * @return string HTML code, "" to ignore table
@ -103,7 +103,7 @@ username.form['auth[driver]'].onchange();
function tableName($tableStatus) { function tableName($tableStatus) {
return h($tableStatus["Name"]); return h($tableStatus["Name"]);
} }
/** Field caption used in select and edit /** Field caption used in select and edit
* @param array single field returned from fields() * @param array single field returned from fields()
* @param int order of column in select * @param int order of column in select
@ -112,7 +112,7 @@ username.form['auth[driver]'].onchange();
function fieldName($field, $order = 0) { function fieldName($field, $order = 0) {
return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>'; return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>';
} }
/** Print links after select heading /** Print links after select heading
* @param array result of SHOW TABLE STATUS * @param array result of SHOW TABLE STATUS
* @param string new item options, NULL for no new item * @param string new item options, NULL for no new item
@ -137,7 +137,7 @@ username.form['auth[driver]'].onchange();
} }
echo "\n"; echo "\n";
} }
/** Get foreign keys for table /** Get foreign keys for table
* @param string * @param string
* @return array same format as foreign_keys() * @return array same format as foreign_keys()
@ -145,7 +145,7 @@ username.form['auth[driver]'].onchange();
function foreignKeys($table) { function foreignKeys($table) {
return foreign_keys($table); return foreign_keys($table);
} }
/** Find backward keys for table /** Find backward keys for table
* @param string * @param string
* @param string * @param string
@ -154,7 +154,7 @@ username.form['auth[driver]'].onchange();
function backwardKeys($table, $tableName) { function backwardKeys($table, $tableName) {
return array(); return array();
} }
/** Print backward keys for row /** Print backward keys for row
* @param array result of $this->backwardKeys() * @param array result of $this->backwardKeys()
* @param array * @param array
@ -162,19 +162,19 @@ username.form['auth[driver]'].onchange();
*/ */
function backwardKeysPrint($backwardKeys, $row) { function backwardKeysPrint($backwardKeys, $row) {
} }
/** Query printed in select before execution /** Query printed in select before execution
* @param string query to be executed * @param string query to be executed
* @return string * @return string
*/ */
function selectQuery($query) { function selectQuery($query) {
global $jush, $token; global $jush;
return "<form action='" . h(ME) . "sql=' method='post'><p><span onclick=\"return !selectEditSql(event, this, '" . lang('Execute') . "');\">" return "<p><code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code>"
. "<code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code>"
. " <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>" . " <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>"
. "</span><input type='hidden' name='token' value='$token'></p></form>\n"; // </p> - required for IE9 inline edit . "</p>" // </p> - required for IE9 inline edit
;
} }
/** Description of a row in a table /** Description of a row in a table
* @param string * @param string
* @return string SQL expression, empty string for no description * @return string SQL expression, empty string for no description
@ -182,7 +182,7 @@ username.form['auth[driver]'].onchange();
function rowDescription($table) { function rowDescription($table) {
return ""; return "";
} }
/** Get descriptions of selected data /** Get descriptions of selected data
* @param array all data to print * @param array all data to print
* @param array * @param array
@ -191,7 +191,7 @@ username.form['auth[driver]'].onchange();
function rowDescriptions($rows, $foreignKeys) { function rowDescriptions($rows, $foreignKeys) {
return $rows; return $rows;
} }
/** Get a link to use in select table /** Get a link to use in select table
* @param string raw value of the field * @param string raw value of the field
* @param array single field returned from fields() * @param array single field returned from fields()
@ -199,7 +199,7 @@ username.form['auth[driver]'].onchange();
*/ */
function selectLink($val, $field) { function selectLink($val, $field) {
} }
/** Value printed in select table /** Value printed in select table
* @param string HTML-escaped value to print * @param string HTML-escaped value to print
* @param string link to foreign key * @param string link to foreign key
@ -213,7 +213,7 @@ username.form['auth[driver]'].onchange();
} }
return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return); return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return);
} }
/** Value conversion used in select and edit /** Value conversion used in select and edit
* @param string * @param string
* @param array single field returned from fields() * @param array single field returned from fields()
@ -222,7 +222,7 @@ username.form['auth[driver]'].onchange();
function editVal($val, $field) { function editVal($val, $field) {
return $val; return $val;
} }
/** Print columns box in select /** Print columns box in select
* @param array result of selectColumnsProcess()[0] * @param array result of selectColumnsProcess()[0]
* @param array selectable columns * @param array selectable columns
@ -243,7 +243,7 @@ username.form['auth[driver]'].onchange();
} }
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
/** Print search box in select /** Print search box in select
* @param array result of selectSearchProcess() * @param array result of selectSearchProcess()
* @param array selectable columns * @param array selectable columns
@ -273,7 +273,7 @@ username.form['auth[driver]'].onchange();
} }
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
/** Print order box in select /** Print order box in select
* @param array result of selectOrderProcess() * @param array result of selectOrderProcess()
* @param array selectable columns * @param array selectable columns
@ -294,7 +294,7 @@ username.form['auth[driver]'].onchange();
echo checkbox("desc[$i]", 1, false, lang('descending')) . "</div>\n"; echo checkbox("desc[$i]", 1, false, lang('descending')) . "</div>\n";
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
/** Print limit box in select /** Print limit box in select
* @param string result of selectLimitProcess() * @param string result of selectLimitProcess()
* @return null * @return null
@ -304,7 +304,7 @@ username.form['auth[driver]'].onchange();
echo "<input type='number' name='limit' class='size' value='" . h($limit) . "' onchange='selectFieldChange(this.form);'>"; echo "<input type='number' name='limit' class='size' value='" . h($limit) . "' onchange='selectFieldChange(this.form);'>";
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
/** Print text length box in select /** Print text length box in select
* @param string result of selectLengthProcess() * @param string result of selectLengthProcess()
* @return null * @return null
@ -316,7 +316,7 @@ username.form['auth[driver]'].onchange();
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
} }
/** Print action box in select /** Print action box in select
* @param array * @param array
* @return null * @return null
@ -342,21 +342,21 @@ username.form['auth[driver]'].onchange();
echo "</script>\n"; echo "</script>\n";
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
} }
/** Print command box in select /** Print command box in select
* @return bool whether to print default commands * @return bool whether to print default commands
*/ */
function selectCommandPrint() { function selectCommandPrint() {
return !information_schema(DB); return !information_schema(DB);
} }
/** Print import box in select /** Print import box in select
* @return bool whether to print default import * @return bool whether to print default import
*/ */
function selectImportPrint() { function selectImportPrint() {
return !information_schema(DB); return !information_schema(DB);
} }
/** Print extra text in the end of a select form /** Print extra text in the end of a select form
* @param array fields holding e-mails * @param array fields holding e-mails
* @param array selectable columns * @param array selectable columns
@ -364,7 +364,7 @@ username.form['auth[driver]'].onchange();
*/ */
function selectEmailPrint($emailFields, $columns) { function selectEmailPrint($emailFields, $columns) {
} }
/** Process columns box in select /** Process columns box in select
* @param array selectable columns * @param array selectable columns
* @param array * @param array
@ -384,7 +384,7 @@ username.form['auth[driver]'].onchange();
} }
return array($select, $group); return array($select, $group);
} }
/** Process search box in select /** Process search box in select
* @param array * @param array
* @param array * @param array
@ -431,7 +431,7 @@ username.form['auth[driver]'].onchange();
} }
return $return; return $return;
} }
/** Process order box in select /** Process order box in select
* @param array * @param array
* @param array * @param array
@ -448,21 +448,21 @@ username.form['auth[driver]'].onchange();
} }
return $return; return $return;
} }
/** Process limit box in select /** Process limit box in select
* @return string expression to use in LIMIT, will be escaped * @return string expression to use in LIMIT, will be escaped
*/ */
function selectLimitProcess() { function selectLimitProcess() {
return (isset($_GET["limit"]) ? $_GET["limit"] : "50"); return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
} }
/** Process length box in select /** Process length box in select
* @return string number of characters to shorten texts, will be escaped * @return string number of characters to shorten texts, will be escaped
*/ */
function selectLengthProcess() { function selectLengthProcess() {
return (isset($_GET["text_length"]) ? $_GET["text_length"] : "100"); return (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
} }
/** Process extras in select form /** Process extras in select form
* @param array AND conditions * @param array AND conditions
* @param array * @param array
@ -471,7 +471,7 @@ username.form['auth[driver]'].onchange();
function selectEmailProcess($where, $foreignKeys) { function selectEmailProcess($where, $foreignKeys) {
return false; return false;
} }
/** Build SQL query used in select /** Build SQL query used in select
* @param array result of selectColumnsProcess()[0] * @param array result of selectColumnsProcess()[0]
* @param array result of selectSearchProcess() * @param array result of selectSearchProcess()
@ -484,7 +484,7 @@ username.form['auth[driver]'].onchange();
function selectQueryBuild($select, $where, $group, $order, $limit, $page) { function selectQueryBuild($select, $where, $group, $order, $limit, $page) {
return ""; return "";
} }
/** Query printed after execution in the message /** Query printed after execution in the message
* @param string executed query * @param string executed query
* @return string * @return string
@ -500,7 +500,7 @@ username.form['auth[driver]'].onchange();
$history[$_GET["db"]][] = array($query, time()); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"] $history[$_GET["db"]][] = array($query, time()); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>'; // @ - time zone may be not set return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>'; // @ - time zone may be not set
} }
/** Functions displayed in edit form /** Functions displayed in edit form
* @param array single field from fields() * @param array single field from fields()
* @return array * @return array
@ -522,7 +522,7 @@ username.form['auth[driver]'].onchange();
} }
return explode("/", $return); return explode("/", $return);
} }
/** Get options to display edit field /** Get options to display edit field
* @param string table name * @param string table name
* @param array single field from fields() * @param array single field from fields()
@ -539,7 +539,7 @@ username.form['auth[driver]'].onchange();
} }
return ""; return "";
} }
/** Process sent input /** Process sent input
* @param array single field from fields() * @param array single field from fields()
* @param string * @param string
@ -567,7 +567,7 @@ username.form['auth[driver]'].onchange();
} }
return unconvert_field($field, $return); return unconvert_field($field, $return);
} }
/** Returns export output options /** Returns export output options
* @return array * @return array
*/ */
@ -578,21 +578,21 @@ username.form['auth[driver]'].onchange();
} }
return $return; return $return;
} }
/** Returns export format options /** Returns export format options
* @return array empty to disable export * @return array empty to disable export
*/ */
function dumpFormat() { function dumpFormat() {
return array('sql' => 'SQL', 'csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV'); return array('sql' => 'SQL', 'csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV');
} }
/** Export database structure /** Export database structure
* @param string * @param string
* @return null prints data * @return null prints data
*/ */
function dumpDatabase($db) { function dumpDatabase($db) {
} }
/** Export table structure /** Export table structure
* @param string * @param string
* @param string * @param string
@ -626,7 +626,7 @@ username.form['auth[driver]'].onchange();
} }
} }
} }
/** Export table data /** Export table data
* @param string * @param string
* @param string * @param string
@ -697,7 +697,7 @@ username.form['auth[driver]'].onchange();
} }
} }
} }
/** Set export filename /** Set export filename
* @param string * @param string
* @return string filename without extension * @return string filename without extension
@ -705,7 +705,7 @@ username.form['auth[driver]'].onchange();
function dumpFilename($identifier) { function dumpFilename($identifier) {
return friendly_url($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost")); return friendly_url($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost"));
} }
/** Send headers for export /** Send headers for export
* @param string * @param string
* @param bool * @param bool
@ -724,7 +724,7 @@ username.form['auth[driver]'].onchange();
} }
return $ext; return $ext;
} }
/** Print homepage /** Print homepage
* @return bool whether to print default homepage * @return bool whether to print default homepage
*/ */
@ -735,7 +735,7 @@ username.form['auth[driver]'].onchange();
echo (support("privileges") ? "<a href='" . h(ME) . "privileges='>" . lang('Privileges') . "</a>\n" : ""); echo (support("privileges") ? "<a href='" . h(ME) . "privileges='>" . lang('Privileges') . "</a>\n" : "");
return true; return true;
} }
/** Prints navigation after Adminer title /** 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 * @param string can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema
* @return null * @return null
@ -796,7 +796,7 @@ username.form['auth[driver]'].onchange();
} }
} }
} }
/** Prints databases list in menu /** Prints databases list in menu
* @param string * @param string
* @return null * @return null
@ -830,7 +830,7 @@ username.form['auth[driver]'].onchange();
: "")))); : ""))));
echo "</p></form>\n"; echo "</p></form>\n";
} }
/** Prints table list in menu /** Prints table list in menu
* @param array result of table_status('', true) * @param array result of table_status('', true)
* @return null * @return null
@ -846,7 +846,7 @@ username.form['auth[driver]'].onchange();
) . "<br>\n"; ) . "<br>\n";
} }
} }
} }
$adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer); $adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);

View file

@ -13,7 +13,7 @@ function bodyLoad(version) {
link.type = 'text/css'; link.type = 'text/css';
link.href = jushRoot + 'jush.css'; link.href = jushRoot + 'jush.css';
document.getElementsByTagName('head')[0].appendChild(link); document.getElementsByTagName('head')[0].appendChild(link);
var script = document.createElement('script'); var script = document.createElement('script');
script.src = jushRoot + 'jush.js'; script.src = jushRoot + 'jush.js';
script.onload = function () { script.onload = function () {
@ -178,30 +178,6 @@ function selectFieldChange(form) {
setHtml('noindex', (ok ? '' : '!')); setHtml('noindex', (ok ? '' : '!'));
} }
/** Create edit query form
* @param MouseEvent
* @param HTMLSpanElement
* @param string
*/
function selectEditSql(event, el, label) {
var a = parentTag(getTarget(event), 'a');
if (!isCtrl(event) || (a && a.href)) {
return;
}
var sql = el.firstChild;
var input = document.createElement('input');
input.name = 'query';
input.value = sql.textContent || sql.innerText;
input.style.width = sql.offsetWidth + 'px';
el.innerHTML = '';
el.appendChild(input);
var submit = document.createElement('input');
submit.type = 'submit';
submit.value = label;
el.appendChild(submit);
return true;
}
var added = '.', rowCount; var added = '.', rowCount;

View file

@ -11,6 +11,7 @@ Disable underlining links
Improve speed of CSV import Improve speed of CSV import
Keep form values after refresh in Firefox Keep form values after refresh in Firefox
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
Don't display SQL edit form on Ctrl+click on the select query, introduced in Adminer 3.6.4
PostgreSQL: Fix handling of nextval() default values PostgreSQL: Fix handling of nextval() default values
Adminer 3.7.1 (released 2013-06-29): Adminer 3.7.1 (released 2013-06-29):