class FeedHtmlField{ var $rawFieldContent; var $truncSize,$syndicateHtml; function FeedHtmlField($parFieldContent){ if($parFieldContent){ $this- rawFieldContent=$parFieldContent; } } function output(){ if(!$this- rawFieldContent){ $result=""; } elseif($this- syndicateHtml){ $result=" ![CDATA[".$this- rawFieldContent."]] }else{ if($this- truncSize and is_int($this- truncSize)){ $result=FeedCreator::iTrunc(htmlspecialchars($this- rawFieldContent),$this- truncSize); }else{ $result=htmlspecialchars($this- rawFieldContent); } } return $result; } }
class UniversalFeedCreator extends FeedCreator{ var $_feed; function _setFormat($format){ switch (strtoupper($format)){ case "2.0": // fall through case "RSS2.0": $this- _feed=new RSSCreator20(); break; case "0.91": // fall through case "RSS0.91": $this- _feed=new RSSCreator091(); break; default: $this- _feed=new RSSCreator091(); break; } $vars=get_object_vars($this); foreach ($vars as $key = $value){ // prevent overwriting of properties "contentType","encoding"; do not copy "_feed" itself if(!in_array($key, array("_feed","contentType","encoding"))){ $this- _feed- {$key}=$this- {$key}; } } }
function createFeed($format="RSS0.91"){ $this- _setFormat($format); return $this- _feed- createFeed(); }
function saveFeed($format="RSS0.91",$filename="",$displayContents=true){ $this- _setFormat($format); $this- _feed- saveFeed($filename,$displayContents); }
function useCached($format="RSS0.91",$filename="",$timeout=3600){ $this- _setFormat($format); $this- _feed- useCached($filename,$timeout); } }
class FeedCreator extends HtmlDescribable{ var $title,$description,$link; var $syndicationURL,$image,$language,$copyright,$pubDate,$lastBuildDate,$editor,$editorEmail,$webmaster,$category,$docs,$ttl,$rating,$skipHours,$skipDays; var $xslStyleSheet=""; var $items=Array(); var $contentType="application/xml"; var $encoding="utf-8"; var $additionalElements=Array();
function addItem($item){ $this- items[]=$item; }
function clearItem2Null(){ $this- items=array(); }
function iTrunc($string,$length){ if(strlen($string) =$length){ return $string; }