From: Marcel Werk Date: Sun, 21 Apr 2024 13:57:29 +0000 (+0200) Subject: Add documentation of the new RSS feed API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=092633c1bcda63bf40a2947afd25e0f2c7499705;p=GitHub%2FWoltLab%2Fwoltlab.github.io.git Add documentation of the new RSS feed API Closes #413 --- diff --git a/docs/migration/wsc60/php.md b/docs/migration/wsc60/php.md index 28bde610..b92a11d9 100644 --- a/docs/migration/wsc60/php.md +++ b/docs/migration/wsc60/php.md @@ -28,3 +28,7 @@ class MyForm extends AbstractForm { } } ``` + +## RSS Feeds + +A [new API](../../php/api/rss_feeds.md) for the output of content as an RSS feed has been introduced. diff --git a/docs/php/api/rss_feeds.md b/docs/php/api/rss_feeds.md new file mode 100644 index 00000000..932325b4 --- /dev/null +++ b/docs/php/api/rss_feeds.md @@ -0,0 +1,89 @@ +The RSS feed API makes it possible to output content in the RSS format in accordance with the [RSS 2.0 specifications](https://www.rssboard.org/rss-specification). +The [ArticleRssFeedPage](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/page/ArticleRssFeedPage.class.php) is available as a reference implementation. + +## `RssFeed` + +[RssFeed](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeed.class.php) represents an RSS feed. + +After content has been added to the RSS feed, the feed can be output as XML using the `render` method. + +Example: + +```php +$feed = new RssFeed(); +... +$output = $feed->render(); +``` + +## `RssFeedCategory` + +[RssFeedCategory](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedCategory.class.php) represents a category of a feed item. A feed item can have multiple categories. + +An instance of `RssFeedCategory` is created implicitly when a category is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->category('title', 'domain'); +``` + +## `RssFeedChannel` + +[RssFeedChannel](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedChannel.class.php) represents a channel within an RSS feed. + +Example: + +```php +$feed = new RssFeed(); +$channel = new RssFeedChannel(); +$channel + ->title('title') + ->description('description') + ->link('https://www.example.net'); +$feed->channel($channel); +``` + +## `RssFeedEnclosure` + +[RssFeedEnclosure](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedEnclosure.class.php) represents an enclosure of a feed item. A feed item can only have one enclosure. + +An instance of `RssFeedEnclosure` is created implicitly when an enclosure is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->enclosure('url', /*size*/1024, 'mime/type'); +``` + +## `RssFeedItem` + +[RssFeedItem](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedItem.class.php) represents an item in an RSS feed. + +Example: + +```php +$feed = new RssFeed(); +$channel = new RssFeedChannel(); +$feed->channel($channel); + +$item = new RssFeedItem(); +$item + ->title('title') + ->link('url'); +$channel->item($item); +``` + +## `RssFeedSource` + +[RssFeedSource](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedSource.class.php) represents the scource of a feed item. A feed item can only have one scource. + +An instance of `RssFeedSource` is created implicitly when an scource is assigned to a feed item. + +Example: + +```php +$item = new RssFeedItem(); +$item->source('title', 'url'); +``` diff --git a/mkdocs.yml b/mkdocs.yml index 1195ba04..e4f50a58 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ nav: - 'Package Installation Plugins': 'php/api/package_installation_plugins.md' - 'User Activity Points': 'php/api/user_activity_points.md' - 'User Notifications': 'php/api/user_notifications.md' + - 'RSS Feeds': 'php/api/rss_feeds.md' - 'Sitemaps': 'php/api/sitemaps.md' - 'Code Style': 'php/code-style.md' - 'Apps': 'php/apps.md'