Skip to content

Commit 97f54b4

Browse files
committed
Refactor ArticlePage
1 parent b43ad7d commit 97f54b4

5 files changed

Lines changed: 133 additions & 118 deletions

File tree

com.woltlab.wcf/templates/article.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
{include file='entryTags' objectType='com.woltlab.wcf.article'}
118118

119-
{include file='entryAttachments' objectID=$article->articleID}
119+
{include file='entryAttachments' attachments=$article->getAttachments()}
120120

121121
<footer class="entry__footer">
122122
{if MODULE_LIKE && ARTICLE_ENABLE_LIKE && $__wcf->session->getPermission('user.like.canViewLike')}

wcfsetup/install/files/lib/data/TCollectionAttachments.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ protected function getAttachmentPermissions(): array
6464

6565
protected function hasAttachments(DatabaseObject $object): bool
6666
{
67+
// @phpstan-ignore property.notFound
6768
return $object->attachments > 0;
6869
}
6970

wcfsetup/install/files/lib/data/article/Article.class.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use wcf\data\article\category\ArticleCategory;
66
use wcf\data\article\content\ArticleContent;
7-
use wcf\data\attachment\GroupedAttachmentList;
7+
use wcf\data\attachment\Attachment;
88
use wcf\data\CollectionDatabaseObject;
99
use wcf\data\ILinkableObject;
1010
use wcf\data\IPopoverObject;
@@ -336,19 +336,12 @@ public function getUsername(): string
336336
}
337337

338338
/**
339+
* @return Attachment[]
339340
* @since 6.0
340341
*/
341-
public function getAttachments(): ?GroupedAttachmentList
342+
public function getAttachments(): array
342343
{
343-
if ($this->attachments) {
344-
$attachmentList = new GroupedAttachmentList('com.woltlab.wcf.article');
345-
$attachmentList->getConditionBuilder()->add('attachment.objectID IN (?)', [$this->articleID]);
346-
$attachmentList->readObjects();
347-
348-
return $attachmentList;
349-
}
350-
351-
return null;
344+
return $this->getCollection()->getAttachments($this);
352345
}
353346

354347
#[\Override]

wcfsetup/install/files/lib/data/article/ArticleCollection.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use wcf\data\article\content\ArticleContent;
66
use wcf\data\article\content\ArticleContentList;
77
use wcf\data\DatabaseObjectCollection;
8+
use wcf\data\TCollectionAttachments;
89
use wcf\data\TCollectionLabels;
910
use wcf\data\TCollectionReactions;
1011
use wcf\data\TCollectionUserProfiles;
@@ -29,6 +30,7 @@ class ArticleCollection extends DatabaseObjectCollection
2930
use TCollectionUserProfiles;
3031
use TCollectionLabels;
3132
use TCollectionVisitTimes;
33+
use TCollectionAttachments;
3234

3335
/**
3436
* @var array<int, array<int, ArticleContent>>
@@ -131,4 +133,10 @@ protected function getVisitTrackerObjectType(): string
131133
{
132134
return 'com.woltlab.wcf.article';
133135
}
136+
137+
#[\Override]
138+
protected function getAttachmentObjectType(): string
139+
{
140+
return 'com.woltlab.wcf.article';
141+
}
134142
}

0 commit comments

Comments
 (0)