2 namespace wcf\data\page\content
;
3 use wcf\data\DatabaseObject
;
4 use wcf\data\ILinkableObject
;
5 use wcf\system\html\output\HtmlOutputProcessor
;
6 use wcf\system\html\simple\HtmlSimpleParser
;
7 use wcf\system\message\embedded\
object\MessageEmbeddedObjectManager
;
8 use wcf\system\request\LinkHandler
;
12 * Represents a page content.
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Data\Page\Content
20 * @property-read integer $pageContentID unique id of the page content
21 * @property-read integer $pageID id of the page the page content belongs to
22 * @property-read integer $languageID id of the page content's language
23 * @property-read string $title title of the page in the associated language
24 * @property-read string $content actual content of the page in the associated language
25 * @property-read string $metaDescription meta description of the page in the associated language
26 * @property-read string $metaKeywords meta keywords of the page in the associated language
27 * @property-read string $customURL custom url of the page in the associated language
28 * @property-read integer $hasEmbeddedObjects is `1` if the page content contains embedded objects, otherwise `0`
30 class PageContent
extends DatabaseObject
implements ILinkableObject
{
34 protected static $databaseTableName = 'page_content';
39 protected static $databaseTableIndexName = 'pageContentID';
42 * Returns the page's formatted content.
46 public function getFormattedContent() {
47 MessageEmbeddedObjectManager
::getInstance()->loadObjects('com.woltlab.wcf.page.content', [$this->pageContentID
]);
49 $processor = new HtmlOutputProcessor();
50 $processor->process($this->content
, 'com.woltlab.wcf.page.content', $this->pageContentID
);
52 return $processor->getHtml();
56 * Parses simple placeholders embedded in raw html.
58 * @return string parsed content
60 public function getParsedContent() {
61 MessageEmbeddedObjectManager
::getInstance()->loadObjects('com.woltlab.wcf.page.content', [$this->pageContentID
]);
63 return HtmlSimpleParser
::getInstance()->replaceTags('com.woltlab.wcf.page.content', $this->pageContentID
, $this->content
);
67 * Parses simple placeholders embedded in HTML with template scripting.
69 * @param string $templateName content template name
70 * @return string parsed template
72 public function getParsedTemplate($templateName) {
73 MessageEmbeddedObjectManager
::getInstance()->loadObjects('com.woltlab.wcf.page.content', [$this->pageContentID
]);
74 HtmlSimpleParser
::getInstance()->setContext('com.woltlab.wcf.page.content', $this->pageContentID
);
76 WCF
::getTPL()->registerPrefilter(['simpleEmbeddedObject']);
78 $returnValue = WCF
::getTPL()->fetch($templateName);
80 WCF
::getTPL()->removePrefilter('simpleEmbeddedObject');
86 * Returns a certain page content.
88 * @param integer $pageID
89 * @param integer $languageID
90 * @return PageContent|null
92 public static function getPageContent($pageID, $languageID) {
93 if ($languageID !== null) {
95 FROM wcf" . WCF_N
. "_page_content
98 $statement = WCF
::getDB()->prepareStatement($sql);
99 $statement->execute([$pageID, $languageID]);
103 FROM wcf" . WCF_N
. "_page_content
105 AND languageID IS NULL";
106 $statement = WCF
::getDB()->prepareStatement($sql);
107 $statement->execute([$pageID]);
110 if (($row = $statement->fetchSingleRow()) !== false) {
111 return new PageContent(null, $row);
120 public function getLink() {
121 return LinkHandler
::getInstance()->getCmsLink($this->pageID
, $this->languageID
);