From: Marcel Werk Date: Mon, 17 Oct 2016 22:24:57 +0000 (+0200) Subject: Fixed embedded objects in boxes X-Git-Tag: 3.0.0_Beta_3~18 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=be58327fa212947358693ad7c57a34c8f3f6f868;p=GitHub%2FWoltLab%2FWCF.git Fixed embedded objects in boxes --- diff --git a/wcfsetup/install/files/lib/data/box/BoxAction.class.php b/wcfsetup/install/files/lib/data/box/BoxAction.class.php index 42e0f1ce0f..c100bf66ec 100644 --- a/wcfsetup/install/files/lib/data/box/BoxAction.class.php +++ b/wcfsetup/install/files/lib/data/box/BoxAction.class.php @@ -91,7 +91,9 @@ class BoxAction extends AbstractDatabaseObjectAction { } } else if ($box->boxType == 'html' || $box->boxType == 'tpl') { - HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content); + if (HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content)) { + $boxContentEditor->update(['hasEmbeddedObjects' => 1]); + } } } } @@ -172,7 +174,9 @@ class BoxAction extends AbstractDatabaseObjectAction { } } else if ($box->boxType == 'html' || $box->boxType == 'tpl') { - HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content); + if ($boxContent->hasEmbeddedObjects != HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content)) { + $boxContentEditor->update(['hasEmbeddedObjects' => $boxContent->hasEmbeddedObjects ? 0 : 1]); + } } } diff --git a/wcfsetup/install/files/lib/data/box/BoxList.class.php b/wcfsetup/install/files/lib/data/box/BoxList.class.php index fb5f5fe150..a4b2258e55 100644 --- a/wcfsetup/install/files/lib/data/box/BoxList.class.php +++ b/wcfsetup/install/files/lib/data/box/BoxList.class.php @@ -48,6 +48,7 @@ class BoxList extends DatabaseObjectList { if (!empty($boxIDs)) { $contentList = new BoxContentList(); $contentList->enableImageLoading(); + $contentList->enableEmbeddedObjectLoading(); $contentList->getConditionBuilder()->add('box_content.boxID IN (?)', [$this->objectIDs]); $contentList->getConditionBuilder()->add('(box_content.languageID IS NULL OR box_content.languageID = ?)', [WCF::getLanguage()->languageID]); $contentList->readObjects(); diff --git a/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php b/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php index 6571f8b542..9edd4fb37a 100644 --- a/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php +++ b/wcfsetup/install/files/lib/data/box/content/BoxContent.class.php @@ -4,7 +4,6 @@ use wcf\data\media\ViewableMedia; use wcf\data\DatabaseObject; use wcf\system\html\output\HtmlOutputProcessor; use wcf\system\html\simple\HtmlSimpleParser; -use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; use wcf\system\WCF; /** @@ -103,8 +102,6 @@ class BoxContent extends DatabaseObject { * @return string */ public function getFormattedContent() { - MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.box.content', [$this->boxContentID]); - $processor = new HtmlOutputProcessor(); $processor->process($this->content, 'com.woltlab.wcf.box.content', $this->boxContentID); @@ -117,8 +114,6 @@ class BoxContent extends DatabaseObject { * @return string parsed content */ public function getParsedContent() { - MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.box.content', [$this->boxContentID]); - return HtmlSimpleParser::getInstance()->replaceTags('com.woltlab.wcf.box.content', $this->boxContentID, $this->content); } @@ -129,7 +124,6 @@ class BoxContent extends DatabaseObject { * @return string parsed template */ public function getParsedTemplate($templateName) { - MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.box.content', [$this->boxContentID]); HtmlSimpleParser::getInstance()->setContext('com.woltlab.wcf.box.content', $this->boxContentID); WCF::getTPL()->registerPrefilter(['simpleEmbeddedObject']); diff --git a/wcfsetup/install/files/lib/data/box/content/BoxContentList.class.php b/wcfsetup/install/files/lib/data/box/content/BoxContentList.class.php index 97339892be..e5d03dc4bd 100644 --- a/wcfsetup/install/files/lib/data/box/content/BoxContentList.class.php +++ b/wcfsetup/install/files/lib/data/box/content/BoxContentList.class.php @@ -2,6 +2,7 @@ namespace wcf\data\box\content; use wcf\data\media\ViewableMediaList; use wcf\data\DatabaseObjectList; +use wcf\system\message\embedded\object\MessageEmbeddedObjectManager; /** * Represents a list of box content. @@ -29,21 +30,30 @@ class BoxContentList extends DatabaseObjectList { */ protected $imageLoading = false; + /** + * enables/disables the loading of embedded objects + * @var boolean + */ + protected $embeddedObjectLoading = false; + /** * @inheritDoc */ public function readObjects() { parent::readObjects(); - if ($this->imageLoading) { - $imageIDs = []; - foreach ($this->getObjects() as $boxContent) { - if ($boxContent->imageID) { - $imageIDs[] = $boxContent->imageID; - } + $imageIDs = $embeddedObjectBoxContentIDs = []; + foreach ($this->getObjects() as $boxContent) { + if ($boxContent->imageID) { + $imageIDs[] = $boxContent->imageID; } - // cache images + if ($boxContent->hasEmbeddedObjects) { + $embeddedObjectBoxContentIDs[] = $boxContent->boxContentID; + } + } + + if ($this->imageLoading) { if (!empty($imageIDs)) { $mediaList = new ViewableMediaList(); $mediaList->setObjectIDs($imageIDs); @@ -57,9 +67,14 @@ class BoxContentList extends DatabaseObjectList { } } } + + if ($this->embeddedObjectLoading) { + if (!empty($embeddedObjectBoxContentIDs)) { + MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.box.content', $embeddedObjectBoxContentIDs); + } + } } - /** * Enables/disables the loading of box content images. * @@ -68,4 +83,13 @@ class BoxContentList extends DatabaseObjectList { public function enableImageLoading($enable = true) { $this->imageLoading = $enable; } + + /** + * Enables/disables the loading of embedded objects. + * + * @param boolean $enable + */ + public function enableEmbeddedObjectLoading($enable = true) { + $this->embeddedObjectLoading = $enable; + } }