Alpha Framework 3.1.0 API Documentation

Atom extends Feed

Atom 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) 2018, 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

$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.
$record  : ActiveRecord
The Record which we will serve up in this feed.
__construct()  : mixed
Constructor to create a new Atom feed.
addAuthor()  : mixed
Adds an auther to a feed.
addRecord()  : mixed
Method for adding a Record to the current feed.
loadRecords()  : mixed
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()  : mixed
Method for mapping Record fieldnames to feed field names.
addItem()  : mixed
Method for adding an item to a feed.
createFeedElement()  : DOMElement
Method for creating a new feed element.
createLink()  : mixed
Method for creating link elements (note that Atom has a different format).
createRSSNode()  : mixed
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 = false
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://www.w3.org/2005/Atom'
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 = '<feed xmlns="http://www.w3.org/2005/Atom" />'
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' => 'entry', 'feeddesc' => 'subtitle', 'itemdesc' => 'summary')
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()

Constructor to create a new Atom feed.

public __construct(string $title, string $url, string $description[, string $pubDate = null ][, int $id = null ]) : mixed
Parameters
$title : string
$url : string
$description : string
$pubDate : string = null
$id : int = null
Tags
since
1.0
Return values
mixed

addAuthor()

Adds an auther to a feed.

public addAuthor(string $name) : mixed
Parameters
$name : string

The name of the author.

Tags
since
1.0
Return values
mixed

addRecord()

Method for adding a Record to the current feed.

public addRecord(ActiveRecord $Record) : mixed
Parameters
$Record : ActiveRecord
Return values
mixed

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) : mixed
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
Return values
mixed

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 ][, int $id = null ]) : mixed
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 : int = null

The feed id, only used in Atom feeds.

Tags
since
1.0
Return values
mixed

addItem()

Method for adding an item to a feed.

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

Return values
mixed

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(mixed $parent, mixed $url) : mixed
Parameters
$parent : mixed

The parent element.

$url : mixed

The URL for the link.

Return values
mixed

createRSSNode()

Method for creating an RSS node with a title, url and description.

protected createRSSNode(int $type, DOMElement $parent, string $title, string $url, string $description[, string $pubDate = null ][, int $id = null ]) : mixed
Parameters
$type : int

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

The feed id, only used in Atom feeds.

Tags
since
1.0
throws
IllegalArguementException
Return values
mixed

Search results