Add TUserOnlineLocationPageHandler
authorMatthias Schmidt <gravatronics@live.com>
Sun, 18 Sep 2016 11:10:09 +0000 (13:10 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 18 Sep 2016 11:10:12 +0000 (13:10 +0200)
wcfsetup/install/files/lib/system/page/handler/TUserOnlineLocationPageHandler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/page/handler/UserPageHandler.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 (file)
index 0000000..6ef6170
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\page\Page;
+use wcf\data\user\online\UserOnline;
+use wcf\system\cache\runtime\UserRuntimeCache;
+use wcf\system\WCF;
+
+/**
+ * Implementation of the `IOnlineLocationPageHandler` interface for user-bound pages.
+ *
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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);
+               }
+       }
+}
index 7c2ae8e8bc2c3bad552500febcab4a67ee60c50d..07e314e4a05a9154bf435560538a2a3dbefdb333 100644 (file)
@@ -1,13 +1,9 @@
 <?php
 namespace wcf\system\page\handler;
-use wcf\data\page\Page;
-use wcf\data\user\online\UserOnline;
-use wcf\system\cache\runtime\UserRuntimeCache;
-use wcf\system\WCF;
 
 /**
  * Menu page handler for the user profile page.
- *
+ * 
  * @author     Matthias Schmidt
  * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
@@ -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;
 }