Alpha Framework 4.0.0 API Documentation

RSS2 extends Feed
in package

RSS 2.0 class for syndication.

Tags
since
1.0
author

John Collins dev@alphaframework.org

license

http://www.opensource.org/licenses/bsd-license.php The BSD License

copyright

Copyright (c) 2021, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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
since
1.0

$fieldNameMappings

An array containing Record field names -> RSS field name mappings.

protected array<string|int, mixed> $fieldNameMappings
Tags
since
1.0

$hasChannel

If the feed format has a channel or not.

protected bool $hasChannel = true
Tags
since
1.0

$items

An array of feed items.

protected array<string|int, mixed> $items
Tags
since
1.0

$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
since
1.0

$rootTag

The actual root tag used in each feed type.

protected string $rootTag = '<rss version="2.0" />'
Tags
since
1.0

$rssDoc

The DOMDocument object used to create the feed.

protected DOMDocument $rssDoc
Tags
since
1.0

$tagMap

Maps the tags to the feed-specific tags.

protected array<string|int, mixed> $tagMap = array('item' => 'item', 'feeddesc' => 'description', 'itemdesc' => 'description')
Tags
since
1.0

$logger

Trace logger.

private static Logger $logger = null
Tags
since
1.0

$record

The Record which we will serve up in this feed.

private ActiveRecord $record
Tags
since
1.0

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.

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
since
1.0

render()

Returns the formatted XML for the feed as a string.

public render() : string
Tags
since
1.0
Return values
string

setFieldMappings()

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
since
1.0

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
since
1.0

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
since
1.0
Return values
DOMElement

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
since
1.0

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.

Tags
since
1.0
throws
IllegalArguementException

        
On this page

Search results