+<script data-relocate="true">
+ require(['Language'], function (Language) {
+ Language.addObject({
+ 'wcf.page.search': '{lang}wcf.page.search{/lang}',
+ 'wcf.page.search.error.tooShort': '{lang}wcf.page.search.error.tooShort{/lang}',
+ 'wcf.page.search.error.noResults': '{lang}wcf.page.search.error.noResults{/lang}',
+ 'wcf.page.search.name': '{lang}wcf.page.search.name{/lang}',
+ 'wcf.page.search.results': '{lang}wcf.page.search.results{/lang}'
+ });
+ })
+</script>
+
+{if $boxType == 'html' || $boxType == 'tpl'}
+ <ul class="codemirrorToolbar">
+ <li><a href="#" id="codemirror-content{@$languageID}-media" class="jsTooltip" title="{lang}wcf.editor.button.media{/lang}"><span class="icon icon16 fa-file-o"></span></a></li>
+ <li><a href="#" id="codemirror-content{@$languageID}-page" class="jsTooltip" title="{lang}wcf.editor.button.page{/lang}"><span class="icon icon16 fa-file-text-o"></span></a></li>
+ </ul>
+ <script data-relocate="true">
+ require(['WoltLabSuite/Core/Acp/Ui/CodeMirror/Media', 'WoltLabSuite/Core/Acp/Ui/CodeMirror/Page'], function(AcpUiCodeMirrorMedia, AcpUiCodeMirrorPage) {
+ new AcpUiCodeMirrorMedia('content{@$languageID}');
+ new AcpUiCodeMirrorPage('content{@$languageID}');
+ });
+ </script>
+{/if}
+
{if $boxType == 'text'}
<textarea name="content[{@$languageID}]" id="content{@$languageID}"
{if $boxType == 'text'}
if ($boxContent !== null) {
if ($this->boxType == 'text') {
- $processor = new HtmlOutputProcessor();
- $processor->process($boxContent->content, 'com.woltlab.wcf.box.content', $boxContent->boxContentID);
-
- return $processor->getHtml();
+ return $boxContent->getFormattedContent();
+ }
+ else if ($this->boxType == 'html') {
+ return $boxContent->getParsedContent();
+ }
+ else if ($this->boxType == 'tpl') {
+ return $boxContent->getParsedTemplate($this->getTplName(WCF::getLanguage()->languageID));
}
-
- return $boxContent->content;
}
return '';
}
use wcf\system\box\IConditionBoxController;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
+use wcf\system\html\simple\HtmlSimpleParser;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\WCF;
$boxContentEditor->update(['hasEmbeddedObjects' => 1]);
}
}
+ else if ($box->boxType == 'html' || $box->boxType == 'tpl') {
+ HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content);
+ }
}
}
'content' => $content['content'],
'imageID' => $content['imageID']
]);
+ $boxContent = BoxContent::getBoxContent($box->boxID, ($languageID ?: null));
}
else {
/** @var BoxContent $boxContent */
$boxContentEditor->update(['hasEmbeddedObjects' => $boxContent->hasEmbeddedObjects ? 0 : 1]);
}
}
+ else if ($box->boxType == 'html' || $box->boxType == 'tpl') {
+ HtmlSimpleParser::getInstance()->parse('com.woltlab.wcf.box.content', $boxContent->boxContentID, $boxContent->content);
+ }
}
// save template
namespace wcf\data\box\content;
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;
/**
public function setImage(ViewableMedia $image) {
$this->image = $image;
}
+
+ /**
+ * Returns the box's formatted content.
+ *
+ * @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 $processor->getHtml();
+ }
+
+ /**
+ * Parses simple placeholders embedded in raw html.
+ *
+ * @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);
+ }
+
+ /**
+ * Parses simple placeholders embedded in HTML with template scripting.
+ *
+ * @param string $templateName content template name
+ * @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']);
+
+ $returnValue = WCF::getTPL()->fetch($templateName);
+
+ WCF::getTPL()->removePrefilter('simpleEmbeddedObject');
+
+ return $returnValue;
+ }
}