*/
protected function getControllerName($application, $controller) {
if (!isset(self::$controllerNames[$controller])) {
- $parts = preg_split('~([A-Z][a-z0-9]+)~', $controller, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $controllerName = '';
- for ($i = 0, $length = count($parts); $i < $length; $i++) {
- if (!empty($controllerName)) $controllerName .= '-';
- $controllerName .= strtolower($parts[$i]);
- }
-
+ $controllerName = RequestHandler::getTokenizedController($controller);
$alias = (!$this->isACP) ? RequestHandler::getInstance()->getAliasByController($controllerName) : null;
self::$controllerNames[$controller] = ($alias) ?: $controllerName;
// check if controller was provided exactly as it should
if (!URL_LEGACY_MODE && !$this->isACPRequest()) {
if (preg_match('~([A-Za-z0-9]+)(?:Action|Form|Page)$~', $classData['className'], $matches)) {
- $parts = preg_split('~([A-Z][a-z0-9]+)~', $matches[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $parts = array_map('strtolower', $parts);
- $realController = implode('-', $parts);
+ $realController = self::getTokenizedController($matches[1]);
if ($controller != $realController) {
$this->redirect($routeData, $application, $matches[1]);
$this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType']);
}
catch (SystemException $e) {
+ die("<pre>".$e->getMessage());
throw new IllegalLinkException();
}
}
}
}
- $redirectURL = LinkHandler::getInstance()->getLink($routeData['controller'], $linkData);
+ $redirectURL = LinkHandler::getInstance()->getLink($routeData['controller'], $routeData);
HeaderUtil::redirect($redirectURL, true);
exit;
}
// check if currently invoked application matches the landing page
if ($landingPageApplication == $application) {
$routeData['controller'] = $landingPage->getController();
+ if (!URL_LEGACY_MODE) $routeData['controller'] = self::getTokenizedController($routeData['controller']);
return;
}
exit;
}
else {
- $routeData['controller'] = preg_replace('~(Action|Form|Page)$~', '', array_pop($controller));
+ $routeData['controller'] = self::getTokenizedController(preg_replace('~(Action|Form|Page)$~', '', array_pop($controller)));
return;
}
}
return null;
}
+
+ /**
+ * Returns the tokenized controller name, e.g. BoardList -> board-list.
+ *
+ * @param string controller
+ * @return string
+ */
+ public static function getTokenizedController($controller) {
+ $parts = preg_split('~([A-Z][a-z0-9]+)~', $controller, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ $parts = array_map('strtolower', $parts);
+
+ return implode('-', $parts);
+ }
}