From 4a6f34f6260326556142691f3ebaf993197ac866 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sat, 10 Oct 2026 23:58:07 +0200 Subject: [PATCH] Allow quoting article contents ref https://www.woltlab.com/community/thread/294668-zitate-speichern-in-artikeln-m%C3%B6glich-machen/ --- com.woltlab.wcf/objectType.xml | 5 ++ com.woltlab.wcf/templates/article.tpl | 7 ++ .../article/content/ArticleContent.class.php | 75 ++++++++++++++++++- ...rticleContentMessageQuoteHandler.class.php | 32 ++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/lib/system/message/quote/ArticleContentMessageQuoteHandler.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 2e47222f793..6ee56891aaa 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -71,6 +71,11 @@ com.woltlab.wcf.message 1 + + com.woltlab.wcf.article.content + com.woltlab.wcf.message.quote + wcf\system\message\quote\ArticleContentMessageQuoteHandler + com.woltlab.wcf.article com.woltlab.wcf.label.object diff --git a/com.woltlab.wcf/templates/article.tpl b/com.woltlab.wcf/templates/article.tpl index c1f57ef1ec4..8f8c3eab8c8 100644 --- a/com.woltlab.wcf/templates/article.tpl +++ b/com.woltlab.wcf/templates/article.tpl @@ -67,6 +67,7 @@
{if $articleContent->getImage() && $articleContent->getImage()->hasThumbnail('large')}
getDiscussionProvider()->renderDiscussions()} + + {include file='footer'} 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 55f5de3e62d..eb3006b08f2 100644 --- a/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php +++ b/wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php @@ -5,6 +5,7 @@ use wcf\data\article\Article; use wcf\data\attachment\Attachment; use wcf\data\CollectionDatabaseObject; +use wcf\data\IMessage; use wcf\data\ITitledLinkObject; use wcf\data\language\Language; use wcf\data\media\ViewableMedia; @@ -42,7 +43,7 @@ * * @extends CollectionDatabaseObject */ -class ArticleContent extends CollectionDatabaseObject implements ITitledLinkObject, IRouteController +class ArticleContent extends CollectionDatabaseObject implements IMessage, ITitledLinkObject, IRouteController { /** * @inheritDoc @@ -138,6 +139,78 @@ public function getArticle(): Article return $this->getCollection()->getArticle($this); } + /** + * @since 6.3 + */ + #[\Override] + public function getExcerpt(int $maxLength = 255): string + { + return StringUtil::truncateHTML($this->getSimplifiedFormattedContent(), $maxLength); + } + + /** + * @since 6.3 + */ + #[\Override] + public function getFormattedMessage(): string + { + return $this->getFormattedContent(); + } + + /** + * @since 6.3 + */ + #[\Override] + public function getMessage(): string + { + return $this->content ?? ''; + } + + /** + * @since 6.3 + */ + #[\Override] + public function isVisible(): bool + { + return $this->getArticle()->canRead(); + } + + /** + * @since 6.3 + */ + #[\Override] + public function getTime(): int + { + return $this->getArticle()->getTime(); + } + + /** + * @since 6.3 + */ + #[\Override] + public function getUserID(): ?int + { + return $this->getArticle()->getUserID(); + } + + /** + * @since 6.3 + */ + #[\Override] + public function getUsername(): string + { + return $this->getArticle()->getUsername(); + } + + /** + * @since 6.3 + */ + #[\Override] + public function __toString(): string + { + return $this->getFormattedContent(); + } + /** * Returns the language of this article content or `null` if no language has been specified. */ diff --git a/wcfsetup/install/files/lib/system/message/quote/ArticleContentMessageQuoteHandler.class.php b/wcfsetup/install/files/lib/system/message/quote/ArticleContentMessageQuoteHandler.class.php new file mode 100644 index 00000000000..2456e7312d9 --- /dev/null +++ b/wcfsetup/install/files/lib/system/message/quote/ArticleContentMessageQuoteHandler.class.php @@ -0,0 +1,32 @@ + + * @since 6.3 + */ +final class ArticleContentMessageQuoteHandler extends AbstractMessageQuoteHandler +{ + #[\Override] + public function getMessage(int $objectID): ?IMessage + { + $articleContent = new ArticleContent($objectID); + if ($articleContent->isNil()) { + return null; + } + + if (!$articleContent->isVisible()) { + return null; + } + + return $articleContent; + } +}