encoding = 'UTF-8'; $this->items = array(); $this->description = ''; $this->link = ''; $this->title = ''; $this->iTunes = false; $this->iTunesNS = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; } public function addItem() { $item = new IMuRSSItem; $this->items[] = $item; return $item; } public function createXML() { $xml = new IMuXMLDocument(); $elem = $xml->element('rss'); $elem->attr('version', '2.0'); if ($this->iTunes) $elem->attr('xmlns:itunes', $this->iTunesNS); $elem->push(); $elem = $xml->element('channel'); $elem->push(); // Mandatory $xml->element('description', $this->description); $xml->element('link', $this->link); $xml->element('title', $this->title); // Not mandatory but always included $date = date('r'); $xml->element('lastBuildDate', $date); $xml->element('pubDate', $date); // Optional if (isset($this->author)) $xml->element('author', $this->author); if (isset($this->category)) $xml->element('category', $this->category); if (isset($this->copyright)) $xml->element('copyright', $this->copyright); if (isset($this->language)) $xml->element('language', $this->language); // iTunes-specific if ($this->iTunes) { if (isset($this->explicit)) { $explicit = $this->explicit; if (is_bool($explicit)) $explicit = $explicit ? 'Yes' : 'No'; $xml->element('itunes:explicit', $explicit); } if (isset($this->image)) $xml->element('itunes:image', $this->image); } foreach ($this->items as $item) $item->createXML($xml); return $xml->saveXML(); } private $items; } class IMuRSSItem { public $author; public $category; public $description; public $length; public $link; public $mimeType; public $pubDate; public $title; public $url; public function __construct() { $this->author = ''; $this->category = ''; $this->description = ''; $this->length = ''; $this->link = ''; $this->mimeType = ''; $this->pubDate = ''; $this->title = ''; $this->url = ''; } public function createXML($xml) { $elem = $xml->element('item'); $elem->push(); if (isset($this->author) && $this->author != '') $xml->element('author', $this->author); if (isset($this->category) && $this->category != '') $xml->element('category', $this->category); $xml->element('description', $this->description); $elem = $xml->element('enclosure'); $elem->attr('url', $this->url); $elem->attr('length', $this->length); $elem->attr('type', $this->mimeType); $xml->element('guid', $this->link); $xml->element('link', $this->link); $xml->element('pubDate', $this->pubDate); $xml->element('title', $this->title); } } ?>