Improved fallback creation of article teasers
authorMarcel Werk <burntime@woltlab.com>
Thu, 12 Jan 2017 15:20:23 +0000 (16:20 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 12 Jan 2017 15:20:23 +0000 (16:20 +0100)
wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php

index 2de78a101f97a96ffe230c1a15288181683364a1..d25ec43b58f3c11ab408e7fa6276ee90271ab8a9 100644 (file)
@@ -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\input\HtmlInputProcessor;
 use wcf\system\html\output\AmpHtmlOutputProcessor;
 use wcf\system\html\output\HtmlOutputProcessor;
 use wcf\system\language\LanguageFactory;
@@ -78,7 +79,9 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
                        return StringUtil::encodeHTML($this->teaser);
                }
                else {
-                       return StringUtil::truncateHTML(StringUtil::stripHTML($this->getFormattedContent()));
+                       $htmlInputProcessor = new HtmlInputProcessor();
+                       $htmlInputProcessor->processIntermediate($this->content);
+                       return StringUtil::encodeHTML(StringUtil::truncate($htmlInputProcessor->getTextContent(), 500));
                }
        }