Class xml_domit_rss_base_document
A base class for DOMIT!RSS and DOMIT! RSS Lite documents

isPublic? no
isAbstract? yes

Inheritance tree:


xml_domit_rss_base
|
xml_domit_rss_elementindexer
|
xml_domit_rss_base_document

Known subclasses:

xml_domit_rss_document, xml_domit_rss_document_lite

Source file: xml_domit_rss_shared.php




Constructor
Instantiates a new xml_domit_rss_base_document.

Signature: xml_domit_rss_base_document($url = '', $cacheDir = './', $cacheTime = 3600)

isPublic? no




Public Constants



Private Constants
DOMIT_RSS_ELEMENT_CHANNEL
channel constant

Type: String

Value: channel

DOMIT_RSS_ELEMENT_ITEM
item constant

Type: String

Value: item

DOMIT_RSS_ELEMENT_TITLE
title constant

Type: String

Value: title

DOMIT_RSS_ELEMENT_LINK
link constant

Type: String

Value: link

DOMIT_RSS_ELEMENT_DESCRIPTION
channel constant

Type: String

Value: description

DOMIT_RSS_ATTR_VERSION
channel constant

Type: String

Value: version

DOMIT_RSS_ARRAY_ITEMS
name of array containing list of existing RSS items

Type: String

Value: items

DOMIT_RSS_ARRAY_CHANNELS
name of array containing list of existing RSS channels

Type: String

Value: channels

DOMIT_RSS_ARRAY_CATEGORIES
name of array containing list of existing RSS categories

Type: String

Value: categories




Public Fields



Private Fields
domit_rss_items
An array of item elements (only present in some RSS formats).

Type: Array

domit_rss_channels
An array of existing channel elements.

Type: Array

domit_rss_categories
An array of existing category elements.

Type: Array

cache
A reference to the file caching object.

Type: Object

useCacheLite
True if PEAR:Cache_Lite is to be used instead of php_text_cache.

Type: boolean

parser
The name of the current parser - either 'DOMIT_RSS' or 'DOMIT_RSS_LITE'.

Type: string

httpConnection
A reference to a http connection or proxy, if one is required.

Type: object




Public Methods
setConnection
Specifies the parametersof the http conection used to obtain the xml data.

Signature: setConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null)

Parameters:

String host - The ip address or domain name of the connection.

String path - The path of the connection.

int port - The port that the connection is listening on.

int timeout - The timeout value for the connection.

String user - The user name, if authentication is required.

String password - The password, if authentication is required.

Example:

A manual HTTP connection is specified:

$rssdoc->setConnection('http://www.engageinteractive.com');

setAuthorization
Specifies basic authentication for an http connection.

Signature: setAuthorization($user, $password)

Parameters:

String user - The user name.

String password - The password.

Example:

Authorization is specified for the HTTP connection:

$rssdoc->setAuthorization('johndoe', 'xyzzy');

setProxyConnection
Specifies the parameters of the http conection used to obtain the xml data.

Signature: setProxyConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null)

Parameters:

String host - The ip address or domain name of the connection.

String path - The path of the connection.

int port - The port that the connection is listening on.

int timeout - The timeout value for the connection.

String user - The user name, if authentication is required.

String password - The password, if authentication is required.

Example:

A HTTP proxy connection is specified:

$rssdoc->setProxyConnection('http://www.engageinteractive.com');

setProxyAuthorization
Specifies basic authentication for an http connection.

Signature: setProxyAuthorization($user, $password)

Parameters:

String user - The user name.

String password - The password.

Example:

Authorization is specified for the HTTP connection:

$rssdoc->setProxyAuthorization('johndoe', 'xyzzy');

parsedBy
Returns the name of the parser.

Signature: parsedBy()

Returns:

string - Either 'DOMIT_RSS' or 'DOMIT_RSS_LITE'.

useCacheLite
Substitutes PEAR::Cache_Lite for the default php_text_cache.

Signature: useCacheLite($doUseCacheLite, $pathToLibrary = './Lite.php', $cacheDir = './', $cacheTime = 3600)

Parameters:

boolean doUseCacheLite - True if Cache Lite is to be used.

String pathToLibrary - Absolute or relative path to the Cache Lite library.

String cacheDir - Directory for cache files.

int cacheTime - Expiration time for a cache file.

Example:

Cache Lite is used.

$rssdoc->useCacheLite(true, './cache/Lite.php', 'tmp/', 1800);

loadRSS
Loads and parses the RSS at the specified url.

Signature: loadRSS($url)

Parameters:

String url - The url for the RSS data.

Returns:

boolean - True if parsing is successful.

Example:

Load and parse an RSS feed.

$rssdoc->loadRSS('http://www.somefeed.com/somefeed.rss');

parseRSS
Parses the RSS text provided.

Signature: parseRSS($rssText)

Parameters:

String rssText - The RSS text.

Returns:

boolean - True if parsing is successful.

Example:

Parse some RSS text.

$rssdoc->parseRSS('<rss version="0.91">...</rss>');

getDocument
Gets a reference to the underlying DOM document.

Signature: &getDocument()

Returns:

Object - A reference to the underlying DOM document.

Example:

The underlying DOM document is returned.

$xmldoc = $rssdoc->getDocument();

getNode
Gets a reference to the root DOM element.

Signature: &getNode()

Returns:

Object - A reference to the root DOM element.

Example:

The underlying root DOM element is returned.

$docElement = $rssdoc->getNode();

getRSSVersion
Returns the version of RSS used to format the data.

Signature: getRSSVersion()

Returns:

String - The version of RSS used to format the data .

Example:

Returns the version of RSS used to format the data.

$version = $rssdoc->getRSSVersion();

getChannelCount
Returns the number of channels in the document.

Signature: getChannelCount()

Returns:

int - The number of channels in the document.

Example:

Returns the number of channels in the document.

$numChannels = $rssdoc->getChannelCount();

getChannel
Returns a reference to the channel located at the specified index.

Signature: &getChannel($index)

Returns:

Object - A reference to the channel located at the specified index.

Example:

Returns the first channel.

$firstChannel = $rssdoc->getChannel(0);




Private Methods
createDocument
Creates an empty DOMIT! document to contain the RSS nodes.

Signature: createDocument()

createDefaultCache
Instantiates a default cache (php_text_cache).

Signature: createDefaultCache($cacheDir = './', $cacheTime = 3600)

Parameters:

String cacheDir - Directory for cache files.

int cacheTime - Expiration time for a cache file.

getDataFromCache
Retrieves the RSS data from the url/cache file.

Signature: getDataFromCache($url)

Parameters:

String url - The url for the RSS data.

Returns:

String - The RSS data.

parseRSSData
Parses the RSS data provided.

Signature: parseRSSData($rssText)

Parameters:

String rssText - The RSS data.

Returns:

boolean - True if parsing is successful.

loadRSSData
Retrieves the RSS data from the url/cache file and parses it.

Signature: loadRSSData($url)

Parameters:

String url - The url for the RSS data.

Returns:

boolean - True if parsing is successful.

getTextFromFile
Get text from an url or file.

Signature: getTextFromFile($filename)

Parameters:

String filename - The url or file path.

Returns:

String - The text contained in the file, or an empty string.

getDataFromFile
Retrieves binary or text data from the specified file.

Signature: &getDataFromFile($filename, $readAttributes)

Parameters:

String filename - The file path.

String readAttributes - The attributes for the read operation ('r' or 'rb').

Returns:

String - The text or binary data contained in the file.

fromFile
Reads in RSS text from a file and parses it.

Signature: &fromFile($filename)

Parameters:

String filename - The file path.

Returns:

boolean - True if parsing is successful.

fromString
Reads in RSS text from a string and parses it.

Signature: &fromString($rssText)

Parameters:

String rssText - The RSS text.

Returns:

boolean - True if parsing is successful.

handleChannelElementsEmbedded
Forces channel elements that are external to a channel to be referenced as subelements of that channel.

Signature: handleChannelElementsEmbedded()


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.