Commit | Line | Data |
---|---|---|
ba2cfa5a MW |
1 | <?php |
2 | ||
3 | namespace wcf\page; | |
4 | ||
5 | use wcf\data\conversation\UserConversationList; | |
6 | use wcf\system\rssFeed\RssFeed; | |
7 | use wcf\system\rssFeed\RssFeedItem; | |
8 | use wcf\system\WCF; | |
9 | ||
10 | /** | |
11 | * Outputs a list of recent conversations as an rss feed. | |
12 | * | |
13 | * @author Marcel Werk | |
14 | * @copyright 2001-2024 WoltLab GmbH | |
15 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
16 | */ | |
17 | class ConversationRssFeedPage extends AbstractRssFeedPage | |
18 | { | |
19 | /** | |
20 | * @inheritDoc | |
21 | */ | |
22 | public $loginRequired = true; | |
23 | ||
24 | protected UserConversationList $conversations; | |
25 | ||
26 | #[\Override] | |
27 | public function readData() | |
28 | { | |
29 | parent::readData(); | |
30 | ||
31 | $this->conversations = new UserConversationList(WCF::getUser()->userID); | |
32 | $this->conversations->sqlLimit = 20; | |
33 | $this->conversations->sqlOrderBy = 'conversation.lastPostTime DESC'; | |
34 | $this->conversations->readObjects(); | |
35 | } | |
36 | ||
37 | #[\Override] | |
38 | protected function getRssFeed(): RssFeed | |
39 | { | |
40 | $feed = new RssFeed(); | |
41 | $channel = $this->getDefaultChannel(); | |
42 | $channel->title(WCF::getLanguage()->get('wcf.conversation.conversations')); | |
43 | ||
44 | if ($this->conversations->valid()) { | |
45 | $channel->lastBuildDateFromTimestamp($this->conversations->current()->lastPostTime); | |
46 | } | |
47 | $feed->channel($channel); | |
48 | ||
49 | foreach ($this->conversations as $conversation) { | |
50 | $item = new RssFeedItem(); | |
51 | $item | |
52 | ->title($conversation->getTitle()) | |
53 | ->link($conversation->getLink()) | |
54 | ->description($conversation->getFirstMessage()->getExcerpt()) | |
55 | ->pubDateFromTimestamp($conversation->lastPostTime) | |
56 | ->creator($conversation->lastPoster) | |
57 | ->guid($conversation->getLink()) | |
58 | ->contentEncoded($conversation->getFirstMessage()->getSimplifiedFormattedMessage()) | |
59 | ->slashComments($conversation->replies); | |
60 | ||
61 | $channel->item($item); | |
62 | } | |
63 | ||
64 | return $feed; | |
65 | } | |
66 | } |