Allow setting `containerContentType` content of user like list
authorMatthias Schmidt <gravatronics@live.com>
Sun, 20 Aug 2017 08:08:35 +0000 (10:08 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 20 Aug 2017 08:08:35 +0000 (10:08 +0200)
com.woltlab.wcf/templates/userProfileLikeItem.tpl
wcfsetup/install/files/lib/data/like/ViewableLike.class.php

index 873fe1c966e8a5764ccd348f5a9a863481310ec5..e5d7bd6c56487a4b4b549db390768aa51f3e5a5e 100644 (file)
@@ -10,7 +10,7 @@
                                                <small class="separatorLeft">{@$like->time|time}</small>
                                        </h3>
                                        <div>{@$like->getTitle()}</div>
-                                       <small class="containerContentType">{lang}wcf.like.objectType.{@$like->getObjectTypeName()}{/lang}</small>
+                                       <small class="containerContentType">{$like->getObjectTypeDescription()}</small>
                                </div>
                                
                                <div class="containerContent">{@$like->getDescription()}</div>
index 844b847b240cbb7916a755b87cd39456f2813b98..b8afa50350f130f1d6a3d6344e6aa7d21f889467 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\WCF;
 
 /**
  * Provides methods for viewable likes.
@@ -44,7 +45,14 @@ class ViewableLike extends DatabaseObjectDecorator {
         * user profile
         * @var UserProfile
         */
-       protected $userProfile = null;
+       protected $userProfile;
+       
+       /**
+        * description of the object type displayed in the list of likes
+        * @var         string
+        * @since       3.1
+        */
+       protected $objectTypeDescription;
        
        /**
         * Marks this like as accessible for current user.
@@ -129,4 +137,31 @@ class ViewableLike extends DatabaseObjectDecorator {
        public function getObjectTypeName() {
                return ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID)->objectType;
        }
+       
+       /**
+        * Sets the description of the object type displayed in the list of likes.
+        * 
+        * @param       string          $name
+        * @since       3.1
+        */
+       public function setObjectTypeDescription($name) {
+               $this->objectTypeDescription = $name;
+       }
+       
+       /**
+        * Returns the description of the object type displayed in the list of likes.
+        * 
+        * If no description has been set before, `wcf.like.objectType.{$this->getObjectTypeName()}`
+        * is returned. 
+        * 
+        * @return      string
+        * @since       3.1
+        */
+       public function getObjectTypeDescription() {
+               if ($this->objectTypeDescription !== null) {
+                       return $this->objectTypeDescription;
+               }
+               
+               return WCF::getLanguage()->getDynamicVariable('wcf.like.objectType.' . $this->getObjectTypeName());
+       }
 }