* @param string $application application identifier
* @param string $controller url controller
* @param boolean $isAcpRequest true if this is an ACP request
+ * @param boolean $skipCustomUrls true if custom url resolution should be suppressed, is always true for ACP requests
* @return mixed array containing className, controller and pageType or a string containing the controller name for aliased controllers
* @throws SystemException
*/
- public function resolve($application, $controller, $isAcpRequest) {
+ public function resolve($application, $controller, $isAcpRequest, $skipCustomUrls = false) {
// validate controller
if (!preg_match('~^[a-z][a-z0-9]+(?:\-[a-z][a-z0-9]+)*$~', $controller)) {
throw new SystemException("Malformed controller name '" . $controller . "'");
if ($classData === null) {
throw new SystemException("Unknown controller '" . $controller . "'");
}
- else if (!$isAcpRequest) {
- // handle controllers with a custom url
- $controller = $classData['controller'];
+ else {
+ // the ACP does not support custom urls at all
+ if ($isAcpRequest) $skipCustomUrls = true;
- if (isset($this->customUrls['reverse'][$application]) && isset($this->customUrls['reverse'][$application][$controller])) {
- return $this->customUrls['reverse'][$application][$controller];
- }
- else if ($application !== 'wcf') {
- if (isset($this->customUrls['reverse']['wcf']) && isset($this->customUrls['reverse']['wcf'][$controller])) {
- return $this->customUrls['reverse']['wcf'][$controller];
+ if (!$skipCustomUrls) {
+ // handle controllers with a custom url
+ $controller = $classData['controller'];
+
+ if (isset($this->customUrls['reverse'][$application]) && isset($this->customUrls['reverse'][$application][$controller])) {
+ return $this->customUrls['reverse'][$application][$controller];
+ }
+ else if ($application !== 'wcf') {
+ if (isset($this->customUrls['reverse']['wcf']) && isset($this->customUrls['reverse']['wcf'][$controller])) {
+ return $this->customUrls['reverse']['wcf'][$controller];
+ }
}
}
}
exit;
}
- $classData = ControllerMap::getInstance()->resolve($application, $controller, $this->isACPRequest());
+ $classData = ControllerMap::getInstance()->resolve($application, $controller, $this->isACPRequest(), RouteHandler::getInstance()->isRenamedController());
if (is_string($classData)) {
$this->redirect($routeData, $application, $classData);
}
}
}
catch (SystemException $e) {
+ if (defined('ENABLE_DEBUG_MODE') && ENABLE_DEBUG_MODE && defined('ENABLE_DEVELOPER_TOOLS') && ENABLE_DEVELOPER_TOOLS) {
+ throw $e;
+ }
+
throw new IllegalLinkException();
}
}
* current path info component
* @var string
*/
- protected static $pathInfo = null;
+ protected static $pathInfo;
/**
* HTTP protocol, either 'http://' or 'https://'
* HTTP encryption
* @var boolean
*/
- protected static $secure = null;
+ protected static $secure;
/**
* list of application abbreviation and default controller name
* @var string[]
*/
- protected $defaultControllers = null;
+ protected $defaultControllers;
/**
- * true, if default controller is used (support for custom landing page)
+ * true if the default controller is used (support for custom landing page)
* @var boolean
*/
protected $isDefaultController = false;
+ /**
+ * true if the controller was renamed and has already been transformed
+ * @var boolean
+ */
+ protected $isRenamedController = false;
+
/**
* list of available routes
* @var IRequestRoute[]
* parsed route data
* @var array
*/
- protected $routeData = null;
+ protected $routeData;
/**
* Sets default routes.
$this->isDefaultController = $this->routeData['isDefaultController'];
unset($this->routeData['isDefaultController']);
+ if (isset($this->routeData['isRenamedController'])) {
+ $this->isRenamedController = $this->routeData['isRenamedController'];
+ unset($this->routeData['isRenamedController']);
+ }
+
$this->registerRouteData();
return true;
}
return $this->isDefaultController;
}
+
+ /**
+ * Returns true if the controller was renamed and has already been transformed.
+ *
+ * @return boolean
+ */
+ public function isRenamedController() {
+ return $this->isRenamedController;
+ }
+
/**
* Returns parsed route data
*
-
(?P<title>[^/]+)
)?
- /
+ /?
)?
$~x';
}
$this->routeData['application'] = $this->staticApplication;
- $this->routeData['controller'] = $controller;
+ $this->routeData['controller'] = ControllerMap::transformController($this->staticController);
$this->routeData['isDefaultController'] = false;
+ $this->routeData['isRenamedController'] = (strcasecmp($controller, $this->staticController) !== 0);
return true;
}