From: Alexander Ebert Date: Fri, 22 Jul 2016 10:03:05 +0000 (+0200) Subject: Fixed page locations to include all parents X-Git-Tag: 3.0.0_Beta_1~1003 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eb5dcb1d751c32a18c80848d0d4484fb645a6875;p=GitHub%2FWoltLab%2FWCF.git Fixed page locations to include all parents --- diff --git a/wcfsetup/install/files/lib/system/breadcrumb/Breadcrumbs.class.php b/wcfsetup/install/files/lib/system/breadcrumb/Breadcrumbs.class.php index 6b53b27b23..5cd27c98f4 100644 --- a/wcfsetup/install/files/lib/system/breadcrumb/Breadcrumbs.class.php +++ b/wcfsetup/install/files/lib/system/breadcrumb/Breadcrumbs.class.php @@ -87,28 +87,6 @@ class Breadcrumbs extends SingletonFactory implements \Countable, \Iterator { // by all relevant ancestors, but breadcrumbs appear in the reverse order $locations = array_reverse($locations); - // use the top-most location to find the path up to the very top of - // the page order - if (!empty($locations)) { - $location = $locations[0]; - - if ($location['pageID']) { - $page = PageCache::getInstance()->getPage($location['pageID']); - while ($page !== null && $page->parentPageID) { - $page = PageCache::getInstance()->getPage($page->parentPageID); - - array_unshift($locations, [ - 'identifier' => $page->identifier, - 'link' => $page->getLink(), - 'pageID' => $page->pageID, - 'pageObjectID' => 0, - 'title' => $page->getTitle(), - 'useAsParentLocation' => false - ]); - } - } - } - // add the landing page as first location, unless it is already included $landingPage = PageCache::getInstance()->getLandingPage(); $addLandingPage = true; diff --git a/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php b/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php index 0790f15309..ee0ed7e69e 100644 --- a/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php +++ b/wcfsetup/install/files/lib/system/page/PageLocationManager.class.php @@ -16,6 +16,12 @@ use wcf\system\SingletonFactory; * @since 3.0 */ class PageLocationManager extends SingletonFactory { + /** + * true if all parents of the highest page have been added + * @var boolean + */ + protected $addedParentLocations = false; + /** * list of locations with descending priority * @var array @@ -108,6 +114,37 @@ class PageLocationManager extends SingletonFactory { * @return array */ public function getLocations() { + if (!$this->addedParentLocations) { + $this->addParents(); + + $this->addedParentLocations = true; + } + return $this->stack; } + + /** + * Adds all parents as defined through the page configuration. + */ + protected function addParents() { + if (!empty($this->stack)) { + $location = end($this->stack); + + if ($location['pageID']) { + $page = PageCache::getInstance()->getPage($location['pageID']); + while ($page !== null && $page->parentPageID) { + $page = PageCache::getInstance()->getPage($page->parentPageID); + + $this->stack[] = [ + 'identifier' => $page->identifier, + 'link' => $page->getLink(), + 'pageID' => $page->pageID, + 'pageObjectID' => 0, + 'title' => $page->getTitle(), + 'useAsParentLocation' => false + ]; + } + } + } + } }