Use page objects for user online location
authorMatthias Schmidt <gravatronics@live.com>
Sun, 27 Mar 2016 08:04:28 +0000 (10:04 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 27 Mar 2016 08:04:28 +0000 (10:04 +0200)
17 files changed:
CHANGELOG.md
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/objectTypeDefinition.xml
com.woltlab.wcf/page.xml
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/data/user/online/UserOnline.class.php
wcfsetup/install/files/lib/page/CmsPage.class.php
wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php
wcfsetup/install/files/lib/system/page/handler/IMenuPageHandler.class.php
wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/user/online/location/IUserOnlineLocation.class.php
wcfsetup/install/files/lib/system/user/online/location/UserLocation.class.php
wcfsetup/install/files/lib/system/user/online/location/UserOnlineLocationHandler.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index b05c294f9aedcaab6ae109b93913a1fe322ef769..6df2c54ead778bc560f7c3df302c9f6f3b5c9c09 100644 (file)
 * Continuous numeration of edit history version in template.
 * `\wcf\data\user\UserProfile::getGuestUserProfile()` added.
 
+#### CMS
+
+* User online location is handled via the `wcf\data\page\Page` objects. Static locations only need a language item `wcf.page.onlineLocation.{$page->identifier}`, more complex locations can use the online location-related methods of `wcf\system\page\handler\IMenuPageHandler`. For CMS pages, their title is used.
+
 #### New Traits
 
 * `wcf\data\TDatabaseObjectOptions` for database object-bound options validation.
index a3b7f39fe45da5713b53b223a036637178043dab..e47ba5c28110945cc7448da7d9390424292afdab 100644 (file)
                        <classname>wcf\system\moderation\queue\report\UserModerationQueueReportHandler</classname>
                </type>
                
-               <!-- user online locations -->
-               <type>
-                       <name>com.woltlab.wcf.user.UserPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <classname><![CDATA[wcf\system\user\online\location\UserLocation]]></classname>
-                       <controller><![CDATA[wcf\page\UserPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.UserPage</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.UsersOnlineListPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\page\UsersOnlineListPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.UsersOnlineListPage</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.MembersListPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\page\MembersListPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.MembersListPage</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.TeamPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\page\TeamPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.TeamPage</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.DashboardPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\page\DashboardPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.DashboardPage</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.RecentActivityListPage</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\page\RecentActivityListPage]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.RecentActivityListPage</languagevariable>
-               </type>
-               
-               <type>
-                       <name>com.woltlab.wcf.user.RegisterForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\RegisterForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.RegisterForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.LostPasswordForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\LostPasswordForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.LostPasswordForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.NewPasswordForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\NewPasswordForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.LostPasswordForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.LoginForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\LoginForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.LoginForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.AccountManagementForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\AccountManagementForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.AccountManagementForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.AvatarEditForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\AvatarEditForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.AvatarEditForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.SettingsForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\SettingsForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.SettingsForm</languagevariable>
-               </type>
-               <type>
-                       <name>com.woltlab.wcf.user.SignatureEditForm</name>
-                       <definitionname>com.woltlab.wcf.user.online.location</definitionname>
-                       <controller><![CDATA[wcf\form\SignatureEditForm]]></controller>
-                       <languagevariable>wcf.user.usersOnline.location.SignatureEditForm</languagevariable>
-               </type>
-               
                <!-- moderation type -->
                <type>
                        <name>com.woltlab.wcf.moderation.activation</name>
index 7849068766a45747ecf18752503d751ceec99264..b1d1ce8e66d8879d182d11d290becb7ec39ec771 100644 (file)
                        <name>com.woltlab.wcf.user.dashboardContainer</name>
                </definition>
                
-               <definition>
-                       <name>com.woltlab.wcf.user.online.location</name>
-                       <interfacename><![CDATA[wcf\system\user\online\location\IUserOnlineLocation]]></interfacename>
-               </definition>
-               
                <definition>
                        <name>com.woltlab.wcf.user.objectWatch</name>
                        <interfacename><![CDATA[wcf\system\user\object\watch\IUserObjectWatch]]></interfacename>
                        <name>com.woltlab.wcf.bulkProcessing.user.action</name>
                        <interfacename><![CDATA[wcf\system\bulk\processing\IBulkProcessingAction]]></interfacename>
                </definition>
+               
+               <!-- deprecated -->
+               <definition>
+                       <name>com.woltlab.wcf.user.online.location</name>
+                       <interfacename><![CDATA[wcf\system\user\online\location\IUserOnlineLocation]]></interfacename>
+               </definition>
+               <!-- /deprecated -->
        </import>
        
        <delete>
index 1d25d9f0f1d3d7888a9d93e99f2dc52b804553a2..97fd8fb1a32e04b8917b2b968c415ea5b005832d 100644 (file)
                        <options>module_members_list</options>
                </page>
                
+               <page identifier="com.woltlab.wcf.AccountManagement">
+                       <controller>wcf\form\AccountManagementForm</controller>
+                       <name language="de"><![CDATA[Benutzerkonto-Verwaltung]]></name>
+                       <name language="en"><![CDATA[Account Management]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.AvatarEdit">
+                       <controller>wcf\form\AvatarEditForm</controller>
+                       <name language="de"><![CDATA[Avatar-Verwaltung]]></name>
+                       <name language="en"><![CDATA[Avatar Management]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Disclaimer">
+                       <controller>wcf\form\DisclaimerForm</controller>
+                       <name language="de"><![CDATA[Disclaimer]]></name>
+                       <name language="en"><![CDATA[Disclaimer]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.EmailActivation">
+                       <controller>wcf\form\EmailActivationForm</controller>
+                       <name language="de"><![CDATA[Aktivierung neuer E-Mail-Adresse]]></name>
+                       <name language="en"><![CDATA[New Email Address Verification]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.EmailNewActivationCode">
+                       <controller>wcf\form\EmailNewActivationCodeForm</controller>
+                       <name language="de"><![CDATA[E-Mail-Aktivierungscode-Anforderung]]></name>
+                       <name language="en"><![CDATA[New Email Activation Code Request]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Login">
+                       <controller>wcf\form\LoginForm</controller>
+                       <name language="de"><![CDATA[Anmeldung]]></name>
+                       <name language="en"><![CDATA[Login]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.LostPassword">
+                       <controller>wcf\form\LostPasswordForm</controller>
+                       <name language="de"><![CDATA[Kennwort vergessen]]></name>
+                       <name language="en"><![CDATA[Lost Password]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Mail">
+                       <controller>wcf\form\MailForm</controller>
+                       <name language="de"><![CDATA[E-Mail-Formular]]></name>
+                       <name language="en"><![CDATA[Mail Form]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.NewPassword">
+                       <controller>wcf\form\NewPasswordForm</controller>
+                       <name language="de"><![CDATA[Neues Kennwort]]></name>
+                       <name language="en"><![CDATA[New Password Request]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.NotificationSettings">
+                       <controller>wcf\form\NotificationSettingsForm</controller>
+                       <name language="de"><![CDATA[Benachrichtigungseinstellungen]]></name>
+                       <name language="en"><![CDATA[Notification Settings]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.RegisterActivation">
+                       <controller>wcf\form\RegisterActivationForm</controller>
+                       <name language="de"><![CDATA[Registrierung abschließen]]></name>
+                       <name language="en"><![CDATA[Complete Registration]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Register">
+                       <controller>wcf\form\RegisterForm</controller>
+                       <name language="de"><![CDATA[Registrierung]]></name>
+                       <name language="en"><![CDATA[Registration]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.RegisterNewActivationCode">
+                       <controller>wcf\form\RegisterNewActivationCodeForm</controller>
+                       <name language="de"><![CDATA[Aktivierungscode-Anforderung]]></name>
+                       <name language="en"><![CDATA[New Activation Code Request]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Search">
+                       <controller>wcf\form\SearchForm</controller>
+                       <name language="de"><![CDATA[Suche]]></name>
+                       <name language="en"><![CDATA[Search]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.Settings">
+                       <controller>wcf\form\SettingsForm</controller>
+                       <name language="de"><![CDATA[Einstellungen]]></name>
+                       <name language="en"><![CDATA[Settings]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.SignatureEdit">
+                       <controller>wcf\form\SignatureEditForm</controller>
+                       <name language="de"><![CDATA[Signatur-Verwaltung]]></name>
+                       <name language="en"><![CDATA[Signature Management]]></name>
+                       <options>module_user_signature</options>
+               </page>
+               <page identifier="com.woltlab.wcf.DeletedContentList">
+                       <controller>wcf\page\DeletedContentListPage</controller>
+                       <name language="de"><![CDATA[Gelöschte Inhalte]]></name>
+                       <name language="en"><![CDATA[Deleted Content]]></name>
+                       <permissions>mod.general.canUseModeration</permissions>
+               </page>
+               <page identifier="com.woltlab.wcf.EditHistory">
+                       <controller>wcf\page\EditHistoryPage</controller>
+                       <name language="de"><![CDATA[TODO]]></name>
+                       <name language="en"><![CDATA[TODO]]></name>
+                       <options>module_edit_history</options>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               <page identifier="com.woltlab.wcf.Following">
+                       <controller>wcf\page\FollowingPage</controller>
+                       <name language="de"><![CDATA[Benutzer, denen Sie folgen]]></name>
+                       <name language="en"><![CDATA[Followed Users]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.IgnoredUsers">
+                       <controller>wcf\page\IgnoredUsersPage</controller>
+                       <name language="de"><![CDATA[Blockierte Benutzer]]></name>
+                       <name language="en"><![CDATA[Blocked Users]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.ModerationList">
+                       <controller>wcf\page\ModerationListPage</controller>
+                       <name language="de"><![CDATA[Moderation]]></name>
+                       <name language="en"><![CDATA[Moderation]]></name>
+                       <permissions>mod.general.canUseModeration</permissions>
+               </page>
+               <page identifier="com.woltlab.wcf.ModerationActivation">
+                       <controller>wcf\form\ModerationActivationForm</controller>
+                       <name language="de"><![CDATA[Inhaltsfreischaltung]]></name>
+                       <name language="en"><![CDATA[Content Approval]]></name>
+                       <parent>com.woltlab.wcf.ModerationList</parent>
+                       <permissions>mod.general.canUseModeration</permissions>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               <page identifier="com.woltlab.wcf.ModerationReport">
+                       <controller>wcf\form\ModerationReportForm</controller>
+                       <name language="de"><![CDATA[Inhaltsmeldung]]></name>
+                       <name language="en"><![CDATA[Content Report]]></name>
+                       <parent>com.woltlab.wcf.ModerationList</parent>
+                       <permissions>mod.general.canUseModeration</permissions>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               <page identifier="com.woltlab.wcf.NotificationList">
+                       <controller>wcf\page\NotificationListPage</controller>
+                       <name language="de"><![CDATA[Benachrichtigungen]]></name>
+                       <name language="en"><![CDATA[Notifications]]></name>
+               </page>
+               <page identifier="com.woltlab.wcf.PaidSubscriptionList">
+                       <controller>wcf\page\PaidSubscriptionListPage</controller>
+                       <name language="de"><![CDATA[Bezahlte Mitgliedschaften]]></name>
+                       <name language="en"><![CDATA[Paid Subscriptions]]></name>
+                       <options>module_paid_subscription</options>
+               </page>
+               <page identifier="com.woltlab.wcf.SearchResult">
+                       <controller>wcf\page\SearchResultPage</controller>
+                       <name language="de"><![CDATA[Suchergebnisse]]></name>
+                       <name language="en"><![CDATA[Search Results]]></name>
+                       <parent>com.woltlab.wcf.Search</parent>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               <page identifier="com.woltlab.wcf.Tagged">
+                       <controller>wcf\page\TaggedPage</controller>
+                       <name language="de"><![CDATA[Inhalte mit bestimmtem Tag]]></name>
+                       <name language="en"><![CDATA[Content With Particular Tag]]></name>
+                       <permissions>user.tag.canViewTag</permissions>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               <page identifier="com.woltlab.wcf.User">
+                       <controller>wcf\page\UserPage</controller>
+                       <handler>wcf\system\page\handler\UserPageHandler</handler>
+                       <name language="de"><![CDATA[Benutzerprofil]]></name>
+                       <name language="en"><![CDATA[User Profile]]></name>
+                       <parent>com.woltlab.wcf.MembersList</parent>
+                       <requireObjectID>1</requireObjectID>
+               </page>
+               
                <!-- static -->
                <page identifier="com.woltlab.wcf.CookiePolicy">
                        <name language="en">Cookie Policy</name>
index a0d07996e36475670c736b85f9133b60a89d7147..e576a6eec31af31187f8cdd174a199bb505b8c17 100644 (file)
@@ -14,7 +14,6 @@ use wcf\system\breadcrumb\IBreadcrumbProvider;
 use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\request\LinkHandler;
-use wcf\system\user\online\location\UserOnlineLocationHandler;
 use wcf\system\user\signature\SignatureCache;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\system\WCF;
@@ -320,11 +319,10 @@ class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider
         */
        public function getCurrentLocation() {
                if ($this->currentLocation === null) {
-                       $this->currentLocation = '';
-                       $this->currentLocation = UserOnlineLocationHandler::getInstance()->getLocation(new UserOnline(new User(null, [
-                               'controller' => $this->controller,
-                               'objectID' => $this->locationObjectID
-                       ])));
+                       $userOnline = new UserOnline($this->getDecoratedObject());
+                       $userOnline->setLocation();
+                       
+                       $this->currentLocation = $userOnline->getLocation();
                }
                
                return $this->currentLocation;
index e6dc2ceba202c1e909ef550b9ddb4b72337072cd..7a915c38a7b09a7f354998578cb9e3ab16e0c4fe 100644 (file)
@@ -1,7 +1,11 @@
 <?php
 namespace wcf\data\user\online;
+use wcf\data\page\PageCache;
+use wcf\data\spider\Spider;
 use wcf\data\user\UserProfile;
+use wcf\page\CmsPage;
 use wcf\system\cache\builder\SpiderCacheBuilder;
+use wcf\system\page\handler\IOnlineLocationPageHandler;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 use wcf\util\UserUtil;
@@ -10,7 +14,7 @@ use wcf\util\UserUtil;
  * Represents a user who is online.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.user.online
@@ -25,7 +29,7 @@ class UserOnline extends UserProfile {
        
        /**
         * spider object
-        * @var \wcf\data\spider\Spider
+        * @var Spider
         */
        protected $spider = null;
        
@@ -49,12 +53,61 @@ class UserOnline extends UserProfile {
        }
        
        /**
-        * Sets the location of the user.
+        * Sets the location of the user. If no location is given, the method tries to
+        * automatically determine the location.
+        * Returns true if the location has been successfully set.
         * 
-        * @param       string          $location
+        * @param       string|null     $location
+        * @return      boolean
         */
-       public function setLocation($location) {
+       public function setLocation($location = null) {
+               if ($location === null) {
+                       if ($this->controller) {
+                               if ($this->controller === CmsPage::class) {
+                                       // create location based on cms page title
+                                       if ($this->objectType) {
+                                               $page = PageCache::getInstance()->getPageByIdentifier($this->objectType);
+                                               if ($page !== null) {
+                                                       // TODO: check if active user may access the page
+                                                       $pageContent = $page->getPageContentByLanguage(WCF::getLanguage()->languageID);
+                                                       if (isset($pageContent['title'])) {
+                                                               $this->location = $pageContent['title'];
+                                                               
+                                                               return false;
+                                                       }
+                                               }
+                                       }
+                               }
+                               else {
+                                       $page = PageCache::getInstance()->getPageByController($this->controller);
+                                       if ($page !== null) {
+                                               if ($page->getHandler() !== null && $page->getHandler() instanceof IOnlineLocationPageHandler) {
+                                                       // refer to page handler
+                                                       $this->location = $page->getHandler()->getOnlineLocation($page, $this);
+                                                       
+                                                       return true;
+                                               }
+                                               else {
+                                                       // check if static language item exists
+                                                       $languageItem = 'wcf.page.onlineLocation.' . $page->identifier;
+                                                       $languageItemValue = WCF::getLanguage()->get($languageItem);
+                                                       
+                                                       if ($languageItemValue !== $languageItem) {
+                                                               $this->location = $languageItemValue;
+                                                               
+                                                               return true;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       
+                       $this->location = '';
+                       return false;
+               }
+               
                $this->location = $location;
+               return true;
        }
        
        /**
@@ -251,7 +304,7 @@ class UserOnline extends UserProfile {
        /**
         * Returns the spider object
         * 
-        * @return      \wcf\data\spider\Spider
+        * @return      Spider
         */
        public function getSpider() {
                if (!$this->spiderID) return null;
index 9b67dfe703eaa526f06f8f2eff12c1586250d079..608239c6b8a27e3a940de76c0b6b5ccf482c046a 100644 (file)
@@ -10,7 +10,7 @@ use wcf\system\WCF;
  * Generic controller to display cms content.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage page
@@ -23,6 +23,11 @@ class CmsPage extends AbstractPage {
         */
        public $content;
        
+       /**
+        * @inheritDoc
+        */
+       public $enableTracking = true;
+       
        /**
         * @var integer
         */
@@ -82,4 +87,11 @@ class CmsPage extends AbstractPage {
                        'pageID' => $this->pageID
                ]);
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getObjectType() {
+               return $this->page ? $this->page->identifier : '';
+       }
 }
index 0571b075a5016a22452d44e29705223c03ab3cb3..2598b32524f34bff15bbe3abf3062de92334f26d 100644 (file)
@@ -1,8 +1,12 @@
 <?php
 namespace wcf\page;
 use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\page\PageCache;
+use wcf\data\user\online\UserOnline;
+use wcf\data\user\online\UsersOnlineList;
 use wcf\system\breadcrumb\Breadcrumb;
 use wcf\system\dashboard\DashboardHandler;
+use wcf\system\page\handler\IOnlineLocationPageHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\user\collapsible\content\UserCollapsibleContentHandler;
 use wcf\system\WCF;
@@ -12,7 +16,7 @@ use wcf\util\HeaderUtil;
  * Shows page which lists all users who are online.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage page
@@ -20,48 +24,48 @@ use wcf\util\HeaderUtil;
  */
 class UsersOnlineListPage extends SortablePage {
        /**
-        * @see \wcf\page\AbstractPage::$activeMenuItem
+        * @inheritDoc
         */
        public $activeMenuItem = 'wcf.user.usersOnline';
        
        /**
-        * @see \wcf\page\AbstractPage::$neededPermissions
+        * @inheritDoc
         */
-       public $neededPermissions = array('user.profile.canViewUsersOnlineList');
+       public $neededPermissions = ['user.profile.canViewUsersOnlineList'];
        
        /**
-        * @see \wcf\page\AbstractPage::$enableTracking
+        * @inheritDoc
         */
        public $enableTracking = true;
        
        /**
-        * @see \wcf\page\SortablePage::$defaultSortField
+        * @inheritDoc
         */
        public $defaultSortField = USERS_ONLINE_DEFAULT_SORT_FIELD;
        
        /**
-        * @see \wcf\page\SortablePage::$defaultSortOrder
+        * @inheritDoc
         */
        public $defaultSortOrder = USERS_ONLINE_DEFAULT_SORT_ORDER;
        
        /**
-        * @see \wcf\page\SortablePage::$validSortFields
+        * @inheritDoc
         */
-       public $validSortFields = array('username', 'lastActivityTime', 'requestURI');
+       public $validSortFields = ['username', 'lastActivityTime', 'requestURI'];
        
        /**
-        * @see \wcf\page\MultipleLinkPage::$objectListClassName
+        * @inheritDoc
         */
-       public $objectListClassName = 'wcf\data\user\online\UsersOnlineList';
+       public $objectListClassName = UsersOnlineList::class;
        
        /**
         * page locations
         * @var array
         */
-       public $locations = array();
+       public $locations = [];
        
        /**
-        * @see \wcf\page\IPage::readParameters()
+        * @inheritDoc
         */
        public function readParameters() {
                parent::readParameters();
@@ -72,13 +76,13 @@ class UsersOnlineListPage extends SortablePage {
                }
                
                if (!empty($_POST)) {
-                       HeaderUtil::redirect(LinkHandler::getInstance()->getLink('UsersOnlineList', array(), 'sortField=' . $this->sortField . '&sortOrder=' . $this->sortOrder));
+                       HeaderUtil::redirect(LinkHandler::getInstance()->getLink('UsersOnlineList', [], 'sortField=' . $this->sortField . '&sortOrder=' . $this->sortOrder));
                        exit;
                }
        }
        
        /**
-        * @see \wcf\page\MultipleLinkPage::initObjectList()
+        * @inheritDoc
         */
        protected function initObjectList() {
                parent::initObjectList();
@@ -99,56 +103,50 @@ class UsersOnlineListPage extends SortablePage {
        }
        
        /**
-        * @see \wcf\page\IPage::readData()
+        * @inheritDoc
         */
        public function readData() {
                parent::readData();
                
                // add breadcrumbs
-               if (MODULE_MEMBERS_LIST) WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
-               
-               // load locations
-               foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.online.location') as $objectType) {
-                       $this->locations[$objectType->controller] = $objectType;
+               if (MODULE_MEMBERS_LIST) {
+                       WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.user.members'), LinkHandler::getInstance()->getLink('MembersList')));
                }
                
-               // cache data
+               // cache all necessary data for showing locations
                foreach ($this->objectList as $userOnline) {
-                       if (isset($this->locations[$userOnline->controller]) && $this->locations[$userOnline->controller]->getProcessor()) {
-                               $this->locations[$userOnline->controller]->getProcessor()->cache($userOnline);
+                       if ($userOnline->controller) {
+                               $page = PageCache::getInstance()->getPageByController($userOnline->controller);
+                               if ($page !== null && $page->getHandler() !== null && $page->getHandler() instanceof IOnlineLocationPageHandler) {
+                                       $page->getHandler()->prepareOnlineLocation($page, $userOnline);
+                               }
                        }
                }
                
                // set locations
+               /** @var UserOnline $userOnline */
                foreach ($this->objectList as $userOnline) {
-                       if (isset($this->locations[$userOnline->controller])) {
-                               if ($this->locations[$userOnline->controller]->getProcessor()) {
-                                       $userOnline->setLocation($this->locations[$userOnline->controller]->getProcessor()->get($userOnline, $this->locations[$userOnline->controller]->languagevariable));
-                               }
-                               else {
-                                       $userOnline->setLocation(WCF::getLanguage()->get($this->locations[$userOnline->controller]->languagevariable));
-                               }
-                       }
+                       $userOnline->setLocation();
                }
        }
        
        /**
-        * @see \wcf\page\IPage::assignVariables()
+        * @inheritDoc
         */
        public function assignVariables() {
                parent::assignVariables();
                
                DashboardHandler::getInstance()->loadBoxes('com.woltlab.wcf.user.MembersListPage', $this);
                
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'sidebarCollapsed' => UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'com.woltlab.wcf.user.MembersListPage'),
                        'sidebarName' => 'com.woltlab.wcf.user.MembersListPage',
                        'allowSpidersToIndexThisPage' => true
-               ));
+               ]);
        }
        
        /**
-        * @see \wcf\page\MultipleLinkPage::readObjects()
+        * @inheritDoc
         */
        protected function readObjects() {
                $this->objectList->sqlLimit = 0;
index 6abc43ad6ccf4907aa6d48bc1345847bc4bacfd5..6ed8f22de0bcf06ede8eda1f349d4387d97a6e1f 100644 (file)
@@ -17,7 +17,7 @@ interface IMenuPageHandler {
         * Returns the number of outstanding items for this page for display as a badge, optionally
         * specifying a corresponding object id to limit the scope.
         * 
-        * @param       integer         $objectID       optional page object id
+        * @param       integer|null    $objectID       optional page object id
         * @return      integer         number of outstanding items
         */
        public function getOutstandingItemCount($objectID = null);
@@ -26,7 +26,7 @@ interface IMenuPageHandler {
         * Returns false if this page should be hidden from menus, but does not control the accessibility
         * of the page itself. The visibility can optionally be scoped to the given object id.
         * 
-        * @param       integer         $objectID       optional page object id
+        * @param       integer|null    $objectID       optional page object id
         * @return      boolean         false if the page should be hidden from menus
         */
        public function isVisible($objectID = null);
diff --git a/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/IOnlineLocationPageHandler.class.php
new file mode 100644 (file)
index 0000000..204e4c8
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\page\Page;
+use wcf\data\user\online\UserOnline;
+
+/**
+ * Interface for pages supporting online location.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.page.handler
+ * @category   Community Framework
+ * @since      2.2
+ */
+interface IOnlineLocationPageHandler {
+       /**
+        * Returns the textual description if a user is currently online viewing this page.
+        *
+        * @param       Page            $page           visited page
+        * @param       UserOnline      $user           user online object with request data
+        * @return      string
+        */
+       public function getOnlineLocation(Page $page, UserOnline $user);
+       
+       /**
+        * Prepares fetching all necessary data for the textual description if a user is currently online
+        * viewing this page.
+        *
+        * @param       Page            $page           visited page
+        * @param       UserOnline      $user           user online object with request data
+        */
+       public function prepareOnlineLocation(Page $page, UserOnline $user);
+}
diff --git a/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/TOnlineLocationPageHandler.class.php
new file mode 100644 (file)
index 0000000..f50a56d
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace wcf\system\page\handler;
+use wcf\data\page\Page;
+use wcf\data\user\online\UserOnline;
+
+/**
+ * Default implementation of the interface for pages supporting online location.
+ * 
+ * It is highly recommended to use this trait in any case to achieve better upwards-compatibility
+ * in case of interface changes.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.page.handler
+ * @category   Community Framework
+ * @since      2.2
+ */
+trait TOnlineLocationPageHandler {
+       /**
+        * @see IOnlineLocationPageHandler::getOnlineLocation()
+        */
+       public function getOnlineLocation(Page $page, UserOnline $user) {
+               return '';
+       }
+       
+       /**
+        * @see IOnlineLocationPageHandler::prepareOnlineLocation()
+        */
+       public function prepareOnlineLocation(Page $page, UserOnline $user) {
+               // does nothing
+       }
+}
\ No newline at end of file
diff --git a/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/UserPageHandler.class.php
new file mode 100644 (file)
index 0000000..c4a2ca8
--- /dev/null
@@ -0,0 +1,46 @@
+<?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    WoltLab License <http://www.woltlab.com/license-agreement.html>
+ * @package    com.woltlab.wbb
+ * @subpackage system.page.handler
+ * @category   Burning Board
+ * @since      2.2
+ */
+class UserPageHandler extends AbstractMenuPageHandler implements IOnlineLocationPageHandler {
+       use TOnlineLocationPageHandler;
+       
+       /**
+        * @inheritDoc
+        */
+       public function getOnlineLocation(Page $page, UserOnline $user) {
+               if ($user->objectID === null) {
+                       return '';
+               }
+               
+               $visitedUser = UserRuntimeCache::getInstance()->getObject($user->objectID);
+               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->objectID !== null) {
+                       UserRuntimeCache::getInstance()->cacheObjectID($user->objectID);
+               }
+       }
+}
index fddcfbc993622c2e80fd88170f564834597cccaf..1d94120a6225b69a084e1169344e0cc623bb2d96 100644 (file)
@@ -11,6 +11,7 @@ use wcf\data\user\online\UserOnline;
  * @package    com.woltlab.wcf
  * @subpackage system.user.online.location
  * @category   Community Framework
+ * @deprecated since 2.2
  */
 interface IUserOnlineLocation {
        /**
index 9744b8bb23a2d99494a903250d92b847a17d520d..e4dcf465cc2478b835cc43c66891a4136c8d36cf 100644 (file)
@@ -13,6 +13,7 @@ use wcf\system\WCF;
  * @package    com.woltlab.wcf
  * @subpackage system.user.online.location
  * @category   Community Framework
+ * @deprecated since 2.2
  */
 class UserLocation implements IUserOnlineLocation {
        /**
index b92b9f483f20a13ce55843e8e1ee0269cbb7e4a3..ae703a5a95ec47c9ae97ef51e004bb9247e9a855 100644 (file)
@@ -1,54 +1,34 @@
 <?php
 namespace wcf\system\user\online\location;
-use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\page\PageCache;
 use wcf\data\user\online\UserOnline;
+use wcf\system\page\handler\IOnlineLocationPageHandler;
 use wcf\system\SingletonFactory;
-use wcf\system\WCF;
 
 /**
  * Handles user online locations.
  * 
- * @author     Marcel Werk
- * @copyright  2001-2015 WoltLab GmbH
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.user.online.location
  * @category   Community Framework
+ * @deprecated since 2.2
  */
 class UserOnlineLocationHandler extends SingletonFactory {
        /**
-        * page locations
-        * @var array
-        */
-       public $locations = array();
-       
-       /**
-        * @see \wcf\system\SingletonFactory::init()
-        */
-       protected function init() {
-               // load locations
-               foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.online.location') as $objectType) {
-                       $this->locations[$objectType->controller] = $objectType;
-               }
-       }
-       
-       /**
-        * Gets the location of a given user.
+        * Returns the location of the given user.
         * 
-        * @param       \wcf\data\user\online\UserOnline                $user
+        * @param       UserOnline      $user
         * @return      string
         */
        public function getLocation(UserOnline $user) {
-               if (isset($this->locations[$user->controller])) {
-                       if ($this->locations[$user->controller]->getProcessor()) {
-                               $this->locations[$user->controller]->getProcessor()->cache($user);
-                               return $this->locations[$user->controller]->getProcessor()->get($user, $this->locations[$user->controller]->languagevariable);
-                       }
-                       else {
-                               return WCF::getLanguage()->get($this->locations[$user->controller]->languagevariable);
-                       }
-               }
+               $oldLocation = $user->getLocation();
+               $user->setLocation();
+               $newLocation = $user->getLocation();
+               $user->setLocation($oldLocation);
                
-               return '';
+               return $newLocation;
        }
 }
index 0576f94bd3562afc6e5a2dc4fa3c1a94091dfe3b..50882b7c3e298847154d68e7a6943c63245e65dd 100644 (file)
@@ -2611,6 +2611,18 @@ Fehler sind beispielsweise:
                <item name="wcf.page.com.woltlab.wcf.TeamPage"><![CDATA[Team-Mitglieder]]></item>
                <item name="wcf.page.com.woltlab.wcf.UserPage"><![CDATA[Benutzerprofil]]></item>
                <item name="wcf.page.com.woltlab.wcf.UsersOnlineListPage"><![CDATA[Benutzer online]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.User"><![CDATA[Benutzerprofil von <a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{@$user->userID}">{$user->username}</a>]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.UsersOnlineList"><![CDATA[Benutzer-Online-Liste]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.MembersList"><![CDATA[Mitgliederliste]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Team"><![CDATA[Liste der Team-Mitglieder]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Dashboard"><![CDATA[Dashboard]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Register"><![CDATA[Registrierung]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.LostPassword"><![CDATA[Kennwort vergessen]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Login"><![CDATA[Anmeldung]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.AccountManagement"><![CDATA[Benutzerkonto-Verwaltung]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.AvatarEdit"><![CDATA[Avatar-Verwaltung]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Settings"><![CDATA[Einstellungen]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.SignatureEdit"><![CDATA[Signatur-Verwaltung]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
@@ -3021,18 +3033,6 @@ Sollten Sie sich nicht auf der Website: {@PAGE_TITLE|language} angemeldet haben,
 {/if}]]></item>
                <item name="wcf.user.usersOnline.invisible"><![CDATA[ (unsichtbar)]]></item>
                <item name="wcf.user.usersOnline.marking.legend"><![CDATA[Legende]]></item>
-               <item name="wcf.user.usersOnline.location.UserPage"><![CDATA[Betrachtet das Benutzerprofil von <a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{@$user->userID}">{$user->username}</a>]]></item>
-               <item name="wcf.user.usersOnline.location.UsersOnlineListPage"><![CDATA[Betrachtet die Benutzer-Online-Liste]]></item>
-               <item name="wcf.user.usersOnline.location.MembersListPage"><![CDATA[Betrachtet die Mitgliederliste]]></item>
-               <item name="wcf.user.usersOnline.location.TeamPage"><![CDATA[Betrachtet die Liste der Team-Mitglieder]]></item>
-               <item name="wcf.user.usersOnline.location.DashboardPage"><![CDATA[Betrachtet das Dashboard]]></item>
-               <item name="wcf.user.usersOnline.location.RegisterForm"><![CDATA[Führt die Registrierung durch]]></item>
-               <item name="wcf.user.usersOnline.location.LostPasswordForm"><![CDATA[Fordert ein neues Kennwort an]]></item>
-               <item name="wcf.user.usersOnline.location.LoginForm"><![CDATA[Führt die Anmeldung durch]]></item>
-               <item name="wcf.user.usersOnline.location.AccountManagementForm"><![CDATA[Verwaltet das Benutzerkonto]]></item>
-               <item name="wcf.user.usersOnline.location.AvatarEditForm"><![CDATA[Verwaltet den Avatar]]></item>
-               <item name="wcf.user.usersOnline.location.SettingsForm"><![CDATA[Passt Einstellungen an]]></item>
-               <item name="wcf.user.usersOnline.location.SignatureEditForm"><![CDATA[Bearbeitet die Signatur]]></item>
                <item name="wcf.user.usersOnline.guests"><![CDATA[Gäste]]></item>
                <item name="wcf.user.usersOnline.location"><![CDATA[Ort]]></item>
                <item name="wcf.user.usersOnline.ipAddress"><![CDATA[IP-Adresse]]></item>
index 50546a179ac9444054ce98b2c3765bcac6a0aab5..de8233ebb9c575952bf86fd1ad0d900f925edf57 100644 (file)
@@ -2641,6 +2641,18 @@ Errors are:
                <item name="wcf.page.com.woltlab.wcf.TeamPage"><![CDATA[Staff Members]]></item>
                <item name="wcf.page.com.woltlab.wcf.UserPage"><![CDATA[User Profile]]></item>
                <item name="wcf.page.com.woltlab.wcf.UsersOnlineListPage"><![CDATA[Users Online]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.User"><![CDATA[User profile of <a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{@$user->userID}">{$user->username}</a>]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.UsersOnlineList"><![CDATA[List of Users Online]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.MembersList"><![CDATA[Members List]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Team"><![CDATA[List of Staff Members]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Dashboard"><![CDATA[Dashboard]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Register"><![CDATA[Registration]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.LostPassword"><![CDATA[Lost Password]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Login"><![CDATA[Login]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.AccountManagement"><![CDATA[Account Management]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.AvatarEdit"><![CDATA[Avatar Management]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.Settings"><![CDATA[Settings]]></item>
+               <item name="wcf.page.onlineLocation.com.woltlab.wcf.SignatureEdit"><![CDATA[Signature Management]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
@@ -3047,18 +3059,6 @@ You can safely ignore this email if you did not register with the website: {@PAG
 {/if}]]></item>
                <item name="wcf.user.usersOnline.invisible"><![CDATA[ (invisible)]]></item>
                <item name="wcf.user.usersOnline.marking.legend"><![CDATA[Legend]]></item>
-               <item name="wcf.user.usersOnline.location.UserPage"><![CDATA[Viewing user profile <a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{@$user->userID}">{$user->username}</a>]]></item>
-               <item name="wcf.user.usersOnline.location.UsersOnlineListPage"><![CDATA[Viewing users online]]></item>
-               <item name="wcf.user.usersOnline.location.MembersListPage"><![CDATA[Viewing members list]]></item>
-               <item name="wcf.user.usersOnline.location.TeamPage"><![CDATA[Viewing list of staff members]]></item>
-               <item name="wcf.user.usersOnline.location.DashboardPage"><![CDATA[Viewing dashboard]]></item>
-               <item name="wcf.user.usersOnline.location.RegisterForm"><![CDATA[Registering themself]]></item>
-               <item name="wcf.user.usersOnline.location.LostPasswordForm"><![CDATA[Requesting a new password]]></item>
-               <item name="wcf.user.usersOnline.location.LoginForm"><![CDATA[Logins themself]]></item>
-               <item name="wcf.user.usersOnline.location.AccountManagementForm"><![CDATA[Managing their account]]></item>
-               <item name="wcf.user.usersOnline.location.AvatarEditForm"><![CDATA[Editing their avatar]]></item>
-               <item name="wcf.user.usersOnline.location.SettingsForm"><![CDATA[Editing their settings]]></item>
-               <item name="wcf.user.usersOnline.location.SignatureEditForm"><![CDATA[Editing their signature]]></item>
                <item name="wcf.user.usersOnline.guests"><![CDATA[Guests]]></item>
                <item name="wcf.user.usersOnline.location"><![CDATA[Location]]></item>
                <item name="wcf.user.usersOnline.ipAddress"><![CDATA[IP Address]]></item>