RSS2
extends Feed
in package
RSS 2.0 class for syndication.
Tags
Table of Contents
Properties
- $docElement : DOMElement
- The DOMElement object used to hold the item or entry elements.
- $fieldNameMappings : array<string|int, mixed>
- An array containing Record field names -> RSS field name mappings.
- $hasChannel : bool
- If the feed format has a channel or not.
- $items : array<string|int, mixed>
- An array of feed items.
- $nameSpace : string
- The XML namespace to use in the generated feed.
- $root : DOMElement
- Holds the DOMElement to which metadata is added for the feed.
- $rootTag : string
- The actual root tag used in each feed type.
- $rssDoc : DOMDocument
- The DOMDocument object used to create the feed.
- $tagMap : array<string|int, mixed>
- Maps the tags to the feed-specific tags.
- $logger : Logger
- Trace logger.
- $record : ActiveRecord
- The Record which we will serve up in this feed.
Methods
- __construct() : mixed
- The constructor.
- addRecord() : void
- Method for adding a Record to the current feed.
- loadRecords() : void
- Method to load all of the Record items to the feed from the database, from the newest to the $limit provided.
- render() : string
- Returns the formatted XML for the feed as a string.
- setFieldMappings() : void
- Method for mapping Record fieldnames to feed field names.
- addItem() : void
- Method for adding an item to a feed.
- createFeedElement() : DOMElement
- Method for creating a new feed element.
- createLink() : void
- Method for creating link elements (note that Atom has a different format).
- createRSSNode() : void
- Method for creating an RSS node with a title, url and description.
Properties
$docElement
The DOMElement object used to hold the item or entry elements.
protected
DOMElement
$docElement
Tags
$fieldNameMappings
An array containing Record field names -> RSS field name mappings.
protected
array<string|int, mixed>
$fieldNameMappings
Tags
$hasChannel
If the feed format has a channel or not.
protected
bool
$hasChannel
= true
Tags
$items
An array of feed items.
protected
array<string|int, mixed>
$items
Tags
$nameSpace
The XML namespace to use in the generated feed.
protected
string
$nameSpace
$root
Holds the DOMElement to which metadata is added for the feed.
protected
DOMElement
$root
Tags
$rootTag
The actual root tag used in each feed type.
protected
string
$rootTag
= '<rss version="2.0" />'
Tags
$rssDoc
The DOMDocument object used to create the feed.
protected
DOMDocument
$rssDoc
Tags
$tagMap
Maps the tags to the feed-specific tags.
protected
array<string|int, mixed>
$tagMap
= array('item' => 'item', 'feeddesc' => 'description', 'itemdesc' => 'description')
Tags
$logger
Trace logger.
private
static Logger
$logger
= null
Tags
$record
The Record which we will serve up in this feed.
private
ActiveRecord
$record
Tags
Methods
__construct()
The constructor.
public
__construct(mixed $RecordName, mixed $title, mixed $url, mixed $description[, mixed $pubDate = null ][, mixed $id = null ][, mixed $limit = 10 ]) : mixed
Parameters
- $RecordName : mixed
-
The fully-qualifified classname of the Record to render a feed for.
- $title : mixed
-
The title of the feed.
- $url : mixed
-
The base URL for the feed.
- $description : mixed
-
The description of the feed.
- $pubDate : mixed = null
-
The publish date, only used in Atom feeds.
- $id : mixed = null
-
The feed id, only used in Atom feeds.
- $limit : mixed = 10
-
The amount of items to render in the feed.
addRecord()
Method for adding a Record to the current feed.
public
addRecord(ActiveRecord $record) : void
Parameters
- $record : ActiveRecord
loadRecords()
Method to load all of the Record items to the feed from the database, from the newest to the $limit provided.
public
loadRecords(int $limit, string $sortBy) : void
Parameters
- $limit : int
-
The amount of items to render in the feed.
- $sortBy : string
-
The name of the field to sort the feed by.
Tags
render()
Returns the formatted XML for the feed as a string.
public
render() : string
Tags
Return values
stringsetFieldMappings()
Method for mapping Record fieldnames to feed field names.
public
setFieldMappings(string $title, string $url[, string $description = null ][, string $pubDate = null ][, string|null $id = null ]) : void
Parameters
- $title : string
-
The title of the feed.
- $url : string
-
The base URL for the feed.
- $description : string = null
-
The description of the feed.
- $pubDate : string = null
-
The publish date, only used in Atom feeds.
- $id : string|null = null
-
The feed id, only used in Atom feeds.
Tags
addItem()
Method for adding an item to a feed.
protected
addItem(string $title, string $url[, string $description = null ][, string $pubDate = null ], string|null $id) : void
Parameters
- $title : string
-
The title of the feed.
- $url : string
-
The base URL for the feed.
- $description : string = null
-
The description of the feed.
- $pubDate : string = null
-
The publish date, only used in Atom feeds.
- $id : string|null
-
The feed id, only used in Atom feeds.
Tags
createFeedElement()
Method for creating a new feed element.
protected
createFeedElement(string $name[, string $value = null ]) : DOMElement
Parameters
- $name : string
-
The name of the element.
- $value : string = null
-
The value of the element.
Tags
Return values
DOMElementcreateLink()
Method for creating link elements (note that Atom has a different format).
protected
createLink(DOMElement $parent, string $url) : void
Parameters
- $parent : DOMElement
-
The parent element.
- $url : string
-
The URL for the link.
Tags
createRSSNode()
Method for creating an RSS node with a title, url and description.
protected
createRSSNode(string $type, DOMElement $parent, string $title, string $url, string $description[, string $pubDate = null ], string|null $id) : void
Parameters
- $type : string
-
Can be either (item|feed) to indicate the type of node we are creating.
- $parent : DOMElement
-
The parent element.
- $title : string
-
The title of the feed.
- $url : string
-
The base URL for the feed.
- $description : string
-
The description of the feed.
- $pubDate : string = null
-
The publish date, only used in Atom feeds.
- $id : string|null
-
The feed id, only used in Atom feeds.