f80198aef37bfe0aa18ad300083a57206d67d17c
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\form\builder\container\wysiwyg;
3 use wcf\data\smiley\SmileyCache;
4 use wcf\system\form\builder\container\FormContainer;
5 use wcf\system\form\builder\container\TabFormContainer;
6 use wcf\system\form\builder\container\TabTabMenuFormContainer;
7 use wcf\system\form\builder\wysiwyg\WysiwygSmileyFormNode;
8 use wcf\system\form\builder\TWysiwygFormNode;
9 use wcf\util\StringUtil;
10
11 /**
12 * Represents the tab for the smiley-related fields below a WYSIWYG editor.
13 *
14 * @author Matthias Schmidt
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\Form\Builder\Container\Wysiwyg
18 * @since 5.2
19 */
20 class WysiwygSmileyFormContainer extends TabTabMenuFormContainer {
21 use TWysiwygFormNode;
22
23 /**
24 * name of container template
25 * @var string
26 */
27 protected $templateName = '__wysiwygSmileyFormContainer';
28
29 /**
30 * Creates a new instance of `WysiwygSmileyFormContainer`.
31 */
32 public function __construct() {
33 $this->attribute('data-preselect', 'true')
34 ->attribute('data-collapsible', 'false')
35 ->useAnchors(false);
36 }
37
38 /**
39 * @inheritDoc
40 */
41 public function populate() {
42 parent::populate();
43
44 $smileyCategories = SmileyCache::getInstance()->getCategories();
45
46 foreach ($smileyCategories as $smileyCategory) {
47 $smileyCategory->loadSmilies();
48 if (count($smileyCategory) > 0) {
49 $this->appendChild(
50 TabFormContainer::create($this->getId() . '_smileyCategoryTab' . $smileyCategory->categoryID)
51 ->label(StringUtil::encodeHTML($smileyCategory->getTitle()))
52 ->removeClass('tabMenuContent')
53 ->addClass('messageTabMenuContent')
54 ->appendChild(
55 FormContainer::create($this->getId() . '_smileyCategoryContainer' . $smileyCategory->categoryID)
56 ->removeClass('section')
57 ->appendChild(
58 WysiwygSmileyFormNode::create($this->getId() . '_smileyCategory' . $smileyCategory->categoryID)
59 ->smilies(SmileyCache::getInstance()->getCategorySmilies($smileyCategory->categoryID ?: null))
60 )
61 )
62 );
63 }
64 }
65
66 if (count($this->children()) > 1) {
67 $this->addClass('messageTabMenu');
68 }
69 }
70 }