From d4cbdc61faf53eb5dfa5c78f70fc150a10d91717 Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Mon, 14 Dec 2020 22:10:17 +0100
Subject: [PATCH] [!!!][TASK] Remove unneeded configurations in PageLayoutView

The following tsconfig configurations have been removed in favor of
strong defaults and less configuration options:

- `mod.web_layout.disableIconToolbar`
- `mod.web_layout.disableSearchBox`

Resolves: #93077
Releases: master
Change-Id: I01da28e2b3fbc12693c00cb012c3749b4fa4b0c7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67117
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../Controller/PageLayoutController.php       | 124 +++++++++---------
 ...UnneededConfigurationsInPageLayoutView.rst |  36 +++++
 2 files changed, 96 insertions(+), 64 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-93077-RemovedUnneededConfigurationsInPageLayoutView.rst

diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
index de3231ff706f..ba560d93af88 100644
--- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
+++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
@@ -693,17 +693,15 @@ class PageLayoutController
         }
         $content .= $tableOutput;
         // Making search form:
-        if (!$this->modTSconfig['properties']['disableSearchBox']) {
-            $this->searchContent = $this->getSearchBox();
-            if ($this->searchContent) {
-                $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
-                $toggleSearchFormButton = $this->buttonBar->makeLinkButton()
-                    ->setClasses('t3js-toggle-search-toolbox')
-                    ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon'))
-                    ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL))
-                    ->setHref('#');
-                $this->buttonBar->addButton($toggleSearchFormButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
-            }
+        $this->searchContent = $this->getSearchBox();
+        if ($this->searchContent) {
+            $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
+            $toggleSearchFormButton = $this->buttonBar->makeLinkButton()
+                ->setClasses('t3js-toggle-search-toolbox')
+                ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon'))
+                ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL))
+                ->setHref('#');
+            $this->buttonBar->addButton($toggleSearchFormButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
         }
         // Additional footer content
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'] ?? [] as $hook) {
@@ -788,70 +786,68 @@ class PageLayoutController
             ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
         $this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
 
-        if (empty($this->modTSconfig['properties']['disableIconToolbar'])) {
-            // Edit page properties and page language overlay icons
-            if ($this->isPageEditable(0)) {
-                /** @var \TYPO3\CMS\Core\Http\NormalizedParams */
-                $normalizedParams = $request->getAttribute('normalizedParams');
-                // Edit localized pages only when one specific language is selected
-                if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
-                    $localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
-                    $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
-                    $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-                        ->getQueryBuilderForTable('pages');
-                    $queryBuilder->getRestrictions()
-                        ->removeAll()
-                        ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
-                        ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$this->getBackendUser()->workspace));
-                    $overlayRecord = $queryBuilder
-                        ->select('uid')
-                        ->from('pages')
-                        ->where(
-                            $queryBuilder->expr()->eq(
-                                $localizationParentField,
-                                $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
-                            ),
-                            $queryBuilder->expr()->eq(
-                                $languageField,
-                                $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
-                            )
+        // Edit page properties and page language overlay icons
+        if ($this->isPageEditable(0)) {
+            /** @var \TYPO3\CMS\Core\Http\NormalizedParams */
+            $normalizedParams = $request->getAttribute('normalizedParams');
+            // Edit localized pages only when one specific language is selected
+            if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
+                $localizationParentField = $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'];
+                $languageField = $GLOBALS['TCA']['pages']['ctrl']['languageField'];
+                $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+                    ->getQueryBuilderForTable('pages');
+                $queryBuilder->getRestrictions()
+                    ->removeAll()
+                    ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
+                    ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, (int)$this->getBackendUser()->workspace));
+                $overlayRecord = $queryBuilder
+                    ->select('uid')
+                    ->from('pages')
+                    ->where(
+                        $queryBuilder->expr()->eq(
+                            $localizationParentField,
+                            $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
+                        ),
+                        $queryBuilder->expr()->eq(
+                            $languageField,
+                            $queryBuilder->createNamedParameter($this->current_sys_language, \PDO::PARAM_INT)
                         )
-                        ->setMaxResults(1)
-                        ->execute()
-                        ->fetch();
-                    BackendUtility::workspaceOL('pages', $overlayRecord, (int)$this->getBackendUser()->workspace);
-                    // Edit button
-                    $urlParameters = [
-                        'edit' => [
-                            'pages' => [
-                                $overlayRecord['uid'] => 'edit'
-                            ]
-                        ],
-                        'returnUrl' => $normalizedParams->getRequestUri(),
-                    ];
-
-                    $url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
-                    $editLanguageButton = $this->buttonBar->makeLinkButton()
-                        ->setHref($url)
-                        ->setTitle($lang->getLL('editPageLanguageOverlayProperties'))
-                        ->setIcon($this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL));
-                    $this->buttonBar->addButton($editLanguageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
-                }
+                    )
+                    ->setMaxResults(1)
+                    ->execute()
+                    ->fetch();
+                BackendUtility::workspaceOL('pages', $overlayRecord, (int)$this->getBackendUser()->workspace);
+                // Edit button
                 $urlParameters = [
                     'edit' => [
                         'pages' => [
-                            $this->id => 'edit'
+                            $overlayRecord['uid'] => 'edit'
                         ]
                     ],
                     'returnUrl' => $normalizedParams->getRequestUri(),
                 ];
+
                 $url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
-                $editPageButton = $this->buttonBar->makeLinkButton()
+                $editLanguageButton = $this->buttonBar->makeLinkButton()
                     ->setHref($url)
-                    ->setTitle($lang->getLL('editPageProperties'))
-                    ->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
-                $this->buttonBar->addButton($editPageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
+                    ->setTitle($lang->getLL('editPageLanguageOverlayProperties'))
+                    ->setIcon($this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL));
+                $this->buttonBar->addButton($editLanguageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
             }
+            $urlParameters = [
+                'edit' => [
+                    'pages' => [
+                        $this->id => 'edit'
+                    ]
+                ],
+                'returnUrl' => $normalizedParams->getRequestUri(),
+            ];
+            $url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
+            $editPageButton = $this->buttonBar->makeLinkButton()
+                ->setHref($url)
+                ->setTitle($lang->getLL('editPageProperties'))
+                ->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
+            $this->buttonBar->addButton($editPageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
         }
     }
 
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-93077-RemovedUnneededConfigurationsInPageLayoutView.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-93077-RemovedUnneededConfigurationsInPageLayoutView.rst
new file mode 100644
index 000000000000..d917a7b070b2
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-93077-RemovedUnneededConfigurationsInPageLayoutView.rst
@@ -0,0 +1,36 @@
+.. include:: ../../Includes.txt
+
+====================================================================
+Breaking: #93077 - Removed unneeded configurations in PageLayoutView
+====================================================================
+
+See :issue:`93077`
+
+Description
+===========
+
+The following TSconfig settings have been removed in favor of strong defaults and less configuration:
+
+- :ts:`mod.web_layout.disableIconToolbar`
+- :ts:`mod.web_layout.disableSearchBox`
+
+
+Impact
+======
+
+The settings :ts:`mod.web_layout.disableIconToolbar` and :ts:`mod.web_layout.disableSearchBox` are
+not evaluated anymore and the edit button and the searchbox are always shown in the page module.
+
+
+Affected Installations
+======================
+
+TYPO3 installations using the settings :ts:`mod.web_layout.disableIconToolbar` or :ts:`mod.web_layout.disableSearchBox`.
+
+
+Migration
+=========
+
+There is no migration possible.
+
+.. index:: Backend, TSConfig, NotScanned, ext:backend
-- 
GitLab