From: Matthias Schmidt Date: Sun, 18 Sep 2016 11:10:09 +0000 (+0200) Subject: Add TUserOnlineLocationPageHandler X-Git-Tag: 3.0.0_Beta_1~113 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=29340381b38610d6d0de9983b993ed7db0898c42;p=GitHub%2FWoltLab%2FWCF.git Add TUserOnlineLocationPageHandler --- 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; }