Smiley support when adding articles, boxes and pages
authorAlexander Ebert <ebert@woltlab.com>
Thu, 6 Dec 2018 23:06:16 +0000 (00:06 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 6 Dec 2018 23:06:16 +0000 (00:06 +0100)
See #2639

wcfsetup/install/files/acp/templates/__messageFormSmilies.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/articleAdd.tpl
wcfsetup/install/files/acp/templates/boxAdd.tpl
wcfsetup/install/files/acp/templates/messageFormSmilies.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/messageFormTabs.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php
wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php
wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
wcfsetup/install/files/lib/data/smiley/SmileyCache.class.php

diff --git a/wcfsetup/install/files/acp/templates/__messageFormSmilies.tpl b/wcfsetup/install/files/acp/templates/__messageFormSmilies.tpl
new file mode 100644 (file)
index 0000000..bb49b5f
--- /dev/null
@@ -0,0 +1,5 @@
+<ul class="inlineList smileyList">
+       {foreach from=$smilies item=smiley}
+               <li><a title="{lang}{$smiley->smileyTitle}{/lang}" class="jsTooltip jsSmiley">{@$smiley->getHtml()}</a></li>
+       {/foreach}
+</ul>
\ No newline at end of file
index 748f307c2d0c55f48de62e5bdfdba645ffb0f2a0..2dbf1e43cb71cf262f156855f0cbe9ebbc038b5f 100644 (file)
                        
                        {event name='messageFields'}
                </div>
+               
+               {include file='messageFormTabs' wysiwygContainerID='content0'}
        {else}
                <div class="section tabMenuContainer">
                        <nav class="tabMenu">
                                                
                                                {event name='messageFieldsMultilingual'}
                                        </div>
+                                       
+                                       {include file='messageFormTabs' wysiwygContainerID='content'|concat:$availableLanguage->languageID}
                                </div>
                        {/foreach}
                </div>
index e3e1368d787d246b5a644bc19933546d21cfc08f..1c466993a108fcca11a0a2ba2f52a4d8c17da49b 100644 (file)
                                                </dd>
                                        </dl>
                                </div>
+                               
+                               {if $boxType == 'text'}
+                                       {include file='messageFormTabs' wysiwygContainerID='content0'}
+                               {/if}
                        {else}
                                <div class="tabMenuContainer">
                                        <nav class="menu">
                                                                                        {/if}
                                                                                </dd>
                                                                        </dl>
+                                                                       
+                                                                       {if $boxType == 'text'}
+                                                                               {include file='messageFormTabs' wysiwygContainerID='content'|concat:$availableLanguage->languageID}
+                                                                       {/if}
                                                                {/if}
                                                        </div>
                                                </div>
diff --git a/wcfsetup/install/files/acp/templates/messageFormSmilies.tpl b/wcfsetup/install/files/acp/templates/messageFormSmilies.tpl
new file mode 100644 (file)
index 0000000..ae7276d
--- /dev/null
@@ -0,0 +1,55 @@
+{if !$__messageFormSmiliesJavascript|isset}
+       {assign var='__messageFormSmiliesJavascript' value=true}
+       
+       {js application='wcf' file='WCF.Message' bundle='WCF.Combined'}
+{/if}
+
+{assign var=__tabCount value=0}
+{capture assign=__categoryTabs}
+       {foreach from=$smileyCategories item=smileyCategory}
+               {assign var=__tabCount value=$__tabCount + 1}
+               {assign var='__smileyAnchor' value='smilies-'|concat:$smileyCategory->categoryID}
+               <li data-name="smilies-{@$smileyCategory->categoryID}" data-smiley-category-id="{@$smileyCategory->categoryID}"><a>{$smileyCategory->title|language}</a></li>
+       {/foreach}
+{/capture}
+
+<div class="messageTabMenuContent{if $__tabCount} messageTabMenu{/if}" data-preselect="true" data-collapsible="false" id="smilies-{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}">
+       {capture assign=__defaultSmilies}
+               {assign var='__firstSmileyCategory' value=$smileyCategories|reset}
+               {if $__firstSmileyCategory->categoryID}
+                       {include file='__messageFormSmilies' smilies=$__wcf->getSmileyCache()->getCategorySmilies($__firstSmileyCategory->categoryID)}
+               {else}
+                       {include file='__messageFormSmilies' smilies=$__wcf->getSmileyCache()->getCategorySmilies()}
+               {/if}
+       {/capture}
+       
+       {if $__tabCount > 1}
+               <nav class="jsOnly">
+                       <ul>
+                               {@$__categoryTabs}
+                       </ul>
+               </nav>
+               
+               {foreach from=$smileyCategories item=smileyCategory}
+                       <div class="messageTabMenuContent" id="smilies-{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}-{@$smileyCategory->categoryID}">
+                               {if !$smileyCategory->categoryID}{@$__defaultSmilies}{/if}
+                       </div>
+               {/foreach}
+               
+               <script data-relocate="true">
+                       $(function() {
+                               new WCF.Message.SmileyCategories('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}');
+                       });
+               </script>
+       {else}
+               {@$__defaultSmilies}
+       {/if}
+       
+       {event name='fields'}
+       
+       <script data-relocate="true">
+               $(function() {
+                       new WCF.Message.Smilies('{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}');
+               });
+       </script>
+</div>
diff --git a/wcfsetup/install/files/acp/templates/messageFormTabs.tpl b/wcfsetup/install/files/acp/templates/messageFormTabs.tpl
new file mode 100644 (file)
index 0000000..e9f7ee4
--- /dev/null
@@ -0,0 +1,22 @@
+{hascontent}
+       <div class="messageTabMenu" data-preselect="{if $preselectTabMenu|isset}{$preselectTabMenu}{else}false{/if}" data-wysiwyg-container-id="{if $wysiwygContainerID|isset}{$wysiwygContainerID}{else}text{/if}">
+               <nav class="messageTabMenuNavigation jsOnly">
+                       <ul>
+                               {content}
+                                       {if MODULE_SMILEY && !$smileyCategories|empty}<li data-name="smilies"><a><span class="icon icon16 fa-smile-o"></span> <span>{lang}wcf.message.smilies{/lang}</span></a></li>{/if}
+                                       {event name='tabMenuTabs'}
+                               {/content}
+                       </ul>
+               </nav>
+               
+               {if MODULE_SMILEY && !$smileyCategories|empty}{include file='messageFormSmilies'}{/if}
+               
+               {event name='tabMenuContents'}
+       </div>
+       
+       <script data-relocate="true">
+               $(function() {
+                       $('.messageTabMenu').messageTabMenu();
+               });
+       </script>
+{/hascontent}
index 9b53072948a61a8158cf91b5ed8668978fc16929..efd8caf2be9316a356a896fbe0a7f8c6b1990fd3 100644 (file)
                                                </dd>
                                        </dl>
                                        
+                                       {if $pageType == 'text'}
+                                               {include file='messageFormTabs' wysiwygContainerID='content0'}
+                                       {/if}
+                                       
                                        <dl{if $errorField == 'metaDescription'} class="formError"{/if}>
                                                <dt><label for="metaDescription">{lang}wcf.acp.page.metaDescription{/lang}</label></dt>
                                                <dd>
                                                                                </dd>
                                                                        </dl>
                                                                        
+                                                                       {if $pageType == 'text'}
+                                                                               {include file='messageFormTabs' wysiwygContainerID='content'|concat:$availableLanguage->languageID}
+                                                                       {/if}
+                                                                       
                                                                        {assign var='__errorFieldName' value='metaDescription_'|concat:$availableLanguage->languageID}
                                                                        <dl{if $errorField == $__errorFieldName} class="formError"{/if}>
                                                                                <dt><label for="metaDescription{@$availableLanguage->languageID}">{lang}wcf.acp.page.metaDescription{/lang}</label></dt>
index 72988440cad167d566b7711d53ee222c077cd778..ece07c90b7a7439a50c17ff0d11c74c594b7eee7 100644 (file)
@@ -8,6 +8,7 @@ use wcf\data\label\group\ViewableLabelGroup;
 use wcf\data\language\Language;
 use wcf\data\media\Media;
 use wcf\data\media\ViewableMediaList;
+use wcf\data\smiley\SmileyCache;
 use wcf\data\user\User;
 use wcf\form\AbstractForm;
 use wcf\system\cache\builder\ArticleCategoryLabelCacheBuilder;
@@ -487,6 +488,8 @@ class ArticleAddForm extends AbstractForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               SmileyCache::getInstance()->assignVariables();
+               
                WCF::getTPL()->assign([
                        'action' => 'add',
                        'isMultilingual' => $this->isMultilingual,
index 2ea205265f9a02651719cf157756ea1c35447521..db8beaf57f14de30b0163f89c39f66a66377204a 100644 (file)
@@ -9,6 +9,7 @@ use wcf\data\object\type\ObjectType;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\page\Page;
 use wcf\data\page\PageNodeTree;
+use wcf\data\smiley\SmileyCache;
 use wcf\form\AbstractForm;
 use wcf\system\acl\simple\SimpleAclHandler;
 use wcf\system\box\IBoxController;
@@ -622,6 +623,8 @@ class BoxAddForm extends AbstractForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               SmileyCache::getInstance()->assignVariables();
+               
                WCF::getTPL()->assign([
                        'action' => 'add',
                        'isMultilingual' => $this->isMultilingual,
index 3881337fc215807536b91e8689da782dbbf31144..4f87cbaa73e87779ca37a4e9f2c3fe0ee25cf206 100644 (file)
@@ -14,6 +14,7 @@ use wcf\data\page\Page;
 use wcf\data\page\PageAction;
 use wcf\data\page\PageEditor;
 use wcf\data\page\PageNodeTree;
+use wcf\data\smiley\SmileyCache;
 use wcf\form\AbstractForm;
 use wcf\system\acl\simple\SimpleAclHandler;
 use wcf\system\exception\IllegalLinkException;
@@ -699,6 +700,8 @@ class PageAddForm extends AbstractForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               SmileyCache::getInstance()->assignVariables();
+               
                WCF::getTPL()->assign([
                        'action' => 'add',
                        'parentPageID' => $this->parentPageID,
index 69a65067fbe0e4cb0dc8619c7b3856034d5d18cd..e9bb88477bdcbfbf743c23ad0724306781d0338b 100644 (file)
@@ -5,6 +5,7 @@ use wcf\data\smiley\category\SmileyCategory;
 use wcf\system\cache\builder\SmileyCacheBuilder;
 use wcf\system\category\CategoryHandler;
 use wcf\system\SingletonFactory;
+use wcf\system\WCF;
 
 /**
  * Manages the smiley cache.
@@ -128,4 +129,27 @@ class SmileyCache extends SingletonFactory {
                
                return [];
        }
+       
+       /**
+        * Assigns the smilies and their categories to the template.
+        * 
+        * @since 3.2
+        */
+       public function assignVariables() {
+               if (!MODULE_SMILEY) {
+                       return;
+               }
+               
+               $smileyCategories = $this->getVisibleCategories();
+               $firstCategory = reset($smileyCategories);
+               $defaultSmilies = [];
+               if ($firstCategory) {
+                       $defaultSmilies = $this->getCategorySmilies($firstCategory->categoryID ?: null);
+               }
+               
+               WCF::getTPL()->assign([
+                       'defaultSmilies' => $defaultSmilies,
+                       'smileyCategories' => $smileyCategories,
+               ]);
+       }
 }