}
}
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]);
+ }
}
}
}
}
}
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]);
+ }
}
}
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();
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;
/**
* @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);
* @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);
}
* @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']);
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.
*/
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);
}
}
}
+
+ if ($this->embeddedObjectLoading) {
+ if (!empty($embeddedObjectBoxContentIDs)) {
+ MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.box.content', $embeddedObjectBoxContentIDs);
+ }
+ }
}
-
/**
* Enables/disables the loading of box content images.
*
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;
+ }
}