</nav>
{foreach from=$smileyCategories item=smileyCategory}
- {if !$smileyCategory->isDisabled}
- <div id="smilies-{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}-{@$smileyCategory->categoryID}">
- {if !$smileyCategory->categoryID}{@$__defaultSmilies}{/if}
- </div>
- {/if}
+ <div id="smilies-{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}-{@$smileyCategory->categoryID}">
+ {if !$smileyCategory->categoryID}{@$__defaultSmilies}{/if}
+ </div>
{/foreach}
<script data-relocate="true">
-{assign var=smileyCategories value=$__wcf->getSmileyCache()->getCategories()}
+{assign var=smileyCategories value=$__wcf->getSmileyCache()->getVisibleCategories()}
{if !$permissionCanUseSmilies|isset}{assign var=permissionCanUseSmilies value='user.message.canUseSmilies'}{/if}
{if !$wysiwygContainerID|isset}{assign var=wysiwygContainerID value='text'}{/if}
$('.messageTabMenu').messageTabMenu();
});
//]]>
-</script>
\ No newline at end of file
+</script>
*/
protected $cachedCategories = array();
+ /**
+ * enabled smiley categories with at least one smiley
+ * @var array<\wcf\data\smiley\category\SmileyCategory>
+ */
+ protected $visibleCategories = null;
+
/**
* @see \wcf\system\SingletonFactory::init()
*/
return $this->cachedCategories;
}
+ /**
+ * Returns all enabled smiley categories with at least one smiley.
+ *
+ * @return array<\wcf\data\smiley\category\SmileyCategory>
+ */
+ public function getVisibleCategories() {
+ if ($this->visibleCategories === null) {
+ $this->visibleCategories = array();
+
+ foreach ($this->cachedCategories as $key => $category) {
+ if (!$category->isDisabled) {
+ $category->loadSmilies();
+
+ if (count($category)) {
+ $this->visibleCategories[$key] = $category;
+ }
+ }
+ }
+ }
+
+ return $this->visibleCategories;
+ }
+
/**
* Returns all the smilies of a category.
*
// get default smilies
if (MODULE_SMILEY) {
- $this->smileyCategories = SmileyCache::getInstance()->getCategories();
- foreach ($this->smileyCategories as $index => $category) {
- $category->loadSmilies();
-
- // remove empty categories
- if (!count($category) || $category->isDisabled) {
- unset($this->smileyCategories[$index]);
- }
- }
+ $this->smileyCategories = SmileyCache::getInstance()->getVisibleCategories();
$firstCategory = reset($this->smileyCategories);
if ($firstCategory) {