From 0805c914f6b51874e04f938471af5e5cabc50de0 Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Mon, 16 Aug 2021 13:34:59 +0200
Subject: [PATCH] [BUGFIX] Do not show language switch in edit multiple

FormEngine allows to edit multiple records at once.
This view can e.g. be accessed using the recordlists'
"Edit marked" button.

Since the "language switcher" only affects the first
displayed record, it is now not longer rendered, when
in "edit multiple" view.

To improve readability of the code, all those places
now use the same "speaking" method.

Resolves: #94900
Releases: master
Change-Id: Iae0ccd69616324fed915dbc0bb781c4edc95971b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70618
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../Controller/EditDocumentController.php     | 21 ++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
index 2b14d5e6bd19..12eb32fc6091 100644
--- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
+++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
@@ -1031,8 +1031,8 @@ class EditDocumentController
         $this->resolveMetaInformation();
         $this->getButtons($request);
 
-        // Create language switch options if the record is already persisted
-        if ($this->isSavedRecord) {
+        // Create language switch options if the record is already persisted and it is a single record to edit
+        if ($this->isSavedRecord && $this->isSingleRecordView()) {
             $this->languageSwitch(
                 (string)($this->firstEl['table'] ?? ''),
                 (int)($this->firstEl['uid'] ?? 0),
@@ -1633,7 +1633,7 @@ class EditDocumentController
             && !$this->getDisableDelete()
             && !$this->isRecordCurrentBackendUser()
             && $this->isSavedRecord
-            && count($this->elementsData) === 1
+            && $this->isSingleRecordView()
         ) {
             $classNames = 't3js-editform-delete-record';
             $returnUrl = $this->retUrl;
@@ -1711,7 +1711,7 @@ class EditDocumentController
     protected function registerHistoryButtonToButtonBar(ButtonBar $buttonBar, string $position, int $group)
     {
         if (
-            count($this->elementsData) === 1
+            $this->isSingleRecordView()
             && !empty($this->firstEl['table'])
             && $this->getTsConfigOption($this->firstEl['table'], 'showHistory')
         ) {
@@ -1739,7 +1739,7 @@ class EditDocumentController
     {
         if (
             $this->columnsOnly
-            && count($this->elementsData) === 1
+            && $this->isSingleRecordView()
         ) {
             $columnsOnlyButton = $buttonBar->makeLinkButton()
                 ->setHref($this->R_URI . '&columnsOnly=')
@@ -2577,6 +2577,17 @@ class EditDocumentController
         return '';
     }
 
+    /**
+     * Whether a single record view is requested. This
+     * means, only one element exists in $elementsData.
+     *
+     * @return bool
+     */
+    protected function isSingleRecordView(): bool
+    {
+        return count($this->elementsData) === 1;
+    }
+
     /**
      * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
      */
-- 
GitLab