Fixes link bugs within application groups
authorMatthias Schmidt <gravatronics@live.com>
Sat, 14 Jul 2012 19:47:38 +0000 (21:47 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 14 Jul 2012 19:47:38 +0000 (21:47 +0200)
* 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.

wcfsetup/install/files/lib/data/page/menu/item/PageMenuItem.class.php
wcfsetup/install/files/lib/system/request/LinkHandler.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php
wcfsetup/install/files/lib/system/request/RouteHandler.class.php

index ffedc4ddf705c9b5ad56498c7cc91324e8baa259..da0cfff9bca9502a5e8b635e9e2fd7b41638142a 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\page\menu\item;
 use wcf\data\ProcessibleDatabaseObject;
+use wcf\system\application\ApplicationHandler;
 use wcf\system\menu\page\DefaultPageMenuItemProvider;
 use wcf\system\menu\ITreeMenuItem;
 use wcf\system\request\LinkHandler;
@@ -46,6 +47,13 @@ class PageMenuItem extends ProcessibleDatabaseObject implements ITreeMenuItem {
         * @see wcf\system\menu\ITreeMenuItem::getLink()
         */
        public function getLink() {
-               return LinkHandler::getInstance()->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);
        }
 }
index 6b21e65611cbfdf03da30326e95e5208aa389ba0..e42438d6ae22e279030e567727d8eb16cdc7faf5 100644 (file)
@@ -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
index a3628aed31adab1d92265b1202f15a3da43ebc45..15f4e19e03b7d87d9bf32fa704c06d31fe4a3b10 100644 (file)
@@ -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;
+       }
 }
index bf06ab0707bd7597cc1c2fc155322d629762137e..a2b09acf4ba05fb5d8414370494e9bcfad12646d 100644 (file)
@@ -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<wcf\system\request\Route>
@@ -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;
                        }