From: Matthias Schmidt Date: Sun, 10 Mar 2019 14:11:53 +0000 (+0100) Subject: Change `WysiwygSmileyFormField` to `WysiwygSmileyFormNode` X-Git-Tag: 5.2.0_Alpha_1~228^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=196722ce54a633265c34d53d0bd63a6b4a6dcb18;p=GitHub%2FWoltLab%2FWCF.git Change `WysiwygSmileyFormField` to `WysiwygSmileyFormNode` See #2852 --- diff --git a/com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl b/com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl deleted file mode 100644 index 422140bc01..0000000000 --- a/com.woltlab.wcf/templates/__wysiwygSmileyFormField.tpl +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl b/com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl new file mode 100644 index 0000000000..eb8d7e6539 --- /dev/null +++ b/com.woltlab.wcf/templates/__wysiwygSmileyFormNode.tpl @@ -0,0 +1,5 @@ + diff --git a/syncTemplates.json b/syncTemplates.json index 28fabe23a5..f98b8e2307 100644 --- a/syncTemplates.json +++ b/syncTemplates.json @@ -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 index 422140bc01..0000000000 --- a/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormField.tpl +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl b/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl new file mode 100644 index 0000000000..422140bc01 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/__wysiwygSmileyFormNode.tpl @@ -0,0 +1,5 @@ + diff --git a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygSmileyFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygSmileyFormContainer.class.php index f3a6406f0d..f80198aef3 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygSmileyFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygSmileyFormContainer.class.php @@ -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 index 582da24052..0000000000 --- a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygSmileyFormField.class.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @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 index 0000000000..46b419f7ef --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/wysiwyg/WysiwygSmileyFormNode.class.php @@ -0,0 +1,99 @@ + + * @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 + } +}