[BUGFIX] Use pageTree.backgroundColor recursively 89/56489/10
authorGuido Schmechel <littlegee@web.de>
Fri, 30 Mar 2018 15:43:29 +0000 (17:43 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 11 May 2018 13:01:40 +0000 (15:01 +0200)
When a page is listed in the pageTree, the option
pageTree.backgroundColor is recursively checked and all
subpages get the backgroundColor.

Now with subpages as a mount, the backgroundColor of the
parent page is adopted.

Resolves: #81987
Releases: master, 8.7
Change-Id: I29d444da96d9d2038a4940896fd848bf42e43f47
Reviewed-on: https://review.typo3.org/56489
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: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Controller/Page/TreeController.php

index d9a8804..397c14c 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Workspaces\Service\WorkspaceService;
 
 /**
@@ -324,6 +325,8 @@ class TreeController
     {
         $backendUser = $this->getBackendUser();
         $repository = GeneralUtility::makeInstance(PageTreeRepository::class, (int)$backendUser->workspace);
+        $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
+
         $entryPoints = (int)($backendUser->uc['pageTree_temporaryMountPoint'] ?? 0);
         if ($entryPoints > 0) {
             $entryPoints = [$entryPoints];
@@ -340,11 +343,23 @@ class TreeController
         if (empty($entryPoints)) {
             return [];
         }
+
         foreach ($entryPoints as $k => &$entryPoint) {
             if (in_array($entryPoint, $this->hiddenRecords, true)) {
                 unset($entryPoints[$k]);
                 continue;
             }
+
+            if (!empty($this->backgroundColors) && is_array($this->backgroundColors)) {
+                $entryPointRootLine = $pageRepository->getRootLine($entryPoint);
+                foreach ($entryPointRootLine as $rootLineEntry) {
+                    $parentUid = $rootLineEntry['uid'];
+                    if ($this->backgroundColors[$parentUid] !== null && $this->backgroundColors[$entryPoint] === null) {
+                        $this->backgroundColors[$entryPoint] = $this->backgroundColors[$parentUid];
+                    }
+                }
+            }
+
             $entryPoint = $repository->getTree($entryPoint, function ($page) use ($backendUser) {
                 // check each page if the user has permission to access it
                 return $backendUser->doesUserHaveAccess($page, Permission::PAGE_SHOW);