From fa644e2defdf80f01a5882cb2e83b99dc2518fbd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 28 Jul 2016 12:40:22 +0200 Subject: [PATCH] Use proper html output for AMP pages --- com.woltlab.wcf/templates/ampArticle.tpl | 2 +- .../data/article/content/ArticleContent.class.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/ampArticle.tpl b/com.woltlab.wcf/templates/ampArticle.tpl index 9ce2344d8e..f4bcbdc8b8 100644 --- a/com.woltlab.wcf/templates/ampArticle.tpl +++ b/com.woltlab.wcf/templates/ampArticle.tpl @@ -61,7 +61,7 @@ {/if}
- {@$articleContent->getFormattedContent()} + {@$articleContent->getAmpFormattedContent()}
diff --git a/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php b/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php index 05dfd77627..042e3d671a 100644 --- a/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php +++ b/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php @@ -4,6 +4,7 @@ use wcf\data\article\Article; use wcf\data\language\Language; use wcf\data\DatabaseObject; use wcf\data\ILinkableObject; +use wcf\system\html\output\AmpHtmlOutputProcessor; use wcf\system\html\output\HtmlOutputProcessor; use wcf\system\language\LanguageFactory; use wcf\system\request\IRouteController; @@ -98,6 +99,18 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo return $processor->getHtml(); } + /** + * Returns the article's formatted content ready for use with Google AMP pages. + * + * @return string + */ + public function getAmpFormattedContent() { + $processor = new AmpHtmlOutputProcessor(); + $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID); + + return $processor->getHtml(); + } + /** * Returns article object. * -- 2.20.1