[BUGFIX] Media field is empty on page localization 19/29719/5
authorOliver Hader <oliver@typo3.org>
Mon, 28 Apr 2014 20:32:17 +0000 (22:32 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 2 May 2014 17:57:57 +0000 (19:57 +0200)
If comparing localization of regular tables (like tt_content) to
pages and its specific overlay table pages_language_overlay, the
main difference is, that regular tables are copied directly and
page translation are shown in the edit view first - without
persisting to the database and thus not having a proper uid at
this time, yet.

This means, that "localizeChildrenAtParentLocalization" in the
TCA field configuration won't have any effect.

This change brings back the IRRE localization icons for children
and "localize all" link for the media field. However, those are
only displayed if the new page overlay has been saved once.

Resolves: #57488
Releases: 6.2
Change-Id: I29886776b40accce48ce5cd10937ff65b20430fb
Reviewed-on: https://review.typo3.org/29719
Reviewed-by: Markus Klein
Reviewed-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Tested-by: Nadir S.
Reviewed-by: Frans Saris
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/frontend/Configuration/TCA/pages_language_overlay.php

index cd6cc39..cf9518b 100644 (file)
@@ -185,11 +185,14 @@ class InlineElement {
                        return FALSE;
                }
                $item = '';
+               $levelLinks = '';
+               $localizationLinks = '';
                // Count the number of processed inline elements
                $this->inlineCount++;
                // Init:
                $config = $PA['fieldConf']['config'];
                $foreign_table = $config['foreign_table'];
+               $language = 0;
                if (BackendUtility::isTableLocalizable($table)) {
                        $language = (int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
                }
@@ -273,6 +276,17 @@ class InlineElement {
                                'possible' => $this->getPossibleRecordsFlat($possibleRecords)
                        );
                }
+               // Render the localization links
+               if ($language > 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0 && MathUtility::canBeInterpretedAsInteger($row['uid'])) {
+                       // Add the "Localize all records" link before all child records:
+                       if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
+                               $localizationLinks .= ' ' . $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $foreign_table, $config);
+                       }
+                       // Add the "Synchronize with default language" link before all child records:
+                       if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
+                               $localizationLinks .= ' ' . $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $foreign_table, $config);
+                       }
+               }
                // If it's required to select from possible child records (reusable children), add a selector box
                if ($config['foreign_selector'] && $config['appearance']['showPossibleRecordsSelector'] !== FALSE) {
                        // If not already set by the foreign_unique, set the possibleRecords here and the uniqueIds to an empty array
@@ -281,7 +295,10 @@ class InlineElement {
                                $uniqueIds = array();
                        }
                        $selectorBox = $this->renderPossibleRecordsSelector($possibleRecords, $config, $uniqueIds);
-                       $item .= $selectorBox;
+                       $item .= $selectorBox . $localizationLinks;
+               // Render the level links (create new record):
+               } else {
+                       $levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $foreign_table, $config);
                }
                // Wrap all inline fields of a record with a <div> (like a container)
                $item .= '<div id="' . $nameObject . '">';
@@ -289,23 +306,9 @@ class InlineElement {
                if ($relatedRecords['count'] >= $maxitems || $uniqueMax > 0 && $relatedRecords['count'] >= $uniqueMax) {
                        $config['inline']['inlineNewButtonStyle'] = 'display: none;';
                }
-               // Render the level links (create new record, localize all, synchronize):
-               if ($config['appearance']['levelLinksPosition'] != 'none') {
-                       $levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $foreign_table, $config);
-                       if ($language > 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0) {
-                               // Add the "Localize all records" link before all child records:
-                               if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
-                                       $levelLinks .= ' ' . $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $foreign_table, $config);
-                               }
-                               // Add the "Synchronize with default language" link before all child records:
-                               if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
-                                       $levelLinks .= ' ' . $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $foreign_table, $config);
-                               }
-                       }
-               }
                // Add the level links before all child records:
                if (in_array($config['appearance']['levelLinksPosition'], array('both', 'top'))) {
-                       $item .= $levelLinks;
+                       $item .= $levelLinks . $localizationLinks;
                }
                $item .= '<div id="' . $nameObject . '_records">';
                $relationList = array();
@@ -320,7 +323,7 @@ class InlineElement {
                $item .= '</div>';
                // Add the level links after all child records:
                if (in_array($config['appearance']['levelLinksPosition'], array('both', 'bottom'))) {
-                       $item .= $levelLinks;
+                       $item .= $levelLinks . $localizationLinks;
                }
                if (is_array($config['customControls'])) {
                        $item .= '<div id="' . $nameObject . '_customControls">';
@@ -642,6 +645,7 @@ class InlineElement {
                // Initialize:
                $cells = array();
                $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
+               $isParentExisting = MathUtility::canBeInterpretedAsInteger($parentUid);
                $tcaTableCtrl = &$GLOBALS['TCA'][$foreign_table]['ctrl'];
                $tcaTableCols = &$GLOBALS['TCA'][$foreign_table]['columns'];
                $isPagesTable = $foreign_table == 'pages' ? TRUE : FALSE;
@@ -726,7 +730,7 @@ class InlineElement {
                        if ($enabledControls['dragdrop'] && $permsEdit && $enableManualSorting && $config['appearance']['useSortable']) {
                                $cells['dragdrop'] = IconUtility::getSpriteIcon('actions-move-move', array('data-id' => $rec['uid'], 'class' => 'sortableHandle', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.move', TRUE)));
                        }
-               } elseif ($isVirtualRecord) {
+               } elseif ($isVirtualRecord && $isParentExisting) {
                        if ($enabledControls['localize'] && isset($rec['__create'])) {
                                $onClick = 'inline.synchronizeLocalizeRecords(\'' . $nameObjectFt . '\', ' . $rec['uid'] . ');';
                                $cells['localize'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . IconUtility::getSpriteIcon('actions-document-localize', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:localize', TRUE))) . '</a>';
@@ -1718,6 +1722,7 @@ class InlineElement {
                                $uid = $workspaceVersion['uid'];
                        }
                }
+               /** @var $trData \TYPO3\CMS\Backend\Form\DataPreprocessor */
                $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
                $trData->addRawData = TRUE;
                $trData->lockRecords = 1;
index 1d0a7b3..09143cf 100644 (file)
@@ -155,7 +155,16 @@ return array(
                'media' => array(
                        'exclude' => 1,
                        'label' => $GLOBALS['TCA']['pages']['columns']['media']['label'],
-                       'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media')
+                       'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
+                               'media',
+                               array(
+                                       'appearance' => array(
+                                               'levelLinksPosition' => 'top',
+                                               'showPossibleLocalizationRecords' => TRUE,
+                                               'showAllLocalizationLink' => TRUE,
+                                       ),
+                               )
+                       )
                ),
                'url' => array(
                        'exclude' => 1,