[BUGFIX] Trim labels from flexforms to ensure LLL: is noticed 34/44534/4
authorMarkus Klein <markus.klein@typo3.org>
Wed, 4 Nov 2015 13:27:54 +0000 (14:27 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Wed, 4 Nov 2015 16:06:33 +0000 (17:06 +0100)
Resolves: #71318
Releases: master
Change-Id: I8ed8d9a1ecc670f8aed43e02cfc55563b0c681ce
Reviewed-on: https://review.typo3.org/44534
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php
typo3/sysext/backend/Classes/Form/Container/FlexFormSectionContainer.php
typo3/sysext/backend/Classes/Form/Container/FlexFormTabsContainer.php
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaCheckboxItems.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaRadioItems.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php

index 7c2a6ce..fb8e0ab 100644 (file)
@@ -63,8 +63,8 @@ class FlexFormElementContainer extends AbstractContainer
                 }
 
                 $sectionTitle = '';
-                if (!empty($flexFormFieldArray['title'])) {
-                    $sectionTitle = $languageService->sL($flexFormFieldArray['title']);
+                if (!empty(trim($flexFormFieldArray['title']))) {
+                    $sectionTitle = $languageService->sL(trim($flexFormFieldArray['title']));
                 }
 
                 $options = $this->data;
index bbb2a83..02d12af 100644 (file)
@@ -67,8 +67,8 @@ class FlexFormSectionContainer extends AbstractContainer
                 // There may be cases where a field is still in DB but does not exist in definition
                 if (is_array($containerDataStructure)) {
                     $sectionTitle = '';
-                    if (!empty($containerDataStructure['title'])) {
-                        $sectionTitle = $languageService->sL($containerDataStructure['title']);
+                    if (!empty(trim($containerDataStructure['title']))) {
+                        $sectionTitle = $languageService->sL(trim($containerDataStructure['title']));
                     }
 
                     $options = $this->data;
@@ -94,8 +94,8 @@ class FlexFormSectionContainer extends AbstractContainer
         foreach ($flexFormFieldsArray as $flexFormContainerName => $flexFormFieldDefinition) {
             $containerTemplateHtml = array();
             $sectionTitle = '';
-            if (!empty($flexFormFieldDefinition['title'])) {
-                $sectionTitle = $languageService->sL($flexFormFieldDefinition['title']);
+            if (!empty(trim($flexFormFieldDefinition['title']))) {
+                $sectionTitle = $languageService->sL(trim($flexFormFieldDefinition['title']));
             }
 
             $options = $this->data;
index 42ab85b..70fd2da 100644 (file)
@@ -82,10 +82,10 @@ class FlexFormTabsContainer extends AbstractContainer
             $childReturn = $this->nodeFactory->create($options)->render();
 
             $tabElements[] = array(
-                'label' => !empty($sheetDataStructure['ROOT']['sheetTitle']) ? $languageService->sL($sheetDataStructure['ROOT']['sheetTitle']) : $sheetName,
+                'label' => !empty(trim($sheetDataStructure['ROOT']['sheetTitle'])) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetTitle'])) : $sheetName,
                 'content' => $childReturn['html'],
-                'description' => $sheetDataStructure['ROOT']['sheetDescription'] ? $languageService->sL($sheetDataStructure['ROOT']['sheetDescription']) : '',
-                'linkTitle' => $sheetDataStructure['ROOT']['sheetShortDescr'] ? $languageService->sL($sheetDataStructure['ROOT']['sheetShortDescr']) : '',
+                'description' => trim($sheetDataStructure['ROOT']['sheetDescription']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetDescription'])) : '',
+                'linkTitle' => trim($sheetDataStructure['ROOT']['sheetShortDescr']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetShortDescr'])) : '',
             );
 
             $childReturn['html'] = '';
index 8c17fdb..92460c1 100644 (file)
@@ -256,7 +256,7 @@ class InlineControlContainer extends AbstractContainer
             $html .= $selectorBox . $localizationLinks;
         }
 
-        $title = $languageService->sL($parameterArray['fieldConf']['label']);
+        $title = $languageService->sL(trim($parameterArray['fieldConf']['label']));
         $html .= '<div class="panel-group panel-hover" data-title="' . htmlspecialchars($title) . '" id="' . $nameObject . '_records">';
 
         $sortableRecordUids = [];
index 9978e7e..e72d953 100644 (file)
@@ -42,7 +42,7 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
 
         // Creating the label for the "No Matching Value" entry.
         $noMatchingLabel = isset($parameterArray['fieldTSConfig']['noMatchingValue_label'])
-            ? $this->getLanguageService()->sL($parameterArray['fieldTSConfig']['noMatchingValue_label'])
+            ? $this->getLanguageService()->sL(trim($parameterArray['fieldTSConfig']['noMatchingValue_label']))
             : '[ ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue') . ' ]';
 
         $selItems = $config['items'];
@@ -80,7 +80,7 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
                 $itemArray[1] = rawurlencode(@sprintf($noMatchingLabel, $itemValue));
             } else {
                 if (isset($parameterArray['fieldTSConfig']['altLabels.'][$itemValue])) {
-                    $itemArray[1] = rawurlencode($this->getLanguageService()->sL($parameterArray['fieldTSConfig']['altLabels.'][$itemValue]));
+                    $itemArray[1] = rawurlencode($this->getLanguageService()->sL(trim($parameterArray['fieldTSConfig']['altLabels.'][$itemValue])));
                 }
                 if (isset($parameterArray['fieldTSConfig']['altIcons.'][$itemValue])) {
                     $itemArray[2] = $parameterArray['fieldTSConfig']['altIcons.'][$itemValue];
@@ -149,9 +149,9 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
             if (isset($config['multiSelectFilterItems']) && is_array($config['multiSelectFilterItems']) && count($config['multiSelectFilterItems']) > 1) {
                 $filterDropDownOptions = array();
                 foreach ($config['multiSelectFilterItems'] as $optionElement) {
-                    $optionValue = $this->getLanguageService()->sL(isset($optionElement[1]) && $optionElement[1] != '' ? $optionElement[1]
-                        : $optionElement[0]);
-                    $filterDropDownOptions[] = '<option value="' . htmlspecialchars($this->getLanguageService()->sL($optionElement[0])) . '">'
+                    $optionValue = $this->getLanguageService()->sL(isset($optionElement[1]) && trim($optionElement[1]) !== '' ? trim($optionElement[1])
+                        : trim($optionElement[0]));
+                    $filterDropDownOptions[] = '<option value="' . htmlspecialchars($this->getLanguageService()->sL(trim($optionElement[0]))) . '">'
                         . htmlspecialchars($optionValue) . '</option>';
                 }
                 $filterSelectbox = '<select class="form-control input-sm t3js-formengine-multiselect-filter-dropdown">'
index a9d33a6..7731cb9 100644 (file)
@@ -45,7 +45,7 @@ class SelectSingleElement extends AbstractFormElement
 
         // Creating the label for the "No Matching Value" entry.
         $noMatchingLabel = isset($parameterArray['fieldTSConfig']['noMatchingValue_label'])
-            ? $this->getLanguageService()->sL($parameterArray['fieldTSConfig']['noMatchingValue_label'])
+            ? $this->getLanguageService()->sL(trim($parameterArray['fieldTSConfig']['noMatchingValue_label']))
             : '[ ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noMatchingValue') . ' ]';
 
         // Check against inline uniqueness
index dfa2c47..6f421e5 100644 (file)
@@ -655,7 +655,7 @@ abstract class AbstractItemProvider
                 }
                 // Get all sheets and title
                 foreach ($flexForms as $extIdent => $extConf) {
-                    $extTitle = $languageService->sl($extConf['title']);
+                    $extTitle = $languageService->sl(trim($extConf['title']));
                     // Get all fields in sheet
                     foreach ($extConf['ds']['sheets'] as $sheetName => $sheet) {
                         if (empty($sheet['ROOT']['el']) || !is_array($sheet['ROOT']['el'])) {
@@ -666,7 +666,7 @@ abstract class AbstractItemProvider
                             if (empty($field['TCEforms']['exclude'])) {
                                 continue;
                             }
-                            $fieldLabel = !empty($field['TCEforms']['label']) ? $languageService->sl($field['TCEforms']['label']) : $fieldName;
+                            $fieldLabel = !empty(trim($field['TCEforms']['label'])) ? $languageService->sl(trim($field['TCEforms']['label'])) : $fieldName;
                             $fieldIdent = $table . ':' . $tableField . ';' . $extIdent . ';' . $sheetName . ';' . $fieldName;
                             $excludeArrayTable[] = [trim($labelPrefix . ' ' . $extTitle, ': ') . ': ' . $fieldLabel, $fieldIdent];
                         }
@@ -1114,7 +1114,7 @@ abstract class AbstractItemProvider
             ) {
                 $label = $languageService->sL($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['altLabels.'][$item[1]]);
             } else {
-                $label = $languageService->sL($item[0]);
+                $label = $languageService->sL(trim($item[0]));
             }
             $value = strlen((string)$item[1]) > 0 ? $item[1] : '';
             $icon = $item[2] ?: null;
index 228f5bd..e7cf5f2 100644 (file)
@@ -65,7 +65,7 @@ class TcaCheckboxItems extends AbstractItemProvider implements FormDataProviderI
                     $itemValue[1] = '';
                 }
                 $newItems[$itemKey] = [
-                    $languageService->sL($itemValue[0]),
+                    $languageService->sL(trim($itemValue[0])),
                     $itemValue[1]
                 ];
             }
index 4cf3168..e0c7189 100644 (file)
@@ -71,7 +71,7 @@ class TcaRadioItems extends AbstractItemProvider implements FormDataProviderInte
                     );
                 }
                 $newItems[$itemKey] = [
-                    $languageService->sL($itemValue[0]),
+                    $languageService->sL(trim($itemValue[0])),
                     $itemValue[1]
                 ];
             }
@@ -90,7 +90,7 @@ class TcaRadioItems extends AbstractItemProvider implements FormDataProviderInte
             ) {
                 foreach ($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['altLabels.'] as $itemKey => $label) {
                     if (isset($items[$itemKey][0])) {
-                        $items[$itemKey][0] = $languageService->sL($label);
+                        $items[$itemKey][0] = $languageService->sL(trim($label));
                     }
                 }
             }
index 05a86b1..db6d664 100644 (file)
@@ -584,7 +584,7 @@ class TcaSelectItemsTest extends UnitTestCase
                 3 => null,
             ],
             1 => [
-                0 => ' (input1)',
+                0 => '(input1)',
                 1 => 'fooTable:aFlexField;dummy;sDEF;input1',
                 2 => 'empty-empty',
                 3 => null,