From: Matthias Schmidt Date: Sat, 14 Jul 2012 19:47:38 +0000 (+0200) Subject: Fixes link bugs within application groups X-Git-Tag: 2.0.0_Beta_1~987^2~5^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3f9b6a9540dbf21288f70ddfad0dbcfe42797775;p=GitHub%2FWoltLab%2FWCF.git Fixes link bugs within application groups * LinkHandler doesn't consider if the request is an acp request. * The link of page menu item that belongs to an application has to be build with an association to the application. --- diff --git a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItem.class.php b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItem.class.php index ffedc4ddf7..da0cfff9bc 100644 --- a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItem.class.php +++ b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItem.class.php @@ -1,6 +1,7 @@ getLink(null, array(), $this->menuItemLink); + $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($this->packageID); + + $parameters = array(); + if ($abbreviation) { + $parameters['application'] = $abbreviation; + } + + return LinkHandler::getInstance()->getLink(null, $parameters, $this->menuItemLink); } } diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index 6b21e65611..e42438d6ae 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -88,7 +88,7 @@ class LinkHandler extends SingletonFactory { $application = ApplicationHandler::getInstance()->getPrimaryApplication(); } - $url = $application->domainName . $application->domainPath . $url; + $url = $application->domainName.$application->domainPath.(RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '').$url; } // append previously removed anchor diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index a3628aed31..15f4e19e03 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -22,18 +22,27 @@ class RequestHandler extends SingletonFactory { protected $activeRequest = null; /** - * Handles a http request + * indicates if the request is an acp request + * @var boolean + */ + protected $isACPRequest = false; + + /** + * Handles a http request. * * @param string $application - * @param boolean $isACP + * @param boolean $isACPRequest */ - public function handle($application = 'wcf', $isACP = false) { - if (!RouteHandler::getInstance()->matches($isACP)) { + public function handle($application = 'wcf', $isACPRequest = false) { + $this->isACPRequest = $isACPRequest; + + if (!RouteHandler::getInstance()->matches()) { throw new SystemException("Cannot handle request, no valid route provided."); } // build request - $this->buildRequest($application, $isACP); + $this->buildRequest($application); + // start request $this->activeRequest->execute(); } @@ -42,9 +51,8 @@ class RequestHandler extends SingletonFactory { * Builds a new request. * * @param string $application - * @param boolean $isACP */ - protected function buildRequest($application, $isACP) { + protected function buildRequest($application) { try { $routeData = RouteHandler::getInstance()->getRouteData(); $controller = $routeData['controller']; @@ -55,9 +63,9 @@ class RequestHandler extends SingletonFactory { } // find class - $classData = $this->getClassData($controller, 'page', $application, $isACP); - if ($classData === null) $classData = $this->getClassData($controller, 'form', $application, $isACP); - if ($classData === null) $classData = $this->getClassData($controller, 'action', $application, $isACP); + $classData = $this->getClassData($controller, 'page', $application); + if ($classData === null) $classData = $this->getClassData($controller, 'form', $application); + if ($classData === null) $classData = $this->getClassData($controller, 'action', $application); if ($classData === null) { throw new SystemException("unable to find class for controller '".$controller."'"); @@ -73,10 +81,19 @@ class RequestHandler extends SingletonFactory { } } - protected function getClassData($controller, $pageType, $application, $isACP) { - $className = $application.'\\'.($isACP ? 'acp\\' : '').$pageType.'\\'.ucfirst($controller).ucfirst($pageType); + /** + * Returns the class data for the active request or null if for the given + * configuration no proper class exist. + * + * @param string $controller + * @param string $pageType + * @param string $application + * @return array + */ + protected function getClassData($controller, $pageType, $application) { + $className = $application.'\\'.($this->isACPRequest() ? 'acp\\' : '').$pageType.'\\'.ucfirst($controller).ucfirst($pageType); if ($application != 'wcf' && !class_exists($className)) { - $className = 'wcf\\'.($isACP ? 'acp\\' : '').$pageType.'\\'.ucfirst($controller).ucfirst($pageType); + $className = 'wcf\\'.($this->isACPRequest() ? 'acp\\' : '').$pageType.'\\'.ucfirst($controller).ucfirst($pageType); } if (!class_exists($className)) { return null; @@ -103,4 +120,13 @@ class RequestHandler extends SingletonFactory { public function getActiveRequest() { return $this->activeRequest; } + + /** + * Returns true if the request is an acp request. + * + * @return boolean + */ + public function isACPRequest() { + return $this->isACPRequest; + } } diff --git a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php index bf06ab0707..a2b09acf4b 100644 --- a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php @@ -31,12 +31,6 @@ class RouteHandler extends SingletonFactory { */ protected static $path = ''; - /** - * router filter for ACP - * @var boolean - */ - protected $isACP = false; - /** * list of available routes * @var array @@ -90,16 +84,13 @@ class RouteHandler extends SingletonFactory { * first route which is able to consume all path components is used, * even if other routes may fit better. Route order is crucial! * - * @param boolean $isACP * @return boolean */ - public function matches($isACP) { - $this->isACP = $isACP; - + public function matches() { $pathInfo = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : ''; foreach ($this->routes as $route) { - if ($this->isACP != $route->isACP()) { + if (RequestHandler::getInstance()->isACPRequest() != $route->isACP()) { continue; } @@ -141,7 +132,7 @@ class RouteHandler extends SingletonFactory { */ public function buildRoute(array $components) { foreach ($this->routes as $route) { - if ($this->isACP != $route->isACP()) { + if (RequestHandler::getInstance()->isACPRequest() != $route->isACP()) { continue; }