Fixed menu item handling for landing page
authorAlexander Ebert <ebert@woltlab.com>
Wed, 2 Jan 2013 01:26:21 +0000 (02:26 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 2 Jan 2013 01:26:21 +0000 (02:26 +0100)
Fixes #1066

wcfsetup/install/files/lib/system/breadcrumb/Breadcrumbs.class.php
wcfsetup/install/files/lib/system/menu/page/PageMenu.class.php

index c08ea140d92e1d164c3857dc80de18070dee4e0b..275a418586d14384c6af50b72f2dc20777b79c74 100644 (file)
@@ -30,14 +30,8 @@ class Breadcrumbs extends SingletonFactory implements \Countable, \Iterator {
         * @see wcf\system\SingletonFactory::init()
         */
        protected function init() {
-               // set default menu item
-               $landingPage = PageMenu::getInstance()->getLandingPage();
-               if ($landingPage !== null) {
-                       PageMenu::getInstance()->setActiveMenuItem($landingPage->menuItem);
-                               
-                       // add main breadcrumbs entry
-                       $this->add(new Breadcrumb(WCF::getLanguage()->get(PAGE_TITLE), $landingPage->getLink()));
-               }
+               // add main breadcrumbs entry
+               $this->add(new Breadcrumb(WCF::getLanguage()->get(PAGE_TITLE), PageMenu::getInstance()->getLandingPage()->getLink()));
        }
        
        /**
index e6b75edcf4704824bb04aab7bd99e9e40a6f497e..5f8a9aad0e4775d20cdcff0878c158fde6f664b3 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system\menu\page;
 use wcf\system\breadcrumb\Breadcrumb;
 use wcf\system\cache\CacheHandler;
 use wcf\system\event\EventHandler;
+use wcf\system\exception\SystemException;
 use wcf\system\menu\ITreeMenuItem;
 use wcf\system\menu\TreeMenu;
 use wcf\system\WCF;
@@ -11,7 +12,7 @@ use wcf\system\WCF;
  * Builds the page menu.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.menu.page
@@ -50,6 +51,12 @@ class PageMenu extends TreeMenu {
                                }
                        }
                }
+               
+               if ($this->landingPage === null) {
+                       throw new SystemException("Missing landing page");
+               }
+               
+               $this->setActiveMenuItem($this->landingPage->menuItem);
        }
        
        /**