Added special methods for embedded content parsing only
authorAlexander Ebert <ebert@woltlab.com>
Sun, 10 Jul 2016 15:52:36 +0000 (17:52 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 10 Jul 2016 15:52:42 +0000 (17:52 +0200)
wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php

index 0ab678ae1bca99c4bfc6aea833a7fd1b4eb79f27..997f90dd764336afafecabc874331fd3e688c278 100644 (file)
@@ -58,6 +58,27 @@ class HtmlInputProcessor extends AbstractHtmlProcessor {
                $this->embeddedContent = $this->getHtmlInputNodeProcessor()->getEmbeddedContent();
        }
        
+       /**
+        * Processes only embedded content. This method should only be called when rebuilding
+        * data where only embedded content is relevant, but no actual parsing is required.
+        * 
+        * @param       string          $html           html string
+        * @param       string          $objectType     object type identifier
+        * @param       integer         $objectID       object id
+        * @throws      \UnexpectedValueException
+        */
+       public function processEmbeddedContent($html, $objectType, $objectID) {
+               if (!$objectID) {
+                       throw new \UnexpectedValueException("Object id parameter must be non-zero.");
+               }
+               
+               $this->setContext($objectType, $objectID);
+               
+               $this->getHtmlInputNodeProcessor()->load($this, $html);
+               $this->getHtmlInputNodeProcessor()->processEmbeddedContent();
+               $this->embeddedContent = $this->getHtmlInputNodeProcessor()->getEmbeddedContent();
+       }
+       
        public function validate() {
                // TODO
        }
index 8e2b59ea1f1ac54723df39a587b7f0a0c19b9e8e..90bc8478fc633e77c21f009a216bdffcc27a554e 100644 (file)
@@ -30,8 +30,6 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
        public function process() {
                EventHandler::getInstance()->fireAction($this, 'beforeProcess');
                
-               $this->embeddedContent = [];
-               
                // process metacode markers first
                $this->invokeHtmlNode(new HtmlInputNodeWoltlabMetacodeMarker());
                
@@ -47,11 +45,20 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor {
                $textParser->parse();
                
                // extract embedded content
-               $this->parseEmbeddedContent();
+               $this->processEmbeddedContent();
                
                EventHandler::getInstance()->fireAction($this, 'afterProcess');
        }
        
+       /**
+        * Processes embedded content.
+        */
+       public function processEmbeddedContent() {
+               $this->embeddedContent = [];
+               
+               $this->parseEmbeddedContent();
+       }
+       
        /**
         * Returns the embedded content grouped by type.
         *