From dcad9244c6ee005b6dd834097fde2e71fb6761c2 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 27 Jun 2018 23:27:41 +0200 Subject: [PATCH] Dynamic box title for the users online list See #2587 --- wcfsetup/install/files/lib/data/box/Box.class.php | 6 +++++- .../lib/system/box/AbstractBoxController.class.php | 7 +++++++ .../files/lib/system/box/IBoxController.class.php | 10 ++++++++++ .../box/UserOnlineListBoxController.class.php | 13 +++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/data/box/Box.class.php b/wcfsetup/install/files/lib/data/box/Box.class.php index 35732b44c4..14ed02f8fc 100644 --- a/wcfsetup/install/files/lib/data/box/Box.class.php +++ b/wcfsetup/install/files/lib/data/box/Box.class.php @@ -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; } diff --git a/wcfsetup/install/files/lib/system/box/AbstractBoxController.class.php b/wcfsetup/install/files/lib/system/box/AbstractBoxController.class.php index 51cfa59195..4aadde7875 100644 --- a/wcfsetup/install/files/lib/system/box/AbstractBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/AbstractBoxController.class.php @@ -110,6 +110,13 @@ abstract class AbstractBoxController implements IBoxController { ]))->executeAction(); } + /** + * @inheritDoc + */ + public function getTitle() { + return null; + } + /** * Returns the additional data of the box. * diff --git a/wcfsetup/install/files/lib/system/box/IBoxController.class.php b/wcfsetup/install/files/lib/system/box/IBoxController.class.php index e2055ba460..d627de750c 100644 --- a/wcfsetup/install/files/lib/system/box/IBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/IBoxController.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/box/UserOnlineListBoxController.class.php b/wcfsetup/install/files/lib/system/box/UserOnlineListBoxController.class.php index 2912923d5e..2bbec1efbf 100644 --- a/wcfsetup/install/files/lib/system/box/UserOnlineListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/UserOnlineListBoxController.class.php @@ -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; + } } -- 2.20.1