Dynamic box title for the users online list
authorAlexander Ebert <ebert@woltlab.com>
Wed, 27 Jun 2018 21:27:41 +0000 (23:27 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 27 Jun 2018 21:27:41 +0000 (23:27 +0200)
See #2587

wcfsetup/install/files/lib/data/box/Box.class.php
wcfsetup/install/files/lib/system/box/AbstractBoxController.class.php
wcfsetup/install/files/lib/system/box/IBoxController.class.php
wcfsetup/install/files/lib/system/box/UserOnlineListBoxController.class.php

index 35732b44c4349696579144d1d9c1359575dde3c5..14ed02f8fcb4d5b0ce26969cca929111884f1233 100644 (file)
@@ -202,7 +202,11 @@ class Box extends DatabaseObject {
         */
        public function getBoxContentTitle() {
                $this->getBoxContents();
-               if ($this->isMultilingual || $this->boxType == 'system') {
+               if ($this->isMultilingual || $this->boxType === 'system') {
+                       if ($this->boxType === 'system' && $this->getController()->getTitle()) {
+                               return $this->getController()->getTitle();
+                       }
+                       
                        if (isset($this->boxContents[WCF::getLanguage()->languageID])) {
                                return $this->boxContents[WCF::getLanguage()->languageID]->title;
                        }
index 51cfa591951bea08e2331046921f7ad530d7437b..4aadde78752d4af5bd04efae865149a18331fbcc 100644 (file)
@@ -110,6 +110,13 @@ abstract class AbstractBoxController implements IBoxController {
                ]))->executeAction();
        }
        
+       /**
+        * @inheritDoc
+        */
+       public function getTitle() {
+               return null;
+       }
+       
        /**
         * Returns the additional data of the box.
         * 
index e2055ba460fb9494a8cf79ff483056799046fc5b..d627de750c8e1d888e8aa99f05821971be4c55f2 100644 (file)
@@ -70,6 +70,16 @@ interface IBoxController {
         */
        public function saveAdditionalData();
        
+       /**
+        * Returns the title of this box, the special value `null` can be returned to
+        * apply the default behavior as seen in previous versions. Only supported for
+        * system-type boxes.
+        * 
+        * @return      string|null
+        * @since       3.2
+        */
+       public function getTitle();
+       
        /**
         * Returns a list of supported box positions.
         * 
index 2912923d5e1baca3e3be5bfa2239fcaf5d94b91b..2bbec1efbf7a50811f788e936008d2dacd7e06e9 100644 (file)
@@ -29,6 +29,12 @@ class UserOnlineListBoxController extends AbstractDatabaseObjectListBoxControlle
         */
        public $showRecord = true;
        
+       /**
+        * phrase that is used for the box title
+        * @var string|null
+        */
+       public $title;
+       
        /**
         * @inheritDoc
         */
@@ -85,4 +91,11 @@ class UserOnlineListBoxController extends AbstractDatabaseObjectListBoxControlle
        public function hasLink() {
                return true;
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getTitle() {
+               return $this->title;
+       }
 }