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
6 changes: 3 additions & 3 deletions com.woltlab.wcf/templates/articleList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{/if}

{if $__wcf->getUser()->userID}
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleRssFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
{else}
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleFeed'}{/link}">
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleRssFeed'}{/link}">
{/if}
{/capture}

Expand Down Expand Up @@ -104,7 +104,7 @@
{/capture}

{capture assign='contentInteractionDropdownItems'}
<li><a rel="alternate" href="{if $__wcf->getUser()->userID}{link controller='ArticleFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed'}{/link}{/if}" class="rssFeed">{lang}wcf.global.button.rss{/lang}</a></li>
<li><a rel="alternate" href="{if $__wcf->getUser()->userID}{link controller='ArticleRssFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleRssFeed'}{/link}{/if}" class="rssFeed">{lang}wcf.global.button.rss{/lang}</a></li>
{/capture}

{include file='header'}
Expand Down
6 changes: 3 additions & 3 deletions com.woltlab.wcf/templates/categoryArticleList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
{/if}

{if $__wcf->getUser()->userID}
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleFeed' id=$categoryID}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleRssFeed' id=$categoryID}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
{else}
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleFeed' id=$categoryID}{/link}">
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='ArticleRssFeed' id=$categoryID}{/link}">
{/if}
{/capture}

Expand Down Expand Up @@ -69,7 +69,7 @@
{/capture}

{capture assign='contentInteractionDropdownItems'}
<li><a rel="alternate" href="{if $__wcf->getUser()->userID}{link controller='ArticleFeed' id=$categoryID}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleFeed' id=$categoryID}{/link}{/if}" class="rssFeed">{lang}wcf.global.button.rss{/lang}</a></li>
<li><a rel="alternate" href="{if $__wcf->getUser()->userID}{link controller='ArticleRssFeed' id=$categoryID}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}{else}{link controller='ArticleRssFeed' id=$categoryID}{/link}{/if}" class="rssFeed">{lang}wcf.global.button.rss{/lang}</a></li>
{/capture}

{include file='header'}
Expand Down
4 changes: 2 additions & 2 deletions com.woltlab.wcf/templates/notificationList.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{capture assign='contentTitleBadge'}<span class="badge jsNotificationsBadge">{#$__wcf->getUserNotificationHandler()->countAllNotifications()}</span>{/capture}

{capture assign='headContent'}
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='NotificationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
<link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='NotificationRssFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">
{/capture}

{capture assign='contentInteractionPagination'}
Expand All @@ -15,7 +15,7 @@
{/capture}

{capture assign='contentInteractionDropdownItems'}
<li><a rel="alternate" href="{link controller='NotificationFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">{lang}wcf.global.button.rss{/lang}</a></li>
<li><a rel="alternate" href="{link controller='NotificationRssFeed'}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}">{lang}wcf.global.button.rss{/lang}</a></li>
{/capture}

{include file='header'}
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/files/lib/data/IFeedEntry.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @author Tim Duesterhus
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @deprecated 6.1 use `wcf\system\rssFeed\RssFeedItem` instead
*/
interface IFeedEntry extends IMessage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @author Marcel Werk
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @deprecated 6.1 use `wcf\system\rssFeed\RssFeedItem` instead
*/
interface IFeedEntryWithEnclosure extends IFeedEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
* @deprecated 6.1
*/
class FeedArticle extends ViewableArticle implements IFeedEntryWithEnclosure
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
* @deprecated 6.1
*
* @method FeedArticle current()
* @method FeedArticle[] getObjects()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,7 @@ public function getFormattedTeaser()
if ($this->teaser) {
return \nl2br(StringUtil::encodeHTML($this->teaser), false);
} else {
$htmlOutputProcessor = new HtmlOutputProcessor();
$htmlOutputProcessor->setOutputType('text/simplified-html');
$htmlOutputProcessor->enableUgc = false;
$htmlOutputProcessor->process(
$this->content,
'com.woltlab.wcf.article.content',
$this->articleContentID,
false,
$this->languageID
);

return MessageUtil::truncateFormattedMessage($htmlOutputProcessor->getHtml(), 500);
return MessageUtil::truncateFormattedMessage($this->getSimplifiedFormattedContent(), 500);
}
}

Expand All @@ -122,6 +111,26 @@ public function getFormattedContent()
return $processor->getHtml();
}

/**
* Returns a simplified version of the formatted content.
* @since 6.1
*/
public function getSimplifiedFormattedContent(): string
{
$htmlOutputProcessor = new HtmlOutputProcessor();
$htmlOutputProcessor->setOutputType('text/simplified-html');
$htmlOutputProcessor->enableUgc = false;
$htmlOutputProcessor->process(
$this->content,
'com.woltlab.wcf.article.content',
$this->articleContentID,
false,
$this->languageID
);

return $htmlOutputProcessor->getHtml();
}

/**
* Returns article object.
*
Expand Down
25 changes: 25 additions & 0 deletions wcfsetup/install/files/lib/page/AbstractFeedPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

namespace wcf\page;

use wcf\system\request\LinkHandler;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
use wcf\util\HeaderUtil;

/**
* Generates RSS 2-Feeds.
*
* @author Tim Duesterhus
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @deprecated 6.1 use `AbstractRssFeedPage` instead
*/
abstract class AbstractFeedPage extends AbstractAuthedPage
{
Expand Down Expand Up @@ -96,4 +99,26 @@ public function show()
// show template
WCF::getTPL()->display($this->templateName, $this->application, false);
}

protected function redirectToNewPage(string $className): void
{
$parameters = [];
$url = '';
if ($this->objectIDs !== []) {
if (\count($this->objectIDs) === 1) {
$parameters['id'] = \reset($this->objectIDs);
} else {
$url = 'id=' . \implode(',', $this->objectIDs);
}
}
if (isset($_REQUEST['at'])) {
$parameters['at'] = $_REQUEST['at'];
}
HeaderUtil::redirect(
LinkHandler::getInstance()->getControllerLink($className, $parameters, $url),
true,
false
);
exit;
}
}
78 changes: 78 additions & 0 deletions wcfsetup/install/files/lib/page/AbstractRssFeedPage.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace wcf\page;

use wcf\system\rssFeed\RssFeed;
use wcf\system\rssFeed\RssFeedChannel;
use wcf\system\WCF;
use wcf\util\ArrayUtil;

/**
* Generates RSS 2-Feeds.
*
* @author Tim Duesterhus, Marcel Werk
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
abstract class AbstractRssFeedPage extends AbstractAuthedPage
{
/**
* @inheritDoc
*/
public $useTemplate = false;

/**
* parsed contents of $_REQUEST['id']
* @var int[]
*/
public array $objectIDs = [];

#[\Override]
public function readParameters()
{
parent::readParameters();

if (isset($_REQUEST['id'])) {
if (\is_array($_REQUEST['id'])) {
// ?id[]=1337&id[]=9001
$this->objectIDs = ArrayUtil::toIntegerArray($_REQUEST['id']);
} else {
// ?id=1337 or ?id=1337,9001
$this->objectIDs = ArrayUtil::toIntegerArray(\explode(',', $_REQUEST['id']));
}
}
}

#[\Override]
public function show()
{
parent::show();
if ($this->getPsr7Response()) {
return;
}

$output = $this->getRssFeed()->render();

@\header('Content-Type: application/rss+xml; charset=UTF-8');

echo $output;
}

protected function getDefaultChannel(): RssFeedChannel
{
$channel = new RssFeedChannel();
$channel
->title(WCF::getLanguage()->get(\PAGE_TITLE))
->description(WCF::getLanguage()->get(\PAGE_DESCRIPTION))
->link(WCF::getPath())
->language(WCF::getLanguage()->getFixedLanguageCode())
->pubDateFromTimestamp(\TIME_NOW)
->lastBuildDateFromTimestamp(\TIME_NOW)
->atomLinkSelf(WCF::getRequestURI());

return $channel;
}

protected abstract function getRssFeed(): RssFeed;
}
3 changes: 3 additions & 0 deletions wcfsetup/install/files/lib/page/ArticleFeedPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
* @deprecated 6.1 use `ArticleRssFeedPage` instead
*/
class ArticleFeedPage extends AbstractFeedPage
{
Expand Down Expand Up @@ -47,6 +48,8 @@ public function readParameters()
throw new PermissionDeniedException();
}
}

$this->redirectToNewPage(ArticleRssFeedPage::class);
}

/**
Expand Down
111 changes: 111 additions & 0 deletions wcfsetup/install/files/lib/page/ArticleRssFeedPage.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace wcf\page;

use wcf\data\article\AccessibleArticleList;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\CategoryArticleList;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\rssFeed\RssFeed;
use wcf\system\rssFeed\RssFeedItem;
use wcf\system\WCF;
use wcf\util\StringUtil;

/**
* Outputs a list of cms articles of a certain category as a rss feed.
*
* @author Marcel Werk
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
class ArticleRssFeedPage extends AbstractRssFeedPage
{
public ArticleCategory $category;
public int $categoryID = 0;
public AccessibleArticleList $articles;

#[\Override]
public function readParameters()
{
parent::readParameters();

if ($this->objectIDs !== []) {
$this->categoryID = \reset($this->objectIDs);
$this->category = ArticleCategory::getCategory($this->categoryID);
if ($this->category === null) {
throw new IllegalLinkException();
}
if (!$this->category->isAccessible()) {
throw new PermissionDeniedException();
}
}
}

#[\Override]
public function readData()
{
parent::readData();

if ($this->categoryID) {
$this->articles = new CategoryArticleList($this->categoryID);
} else {
$this->articles = new AccessibleArticleList();
}
$this->articles->sqlOrderBy = 'article.time ' . ARTICLE_SORT_ORDER;
$this->articles->sqlLimit = 20;
$this->articles->readObjects();
}

#[\Override]
protected function getRssFeed(): RssFeed
{
$feed = new RssFeed();
$channel = $this->getDefaultChannel();
if (isset($this->category)) {
$channel->title($this->category->getTitle());
$channel->description($this->category->getDecoratedObject()->getDescription());
} else {
$channel->title(WCF::getLanguage()->get('wcf.article.articles'));
}

if ($this->articles->valid()) {
$channel->lastBuildDateFromTimestamp($this->articles->current()->getTime());
}
$feed->channel($channel);

foreach ($this->articles as $article) {
$item = new RssFeedItem();
$item
->title($article->getTitle())
->link($article->getLink())
->description(StringUtil::truncateHTML($article->getFormattedTeaser(), 255))
->pubDateFromTimestamp($article->time)
->creator($article->username)
->guid($article->getLink())
->contentEncoded($article->getArticleContent()->getSimplifiedFormattedContent())
->slashComments($article->getArticleContent()->comments);

if ($article->getImage() !== null) {
$item->enclosure(
$article->getImage()->getThumbnailLink('small'),
$article->getImage()->smallThumbnailSize,
$article->getImage()->smallThumbnailType
);
}

$category = $article->getDecoratedObject()->getCategory();
if ($category !== null) {
$item->category($category->getTitle());
foreach ($category->getParentCategories() as $category) {
$item->category($category->getTitle());
}
}

$channel->item($item);
}

return $feed;
}
}
Loading