|
Class RSS
{
Var $ title;
Var $ link;
Var $ description;
Var $ language = "en-us ";
Var $ pubDate;
Var $ items;
Var $ tags;
Function RSS ()
{
$ This-> items = array ();
$ This-> tags = array ();
}
Function addItem ($ item)
{
$ This-> items [] = $ item;
}
Function setPubDate ($ when)
{
If (strtotime ($ when) = false)
$ This-> pubDate = date ("D, d m y h: I: s", $ when). "GMT ";
Else
$ This-> pubDate = date ("D, d m y h: I: s", strtotime ($ when). "GMT ";
}
Function getPubDate ()
{
If (empty ($ this-> pubDate ))
Return date ("D, d m y h: I: s"). "GMT ";
Else
Return $ this-> pubDate;
}
Function addTag ($ tag, $ value)
{
$ This-> tags [$ tag] = $ value;
}
Function out ()
{
$ Out = $ this-> header ();
$ Out. =" \ N ";
$ Out. ="". $ This-> title ."\ N ";
$ Out. =" ". $ This-> link ."\ N ";
$ Out. =" ". $ This-> description ." \ N ";
$ Out. =" ". $ This-> language ." \ N ";
$ Out. =" ". $ This-> getPubDate ()." \ N ";
Foreach ($ this-> tags as $ key => $ val) $ out. = "<$ key> $ val \ N ";
Foreach ($ this-> items as $ item) $ out. = $ item-> out ();
$ Out. ="\ N ";
$ Out. = $ this-> footer ();
$ Out = str_replace ("&", "&", $ out );
Return $ out;
}
Function serve ($ contentType = "application/xml ")
{
$ Xml = $ this-> out ();
Header ("Content-type: $ contentType ");
Echo $ xml;
}
Function header ()
{
$ Out =' '. "\ N ";
$ Out. =' '. "\ N ";
Return $ out;
}
Function footer ()
{
Return'';
}
}
Class RSSItem
{
Var $ title;
Var $ link;
Var $ description;
Var $ pubDate;
Var $ guid;
Var $ tags;
Var $ attachment;
Var $ length;
Var $ mimetype;
Function RSSItem ()
{
$ This-> tags = array ();
}
Function setPubDate ($ when)
{
If (strtotime ($ when) = false)
$ This-> pubDate = date ("D, d m y h: I: s", $ when). "GMT ";
Else
$ This-> pubDate = date ("D, d m y h: I: s", strtotime ($ when). "GMT ";
}
Function getPubDate ()
{
If (empty ($ this-> pubDate ))
Return date ("D, d m y h: I: s"). "GMT ";
Else
Return $ this-> pubDate;
}
Function addTag ($ tag, $ value)
{
$ This-> tags [$ tag] = $ value;
}
Function out ()
{
$ Out. =" \ N ";
$ Out. ="". $ This-> title ."\ N ";
$ Out. =" ". $ This-> link ."\ N ";
$ Out. =" ". $ This-> description ." \ N ";
$ Out. =" ". $ This-> getPubDate ()." \ N ";
If ($ this-> attachment! = "")
$ Out. =" ";
If (empty ($ this-> guid) $ this-> guid = $ this-> link;
$ Out. =" ". $ This-> guid ." \ N ";
Foreach ($ this-> tags as $ key => $ val) $ out. = "<$ key> $ val ";
$ Out. ="\ N ";
Return $ out;
}
Function enclosure ($ url, $ mimetype, $ length)
{
$ This-> attachment = $ url;
$ This-> mimetype = $ mimetype;
$ This-> length = $ length;
}
}
|