[TASK] Change fields of TCA type none to Twitter Bootstrap 13/34213/6
authorgriebie <griebenow@alltagsaesthetisierung.de>
Sat, 15 Nov 2014 17:07:13 +0000 (18:07 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Dec 2014 23:45:06 +0000 (00:45 +0100)
The fields for textarea/input are now based on Twitter
Bootstrap by adding "disabled" and "form-control" class.

Additionally, disabled textareas are now used for type=text,
and some doubled calculations are moved to the
TextElement class.

Resolves: #62978
Related: #62973
Releases: master
Change-Id: I0dab4130dc81cc9071283354e9472c3dc5ea40b5
Reviewed-on: http://review.typo3.org/34213
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Element/TextElement.php
typo3/sysext/backend/Classes/Form/FormEngine.php

index 3a0f734..b441693 100644 (file)
@@ -36,9 +36,6 @@ class TextElement extends AbstractFormElement {
         */
        public function render($table, $field, $row, &$additionalInformation) {
                $config = $additionalInformation['fieldConf']['config'];
-               if ($this->formEngine->renderReadonly || $config['readOnly']) {
-                       return $this->formEngine->getSingleField_typeNone_render($config, $additionalInformation['itemFormElValue']);
-               }
 
                // Setting columns number
                $cols = MathUtility::forceIntegerInRange($config['cols'] ?: 30, 5, $this->formEngine->maxTextareaWidth);
@@ -60,6 +57,14 @@ class TextElement extends AbstractFormElement {
                        }
                }
 
+               // must be called after the cols and rows calculation, so the parameters are applied
+               // to read-only fields as well.
+               if ($this->formEngine->renderReadonly || $config['readOnly']) {
+                       $config['cols'] = $cols;
+                       $config['rows'] = $rows;
+                       return $this->formEngine->getSingleField_typeNone_render($config, $additionalInformation['itemFormElValue']);
+               }
+
                $evalList = GeneralUtility::trimExplode(',', $config['eval'], TRUE);
                if (in_array('required', $evalList, TRUE)) {
                        $this->formEngine->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $additionalInformation['itemFormElName'];
index a272d4b..75183db 100644 (file)
@@ -1465,43 +1465,26 @@ class FormEngine {
                if ($config['format']) {
                        $itemValue = $this->formatValue($config, $itemValue);
                }
+               if (!$config['pass_content']) {
+                       $itemValue = htmlspecialchars($itemValue);
+               }
+
                $rows = (int)$config['rows'];
+               // Render as textarea
                if ($rows > 1) {
                        if (!$config['pass_content']) {
-                               $itemValue = nl2br(htmlspecialchars($itemValue));
-                       }
-                       // Like textarea
-                       $cols = MathUtility::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
-                       if (!$config['fixedRows']) {
-                               $origRows = ($rows = MathUtility::forceIntegerInRange($rows, 1, 20));
-                               if (strlen($itemValue) > $this->charsPerRow * 2) {
-                                       $cols = $this->maxTextareaWidth;
-                                       $rows = MathUtility::forceIntegerInRange(round(strlen($itemValue) / $this->charsPerRow), count(explode(LF, $itemValue)), 20);
-                                       if ($rows < $origRows) {
-                                               $rows = $origRows;
-                                       }
-                               }
+                               $itemValue = nl2br($itemValue);
                        }
-
-                       $cols = round($cols * $this->form_largeComp);
+                       $cols = round($config['cols'] * $this->form_largeComp);
                        $width = ceil($cols * $this->form_rowsToStylewidth);
-                       // Hardcoded: 12 is the height of the font
-                       $height = $rows * 12;
-                       $item = '
-                               <div style="overflow:auto; height:' . $height . 'px; width:' . $width . 'px;" class="t3-tceforms-fieldReadOnly">'
-                               . $itemValue . IconUtility::getSpriteIcon('status-status-readonly') . '</div>';
+                       $item = '<textarea class="form-control" style="width:' . $width . 'px;" cols="' . $cols . '" rows="' . $rows . '" disabled>' . $itemValue . '</textarea>';
                } else {
-                       if (!$config['pass_content']) {
-                               $itemValue = htmlspecialchars($itemValue);
-                       }
-                       $cols = $config['cols'] ? $config['cols'] : ($config['size'] ? $config['size'] : $this->maxInputWidth);
+                       $cols = $config['cols'] ?: ($config['size'] ?: $this->maxInputWidth);
                        $cols = round($cols * $this->form_largeComp);
                        $width = ceil($cols * $this->form_rowsToStylewidth);
-                       // Overflow:auto crashes mozilla here. Title tag is useful when text is longer than the div box (overflow:hidden).
                        $item = '
-                               <div style="overflow:hidden; width:' . $width . 'px;" class="t3-tceforms-fieldReadOnly" title="' . $itemValue . '">'
-                               . '<span class="nobr">' . ((string)$itemValue !== '' ? $itemValue : '&nbsp;') . '</span>'
-                               . IconUtility::getSpriteIcon('status-status-readonly') . '</div>';
+                               <input class="form-control" value="'. $itemValue .'" style="width:' . $width . 'px;" type="text" disabled>'
+                               . '<span class="nobr">' . ((string)$itemValue !== '' ? $itemValue : '&nbsp;') . '</span>';
                }
                return $item;
        }