Updated HTML implementation
authorAlexander Ebert <ebert@woltlab.com>
Thu, 26 May 2016 08:36:05 +0000 (10:36 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 26 May 2016 08:36:13 +0000 (10:36 +0200)
files/lib/data/conversation/ConversationAction.class.php
files/lib/data/conversation/message/ConversationMessage.class.php
files/lib/data/conversation/message/ConversationMessageAction.class.php
files/lib/form/ConversationAddForm.class.php

index 3bb08d4e63aad801c3b3da197ca51fc52bf8725c..66af74538bc6cece45fec89861451e69a10b0ff9 100644 (file)
@@ -108,7 +108,8 @@ class ConversationAction extends AbstractDatabaseObjectAction implements IClipbo
                        'data' => $messageData,
                        'conversation' => $conversation,
                        'isFirstPost' => true,
-                       'attachmentHandler' => (isset($this->parameters['attachmentHandler']) ? $this->parameters['attachmentHandler'] : null)
+                       'attachmentHandler' => (isset($this->parameters['attachmentHandler']) ? $this->parameters['attachmentHandler'] : null),
+                       'htmlInputProcessor' => (isset($this->parameters['htmlInputProcessor']) ? $this->parameters['htmlInputProcessor'] : null)
                ]);
                $resultValues = $messageAction->executeAction();
                
index b3199d7f0da409ec7a78b52977416d49a53c0380..6d230c37c70d56c4cb4db8b823ee5bec625b5948 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\DatabaseObject;
 use wcf\data\IMessage;
 use wcf\data\TUserContent;
 use wcf\system\bbcode\MessageParser;
+use wcf\system\html\output\HtmlOutputProcessor;
 use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -63,9 +64,13 @@ class ConversationMessage extends DatabaseObject implements IMessage {
                // assign embedded objects
                MessageEmbeddedObjectManager::getInstance()->setActiveMessage('com.woltlab.wcf.conversation.message', $this->messageID);
                
+               // TODO
+               return (new HtmlOutputProcessor())->process($this->message);
+               
+               // TODO
                // parse and return message
-               MessageParser::getInstance()->setOutputType('text/html');
-               return MessageParser::getInstance()->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes);
+               /*MessageParser::getInstance()->setOutputType('text/html');
+               return MessageParser::getInstance()->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes);*/
        }
        
        /**
index 6bbb2ef1cd58b14342be5b2a518290259b939e7b..2e6aa0f7d35c97207c7672a825b1cc5a04740f8f 100644 (file)
@@ -15,6 +15,7 @@ use wcf\system\bbcode\BBCodeParser;
 use wcf\system\bbcode\PreParser;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
+use wcf\system\html\input\HtmlInputProcessor;
 use wcf\system\message\censorship\Censorship;
 use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\message\quote\MessageQuoteManager;
@@ -83,6 +84,12 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
                        }
                }
                
+               if (!empty($this->parameters['htmlInputProcessor'])) {
+                       /** @var HtmlInputProcessor $htmlInputProcessor */
+                       $htmlInputProcessor = $this->parameters['htmlInputProcessor'];
+                       $this->parameters['data']['message'] = $htmlInputProcessor->getHtml();
+               }
+               
                // create message
                $message = parent::create();
                $messageEditor = new ConversationMessageEditor($message);
@@ -375,7 +382,8 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
                }
                
                $this->validateBeginEdit();
-               $this->validateMessage($this->conversation, $this->parameters['data']['message']);
+               
+               $this->validateMessage($this->conversation, $this->getHtmlInputProcessor($this->parameters['data']['message']));
        }
        
        /**
@@ -383,8 +391,9 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
         */
        public function save() {
                $data = [
-                       'message' => PreParser::getInstance()->parse(MessageUtil::stripCrap($this->parameters['data']['message']), explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes')))
+                       //'message' => PreParser::getInstance()->parse(MessageUtil::stripCrap($this->parameters['data']['message']), explode(',', WCF::getSession()->getPermission('user.message.allowedBBCodes')))
                ];
+               
                if (!$this->message->getConversation()->isDraft) {
                        $data['lastEditTime'] = TIME_NOW;
                        $data['editCount'] = $this->message->editCount + 1;
@@ -455,8 +464,8 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
        /**
         * @inheritDoc
         */
-       public function validateMessage(DatabaseObject $container, $message) {
-               if (mb_strlen($message) > WCF::getSession()->getPermission('user.conversation.maxLength')) {
+       public function validateMessage(DatabaseObject $container, HtmlInputProcessor $htmlInputProcessor) {
+               /*if (mb_strlen($message) > WCF::getSession()->getPermission('user.conversation.maxLength')) {
                        throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.tooLong', ['maxTextLength' => WCF::getSession()->getPermission('user.conversation.maxLength')]));
                }
                
@@ -472,7 +481,7 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
                        if ($result) {
                                throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.censoredWordsFound', ['censoredWords' => $result]));
                        }
-               }
+               }*/
        }
        
        /**
@@ -615,4 +624,18 @@ class ConversationMessageAction extends AbstractDatabaseObjectAction implements
        public function getAttachmentHandler(DatabaseObject $conversation) {
                return new AttachmentHandler('com.woltlab.wcf.conversation.message', 0, $this->parameters['tmpHash']);
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getHtmlInputProcessor($message = null) {
+               if ($message === null) {
+                       return $this->htmlInputProcessor;
+               }
+               
+               $this->htmlInputProcessor = new HtmlInputProcessor();
+               $this->htmlInputProcessor->process($message);
+               
+               return $this->htmlInputProcessor;
+       }
 }
index 48bf944e94f2b8d8c771049403a0b7275b989d54..6521dd2819ded21e0ac01ea4c062ac33161497d7 100644 (file)
@@ -196,13 +196,8 @@ class ConversationAddForm extends MessageForm {
                $conversationData = [
                        'data' => $data,
                        'attachmentHandler' => $this->attachmentHandler,
-                       'messageData' => [
-                               'message' => $this->text,
-                               'enableBBCodes' => $this->enableBBCodes,
-                               'enableHtml' => $this->enableHtml,
-                               'enableSmilies' => $this->enableSmilies,
-                               'showSignature' => $this->showSignature
-                       ]
+                       'htmlInputProcessor' => $this->htmlInputProcessor,
+                       'messageData' => []
                ];
                if (!$this->draft) {
                        $conversationData['participants'] = $this->participantIDs;