From: Joshua Rüsweg Date: Tue, 10 Apr 2018 11:19:12 +0000 (+0200) Subject: Add basic reaction type icon rendering X-Git-Tag: 5.2.0_Alpha_1~364^2~101^2~141 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f12a2816eca917bce47751e18506c002909e12fa;p=GitHub%2FWoltLab%2FWCF.git Add basic reaction type icon rendering See #2508 --- diff --git a/com.woltlab.wcf/templates/reactionTypeIcon.tpl b/com.woltlab.wcf/templates/reactionTypeIcon.tpl new file mode 100644 index 0000000000..4075258636 --- /dev/null +++ b/com.woltlab.wcf/templates/reactionTypeIcon.tpl @@ -0,0 +1,5 @@ + diff --git a/com.woltlab.wcf/templates/reactionTypeImage.tpl b/com.woltlab.wcf/templates/reactionTypeImage.tpl new file mode 100644 index 0000000000..a4577bbdef --- /dev/null +++ b/com.woltlab.wcf/templates/reactionTypeImage.tpl @@ -0,0 +1,6 @@ + diff --git a/wcfsetup/install/files/acp/templates/reactionTypeIcon.tpl b/wcfsetup/install/files/acp/templates/reactionTypeIcon.tpl new file mode 100644 index 0000000000..4075258636 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/reactionTypeIcon.tpl @@ -0,0 +1,5 @@ + diff --git a/wcfsetup/install/files/acp/templates/reactionTypeImage.tpl b/wcfsetup/install/files/acp/templates/reactionTypeImage.tpl new file mode 100644 index 0000000000..a4577bbdef --- /dev/null +++ b/wcfsetup/install/files/acp/templates/reactionTypeImage.tpl @@ -0,0 +1,6 @@ + diff --git a/wcfsetup/install/files/images/reaction/.htaccess b/wcfsetup/install/files/images/reaction/.htaccess new file mode 100644 index 0000000000..c8ab05519b --- /dev/null +++ b/wcfsetup/install/files/images/reaction/.htaccess @@ -0,0 +1 @@ +# This file ensures that these folders are created during an update. \ No newline at end of file diff --git a/wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php b/wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php index 9d443dff79..e990e860ca 100644 --- a/wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php +++ b/wcfsetup/install/files/lib/data/reaction/type/ReactionType.class.php @@ -2,6 +2,7 @@ declare(strict_types=1); namespace wcf\data\reaction\type; use wcf\data\DatabaseObject; +use wcf\system\WCF; /** * Represents an object type definition. @@ -56,7 +57,48 @@ class ReactionType extends DatabaseObject { /** * @inheritDoc */ - public function getTitle() { + protected static $databaseTableIndexName = 'reactionTypeID'; + + /** + * @inheritDoc + */ + public function getTitle():string { return WCF::getLanguage()->get($this->reactionTitle); } + + /** + * Renders the reaction icon. + * + * @return string + */ + public function renderIcon():string { + switch ($this->iconType) { + case self::ICON_TYPE_ICON: { + return WCF::getTPL()->fetch('reactionTypeIcon', 'wcf', [ + 'reactionType' => $this + ], true); + break; + } + + case self::ICON_TYPE_IMAGE: + return WCF::getTPL()->fetch('reactionTypeImage', 'wcf', [ + 'reactionType' => $this + ], true); + break; + + default: + $parameters = [ + 'renderedTemplate' => null + ]; + + EventHandler::getInstance()->fireAction($this, 'renderIcon', $parameters); + + if ($parameters['renderedTemplate']) { + return $parameters['renderedTemplate']; + } + + throw new \LogicException("Unable to render the reaction type icon with the type '". $this->type ."'."); + break; + } + } }