Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions com.woltlab.wcf/objectType.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<definitionname>com.woltlab.wcf.message</definitionname>
<enableToc>1</enableToc>
</type>
<type>
<name>com.woltlab.wcf.article.content</name>
<definitionname>com.woltlab.wcf.message.quote</definitionname>
<classname>wcf\system\message\quote\ArticleContentMessageQuoteHandler</classname>
</type>
<type>
<name>com.woltlab.wcf.article</name>
<definitionname>com.woltlab.wcf.label.object</definitionname>
Expand Down
7 changes: 7 additions & 0 deletions com.woltlab.wcf/templates/article.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

<div
class="section entry article"
data-object-id="{$articleContent->articleContentID}"
>
{if $articleContent->getImage() && $articleContent->getImage()->hasThumbnail('large')}
<div
Expand Down Expand Up @@ -256,4 +257,10 @@

{unsafe:$article->getDiscussionProvider()->renderDiscussions()}

<script data-relocate="true">
require(["WoltLabSuite/Core/Component/Quote/Message"], ({ registerContainer }) => {
registerContainer(".entry.article", ".entry__content", "com.woltlab.wcf.article.content");
});
</script>

{include file='footer'}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +43,7 @@
*
* @extends CollectionDatabaseObject<ArticleContentCollection>
*/
class ArticleContent extends CollectionDatabaseObject implements ITitledLinkObject, IRouteController
class ArticleContent extends CollectionDatabaseObject implements IMessage, ITitledLinkObject, IRouteController
{
/**
* @inheritDoc
Expand Down Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace wcf\system\message\quote;

use wcf\data\article\content\ArticleContent;
use wcf\data\IMessage;

/**
* IMessageQuoteHandler implementation for article contents.
*
* @author Marcel Werk
* @copyright 2001-2026 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @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;
}
}
Loading