diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 9db9808a..e07afd73 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -382,10 +382,12 @@ class Adminer { /** Get options to display edit field * @param string table name * @param array single field from fields() - * @return array options for + * @param string attributes to use inside the tag + * @param string + * @return string custom input field or empty string for default */ - function editInput($table, $field) { - return false; + function editInput($table, $field, $attrs, $value) { + return ''; } /** Process sent input diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 9202a43e..0c15ca60 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -56,7 +56,7 @@ function type_class($type) { } function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $foreign_keys = array()) { - global $inout; + global $inout, $SELF; // $SELF is used by compiled images $column_comments = false; foreach ($fields as $field) { if (strlen($field["comment"])) { diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 547284cc..2b92a820 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -305,9 +305,9 @@ function input($field, $value, $function) { $first = array_search("", $functions); $onchange = ($first ? ' onchange="var f = this.form[\'function[' . addcslashes($name, "\r\n'\\") . ']\']; if (' . $first . ' > f.selectedIndex) f.selectedIndex = ' . $first . ';"' : ''); echo (count($functions) > 1 ? '' : " ") . ''; - $options = $adminer->editInput($_GET["edit"], $field); // usage in call is without a table - if (is_array($options)) { - echo ''; + $input = $adminer->editInput($_GET["edit"], $field, ' name="fields[' . $name . ']"' . $onchange, $value); // usage in call is without a table + if (strlen($input)) { + echo $input; } elseif ($field["type"] == "set") { //! 64 bits preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches); foreach ($matches[1] as $i => $val) { diff --git a/changes.txt b/changes.txt index 0f75f025..414646c6 100644 --- a/changes.txt +++ b/changes.txt @@ -14,6 +14,7 @@ Remove Delete button from Edit page - use mass operation for it Faster multiple update, clone and delete Faster table list in navigation Use HTML Strict instead of XHTML +Remove function minification for performance and customization Fix grant ALL PRIVILEGES with GRANT OPTION Fix CSV import Fix work with default values (thanks to Jiri Pospisil) diff --git a/compile.php b/compile.php index bc1681d7..e4b30622 100644 --- a/compile.php +++ b/compile.php @@ -177,8 +177,8 @@ if ($_COOKIE["adminer_lang"]) { } $file = str_replace('' . "\n", "", $file); $file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\);~", 'compile_file', $file); // integrate static files -$replace = 'htmlspecialchars(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION; -$file = preg_replace('~(?:\\.\\./adminer/|\\./)(default\\.css|functions\\.js|favicon\\.ico)~', '', $file); +$replace = 'htmlspecialchars(preg_replace("~\\\\\\\\?.*~", "", $SELF), ENT_QUOTES) . "?file=\\1&version=' . $VERSION; +$file = preg_replace('~\\.\\./adminer/(default\\.css|functions\\.js|favicon\\.ico)~', '', $file); $file = preg_replace('~\\.\\./adminer/((plus|cross|up|down|arrow)\\.gif)~', '" . ' . $replace, $file); $file = str_replace("../externals/jush/", "http://jush.sourceforge.net/", $file); $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index a8432306..bb968cd9 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -108,6 +108,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 } function selectVal($val, $link, $field) { + global $SELF; // used by compiled images $return = ($val == "NULL" ? " " : $val); if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) { $return = lang('%d byte(s)', strlen($val)); @@ -115,6 +116,9 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 $return = "$return"; } } + if ($field["full_type"] == "tinyint(1)" && $return != " ") { // bool + $return = '' . htmlspecialchars($val) . ''; + } return ($link ? "$return" : $return); } @@ -268,34 +272,37 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 return (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + array(""); } - function editInput($table, $field) { + function editInput($table, $field, $attrs, $value) { global $dbh; - $return = null; $foreign_keys = column_foreign_keys($table); foreach ((array) $foreign_keys[$field["field"]] as $foreign_key) { if (count($foreign_key["source"]) == 1) { $id = idf_escape($foreign_key["target"][0]); $name = $this->rowDescription($foreign_key["table"]); if (strlen($name) && $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($foreign_key["table"]))) <= 1000) { // optionlist with more than 1000 options would be too big - if ($field["null"]) { + $return = array(); + $result = $dbh->query("SELECT $id, $name FROM " . idf_escape($foreign_key["table"]) . " ORDER BY 2"); + if ($field["null"] || !$result->num_rows) { // empty "; } } } - return $return; + if ($field["full_type"] == "tinyint(1)") { // bool + return '"; + } + return ''; } function processInput($field, $value, $function = "") { global $dbh; $return = $dbh->quote(ereg('date|timestamp', $field["type"]) ? preg_replace_callback('(' . preg_replace('~(\\\\\\$([0-9]))~', '(?P[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', 'conversion_date', $value) : $value); - if (!ereg('varchar|text', $field["type"]) && !strlen($value)) { + if (!ereg('varchar|text', $field["type"]) && $field["full_type"] != "tinyint(1)" && !strlen($value)) { $return = "NULL"; } elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") { $return = $value; diff --git a/todo.txt b/todo.txt index 7eee427c..5fd53d7c 100644 --- a/todo.txt +++ b/todo.txt @@ -22,7 +22,6 @@ Download external files (version checker and JUSH) from trusted HTTPS if Adminer ? AJAX editing - select page has all data to display edit form Editor: -JavaScript data validation +JavaScript data validation - columns containing word email, url, md5, sha1, ... Joining tables - PRIMARY KEY (table, joining) Rank, Tree structure -Treat tinyint(1) as bool