Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / option / MessageOptionType.class.php
index 9acbf10c5d9196947acb553c8341e9045ef9d86c..b13d2e8c31878c4afc61844e69f3a765404d66d0 100644 (file)
@@ -1,5 +1,7 @@
 <?php
+
 namespace wcf\system\option;
+
 use wcf\data\option\Option;
 use wcf\data\smiley\SmileyCache;
 use wcf\system\bbcode\BBCodeHandler;
@@ -10,71 +12,83 @@ use wcf\util\ArrayUtil;
 
 /**
  * Option type implementation for message.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Option
+ *
+ * @author  Marcel Werk
+ * @copyright   2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Option
  */
-class MessageOptionType extends TextareaOptionType {
-       /**
-        * @var HtmlInputProcessor
-        */
-       protected $htmlInputProcessor;
-       
-       /**
-        * object type for definition 'com.woltlab.wcf.message'
-        * @var string
-        */
-       protected $messageObjectType = '';
-       
-       /**
-        * @inheritDoc
-        */
-       public function getData(Option $option, $newValue) {
-               if (!$this->messageObjectType) $this->messageObjectType = $option->messageObjectType;
-               if (empty($this->messageObjectType)) {
-                       throw new \RuntimeException("Message object type '".$option->optionName."' requires an object type for definition 'com.woltlab.wcf.message'.");
-               }
-               
-               $permission = $option->disallowedbbcodepermission ?: 'user.message.disallowedBBCodes';
-               BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($permission))));
-               
-               $this->htmlInputProcessor = new HtmlInputProcessor();
-               
-               // the object id is fixed because options are not tied to a specific object
-               // especially when used in the user option context, such as "about me"
-               $this->htmlInputProcessor->process($newValue, $this->messageObjectType, 0);
-               
-               return parent::getData($option, $this->htmlInputProcessor->getHtml());
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function getFormElement(Option $option, $value) {
-               $permission = $option->disallowedbbcodepermission ?: 'user.message.disallowedBBCodes';
-               BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($permission))));
-               
-               WCF::getTPL()->assign([
-                       'defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(),
-                       'option' => $option,
-                       'value' => $value
-               ]);
-               
-               return WCF::getTPL()->fetch('messageOptionType');
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function validate(Option $option, $newValue) {
-               parent::validate($option, $newValue);
-               
-               $disallowedBBCodes = $this->htmlInputProcessor->validate();
-               if (!empty($disallowedBBCodes)) {
-                       WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
-                       throw new UserInputException($option->optionName, 'disallowedBBCodes');
-               }
-       }
+class MessageOptionType extends TextareaOptionType
+{
+    /**
+     * @var HtmlInputProcessor
+     */
+    protected $htmlInputProcessor;
+
+    /**
+     * object type for definition 'com.woltlab.wcf.message'
+     * @var string
+     */
+    protected $messageObjectType = '';
+
+    /**
+     * @inheritDoc
+     */
+    public function getData(Option $option, $newValue)
+    {
+        if (!$this->messageObjectType) {
+            $this->messageObjectType = $option->messageObjectType;
+        }
+        if (empty($this->messageObjectType)) {
+            throw new \RuntimeException("Message object type '" . $option->optionName . "' requires an object type for definition 'com.woltlab.wcf.message'.");
+        }
+
+        $permission = $option->disallowedbbcodepermission ?: 'user.message.disallowedBBCodes';
+        BBCodeHandler::getInstance()->setDisallowedBBCodes(\explode(
+            ',',
+            ArrayUtil::trim(WCF::getSession()->getPermission($permission))
+        ));
+
+        $this->htmlInputProcessor = new HtmlInputProcessor();
+
+        // the object id is fixed because options are not tied to a specific object
+        // especially when used in the user option context, such as "about me"
+        $this->htmlInputProcessor->process($newValue, $this->messageObjectType, 0);
+
+        return parent::getData($option, $this->htmlInputProcessor->getHtml());
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function getFormElement(Option $option, $value)
+    {
+        $permission = $option->disallowedbbcodepermission ?: 'user.message.disallowedBBCodes';
+        BBCodeHandler::getInstance()->setDisallowedBBCodes(\explode(
+            ',',
+            ArrayUtil::trim(WCF::getSession()->getPermission($permission))
+        ));
+
+        WCF::getTPL()->assign([
+            'defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(),
+            'option' => $option,
+            'value' => $value,
+        ]);
+
+        return WCF::getTPL()->fetch('messageOptionType');
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function validate(Option $option, $newValue)
+    {
+        parent::validate($option, $newValue);
+
+        $disallowedBBCodes = $this->htmlInputProcessor->validate();
+        if (!empty($disallowedBBCodes)) {
+            WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
+            throw new UserInputException($option->optionName, 'disallowedBBCodes');
+        }
+    }
 }