<?php
/**************************************************************
*
* DataFeedFile.com (DFF) Framework API
* Copyright (c) 2008 DataFeedFile.com
*
* DFF Framework API uses CreativeCommons.org by-sa license.
* This license lets others remix, tweak, and build upon your work even for commercial reasons,
* as long as they CREDIT DataFeedFile.com and license their new creations under the identical terms.
* This license is often compared to open source software licenses.
* All new works based on yours will carry the same license, so any derivatives will also allow commercial use.
* Please read our license.txt file for more detail.
*
**************************************************************///
// DFF PHP RSS Class
// Version: 1.0.0
// Date : 2008.06.29
//
class RSS_Feed {
public $channel_URL;
public $channel_title;
public $channel_description;
public $channel_language;
public $channel_copyright;
public $channel_date;
public $channel_creator;
public $channel_subject;
public $image_URL;
public $items = array();
public $items_count;
public function RSS_Feed(){
$this->items_count=0;
$this->channel_URL='';
$this->channel_title='';
$this->channel_description='';
$this->channel_language='';
$this->channel_copyright='';
$this->channel_date='';
$this->channel_creator='';
$this->channel_subject='';
$this->image_URL='';
}
public function set_channel($url='http://www.datafeedfile.com',$title='DataFeedFile.com - Deals, Rebates, Coupons, Discounts',$description='Daily listing of online coupons, rebates, discounts and deals',$language='en-us',$copyright='DataFeedFile.com (c)2008',$creator='DataFeedFile.com',$subject='Coupon codes, Rebates, Discounts RSS Feed') {
$this->channel_URL=$url;
$this->channel_title=$title;
$this->channel_description=$description;
$this->channel_language=$language;
$this->channel_copyright=$copyright;
$this->channel_date=date("Y-m-d").'T'.date("H:i:s").'+01:00';
$this->channel_creator=$creator;
$this->channel_subject=$subject;
}
public function set_image($url='http://www.datafeedfile.com/logo.gif') {
$this->image_URL = $url;
}
public function add_item($url, $title, $description) {
$this->items[$this->items_count]['url']=$url;
$this->items[$this->items_count]['title']=$title;
$this->items[$this->items_count]['description']=$description;
$this->items_count++;
}
public function output() {
$output = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$output .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">'."\n";
$output .= '<channel rdf:about="'.$this->DFF_xml_escape_string($this->channel_URL).'">'."\n";
$output .= '<title>'.$this->DFF_xml_escape_string($this->channel_title).'</title>'."\n";
$output .= '<link>'.$this->DFF_xml_escape_string($this->channel_URL).'</link>'."\n";
$output .= '<description>'.$this->DFF_xml_escape_string($this->channel_description).'</description>'."\n";
$output .= '<dc:language>'.$this->channel_language.'</dc:language>'."\n";
$output .= '<dc:rights>'.$this->channel_copyright.'</dc:rights>'."\n";
$output .= '<dc:date>'.$this->channel_date.'</dc:date>'."\n";
$output .= '<dc:creator>'.$this->DFF_xml_escape_string($this->channel_creator).'</dc:creator>'."\n";
$output .= '<dc:subject>'.$this->DFF_xml_escape_string($this->channel_subject).'</dc:subject>'."\n";
$output .= '<items>'."\n";
$output .= '<rdf:Seq>';
foreach($this->items as $item){
$output .= '<rdf:li rdf:resource="'.$this->DFF_xml_escape_string($item['url']).'"/>'."\n";
}
$output .= '</rdf:Seq>'."\n";
$output .= '</items>'."\n";
$output .= '<image rdf:resource="'.$this->image_URL.'"/>'."\n";
$output .= '</channel>'."\n";
foreach($this->items as $item){
$output .= '<item rdf:about="'.$this->DFF_xml_escape_string($item['url']).'">'."\n";
$output .= '<title><![CDATA['.$this->DFF_xml_escape_string($item['title']).']]></title>'."\n";
$output .= '<link>'.$this->DFF_xml_escape_string($item['url']).'</link>'."\n";
$output .= '<description>'.$this->DFF_xml_escape_string($item['description']).'</description>'."\n";
$output .= '<feedburner:origLink>'.$this->DFF_xml_escape_string($item['url']).'</feedburner:origLink>'."\n";
$output .= '</item>'."\n";
}
$output .= '</rdf:RDF>'."\n";
return $output;
}
public function DFF_xml_escape_string($input_str){
return htmlentities($input_str,ENT_QUOTES,'UTF-8',FALSE);
}
} //end-rss class