PHP Classes
elePHPant
Icontem

File: rss_class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sklyuev Nickita  >  Little RSS class  >  rss_class.php  >  Download  
File: rss_class.php
Role: Class source
Content type: text/plain
Description: Class Lilte RSS FEED
Class: Little RSS class
Compose and generate RSS 2.0 feeds
Author: By
Last change: Options are corrected
Date: 6 years ago
Size: 2,016 bytes
 

Contents

Class file image Download
<?php
// litle rss class
class rss_feed{
   
    private
$title;
    private
$desc;
    private
$host;
    private
$encode;
    private
$lang;
    private
$date;
    private
$author;
    private
$generate;
    private
$head;
   
    public function
__construct($host,$title,$desc,$author,$encode="windows-1251",$lang="ru", $generate="Trilodi CMS TEAM"){
       
$this->host=$host;
       
$this->title=$title;
       
$this->desc=$desc;
       
$this->encode=$encode;
       
$this->lang=$lang;
       
$this->author=$author;
       
$this->generate=$generate;
   
   
$feed="<?xml version=\"1.0\" encoding=\"".$this->encode."\"?>\n<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n<title>".$this->title."</title>\n<link>".$this->host."</link>\n<language>".$this->lang."</language>\n<description>".$this->desc."</description>\n<generator>".$this->generate."</generator>";
   
$this->head=$feed;
    return
$this->head;
    }
   
    public function
feed($title, $guid, $description, $category, $creator, $guidOn="true", $pubDate="Mon, 05 Jan 1987 18:44:39", $time_poyas="+0400"){
       
$fead_rss.="\n<item>\n";
       
$fead_rss.="<title>".$title."</title>\n";
       
$fead_rss.="<guid isPermaLink=\"".$guidOn."\">".$guid."</guid>\n";
       
$fead_rss.="<link>".$this->host."/$guid</link>\n";
       
$fead_rss.="<description>\n<![CDATA[$description]]>\n</description>\n";
       
$fead_rss.="<category><![CDATA[$category]]></category>\n";
       
$fead_rss.="<dc:creator>$creator</dc:creator>\n";
       
$fead_rss.="<pubDate>$pubDate $time_poyas</pubDate>\n";
       
$fead_rss.="\n</item>";
        return
$fead_rss;
       
    }
   
    public function
end_feed(){
        return
"\n</channel>\n</rss>";
    }
   
// end class
}
// example
$class= new rss_feed("http://www.kachni.net",'Kachni.NET','The Description','Administration Kachni.NET');
$test.=$class->head;

for (
$i=1;$i<11;$i++){
$test.=$class->feed('Example news &#8470; '.$i, "test#$i.html", '<center> Examle description news &#8470; '.$i."<center><hr>", $i, 'Administration Kachni.NET');
}

$test.=$class->end_feed();
echo
$test;
?>