From 29340381b38610d6d0de9983b993ed7db0898c42 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 18 Sep 2016 13:10:09 +0200 Subject: [PATCH] Add TUserOnlineLocationPageHandler --- .../TUserOnlineLocationPageHandler.class.php | 44 +++++++++++++++++++ .../page/handler/UserPageHandler.class.php | 33 +------------- 2 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php diff --git a/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php new file mode 100644 index 0000000000..6ef6170b04 --- /dev/null +++ b/wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php @@ -0,0 +1,44 @@ + + * @package WoltLabSuite\Core\System\Page\Handler + * @since 3.0 + */ +trait TUserOnlineLocationPageHandler { + use TOnlineLocationPageHandler; + + /** + * @see IOnlineLocationPageHandler::getOnlineLocation() + */ + public function getOnlineLocation(Page $page, UserOnline $user) { + if ($user->pageObjectID === null) { + return ''; + } + + $userObject = UserRuntimeCache::getInstance()->getObject($user->pageObjectID); + if ($userObject === null) { + return ''; + } + + return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['user' => $userObject]); + } + + /** + * @see IOnlineLocationPageHandler::prepareOnlineLocation() + */ + public function prepareOnlineLocation(/** @noinspection PhpUnusedParameterInspection */Page $page, UserOnline $user) { + if ($user->pageObjectID !== null) { + UserRuntimeCache::getInstance()->cacheObjectID($user->pageObjectID); + } + } +} diff --git a/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php index 7c2ae8e8bc..07e314e4a0 100644 --- a/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php @@ -1,13 +1,9 @@ @@ -15,30 +11,5 @@ use wcf\system\WCF; * @since 3.0 */ class UserPageHandler extends AbstractMenuPageHandler implements IOnlineLocationPageHandler { - use TOnlineLocationPageHandler; - - /** - * @inheritDoc - */ - public function getOnlineLocation(Page $page, UserOnline $user) { - if ($user->pageObjectID === null) { - return ''; - } - - $visitedUser = UserRuntimeCache::getInstance()->getObject($user->pageObjectID); - if ($visitedUser === null) { - return ''; - } - - return WCF::getLanguage()->getDynamicVariable('wcf.page.onlineLocation.'.$page->identifier, ['user' => $visitedUser]); - } - - /** - * @inheritDoc - */ - public function prepareOnlineLocation(Page $page, UserOnline $user) { - if ($user->pageObjectID !== null) { - UserRuntimeCache::getInstance()->cacheObjectID($user->pageObjectID); - } - } + use TUserOnlineLocationPageHandler; } -- 2.20.1