diff --git a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php index 60cf8aeae5972233f42726f68b645eac273d0109..f33c4b1003678f4b4e72b663d21afc6d2de2e630 100644 --- a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php @@ -344,8 +344,9 @@ class FormInlineAjaxController // Do not compile existing children, we don't need them now 'inlineCompileExistingChildren' => false, ]; + // Full TcaDatabaseRecord is required here to have the list of connected uids $oldItemList /** @var TcaDatabaseRecord $formDataGroup */ - $formDataGroup = GeneralUtility::makeInstance(InlineParentRecord::class); + $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class); /** @var FormDataCompiler $formDataCompiler */ $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup); $parentData = $formDataCompiler->compile($formDataCompilerInputForParent); @@ -402,7 +403,7 @@ class FormInlineAjaxController } $jsonArray['scriptCall'][] = 'inline.memorizeAddRecord(' . GeneralUtility::quoteJSvalue($nameObjectForeignTable) . ', ' . GeneralUtility::quoteJSvalue($childUid) . ', null, ' . $selectedValue . ');'; // Remove possible virtual records in the form which showed that a child records could be localized: - $transOrigPointerFieldName = $GLOBALS['TCA'][$childData['table']]['ctrl']['transOrigPointerField']; + $transOrigPointerFieldName = $childData['processedTca']['ctrl']['transOrigPointerField']; if (isset($childData['databaseRow'][$transOrigPointerFieldName]) && $childData['databaseRow'][$transOrigPointerFieldName]) { $transOrigPointerField = $childData['databaseRow'][$transOrigPointerFieldName]; if (is_array($transOrigPointerField)) { @@ -410,9 +411,16 @@ class FormInlineAjaxController } $jsonArray['scriptCall'][] = 'inline.fadeAndRemove(' . GeneralUtility::quoteJSvalue($nameObjectForeignTable . '-' . $transOrigPointerField . '_div') . ');'; } - if (!empty($childResult['html'])) { - array_unshift($jsonArray['scriptCall'], 'inline.domAddNewRecord(\'bottom\', ' . GeneralUtility::quoteJSvalue($nameObject . '_records') . ', ' . GeneralUtility::quoteJSvalue($nameObjectForeignTable) . ', json.data);'); - } + + } + // Tell JS to add new HTML of one or multiple (localize all) records to DOM + if (!empty($jsonArray['data'])) { + array_push( + $jsonArray['scriptCall'], + 'inline.domAddNewRecord(\'bottom\', ' . GeneralUtility::quoteJSvalue($nameObject . '_records') + . ', ' . GeneralUtility::quoteJSvalue($nameObjectForeignTable) + . ', json.data);' + ); } } @@ -536,7 +544,7 @@ class FormInlineAjaxController */ protected function mergeChildResultIntoJsonResult(array $jsonResult, array $childResult) { - $jsonResult['data'] = $childResult['html']; + $jsonResult['data'] .= $childResult['html']; $jsonResult['stylesheetFiles'] = $childResult['stylesheetFiles']; if (!empty($childResult['inlineData'])) { $jsonResult['scriptCall'][] = 'inline.addToDataArray(' . json_encode($childResult['inlineData']) . ');'; diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php index a77397f772ece1e4019001b857dd0268d27caabc..7d5cac9ada5857c3c34c55b4805b02ac8750a1f0 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php @@ -161,35 +161,37 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid $result['defaultLanguageRow']['uid'], $result['defaultLanguageRow'][$fieldName] ); + $showPossible = $result['processedTca']['columns'][$fieldName]['config']['appearance']['showPossibleLocalizationRecords']; $showRemoved = $result['processedTca']['columns'][$fieldName]['config']['appearance']['showRemovedLocalizationRecords']; - if ($showPossible || $showRemoved) { - // Find which records are localized, which records are not localized and which are - // localized but miss default language record - $fieldNameWithDefaultLanguageUid = $GLOBALS['TCA'][$childTableName]['ctrl']['transOrigPointerField']; - foreach ($connectedUidsOfLocalizedOverlay as $localizedUid) { - $localizedRecord = $this->getRecordFromDatabase($childTableName, $localizedUid); - $uidOfDefaultLanguageRecord = $localizedRecord[$fieldNameWithDefaultLanguageUid]; - if (in_array($uidOfDefaultLanguageRecord, $connectedUidsOfDefaultLanguageRecord, true)) { - // This localized child has a default language record. Remove this record from list of default language records - $connectedUidsOfDefaultLanguageRecord = array_diff($connectedUidsOfDefaultLanguageRecord, array($uidOfDefaultLanguageRecord)); - // Compile localized record - $result['processedTca']['columns'][$fieldName]['children'][] = $this->compileChild($result, $fieldName, $localizedUid); - } elseif ($showRemoved) { - // This localized child has no default language record. Compile child and mark it as such - $compiledChild = $this->compileChild($result, $fieldName, $localizedUid); - $compiledChild['inlineIsDanglingLocalization'] = true; - $result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild; - } // Discard child if default language is missing and no showRemoved is set - } - if ($showPossible) { - foreach ($connectedUidsOfDefaultLanguageRecord as $defaultLanguageUid) { - // If there are still uids in $connectedUidsOfDefaultLanguageRecord, these are records that - // exist in default language, but are not localized yet. Compile and mark those - $compiledChild = $this->compileChild($result, $fieldName, $defaultLanguageUid); - $compiledChild['inlineIsDefaultLanguage'] = true; - $result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild; - } + + // Find which records are localized, which records are not localized and which are + // localized but miss default language record + $fieldNameWithDefaultLanguageUid = $GLOBALS['TCA'][$childTableName]['ctrl']['transOrigPointerField']; + foreach ($connectedUidsOfLocalizedOverlay as $localizedUid) { + $localizedRecord = $this->getRecordFromDatabase($childTableName, $localizedUid); + $uidOfDefaultLanguageRecord = $localizedRecord[$fieldNameWithDefaultLanguageUid]; + if (in_array($uidOfDefaultLanguageRecord, $connectedUidsOfDefaultLanguageRecord)) { + // This localized child has a default language record. Remove this record from list of default language records + $connectedUidsOfDefaultLanguageRecord = array_diff($connectedUidsOfDefaultLanguageRecord, array($uidOfDefaultLanguageRecord)); + // Compile localized record + $compiledChild = $this->compileChild($result, $fieldName, $localizedUid); + $compiledChild['inlineIsTranslationWithDefaultLanguage'] = true; + $result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild; + } elseif ($showRemoved) { + // This localized child has no default language record. Compile child and mark it as such + $compiledChild = $this->compileChild($result, $fieldName, $localizedUid); + $compiledChild['inlineIsDanglingLocalization'] = true; + $result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild; + } // Discard child if default language is missing and no showRemoved is set + } + if ($showPossible) { + foreach ($connectedUidsOfDefaultLanguageRecord as $defaultLanguageUid) { + // If there are still uids in $connectedUidsOfDefaultLanguageRecord, these are records that + // exist in default language, but are not localized yet. Compile and mark those + $compiledChild = $this->compileChild($result, $fieldName, $defaultLanguageUid); + $compiledChild['inlineIsDefaultLanguage'] = true; + $result['processedTca']['columns'][$fieldName]['children'][] = $compiledChild; } } }