From e2f01f06da8de5ba036cdaadf177b778565d69cc Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 6 Jul 2015 14:41:35 +0200 Subject: [PATCH] Improved handling of default controllers --- .../system/request/FlexibleRoute.class.php | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/lib/system/request/FlexibleRoute.class.php b/wcfsetup/install/files/lib/system/request/FlexibleRoute.class.php index 02766ad230..dc63699259 100644 --- a/wcfsetup/install/files/lib/system/request/FlexibleRoute.class.php +++ b/wcfsetup/install/files/lib/system/request/FlexibleRoute.class.php @@ -41,6 +41,12 @@ class FlexibleRoute implements IRoute { */ protected $pattern = ''; + /** + * primary application's abbreviation (e.g. "wbb") + * @var string + */ + protected $primaryApplication = ''; + /** * list of required components * @var array @@ -140,22 +146,28 @@ class FlexibleRoute implements IRoute { if (!RequestHandler::getInstance()->isACPRequest()) { $landingPage = PageMenu::getInstance()->getLandingPage(); - if ($landingPage !== null && strcasecmp($landingPage->getController(), $components['controller']) == 0) { - $ignoreController = true; + if ($this->primaryApplication === '') { + $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); + $this->primaryApplication = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); } - // check if this is the default controller of the requested application - if (!$ignoreController && $application !== null) { - if (RouteHandler::getInstance()->getDefaultController($application) == $components['controller']) { - // check if this is the primary application and the landing page originates to the same application - $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication(); - $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID); - if ($abbreviation == $application) { - if ($landingPage === null || $landingPage->getController() === $components['controller']) { - $ignoreController = true; - } + // check if this is the default controller + if (strcasecmp(RouteHandler::getInstance()->getDefaultController($application), $components['controller']) === 0) { + // check if this matches the primary application + if ($this->primaryApplication === $application) { + if (strcasecmp($landingPage->getController(), $components['controller']) === 0) { + // skip controller if it matches the default controller + $ignoreController = true; } } + else { + // skip default controller + $ignoreController = true; + } + } + else if (strcasecmp($landingPage->getController(), $components['controller']) === 0) { + // landing page + $ignoreController = true; } } -- 2.20.1