[TASK] Enhance localization behavior of pages.media 39/29839/2
authorOliver Hader <oliver@typo3.org>
Sun, 4 May 2014 09:01:45 +0000 (11:01 +0200)
committerMarc Bastian Heinrichs <typo3@mbh-software.de>
Sun, 4 May 2014 12:35:48 +0000 (14:35 +0200)
With issue #57488 the pages.media field became localizable again,
however the selective approach turns out to be problematic in
terms of overlaying data in the frontend (the "mergeIfNotBlank"
settings and the like).
Thus, instead of letting the editor localize the references after
persisting the parent and having to overlay/fallback in the
frontend, now the references are already shown in the edit view
during the localization (still before being persisted).

Resolves: #58476
Releases: 6.2
Change-Id: Id6980f2a5cfea109375afce27f62cad8c101c58e
Reviewed-on: https://review.typo3.org/29839
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Marc Bastian Heinrichs
Tested-by: Marc Bastian Heinrichs
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/frontend/Configuration/TCA/pages_language_overlay.php

index cf9518b..d1c3ebd 100644 (file)
@@ -1473,6 +1473,7 @@ class InlineElement {
         * @todo Define visibility
         */
        public function getRelatedRecords($table, $field, $row, &$PA, $config) {
+               $language = 0;
                $pid = $row['pid'];
                $elements = $PA['itemFormElValue'];
                $foreignTable = $config['foreign_table'];
@@ -1498,13 +1499,36 @@ class InlineElement {
                $records = $this->getRelatedRecordsArray($pid, $foreignTable, $elements);
                $relatedRecords = array('records' => $records, 'count' => count($records));
                // Merge original language with current localization and show differences:
-               if (is_array($recordsOriginal)) {
+               if (!empty($recordsOriginal)) {
                        $options = array(
                                'showPossible' => isset($config['appearance']['showPossibleLocalizationRecords']) && $config['appearance']['showPossibleLocalizationRecords'],
                                'showRemoved' => isset($config['appearance']['showRemovedLocalizationRecords']) && $config['appearance']['showRemovedLocalizationRecords']
                        );
+                       // Either show records that possibly can localized or removed
                        if ($options['showPossible'] || $options['showRemoved']) {
                                $relatedRecords['records'] = $this->getLocalizationDifferences($foreignTable, $options, $recordsOriginal, $records);
+                       // Otherwise simulate localizeChildrenAtParentLocalization behaviour when creating a new record
+                       // (which has language and translation pointer values set)
+                       } elseif (!empty($config['behaviour']['localizeChildrenAtParentLocalization']) && !MathUtility::canBeInterpretedAsInteger($row['uid'])) {
+                               if (!empty($GLOBALS['TCA'][$foreignTable]['ctrl']['transOrigPointerField'])) {
+                                       $foreignLanguageField = $GLOBALS['TCA'][$foreignTable]['ctrl']['languageField'];
+                               }
+                               if (!empty($GLOBALS['TCA'][$foreignTable]['ctrl']['transOrigPointerField'])) {
+                                       $foreignTranslationPointerField = $GLOBALS['TCA'][$foreignTable]['ctrl']['transOrigPointerField'];
+                               }
+                               // Duplicate child records of default language in form
+                               foreach ($recordsOriginal as $record) {
+                                       if (!empty($foreignLanguageField)) {
+                                               $record[$foreignLanguageField] = $language;
+                                       }
+                                       if (!empty($foreignTranslationPointerField)) {
+                                               $record[$foreignTranslationPointerField] = $record['uid'];
+                                       }
+                                       $newId = uniqid('NEW');
+                                       $record['uid'] = $newId;
+                                       $record['pid'] = $this->inlineFirstPid;
+                                       $relatedRecords['records'][$newId] = $record;
+                               }
                        }
                }
                return $relatedRecords;
index 09143cf..1d0a7b3 100644 (file)
@@ -155,16 +155,7 @@ return array(
                'media' => array(
                        'exclude' => 1,
                        'label' => $GLOBALS['TCA']['pages']['columns']['media']['label'],
-                       'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
-                               'media',
-                               array(
-                                       'appearance' => array(
-                                               'levelLinksPosition' => 'top',
-                                               'showPossibleLocalizationRecords' => TRUE,
-                                               'showAllLocalizationLink' => TRUE,
-                                       ),
-                               )
-                       )
+                       'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media')
                ),
                'url' => array(
                        'exclude' => 1,