[BUGFIX] Use language fields as defined in TCA for „Duplicate“ 41/55741/4
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 15 Feb 2018 19:03:55 +0000 (20:03 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 19 Feb 2018 11:19:56 +0000 (12:19 +0100)
Change-Id: I123e6dae9b0b6a5bb68261bc9ae5aaf75a64822d
Resolves: #83926
Related: #83892
Releases: master
Reviewed-on: https://review.typo3.org/55741
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index dcb24e8..d489e05 100644 (file)
@@ -1330,23 +1330,21 @@ class EditDocumentController
         $buttonBar->addButton($closeButton);
         // DUPLICATE button:
         $record = BackendUtility::getRecord($this->firstEl['table'], $this->firstEl['uid']);
-        $l18nParent = $record['l18n_parent'] ?? 0;
-        $sysLanguageUid = $record['sys_language_uid'] ?? 0;
+        $TCActrl = $GLOBALS['TCA'][$this->firstEl['table']]['ctrl'];
+        $l18nParent = isset($TCActrl['transOrigPointerField'], $record[$TCActrl['transOrigPointerField']])
+            ? (int)$record[$TCActrl['transOrigPointerField']]
+            : 0;
+        $sysLanguageUid = isset($TCActrl['languageField'], $record[$TCActrl['languageField']])
+            ? (int)$record[$TCActrl['languageField']]
+            : 0;
         $showDuplicateButton = false;
         if ($this->firstEl['cmd'] !== 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
-            // Special case: pages
-            if ($this->firstEl['table'] === 'pages') {
-                // show button only, if record is in default language
-                $showDuplicateButton = (int)$sysLanguageUid === 0;
+            if ($sysLanguageUid === 0) {
+                // show button, if record is in default language
+                $showDuplicateButton = true;
             } else {
-                // not pages table
-                if ((int)$sysLanguageUid === 0) {
-                    // show button, if record is in default language
-                    $showDuplicateButton = true;
-                } else {
-                    // show button, if record is NOT in default language AND has no parent
-                    $showDuplicateButton = (int)$l18nParent === 0;
-                }
+                // show button, if record is NOT in default language AND has no parent
+                $showDuplicateButton = $l18nParent === 0;
             }
         }
         if ($showDuplicateButton) {