Update ConversationMessageRebuildDataWorker
authorMatthias Schmidt <gravatronics@live.com>
Mon, 22 Aug 2016 14:34:32 +0000 (16:34 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 22 Aug 2016 14:34:32 +0000 (16:34 +0200)
files/lib/system/worker/ConversationMessageRebuildDataWorker.class.php

index 7bb1cd5469bc50b8df78c547c734895328e5b906..55c3ec23508d757502cbfb2c8f60f8b1a0f79046 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\conversation\message\ConversationMessageEditor;
 use wcf\data\conversation\message\ConversationMessageList;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\system\exception\SystemException;
+use wcf\system\html\input\HtmlInputProcessor;
 use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
 use wcf\system\search\SearchIndexManager;
 use wcf\system\WCF;
@@ -22,6 +23,11 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker {
         */
        protected $limit = 500;
        
+       /**
+        * @var HtmlInputProcessor
+        */
+       protected $htmlInputProcessor;
+       
        /** @noinspection PhpMissingParentCallCommonInspection */
        /**
         * @inheritDoc
@@ -89,11 +95,35 @@ class ConversationMessageRebuildDataWorker extends AbstractRebuildDataWorker {
                        $row = $attachmentStatement->fetchSingleRow();
                        $data['attachments'] = $row['attachments'];
                        
-                       // update embedded objects
-                       throw new SystemException("TODO: we need the html input processor here");
-                       $data['hasEmbeddedObjects'] = (MessageEmbeddedObjectManager::getInstance()->registerObjects('com.woltlab.wcf.conversation.message') ? 1 : 0);
+                       // update message
+                       if (!$message->enableHtml) {
+                               $this->getHtmlInputProcessor()->process($message->message, 'com.woltlab.wcf.conversation.message', $message->messageID, true);
+                               $data['message'] = $this->getHtmlInputProcessor()->getHtml();
+                               $data['enableHtml'] = 1;
+                       }
+                       else {
+                               $this->getHtmlInputProcessor()->processEmbeddedContent($message->message, 'com.woltlab.wcf.conversation.message', $message->messageID);
+                       }
+                       
+                       if (MessageEmbeddedObjectManager::getInstance()->registerObjects($this->getHtmlInputProcessor())) {
+                               $data['hasEmbeddedObjects'] = 1;
+                       }
+                       else {
+                               $data['hasEmbeddedObjects'] = 0;
+                       }
                        
                        $editor->update($data);
                }
        }
+       
+       /**
+        * @return      HtmlInputProcessor
+        */
+       protected function getHtmlInputProcessor() {
+               if ($this->htmlInputProcessor === null) {
+                       $this->htmlInputProcessor = new HtmlInputProcessor();
+               }
+               
+               return $this->htmlInputProcessor;
+       }
 }