[BUGFIX] Only show search on non-empty pages 90/45090/4
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 2 Dec 2015 14:45:58 +0000 (15:45 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 3 Dec 2015 23:23:57 +0000 (00:23 +0100)
If a page has neither content nor subpages, do not show the search button
in the backend.

Resolves: #72027
Releases: master
Change-Id: Iff2657a203f25123c288ea48e6fc553483bdd254
Reviewed-on: https://review.typo3.org/45090
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/recordlist/Classes/RecordList.php

index e59c265..003f75c 100755 (executable)
@@ -997,7 +997,7 @@ class PageLayoutController
             $content .= $output;
         }
         // Making search form:
-        if (!$this->modTSconfig['properties']['disableSearchBox'] && !empty($tableOutput)) {
+        if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dbList->counter > 0 || $this->currentPageHasSubPages())) {
             $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
             $toggleSearchFormButton = $this->buttonBar->makeLinkButton()
                 ->setClasses('t3js-toggle-search-toolbox')
@@ -1529,4 +1529,23 @@ class PageLayoutController
             $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($languageMenu);
         }
     }
+
+    /**
+     * Checks whether the current page has sub pages
+     *
+     * @return bool
+     */
+    protected function currentPageHasSubPages()
+    {
+        $count = $this->getDatabaseConnection()->exec_SELECTcountRows(
+            'uid',
+            'pages',
+            'pid = ' . (int)$this->id
+                . BackendUtility::deleteClause('pages')
+                . BackendUtility::versioningPlaceholderClause('pages')
+                . BackendUtility::getWorkspaceWhereClause('pages')
+        );
+
+        return $count > 0;
+    }
 }
index 84b99f8..384e28c 100644 (file)
@@ -563,14 +563,16 @@ class RecordList extends AbstractModule
         if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) {
             $this->content = $dblist->getSearchBox();
             $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
+
+            $searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton();
+            $searchButton
+                ->setHref('#')
+                ->setClasses('t3js-toggle-search-toolbox')
+                ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon'))
+                ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL));
+            $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton,
+                ButtonBar::BUTTON_POSITION_LEFT, 90);
         }
-        $searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton();
-        $searchButton
-            ->setHref('#')
-            ->setClasses('t3js-toggle-search-toolbox')
-            ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon'))
-            ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL));
-        $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton, ButtonBar::BUTTON_POSITION_LEFT, 90);
 
         if ($this->pageinfo) {
             $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);