From d5d52ef51ea208897be404d74e694d96f65cab8e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 17 Aug 2019 20:52:16 +0200 Subject: [PATCH] Include the number of other reactions in the tooltip --- com.woltlab.wcf/templates/__topReaction.tpl | 10 ++++------ .../lib/system/reaction/ReactionHandler.class.php | 8 ++++++-- wcfsetup/install/lang/de.xml | 2 +- wcfsetup/install/lang/en.xml | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/com.woltlab.wcf/templates/__topReaction.tpl b/com.woltlab.wcf/templates/__topReaction.tpl index 5b59d4d134..9c7e8bcce7 100644 --- a/com.woltlab.wcf/templates/__topReaction.tpl +++ b/com.woltlab.wcf/templates/__topReaction.tpl @@ -1,18 +1,16 @@ {assign var='topReaction' value=$__wcf->getReactionHandler()->getTopReaction($cachedReactions)} {if $topReaction} - {if $render === 'icon'} - {@$topReaction[reaction]->renderIcon()} - {elseif $render === 'tiny'} - + {if $render === 'tiny'} + {@$topReaction[reaction]->renderIcon()} {#$topReaction[count]} {elseif $render === 'short'} - + {@$topReaction[reaction]->renderIcon()} × {#$topReaction[count]} {elseif $render === 'full'} - {@$topReaction[reaction]->renderIcon()} {lang reaction=$topReaction[reaction] count=$topReaction[count]}wcf.like.reaction.topReaction{/lang} + {@$topReaction[reaction]->renderIcon()} {lang reaction=$topReaction[reaction] count=$topReaction[count] other=$topReaction[other]}wcf.like.reaction.topReaction{/lang} {/if} {/if} diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index 8ca0638674..9092605e4a 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -745,10 +745,14 @@ class ReactionHandler extends SingletonFactory { $cachedReactions = @unserialize($cachedReactions); if (is_array($cachedReactions) && !empty($cachedReactions)) { - asort($cachedReactions, SORT_NUMERIC); + $allReactions = array_sum($cachedReactions); + arsort($cachedReactions, SORT_NUMERIC); + + $count = current($cachedReactions); return [ - 'count' => current($cachedReactions), + 'count' => $count, + 'other' => $allReactions - $count, 'reaction' => ReactionTypeCache::getInstance()->getReactionTypeByID(key($cachedReactions)), ]; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 76979fceb2..45db8f9dfe 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3983,7 +3983,7 @@ Dateianhänge: - getTitle()} × {#$count}]]> + getTitle()} × {#$count}{if $other} und {if $other == 1}eine weitere Reaktion{else}{#$other} weitere Reaktionen{/if}{/if}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index dba55ec74e..92c3fc6fc0 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3929,7 +3929,7 @@ Attachments: - getTitle()} × {#$count}]]> + getTitle()} × {#$count}{if $other} and {if $other == 1}one other reaction{else}{#$other} other reactions{/if}{/if}]]> -- 2.20.1