<?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;
* @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);
}
}
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();
}
* 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'];
}
// 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."'");
}
}
- 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;
public function getActiveRequest() {
return $this->activeRequest;
}
+
+ /**
+ * Returns true if the request is an acp request.
+ *
+ * @return boolean
+ */
+ public function isACPRequest() {
+ return $this->isACPRequest;
+ }
}
*/
protected static $path = '';
- /**
- * router filter for ACP
- * @var boolean
- */
- protected $isACP = false;
-
/**
* list of available routes
* @var array<wcf\system\request\Route>
* 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;
}
*/
public function buildRoute(array $components) {
foreach ($this->routes as $route) {
- if ($this->isACP != $route->isACP()) {
+ if (RequestHandler::getInstance()->isACPRequest() != $route->isACP()) {
continue;
}