From: Alexander Ebert Date: Mon, 23 Feb 2015 10:32:55 +0000 (+0100) Subject: Fixed controller names if Route is used w/o compatibility mode X-Git-Tag: 2.1.0~58 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7ae23863b55d955f3cb5c332d233fe6d0be29550;p=GitHub%2FWoltLab%2FWCF.git Fixed controller names if Route is used w/o compatibility mode --- diff --git a/wcfsetup/install/files/lib/system/request/Route.class.php b/wcfsetup/install/files/lib/system/request/Route.class.php index dea54b6734..ee75593a58 100644 --- a/wcfsetup/install/files/lib/system/request/Route.class.php +++ b/wcfsetup/install/files/lib/system/request/Route.class.php @@ -55,6 +55,12 @@ class Route implements IRoute { */ protected $routeData = null; + /** + * cached list of transformed controller names + * @var array + */ + protected static $controllerNames = array(); + /** * list of application abbreviation and default controller name * @var array @@ -301,6 +307,11 @@ class Route implements IRoute { continue; } + // handle controller names + if (!URL_LEGACY_MODE && $component === 'controller') { + $components[$component] = $this->getControllerName($application, $components[$component]); + } + // handle built-in SEO if ($component === 'id' && isset($components['title'])) { $link .= $components[$component] . '-' . $components['title'] . '/'; @@ -340,6 +351,24 @@ class Route implements IRoute { return $this->isACP; } + /** + * Returns the transformed controller name. + * + * @param string $application + * @param string $controller + * @return string + */ + protected function getControllerName($application, $controller) { + if (!isset(self::$controllerNames[$controller])) { + $controllerName = RequestHandler::getTokenizedController($controller); + $alias = (!$this->isACP) ? RequestHandler::getInstance()->getAliasByController($controllerName) : null; + + self::$controllerNames[$controller] = ($alias) ?: $controllerName; + } + + return self::$controllerNames[$controller]; + } + /** * Loads the default controllers for each active application. */