Class: RSS
- Package: saf.XML
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 1.6, 2003-05-23, $Id: RSS.php,v 1.3 2007/10/06 00:06:30 lux Exp $
- Access: public
RSS uses XSLT and Cache to generate content syndicated from other web
sites and to cache it so as not to put unnecessarily load on those
sites. RSS also exposes an EasyText method, which adds support for the
EasyText =RSS tag. Please note: this class depends on the Cache and
XSLT classes.
New in 1.2:
- Added the ability to create RSS documents instead of simply processing them.
This is compatible with RSS version 0.91, but I don't know about 1.0.
New in 1.4:
- Fixed a bug in the EasyText method (stupid spelling mistake!). Thanks Oleg
for the report!
New in 1.6:
- Removed the EasyText() and EasyTextInit() methods.
Usage Example
<?php
$rss = new RSS;
$url = 'http://somesite.com/content.rss';
$rss_content = $rss->getUrl ($url);
$stylesheet = $rss->getXsl ('inc/xsl/somesite.xsl');
$data = $rss->process ($stylesheet, $rss_content, 'cache', 900, $url);
if ($data) {
echo $data;
} else {
echo $rss->xslt->error;
}
?>
Properties
$doc
- Access: public
If an RSS document is being created, this will
contain the XMLDoc object.
$error
$client
- Access: public
The XML-RPC client object.
$errno
- Access: public
The error number (faultCode) if an error occurs.
$name
$value
- Access: public
Value of the attribute.
$version
- Access: public
XML version. Default is 1.0
$encoding
$doctype
- Access: public
May contain the entire DOCTYPE declaration tag, including the
< and >.
$root
- Access: public
The root node of the XML document.
$filename
- Access: public
If this object was read in from a file, it may be specified here.
$xquery
- Access: public
If query() has been called, this will contain the XMLDocQuery object.
$content
- Access: public
Content of the node.
$children = array ()
$attributes = array ()
- Access: public
Array of attribute objects.
$comment
- Access: public
Attach a comment to the node, which will appear as an XML comment
tag above the element.
$cdata = false
- Access: public
Notes whether the contents of this node should be displayed as
a <![CDATA[ ... ]]> block.
$number = 0
- Access: public
Contains the number of this node within its parent node. Numbers
only increase when more than one child has the same name.
$parent
$callbackStart = false
- Access: public
The function or method to use as a callback for the start tag
of the current XML node.
$callbackEnd = false
- Access: public
The function or method to use as a callback for the end tag
of the current XML node.
$callbackObject = false
- Access: public
The object that contains the methods listed in $callbackStart
and $callbackEnd (if they are methods and not ordinary custom or built-in
PHP functions).
$propagateCallback = false
- Access: public
Whether or not to propagate callback settings to new child
nodes upon their creation. Defaults to false.
$nodes
$condition
- Access: private
If a condition token is found, this is set to an array containing
the 'operator' and the 'left' node set of the condition.
$rules = array ()
$current
$schema
$tags
$types = array ('text', 'empty', 'data')
$parser
$rule = 'required'
$err_line
$err_code
$err_byte
$err_colnum
$attrs = array ()
$type = false
$ns
$parents
$test
$xslt
- Access: public
This is an XSLT processor resource returned by the
xslt_create () function. Please note: the XSLT processor
is not created until the process method of this class is
called, so as to maintain compatibility with systems that
do not have Sablotron support installed, but are using
EasyText.
$docroot
- Access: public
If an RSS document is being created, this will
contain a reference to the root node.
$channel
- Access: public
If an RSS document is being created, this will
contain a reference to the current channel.
Methods
getUrl ($url)
- Access: public
- Return: string
Returns the contents of the specified url.
getXsl ($file)
- Access: public
- Return: string
Returns the contents of the specified xsl file.
process ($xsldata, $xmldata, $cache_dir, $cache_duration, $cache_file)
- Access: public
- Return: string
Returns the contents of the transformed data, or
its cached equivalent. Returning 0 means there was an XSL
transformation error.
makeDoc ($version = '0.91')
- Access: public
Creates a new XMLDoc object, sets the root node to 'rss',
and also defines its doctype. Note: $version is the RSS version,
not the XML version.
setDoctype ($doctype)
- Access: public
Allows you to easily modify the doctype of the current
RSS document being created.
addChannel ($title, $link, $description = '', $language = 'en-us')
- Access: public
Creates a new channel XMLNode.
addItem ($title, $link, $description = '')
- Access: public
Creates a new item XMLNode and adds it to the currently
active channel.
write ()
- Access: public
- Return: string
Calls the write() method on the current RSS document,
and returns the result.
