From 0602bb118206463c167d7c0192caec79ec39344c Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 22 Nov 2011 22:24:08 +0100 Subject: [PATCH] Some small optimizations --- .../install/files/lib/data/user/User.class.php | 17 ++++++++++++++++- .../lib/system/request/LinkHandler.class.php | 17 +++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/User.class.php b/wcfsetup/install/files/lib/data/user/User.class.php index 8af6960931..9e5ea6066b 100644 --- a/wcfsetup/install/files/lib/data/user/User.class.php +++ b/wcfsetup/install/files/lib/data/user/User.class.php @@ -4,6 +4,7 @@ use wcf\data\DatabaseObject; use wcf\data\user\group\UserGroup; use wcf\data\user\UserList; use wcf\system\cache\CacheHandler; +use wcf\system\request\IRouteController; use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; use wcf\util\StringUtil; @@ -18,7 +19,7 @@ use wcf\util\StringUtil; * @subpackage data.user * @category Community Framework */ -final class User extends DatabaseObject { +final class User extends DatabaseObject implements IRouteController { /** * @see wcf\data\DatabaseObject::$databaseTableName */ @@ -336,4 +337,18 @@ final class User extends DatabaseObject { public static function getDatabaseTableAlias() { return 'user_table'; } + + /** + * @see wcf\system\request\IRouteController::getID() + */ + public function getID() { + return $this->userID; + } + + /** + * @see wcf\system\request\IRouteController::getTitle() + */ + public function getTitle() { + return $this->username; + } } diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index 6841c8c7ab..459becdc46 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -38,15 +38,24 @@ 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(); + 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(); + } - // remove illegal characters - $parameters['title'] = preg_replace('/[\x0-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/', '-', $parameters['object']->getTitle()); + if ($parameters['object'] instanceof \wcf\system\request\IRouteController) { + $parameters['id'] = $parameters['object']->getID(); + $parameters['title'] = $parameters['object']->getTitle(); + } 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)) { -- 2.20.1