From: Alexander Ebert Date: Sun, 10 Jul 2016 15:52:36 +0000 (+0200) Subject: Added special methods for embedded content parsing only X-Git-Tag: 3.0.0_Beta_1~1218 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=52b50c4af62d85349e9e7ed28fd15ebef97edf07;p=GitHub%2FWoltLab%2FWCF.git Added special methods for embedded content parsing only --- diff --git a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php index 0ab678ae1b..997f90dd76 100644 --- a/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php @@ -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 } diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index 8e2b59ea1f..90bc8478fc 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -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. *