Alpha Framework 4.0.0 API Documentation

RSS extends Feed
in package

RSS 1.0 class for synication.

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.
$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.
$rdfns  : string
The RDF namespace.
$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.
addToItems()  : void
Add a URL to feed item.

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.

protected string $nameSpace = 'http://purl.org/rss/1.0/'
Tags
since
1.0

$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 = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.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

$rdfns

The RDF namespace.

private string $rdfns = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
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(string $RecordName, string $title, string $url, string $description[, string $pubDate = null ][, int $id = null ][, int $limit = 10 ]) : mixed
Parameters
$RecordName : string

The fully-qualifified classname of the Record to render a feed for.

$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 : int = null

The feed id, only used in Atom feeds.

$limit : int = 10

The amount of items to render in the feed.

Tags
throws
IllegalArguementException
since
1.0

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(mixed $title, mixed $link[, mixed $description = null ][, mixed $pubDate = null ][, mixed $id = null ]) : void
Parameters
$title : mixed

The title of the feed.

$link : mixed
$description : mixed = null

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.

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(mixed $type, mixed $parent, mixed $title, mixed $url, mixed $description[, mixed $pubDate = null ][, mixed $id = null ]) : void
Parameters
$type : mixed

Can be either (item|feed) to indicate the type of node we are creating.

$parent : mixed

The parent element.

$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.

addToItems()

Add a URL to feed item.

private addToItems( $url) : void
Parameters
$url :
Tags
since
1.0

        
On this page

Search results