AnewtRssChannel class

RSS channel (feed).

Class Overview

RSS channel (feed).

AnewtRssChannel instances handle a number of properties , which you can set using regular AnewtContainer::set() method calls. These will end up as elements of your RSS channel.

The required properties are:

The optional properties are:

The url property can be used to set a custom URL which will be included in a atom:link element, as suggested by the FeedValidator people. The default url detection will work in most cases though, so there's usually no need to fiddle with this.

You can specify the text encoding used with the encoding property. This defaults to UTF-8. The Anewt RSS module does not do character set conversion, so you should make sure your values are in the right character set before you set them on the AnewtRssChannel and AnewtRssItem instances.

There is also a content-type property that is set to the correct MIME type, i.e. application/rss+xml. You should not override this except for testing, e.g. temporarily serving as text/html helps with debugging your feed. Even though there are lots of text/xml feeds on the web, you should really stick to application/rss+xml. No cookies for you if you change it for production use!

After setting the channel properties, you can add AnewtRssItem instances to it using AnewtRssChannel::add_item(). Finally, you output the complete channel using AnewtRssChannel::flush().

See also

Public Methods

__construct($title=null, $link=null, $description=null)

Create a new channel object.

For convenience, this constructor takes three parameters that must be set according to the RSS specification. If you don't set them here, you're supposed to provided them later by calling the set() method.

Parameters

$title

The channel's title (optional).

$link

The channel's link (optional).

$description

The channel's description (optional).

add_item($item)

Add an AnewtRssItem to the channel.

Parameters

$item

A AnewtRssItem instance.

flush()

Output the channel to a browser.

This renders the page to the browser, including the correct Content-type headers and XML prolog.

Static helper methods

static _build_rss_element($obj, $property, $tagname, $status, $type) [static]

Helper function to create RSS XML elements.

This is only for internal use.

Parameters

$obj

The object from which to retrieve the value

$property

The property name

$tagname

The XML tag name

$status

Status of the element

$type

Data type of the element

Return value

An AnewtXMLDomElement instance, or null.

Private Methods

build_document() [private]

Build an XML document for this channel.

Private Attributes

$properties [private]

List of properties and their specification.

$items [private]

List of items in this feed.

Inheritance

Base Classes

Inherited members