diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 63067301..65089a0e 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -59,9 +59,10 @@ class Adminer { /** Field caption used in select and edit * @param array single field returned from fields() + * @param int order of column in select * @return string */ - function fieldName($field) { + function fieldName($field, $order = 0) { return '' . htmlspecialchars($field["field"]) . ''; } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 7aa5eea7..f7ca86a5 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -181,11 +181,13 @@ if (!$columns) { echo ""; $names = array(); reset($select); + $order = 0; foreach ($rows[0] as $key => $val) { $val = $_GET["columns"][key($select)]; $field = $fields[$select ? $val["col"] : $key]; - $name = ($field ? $adminer->fieldName($field) : "*"); + $name = ($field ? $adminer->fieldName($field, $order) : "*"); if (strlen($name)) { + $order++; $names[$key] = $name; echo '' . apply_sql_function($val["fun"], $name) . ""; } diff --git a/editor/example.php b/editor/example.php index 7b22dd9d..b71e23dc 100644 --- a/editor/example.php +++ b/editor/example.php @@ -23,14 +23,14 @@ function adminer_object() { return ($login == 'admin'); } - function tableName($row) { + function tableName($tableStatus) { // tables without comments would return empty string and will be ignored by Adminer - return htmlspecialchars($row["Comment"]); + return htmlspecialchars($tableStatus["Comment"]); } - function fieldName($field) { - // fields without comments will be ignored - return ($field ? htmlspecialchars($field["comment"]) : "*"); + function fieldName($field, $order = 0) { + // only first five columns with comments will be displayed + return ($order < 5 ? htmlspecialchars($field["comment"]) : ""); } } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 20df161c..59bc8eea 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -32,7 +32,7 @@ class Adminer { return htmlspecialchars(strlen($tableStatus["Comment"]) ? $tableStatus["Comment"] : $tableStatus["Name"]); } - function fieldName($field) { + function fieldName($field, $order = 0) { return htmlspecialchars(strlen($field["comment"]) ? $field["comment"] : $field["field"]); } diff --git a/todo.txt b/todo.txt index c909968a..7eee427c 100644 --- a/todo.txt +++ b/todo.txt @@ -22,10 +22,7 @@ Download external files (version checker and JUSH) from trusted HTTPS if Adminer ? AJAX editing - select page has all data to display edit form Editor: -Choose columns hidden in select -Restrict column selection in select to aggregation functions by index JavaScript data validation Joining tables - PRIMARY KEY (table, joining) -Simplify search - textual, from-to Rank, Tree structure -Treat tinyint(1) as bool, format date +Treat tinyint(1) as bool