Change `WysiwygSmileyFormField` to `WysiwygSmileyFormNode`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 10 Mar 2019 14:11:53 +0000 (15:11 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 10 Mar 2019 14:11:53 +0000 (15:11 +0100)
See #2852

com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl [deleted file]
com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl [new file with mode: 0644]
syncTemplates.json
wcfsetup/install/files/acp/templates/__wysiwygSmileyFormField.tpl [deleted file]
wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygSmileyFormContainer.class.php
wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygSmileyFormField.class.php [deleted file]
wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php [new file with mode: 0644]

diff --git a/com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl b/com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl
deleted file mode 100644 (file)
index 422140b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<ul class="inlineList smileyList">
-       {foreach from=$field->getSmilies() item=smiley}
-               <li><a title="{lang}{$smiley->smileyTitle}{/lang}" class="jsTooltip jsSmiley">{@$smiley->getHtml()}</a></li>
-       {/foreach}
-</ul>
diff --git a/com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl b/com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl
new file mode 100644 (file)
index 0000000..eb8d7e6
--- /dev/null
@@ -0,0 +1,5 @@
+<ul class="inlineList smileyList">
+       {foreach from=$node->getSmilies() item=smiley}
+               <li><a title="{lang}{$smiley->smileyTitle}{/lang}" class="jsTooltip jsSmiley">{@$smiley->getHtml()}</a></li>
+       {/foreach}
+</ul>
index 28fabe23a5600dff697fa0d407b19cff7574e82a..f98b8e2307a420dcf73905fc8bd38c13807b8746 100644 (file)
@@ -45,7 +45,7 @@
     "__wysiwygFormField",
     "__wysiwygPreviewFormButton",
     "__wysiwygSmileyFormContainer",
-    "__wysiwygSmileyFormField",
+    "__wysiwygSmileyFormNode",
     "aclPermissionJavaScript",
     "articleAdd",
     "articleAddDialog",
diff --git a/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormField.tpl b/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormField.tpl
deleted file mode 100644 (file)
index 422140b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<ul class="inlineList smileyList">
-       {foreach from=$field->getSmilies() item=smiley}
-               <li><a title="{lang}{$smiley->smileyTitle}{/lang}" class="jsTooltip jsSmiley">{@$smiley->getHtml()}</a></li>
-       {/foreach}
-</ul>
diff --git a/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl b/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl
new file mode 100644 (file)
index 0000000..422140b
--- /dev/null
@@ -0,0 +1,5 @@
+<ul class="inlineList smileyList">
+       {foreach from=$field->getSmilies() item=smiley}
+               <li><a title="{lang}{$smiley->smileyTitle}{/lang}" class="jsTooltip jsSmiley">{@$smiley->getHtml()}</a></li>
+       {/foreach}
+</ul>
index f3a6406f0d57f078caa09750650a254ae428e390..f80198aef37bfe0aa18ad300083a57206d67d17c 100644 (file)
@@ -4,7 +4,7 @@ use wcf\data\smiley\SmileyCache;
 use wcf\system\form\builder\container\FormContainer;
 use wcf\system\form\builder\container\TabFormContainer;
 use wcf\system\form\builder\container\TabTabMenuFormContainer;
-use wcf\system\form\builder\field\wysiwyg\WysiwygSmileyFormField;
+use wcf\system\form\builder\wysiwyg\WysiwygSmileyFormNode;
 use wcf\system\form\builder\TWysiwygFormNode;
 use wcf\util\StringUtil;
 
@@ -55,7 +55,7 @@ class WysiwygSmileyFormContainer extends TabTabMenuFormContainer {
                                                        FormContainer::create($this->getId() . '_smileyCategoryContainer' . $smileyCategory->categoryID)
                                                                ->removeClass('section')
                                                                ->appendChild(
-                                                                       WysiwygSmileyFormField::create($this->getId() . '_smileyCategory' . $smileyCategory->categoryID)
+                                                                       WysiwygSmileyFormNode::create($this->getId() . '_smileyCategory' . $smileyCategory->categoryID)
                                                                                ->smilies(SmileyCache::getInstance()->getCategorySmilies($smileyCategory->categoryID ?: null))
                                                                )
                                                )
diff --git a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygSmileyFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygSmileyFormField.class.php
deleted file mode 100644 (file)
index 582da24..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-namespace wcf\system\form\builder\field\wysiwyg;
-use wcf\data\smiley\Smiley;
-use wcf\system\form\builder\field\AbstractFormField;
-
-/**
- * Implementation of a form field for the list smilies of a certain category used by a wysiwyg
- * form container.
- * 
- * This is no really a form field in that it does not read any data but only prints data.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field
- * @since      5.2
- */
-class WysiwygSmileyFormField extends AbstractFormField {
-       /**
-        * list of available smilies
-        * @var Smiley[]
-        */
-       protected $smilies = [];
-       
-       /**
-        * @inheritDoc
-        */
-       protected $templateName = '__wysiwygSmileyFormField';
-       
-       /**
-        * Returns the list of available smilies.
-        * 
-        * @return      Smiley[]
-        */
-       public function getSmilies() {
-               return $this->smilies;
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function hasSaveValue() {
-               return false;
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function isAvailable() {
-               return parent::isAvailable() && !empty($this->smilies);
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function readValue() {
-               // does nothing
-       }
-       
-       /**
-        * Sets the list of available smilies.
-        * 
-        * @param       Smiley[]        $smilies        available smilies
-        * @return      WysiwygSmileyFormField          this form field
-        */
-       public function smilies(array $smilies) {
-               foreach ($smilies as $smiley) {
-                       if (!is_object($smiley)) {
-                               throw new \InvalidArgumentException("Given value array contains invalid value of type " . gettype($smiley) . ".");
-                       }
-                       else if (!($smiley instanceof Smiley)) {
-                               throw new \InvalidArgumentException("Given value array contains invalid object of class " . get_class($smiley) . ".");
-                       }
-               }
-               
-               $this->smilies = $smilies;
-               
-               return $this;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php
new file mode 100644 (file)
index 0000000..46b419f
--- /dev/null
@@ -0,0 +1,99 @@
+<?php
+namespace wcf\system\form\builder\wysiwyg;
+use wcf\data\smiley\Smiley;
+use wcf\system\form\builder\IFormChildNode;
+use wcf\system\form\builder\TFormChildNode;
+use wcf\system\form\builder\TFormNode;
+use wcf\system\WCF;
+
+/**
+ * Implementation of a form field for the list smilies of a certain category used by a wysiwyg
+ * form container.
+ * 
+ * This is no really a form field in that it does not read any data but only prints data.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field
+ * @since      5.2
+ */
+class WysiwygSmileyFormNode implements IFormChildNode {
+       use TFormChildNode;
+       use TFormNode {
+               isAvailable as traitIsAvailable;
+       }
+       
+       /**
+        * list of available smilies
+        * @var Smiley[]
+        */
+       protected $smilies = [];
+       
+       /**
+        * @inheritDoc
+        */
+       public function getHtml() {
+               return WCF::getTPL()->fetch('__wysiwygSmileyFormNode', 'wcf', [
+                       'node' => $this
+               ]);
+       }
+       
+       /**
+        * Returns the list of available smilies.
+        * 
+        * @return      Smiley[]
+        */
+       public function getSmilies() {
+               return $this->smilies;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function hasSaveValue() {
+               return false;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function isAvailable() {
+               return $this->traitIsAvailable() && !empty($this->smilies);
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function readValue() {
+               // does nothing
+       }
+       
+       /**
+        * Sets the list of available smilies.
+        * 
+        * @param       Smiley[]        $smilies        available smilies
+        * @return      WysiwygSmileyFormNode           this form field
+        */
+       public function smilies(array $smilies) {
+               foreach ($smilies as $smiley) {
+                       if (!is_object($smiley)) {
+                               throw new \InvalidArgumentException("Given value array contains invalid value of type " . gettype($smiley) . ".");
+                       }
+                       else if (!($smiley instanceof Smiley)) {
+                               throw new \InvalidArgumentException("Given value array contains invalid object of class " . get_class($smiley) . ".");
+                       }
+               }
+               
+               $this->smilies = $smilies;
+               
+               return $this;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function validate() {
+               // does nothing
+       }
+}