Commit 9e6a41c9 authored by Markus Klein's avatar Markus Klein Committed by Alexander Opitz
Browse files

[BUGFIX] Trim labels from flexforms to ensure LLL: is noticed

Resolves: #71318
Releases: master
Change-Id: I8ed8d9a1ecc670f8aed43e02cfc55563b0c681ce
Reviewed-on: https://review.typo3.org/44534

Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Alexander Opitz's avatarAlexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz's avatarAlexander Opitz <opitz.alexander@googlemail.com>
parent 5dee0809
......@@ -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;
......
......@@ -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;
......
......@@ -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'] = '';
......
......@@ -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 = [];
......
......@@ -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">'
......
......@@ -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
......
......@@ -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;
......
......@@ -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]
];
}
......
......@@ -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));
}
}
}
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment