From: Alexander Ebert Date: Mon, 6 Jul 2015 12:41:35 +0000 (+0200) Subject: Improved handling of default controllers X-Git-Tag: 2.1.6~16^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e2f01f06da8de5ba036cdaadf177b778565d69cc;p=GitHub%2FWoltLab%2FWCF.git Improved handling of default controllers --- 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; } }