From bd649d50a6ec6bd1ee8b93250b2b153f95eb6587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 28 Apr 2013 16:54:56 +0200 Subject: [PATCH] Fix smiley selection --- file/lib/page/ChatPage.class.php | 22 ++++++++++++++++------ template/chat.tpl | 8 +++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index c3a661b..3166080 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -136,13 +136,23 @@ class ChatPage extends \wcf\page\AbstractPage { \chat\util\ChatUtil::writeUserData(array('lastSeen' => 0)); } - $smileyCategories = \wcf\data\smiley\SmileyCache::getInstance()->getCategories(); - - foreach ($smileyCategories as $category) { - if (!$category->disabled) $this->smileyCategories[] = $category; + // get default smilies + if (MODULE_SMILEY) { + $this->smileyCategories = \wcf\data\smiley\SmileyCache::getInstance()->getCategories(); + foreach ($this->smileyCategories as $index => $category) { + $category->loadSmilies(); + + // remove empty categories + if (!count($category) || $category->isDisabled) { + unset($this->smileyCategories[$index]); + } + } + + $firstCategory = reset($this->smileyCategories); + if ($firstCategory) { + $this->defaultSmilies = \wcf\data\smiley\SmileyCache::getInstance()->getCategorySmilies($firstCategory->categoryID ?: null); + } } - - $this->defaultSmilies = \wcf\data\smiley\SmileyCache::getInstance()->getCategorySmilies(); } /** diff --git a/template/chat.tpl b/template/chat.tpl index 584bc6d..1d0aa31 100644 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -117,10 +117,8 @@
- {if MODULE_SMILEY} -
- {include file='messageFormSmilies' wysiwygSelector=''} -
+ {if MODULE_SMILEY && $smileyCategories|count} + {include file='messageFormSmilies' wysiwygSelector=''} {/if}