From: Alexander Ebert Date: Fri, 11 Nov 2011 21:20:14 +0000 (+0100) Subject: Enabled basic SEO-like support X-Git-Tag: 2.0.0_Beta_1~1601^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=97b6b000ac329ec5a70a5b95e38e2541d3275107;p=GitHub%2FWoltLab%2FWCF.git Enabled basic SEO-like support --- diff --git a/wcfsetup/install/files/lib/system/request/IRouteController.class.php b/wcfsetup/install/files/lib/system/request/IRouteController.class.php new file mode 100644 index 0000000000..9014e19213 --- /dev/null +++ b/wcfsetup/install/files/lib/system/request/IRouteController.class.php @@ -0,0 +1,28 @@ + + * @package com.woltlab.wcf + * @subpackage system.request + * @category Community Framework + */ +interface IRouteController { + /** + * Returns the object id. + * + * @return integer + */ + public function getID(); + + /** + * Returns the object title. + * + * @return string + */ + public function getTitle(); +} diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index 9ab4ae5299..6841c8c7ab 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -37,6 +37,16 @@ class LinkHandler extends SingletonFactory { // build route if ($controller !== null) { + // handle object + if (isset($parameters['object']) && $parameters['object'] instanceof \wcf\system\request\IRouteController) { + $parameters['id'] = $parameters['object']->getID(); + + // remove illegal characters + $parameters['title'] = preg_replace('/[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/', '-', $parameters['object']->getTitle()); + + unset($parameters['object']); + } + $parameters['controller'] = $controller; $routeURL = RouteHandler::getInstance()->buildRoute($parameters); if (!$isRaw && !empty($url)) { diff --git a/wcfsetup/install/files/lib/system/request/Route.class.php b/wcfsetup/install/files/lib/system/request/Route.class.php index 039f378c74..6159aeda79 100644 --- a/wcfsetup/install/files/lib/system/request/Route.class.php +++ b/wcfsetup/install/files/lib/system/request/Route.class.php @@ -242,7 +242,14 @@ class Route { continue; } - $link .= $components[$component] . '/'; + // handle built-in SEO + if ($component === 'id' && isset($components['title'])) { + $link .= $components[$component] . '-' . $components['title'] . '/'; + unset($components['title']); + } + else { + $link .= $components[$component] . '/'; + } unset($components[$component]); } }