[TASK] Improve constant editor 86/51386/3
authorGeorg Ringer <georg.ringer@gmail.com>
Sun, 22 Jan 2017 20:15:24 +0000 (21:15 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 26 Jan 2017 15:17:39 +0000 (16:17 +0100)
- Skip length check of header
- Use type "number" for integer types
- Apply min & max attributes if available

Resolves: #79421
Releases: master
Change-Id: I508000547214d3d3ca18a8e311ce68dd03dea09b
Reviewed-on: https://review.typo3.org/51386
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Mattias Nilsson <tollepjaer@gmail.com>
Tested-by: Mattias Nilsson <tollepjaer@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php

index b91c03e..5beec4d 100644 (file)
@@ -1071,6 +1071,8 @@ class ExtendedTemplateService extends TemplateService
                             } else {
                                 $retArr['params'] = GeneralUtility::intExplode('-', $retArr['paramstr']);
                             }
+                            $retArr['min'] = $retArr['params'][0];
+                            $retArr['max'] = $retArr['params'][1];
                             $retArr['paramstr'] = $retArr['params'][0] . ' - ' . $retArr['params'][1];
                             break;
                         case 'options':
@@ -1168,12 +1170,6 @@ class ExtendedTemplateService extends TemplateService
                         $head = trim($label_parts[0]);
                         $body = '';
                     }
-                    if (strlen($head) > 35) {
-                        if (!$body) {
-                            $body = $head;
-                        }
-                        $head = GeneralUtility::fixed_lgd_cs($head, 35);
-                    }
                     $typeDat = $this->ext_getTypeData($params['type']);
                     $p_field = '';
                     $raname = substr(md5($params['name']), 0, 10);
@@ -1184,17 +1180,26 @@ class ExtendedTemplateService extends TemplateService
                     switch ($typeDat['type']) {
                         case 'int':
                         case 'int+':
+                            $additionalAttributes = '';
                             if ($typeDat['paramstr']) {
                                 $hint = ' Range: ' . $typeDat['paramstr'];
                             } elseif ($typeDat['type'] === 'int+') {
                                 $hint = ' Range: 0 - ';
+                                $typeDat['min'] = 0;
                             } else {
                                 $hint = ' (Integer)';
                             }
 
+                            if (isset($typeDat['min'])) {
+                                $additionalAttributes .= ' min="' . (int)$typeDat['min'] . '" ';
+                            }
+                            if (isset($typeDat['max'])) {
+                                $additionalAttributes .= ' max="' . (int)$typeDat['max'] . '" ';
+                            }
+
                             $p_field =
-                                '<input class="form-control" id="' . $idName . '" type="text"'
-                                . ' name="' . $fN . '" value="' . $fV . '"' . ' onChange="uFormUrl(' . $aname . ')" />';
+                                '<input class="form-control" id="' . $idName . '" type="number"'
+                                . ' name="' . $fN . '" value="' . $fV . '"' . ' onChange="uFormUrl(' . $aname . ')"' . $additionalAttributes . ' />';
                             break;
                         case 'color':
                             $p_field = '
@@ -1280,8 +1285,6 @@ class ExtendedTemplateService extends TemplateService
                             $userFunctionParams = ['fieldName' => $fN, 'fieldValue' => $fV];
                             $p_field = GeneralUtility::callUserFunction($userFunction, $userFunctionParams, $this);
                             break;
-                        case 'small':
-
                         default:
                             $p_field = '<input class="form-control" id="' . $idName . '" type="text" name="' . $fN . '" value="' . $fV . '"'
                                 . ' onChange="uFormUrl(' . $aname . ')" />';