[php]
* RSSFeed – Class
*
* The RSSFeed-class makes it possible to create a well-formed RSSFeed
* for your Website. It can be easily be included into your code.
* See Example for more details on how to include / setup.
*
* Use Feedreader ([url]http://www.feedreader.com/downloads.php[/url]) to read your feeds.
* **CUT**
* Feedreader is a freeware Windows application that reads and displays Internet
* newsfeeds aka RSS feeds based on XML.
* It supports all major RSS formats – 0.9, 0.91, 1.0 and various extensions such
* as Dublin Core and Slashback. Feedreader utilizes advanced caching methods to
* reduce bandwitch usage, making the program ideal for mobile communication.
* **CUTEND**
*
* The contents of this file are subject to the Gnu Public License (GPL).
* you may not use this file except in compliance with the License. You may obtain a
* copy of the License at [url]http://www.opensource.org/licenses/gpl[/url]-license.html
*
* Latest releases are available at [url]http://phpclasses.org[/url]/. For feedback or
* bug reports, please contact the author at [email]c.bolten@grafiknews.de[/email]. Thanks!
*
* The Initial Developer of the Original Code is Cornelius Bolten.
* Portions created by Cornelius Bolten are Copyright (C) 2003 Cornelius Bolten.
* All Rights Reserved.
**/

class RSSFeed {

/**
* variables
* @access private
*/
var $m_RSSversion = \’1.0\’;
var $m_XMLversion = \’2.0\’;
var $m_channel = NULL;
var $m_FeedItem = \’\’;
var $m_channelItem = \’\’;

/**
* function RSSFeed
* this is the constructor-method of RSSFeed-class
* @access public
*/
function RSSFeed() {
$this->m_channel = \”m_XMLversion.\”\\”?>
\”;
$this->m_channel .= \” xmlns:rdf=\\”[url]http://www.w3.org/1999/02/22[/url]-rdf-syntax-ns#\\”
xmlns=\\”[url]http://purl.org/rss/1.0[/url]/\\”
>
\”;
}

/**
* function addChannel
* Add a Channel to the opened Feed. This is a MUST.
*
* @access public
* @param ChannelTitle String Title of Channel
* @param ChannelDescription String Description of Channel
* @param ChannelLanguage String en,de,fr..etc. Language that channel uses
* @param ChannelURL String URL corresponding to RSS-File
*/
function addChannel($ChannelTitle, $ChannelDescription, $ChannelLanguage, $ChannelURL) {
$this->m_channel .= \”\t
\”;
$this->m_channel .= \”\t\t\”.$ChannelTitle.\”
\”;
$this->m_channel .= \”\t\t\”.$ChannelDescription.\”
\”;
$this->m_channel .= \”\t\t\”.$ChannelLanguage.\”
\”;
}

/**
* function addChannelLink
* Add a Link-Tag to Channel-Informations.
*
* @access public
* @param ChannelLink String Extra add of Link. can be same as ChanneLink@addChannel
* @see addChannel
*/
function addChannelLink($ChannelLink) {
$this->m_channel .= \”\t\t\”.$ChannelLink.\”\”;
}

/**
* function addChannelImage
* Add an Image to Channel-Informations. This image is displayed in FeedReader.
*
* @access public
* @param ImageULR String URL to ChannelImage
* @param ImageTitle String Title of the Image
* @param ImageLink String Link to which image points
*/
function addChannelImage($ImageURL, $ImageTitle, $ImageLink) {
$this->m_channel .= \”\t\t
\”;
$this->m_channel .= \”\t\t\t\”.$ImageTitle.\”
\”;
$this->m_channel .= \”\t\t\t\”.$ImageURL.\”
\”;
$this->m_channel .= \”\t\t\t\”.$ImageLink.\”\”;
$this->m_channel .= \”\t\t
\”;
}

/**
* function addChannelItem
* Add a channelitem to Channel. this is not a news- or article-item!
* to add a news-item use addFeedItem instead.
*
* @access public
* @param ChannelItem String Item-Resource-Link
* @see addFeedItem
*/
function addChannelItem($ChannelItem) {
$this->m_channelItem .= \”\t\t\t\t
\”;
}

/**
* function addFeedItem
* add a feed-item to your feed. this contains the main informations for
* each news/article/etc.-item
*
* @access public
* @param ItemTitle String Title of Item
* @param ItemURL String URL corresponding to Article
* @param ItemDescription String Description of Item (News-Teaser, etc.)
*/
function addFeedItem($ItemTitle, $ItemURL, $ItemDescription) {
$this->m_FeedItem .= \”\t
\”;
$this->m_FeedItem .= \”\t\t\”.$ItemTitle.\”
\”;
$this->m_FeedItem .= \”\t\t\”.$ItemURL.\”\”;
$this->m_FeedItem .= \”\t\t\”.$ItemDescription.\”
\”;
$this->m_FeedItem .= \”\t

\”;
}

/**
* function releaseFeed
* function to release Feed an print the whole RSS-Data.
* this is the final-call of the object.
*/
function releaseFeed() {
header(\”Content-Type: text/xml\”);
print $this->m_channel;
if(strlen($this->m_channelItem) >= 1) {
print \”\t\t

\t\t\t
\”
.$this->m_channelItem
.\”\t\t\t

\t\t
\”;
}
print \”\t
\”;
print $this->m_FeedItem;
print \”
\”;
}
}

?>

[/php]

发表评论

邮箱地址不会被公开。 必填项已用*标注