]> git.joonet.de Git - adminer.git/commitdiff
Edit strings with \n in textarea
authorJakub Vrana <jakub@vrana.cz>
Sun, 12 Aug 2012 03:21:03 +0000 (20:21 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sun, 12 Aug 2012 04:45:09 +0000 (21:45 -0700)
adminer/include/functions.inc.php
adminer/static/functions.js
changes.txt

index 9e47557d8649e482c125a20399dceaa29d3ee5a2..97d011eb6d9e4bf4eb6744ad9e1bcc302ba75535 100644 (file)
@@ -719,8 +719,14 @@ function input($field, $value, $function) {
                        }
                } elseif (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
                        echo "<input type='file' name='fields-$name'$onchange>";
-               } elseif (ereg('text|lob', $field["type"])) {
-                       echo "<textarea " . ($jush != "sqlite" || ereg("\n", $value) ? "cols='50' rows='12'" : "cols='30' rows='1' style='height: 1.2em;'") . "$attrs>" . h($value) . '</textarea>'; // 1.2em - line-height
+               } elseif (($text = ereg('text|lob', $field["type"])) || ereg("\n", $value)) {
+                       if ($text && $jush != "sqlite") {
+                               $attrs .= " cols='50' rows='12'";
+                       } else {
+                               $rows = min(12, substr_count($value, "\n") + 1);
+                               $attrs .= " cols='30' rows='$rows'" . ($rows == 1 ? " style='height: 1.2em;'" : ""); // 1.2em - line-height
+                       }
+                       echo "<textarea$attrs>" . h($value) . '</textarea>';
                } else {
                        // int(3) is only a display hint
                        $maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
index ebf9077db02c944a3bac7e5daec3b91a9c93bb2e..b731c97ddd885063fe49bc4716a8a04151f42f43 100644 (file)
@@ -391,6 +391,7 @@ function selectDblClick(td, event, text) {
                return;
        }
        var original = td.innerHTML;
+       text = text || /\n/.test(original);
        var input = document.createElement(text ? 'textarea' : 'input');
        input.onkeydown = function (event) {
                if (!event) {
index c75bd09bbae3eb63b7606f349e84546942db2dc5..cf7a5976cdd6705dae9d640933beba07b2860c2e 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 3.5.2-dev:
+Edit strings with \n in textarea
 Style logout button as link
 
 Adminer 3.5.1 (released 2012-08-10):