From 0fbeb2d7ff5b21dda28da7d5af26d70c3bb14cbd Mon Sep 17 00:00:00 2001 From: Nicole Cordes Date: Sat, 12 May 2018 12:39:52 +0200 Subject: [PATCH] [BUGFIX] Show all content elements with mod.web_layout.defLangBinding The option is meant to show translated content elements alligned with their translation parent element (connected mode). However this also made content elements diasppear, which were added individually in a language (free mode). With this change, elements for a language in free mode are also shown, when the option is set. Resolves: #62550 Releases: master, 8.7 Change-Id: I96f754ecf4ddb98f22d0d8c7d7da6001fa774d6b Reviewed-on: https://review.typo3.org/56932 Reviewed-by: Nicole Cordes Tested-by: Nicole Cordes Tested-by: TYPO3com Reviewed-by: Wouter Wolters Reviewed-by: Mathias Brodala Tested-by: Mathias Brodala --- .../backend/Classes/View/PageLayoutView.php | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index 55b05d24e2e6..44dbeeebbc9e 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -622,7 +622,7 @@ public function getTable_tt_content($id) $defaultLanguageElementsByColumn[$columnId][] = (isset($row['_ORIG_uid']) ? $row['_ORIG_uid'] : $row['uid']); } $editUidList .= $row['uid'] . ','; - $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0; + $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0 && $this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP); if (!$this->tt_contentConfig['languageMode']) { $singleElementHTML .= '
'; } @@ -693,7 +693,7 @@ public function getTable_tt_content($id) } $singleElementHTML .= '
'; if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) { - $defLangBinding[$columnId][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML; + $defLangBinding[$columnId][$lP][$row[$lP ? 'l18n_parent' : 'uid'] ?: $row['uid']] = $singleElementHTML; } else { $content[$columnId] .= $singleElementHTML; } @@ -977,16 +977,27 @@ public function getTable_tt_content($id) $out .= '' . $columnContent . ''; } $out .= ''; - if ($this->defLangBinding) { - // "defLangBinding" mode - foreach ($defaultLanguageElementsByColumn[$cKey] as $defUid) { + if ($this->defLangBinding && !empty($defLangBinding[$cKey])) { + $maxItemsCount = max(array_map('count', $defLangBinding[$cKey])); + for ($i = 0; $i < $maxItemsCount; $i++) { + $defUid = $defaultLanguageElementsByColumn[$cKey][$i] ?? 0; $cCont = []; foreach ($langListArr as $lP) { - $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . $this->newLanguageButton( - $this->getNonTranslatedTTcontentUids([$defUid], $id, $lP), - $lP, - $cKey - ); + if ($lP > 0 + && is_array($defLangBinding[$cKey][$lP]) + && !$this->checkIfTranslationsExistInLanguage($defaultLanguageElementsByColumn[$cKey], $lP) + && count($defLangBinding[$cKey][$lP]) > $i + ) { + $slice = array_slice($defLangBinding[$cKey][$lP], $i, 1); + $element = $slice[0] ?? ''; + } else { + $element = $defLangBinding[$cKey][$lP][$defUid] ?? ''; + } + $cCont[] = $element . $this->newLanguageButton( + $this->getNonTranslatedTTcontentUids([$defUid], $id, $lP), + $lP, + $cKey + ); } $out .= ' @@ -2002,7 +2013,7 @@ public function newLanguageButton($defaultLanguageUids, $lP, $colPos = 0) $allowTranslate = false; } if (isset($this->languageHasTranslationsCache[$lP]['hasTranslations'])) { - $allowCopy = false; + $allowCopy = !$this->languageHasTranslationsCache[$lP]['hasTranslations']; } } @@ -2565,8 +2576,11 @@ protected function checkIfTranslationsExistInLanguage(array $contentElements, $l } } } + if (!isset($this->languageHasTranslationsCache[$language])) { + $this->languageHasTranslationsCache[$language]['hasTranslations'] = false; + } // Check whether we have a mix of both - if ($this->languageHasTranslationsCache[$language]['hasStandAloneContent'] + if (isset($this->languageHasTranslationsCache[$language]['hasStandAloneContent']) && $this->languageHasTranslationsCache[$language]['hasTranslations'] ) { $this->languageHasTranslationsCache[$language]['mode'] = 'mixed'; @@ -2581,10 +2595,8 @@ protected function checkIfTranslationsExistInLanguage(array $contentElements, $l $queue->addMessage($message); } } - if ($this->languageHasTranslationsCache[$language]['hasTranslations']) { - return true; - } - return false; + + return $this->languageHasTranslationsCache[$language]['hasTranslations']; } /**