FeedWriter\Feed
Universal Feed Writer class
Generate RSS 1.0, RSS2.0 and ATOM Feeds
- Author: Anis uddin Ahmad <anisniit@gmail.com>
Synopsis
class Feed
{
- // constants
- const RSS1 = 'RSS 1.0';
- const RSS2 = 'RSS 2.0';
- const ATOM = 'ATOM';
- // members
- private array $channels = ;
- private array $items = ;
- private array $data = ;
- private array $CDATAEncoding = ;
- private array $namespaces = ;
- private $version = NULL;
- // methods
- protected void __construct()
- public Feed setPagination()
- public Feed addGenerator()
- public Feed addNamespace()
- public Feed setChannelElement()
- public Feed setChannelElementsFromArray()
- public string getMIMEType()
- public void printFeed()
- public string generateFeed()
- public Item createNewItem()
- public Feed addCDATAEncoding()
- public array getCDATAEncoding()
- public void removeCDATAEncoding()
- public Feed addItem()
- public Feed setEncoding()
- public Feed setTitle()
- public Feed setDate()
- public Feed setDescription()
- public Feed setLink()
- public Feed setAtomLink()
- public Feed setSelfLink()
- public Feed setImage()
- public Feed setChannelAbout()
- public static string uuid()
- public static string filterInvalidXMLChars()
- private array getNamespacePrefixes()
- private string makeHeader()
- private string makeFooter()
- private string makeNode()
- private string makeChannels()
- private string makeItems()
- private string startItem()
- private string endItem()
- private string sanitizeCDATA()
Constants
Name | Value |
---|---|
RSS1 | 'RSS 1.0' |
RSS2 | 'RSS 2.0' |
ATOM | 'ATOM' |
Members
private
-
$CDATAEncoding
The tag names which have to encoded as CDATA -
$channels
Collection of all channel elements -
$data
Store some other version wise data -
$items
Collection of items as object of \FeedWriter\Item class. -
$namespaces
Collection of XML namespaces -
$version
Contains the format of this feed.
Methods
private
- endItem() — Closes feed item tag
- getNamespacePrefixes() — Returns all used XML namespace prefixes in this instance.
- makeChannels() — Make the channels.
- makeHeader() — Returns the XML header and root element, depending on the feed type.
- makeItems() — Prints formatted feed items
- makeNode() — Creates a single node in XML format
- sanitizeCDATA() — Sanitizes data which will be later on returned as CDATA in the feed.
- startItem() — Make the starting tag of channels
public
- addCDATAEncoding() — Add one or more tags to the list of CDATA encoded tags
- addGenerator() — Add a channel element indicating the program used to generate the feed.
- addItem() — Add a FeedItem to the main class
- addNamespace() — Add a XML namespace to the internal list of namespaces. After that, custom channel elements can be used properly to generate a valid feed.
- createNewItem() — Create a new Item.
- filterInvalidXMLChars() — Replace invalid XML characters.
- generateFeed() — Generate the feed.
- getCDATAEncoding() — Get list of CDATA encoded properties
- getMIMEType() — Get the appropriate MIME type string for the current feed.
- printFeed() — Print the actual RSS/ATOM file
- removeCDATAEncoding() — Remove tags from the list of CDATA encoded tags
- setAtomLink() — Set custom 'link' channel elements.
- setChannelAbout() — Set the 'about' channel element. Only for RSS 1.0
- setChannelElement() — Add a channel element to the feed.
- setChannelElementsFromArray() — Set multiple channel elements from an array. Array elements should be 'channelName' => 'channelContent' format.
- setDate() — Set the date when the ATOM feed was lastly updated.
- setDescription() — Set the 'description' channel element
- setEncoding() — Set the 'encoding' attribute in the XML prolog.
- setImage() — Set the 'image' channel element
- setLink() — Set the 'link' channel element
- setPagination() — Set the URLs for feed pagination.
- setSelfLink() — Set an 'atom:link' channel element with relation=self attribute.
- setTitle() — Set the 'title' channel element
- uuid() — Generate an UUID.