From 52b50c4af62d85349e9e7ed28fd15ebef97edf07 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 10 Jul 2016 17:52:36 +0200 Subject: [PATCH] Added special methods for embedded content parsing only --- .../html/input/HtmlInputProcessor.class.php | 21 +++++++++++++++++++ .../node/HtmlInputNodeProcessor.class.php | 13 +++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) 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. * -- 2.20.1