From 24042d9e36223c760273a1df29fe7345a908c923 Mon Sep 17 00:00:00 2001 From: Markus Klein <markus.klein@typo3.org> Date: Fri, 29 Jul 2016 11:31:39 +0200 Subject: [PATCH] [BUGFIX] Handle l10n_parent if field is no select-type The value of l10n_parent is not necessarily an array. It may as well be a string from a group-type or simple input. Adjust the condition for overlay detection accordingly. Resolves: #77301 Releases: master, 7.6 Change-Id: I9119dfc0a55d623f037f15ddf1e11f132cf38c0b Reviewed-on: https://review.typo3.org/49261 Tested-by: Bamboo TYPO3com <info@typo3.com> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Form/Container/SingleFieldContainer.php | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php b/typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php index 461467fdd36f..c68ec9d04fb1 100644 --- a/typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php +++ b/typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php @@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation; use TYPO3\CMS\Core\Utility\DiffUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Lang\LanguageService; /** @@ -65,10 +66,25 @@ class SingleFieldContainer extends AbstractContainer // Based on this decision we need to trigger field exclusion or special rendering (like readOnly) if (isset($this->data['processedTca']['ctrl']['transOrigPointerField']) && is_array($this->data['processedTca']['columns'][$this->data['processedTca']['ctrl']['transOrigPointerField']]) - && is_array($row[$this->data['processedTca']['ctrl']['transOrigPointerField']]) - && $row[$this->data['processedTca']['ctrl']['transOrigPointerField']][0] > 0 ) { - $isOverlay = true; + $parentValue = $row[$this->data['processedTca']['ctrl']['transOrigPointerField']]; + if (MathUtility::canBeInterpretedAsInteger($parentValue)) { + $isOverlay = (bool)$parentValue; + } elseif (is_array($parentValue)) { + // This case may apply if the value has been converted to an array by the select data provider + $isOverlay = !empty($parentValue) ? (bool)$parentValue[0] : false; + } elseif (is_string($parentValue) && $parentValue !== '') { + // This case may apply if a group definition is used in TCA and the group provider builds a weird string + $recordsReferencedInField = GeneralUtility::trimExplode(',', $parentValue); + // Pick the first record because if you set multiple records you're in trouble anyways + $recordIdentifierParts = GeneralUtility::trimExplode('|', $recordsReferencedInField[0]); + list(, $refUid) = BackendUtility::splitTable_Uid($recordIdentifierParts[0]); + $isOverlay = MathUtility::canBeInterpretedAsInteger($refUid) ? (bool)$refUid : false; + } else { + throw new \InvalidArgumentException('The given value for the original language field ' + . $this->data['processedTca']['ctrl']['transOrigPointerField'] + . ' of table ' . $table . ' contains an invalid value.', 1470742770); + } } // A couple of early returns in case the field should not be rendered @@ -79,7 +95,7 @@ class SingleFieldContainer extends AbstractContainer // @todo: Drop option "showIfRTE" ? || !$backendUser->isRTE() && $parameterArray['fieldConf']['config']['showIfRTE'] // Return if field should not be rendered in translated records - || $isOverlay && !$parameterArray['fieldConf']['l10n_display'] && $parameterArray['fieldConf']['l10n_mode'] === 'exclude' + || $isOverlay && empty($parameterArray['fieldConf']['l10n_display']) && $parameterArray['fieldConf']['l10n_mode'] === 'exclude' // @todo: localizationMode still needs handling! || $isOverlay && $this->data['localizationMode'] && $this->data['localizationMode'] !== $parameterArray['fieldConf']['l10n_cat'] || $this->inlineFieldShouldBeSkipped() -- GitLab