]> git.joonet.de Git - adminer.git/commitdiff
Allow redefining editInput for enum (bug #3048711)
authorJakub Vrana <jakub@vrana.cz>
Fri, 22 Oct 2010 22:28:48 +0000 (00:28 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 22 Oct 2010 22:28:48 +0000 (00:28 +0200)
adminer/include/adminer.inc.php
adminer/include/functions.inc.php
editor/include/adminer.inc.php

index 7068088c2fe4bea9cede486a4ea236940997ff1f..9181d3118109f34b0ac3fdb78c578172f4196d17 100644 (file)
@@ -430,8 +430,10 @@ document.getElementById('username').focus();
        */
        function editInput($table, $field, $attrs, $value) {
                if ($field["type"] == "enum") {
-                       return ($field["null"] ? "<label><input type='radio'$attrs value=''" . (isset($value) || isset($_GET["select"]) ? "" : " checked") . "><i>NULL</i></label> " : "")
+                       return (isset($_GET["select"]) ? "<label><input type='radio'$attrs value='-1' checked><i>" . lang('original') . "</i></label> " : "")
+                               . ($field["null"] ? "<label><input type='radio'$attrs value=''" . (isset($value) || isset($_GET["select"]) ? "" : " checked") . "><i>NULL</i></label> " : "")
                                . "<label><input type='radio'$attrs value='0'" . ($value === 0 ? " checked" : "") . "><i>" . lang('empty') . "</i></label>"
+                               . enum_input("radio", $attrs, $field, $value)
                        ;
                }
                return "";
index 7fe46c448e4b3b197f0dfb80c608a0a89bbdc88d..489108f26588582131cf9ea3e9cdbd68fabe92d9 100644 (file)
@@ -568,11 +568,13 @@ function column_foreign_keys($table) {
 */
 function enum_input($type, $attrs, $field, $value) {
        preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
+       $return = "";
        foreach ($matches[1] as $i => $val) {
                $val = stripcslashes(str_replace("''", "'", $val));
                $checked = (is_int($value) ? $value == $i+1 : (is_array($value) ? in_array($i+1, $value) : $value === $val));
-               echo " <label><input type='$type'$attrs value='" . ($i+1) . "'" . ($checked ? ' checked' : '') . '>' . h($val) . '</label>';
+               $return .= " <label><input type='$type'$attrs value='" . ($i+1) . "'" . ($checked ? ' checked' : '') . '>' . h($val) . '</label>';
        }
+       return $return;
 }
 
 /** Print edit input field
@@ -588,9 +590,7 @@ function input($field, $value, $function) {
        $functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
        $attrs = " name='fields[$name]'";
        if ($field["type"] == "enum") {
-               echo nbsp($functions[""]) . "<td>" . ($functions["orig"] ? "<label><input type='radio'$attrs value='-1' checked><i>$functions[orig]</i></label> " : "");
-               echo $adminer->editInput($_GET["edit"], $field, $attrs, $value);
-               enum_input("radio", $attrs, $field, $value);
+               echo nbsp($functions[""]) . "<td>" . $adminer->editInput($_GET["edit"], $field, $attrs, $value);
        } else {
                $first = 0;
                foreach ($functions as $key => $val) {
index 099d74ed6f7aff04a7fe94baafcd268484f6f631..af6b47e1420dbdd03c336f5c0cbee164650cbbc5 100644 (file)
@@ -202,7 +202,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                                $key = $keys[$name];
                                $i--;
                                echo "<div>" . h($desc) . "<input type='hidden' name='where[$i][col]' value='" . h($name) . "'>:";
-                               enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"]); //! impossible to search for NULL
+                               echo enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"]); //! impossible to search for NULL
                                echo "</div>\n";
                                unset($columns[$name]);
                        }
@@ -392,7 +392,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
        
        function editInput($table, $field, $attrs, $value) {
                if ($field["type"] == "enum") {
-                       return ($field["null"] ? "<input type='radio'$attrs value=''" . ($value || isset($_GET["select"]) ? "" : " checked") . ">" : "");
+                       return (isset($_GET["select"]) ? "<label><input type='radio'$attrs value='-1' checked><i>" . lang('original') . "</i></label> " : "")
+                               . ($field["null"] ? "<label><input type='radio'$attrs value=''" . ($value || isset($_GET["select"]) ? "" : " checked") . "><i>" . lang('empty') . "</i></label>" : "")
+                               . enum_input("radio", $attrs, $field, $value)
+                       ;
                }
                $options = $this->_foreignKeyOptions($table, $field["field"]);
                if ($options) {