From: Alexander Ebert Date: Mon, 31 Dec 2012 01:38:05 +0000 (+0100) Subject: Build link to landing page if controller = null X-Git-Tag: 2.0.0_Beta_1~635 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9c720493b4b309bd7a7b14ac36179b0f3252dc58;p=GitHub%2FWoltLab%2FWCF.git Build link to landing page if controller = null --- diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index 92aa513ff0..fe2a6539ff 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -1,5 +1,7 @@ getDecoratedObject() instanceof \wcf\system\request\IRouteController) { - $parameters['object'] = $parameters['object']->getDecoratedObject(); - } - - if ($parameters['object'] instanceof \wcf\system\request\IRouteController) { - $parameters['id'] = $parameters['object']->getID(); - $parameters['title'] = $parameters['object']->getTitle(); - } - - unset($parameters['object']); + if ($controller === null) { + // build link to landing page + $landingPage = PageMenu::getInstance()->getLandingPage(); + $controller = $landingPage->getController(); + $abbreviation = $landingPage->getApplication(); + $url = $landingPage->menuItemLink; + } + + // handle object + if (isset($parameters['object'])) { + if (!($parameters['object'] instanceof \wcf\system\request\IRouteController) && $parameters['object'] instanceof \wcf\data\DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof \wcf\system\request\IRouteController) { + $parameters['object'] = $parameters['object']->getDecoratedObject(); } - if (isset($parameters['title'])) { - // remove illegal characters - $parameters['title'] = trim(preg_replace('/[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/', '-', $parameters['title']), '-'); + if ($parameters['object'] instanceof \wcf\system\request\IRouteController) { + $parameters['id'] = $parameters['object']->getID(); + $parameters['title'] = $parameters['object']->getTitle(); } - $parameters['controller'] = $controller; - $routeURL = RouteHandler::getInstance()->buildRoute($parameters); - if (!$isRaw && !empty($url)) { - $routeURL .= (strpos($routeURL, '?') === false) ? '?' : '&'; - } - $url = $routeURL . $url; + unset($parameters['object']); + } + + if (isset($parameters['title'])) { + // remove illegal characters + $parameters['title'] = trim(preg_replace('/[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/', '-', $parameters['title']), '-'); + } + + $parameters['controller'] = $controller; + $routeURL = RouteHandler::getInstance()->buildRoute($parameters); + if (!$isRaw && !empty($url)) { + $routeURL .= (strpos($routeURL, '?') === false) ? '?' : '&'; } + $url = $routeURL . $url; // append session id if ($appendSession) {