Permalink
Browse files

Edit strings with \n in textarea

  • Loading branch information...
1 parent 98bc4fc commit f0d97a7c7f3587360e20c392505aec2d3e2800f2 @vrana committed Aug 12, 2012
Showing with 10 additions and 2 deletions.
  1. +8 −2 adminer/include/functions.inc.php
  2. +1 −0 adminer/static/functions.js
  3. +1 −0 changes.txt
@@ -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));
@@ -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) {
View
@@ -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):

0 comments on commit f0d97a7

Please sign in to comment.