Axiom (v1.2.0)

A lightweight PHP framework
H:/Workspace/php-axiom/www/php-axiom/libraries/axiom/axRssFeedWriter.class.php
Go to the documentation of this file.
00001 <?php
00016 class axRssFeedWriter extends axFeedWriter {
00017     
00022     protected $_rss;
00023     
00029     protected $_channel;
00030     
00035     public function __construct (axFeed $feed) {
00036         parent::__construct($feed);
00037         
00038         $this->_rss = $this->appendChild(new DOMElement('rss'));
00039         $this->_rss->setAttribute('version', '2.0');
00040         $this->_channel = $this->appendChild(new DOMElement('channel'));
00041         
00042         $this->buildFeedInfo();
00043         $this->buildItems();
00044     }
00045     
00049     protected function buildFeedInfo () {
00050         $this->_channel->appendChild(new DOMElement('title', $this->_feed->getTitle()));
00051         $this->_channel->appendChild(new DOMElement('link', $this->_feed->getLink()));
00052         $this->_channel->appendChild(new DOMElement('description', $this->_feed->getDescription()));
00053         $this->_channel->appendChild(new DOMElement('language', $this->_feed->getLang()));
00054         $this->_channel->appendChild(new DOMElement('lastBuildDate', $this->_feed->getDate()));
00055         $this->_channel->appendChild(new DOMElement('copyright'), $this->_feed->getCopyright());
00056     }
00057     
00061     protected function buildItems () {
00062         foreach ($this->_feed->getEntries() as $entry) {
00063             
00065             
00066             $item = $this->_channel->appendChild(new DOMElement('item'));
00067             $item->appendChild(new DOMText($entry->getContent()));
00068             $item->appendChild(new DOMElement('title', $entry->getTitle()));
00069             $item->appendChild(new DOMElement('link', $entry->getLink()));
00070             $item->appendChild(new DOMElement('description', $entry->getDescription()));
00071             
00072             if ($author = $entry->getAuthor()) {
00073                 if (isset($author['mail']))
00074                     $item->appendChild(new DOMElement('author', $author['email']));
00075                 elseif (isset($author['name']))
00076                     $item->appendChild(new DOMElement('author', $author['name']));
00077                 elseif (isset($author['uri']))
00078                     $item->appendChild(new DOMElement('author', $author['uri']));
00079             }
00080             
00081             if ($date = $entry->getDate())
00082                 $item->appendChild(new DOMElement('pubDate', $date));
00083             
00084             if ($comments = $entry->getComments())
00085                 $item->appendChild(new DOMElement('comments', $comments));
00086             
00087             if ($id = $entry->getId())
00088                 $item->appendChild(new DOMElement('guid', $id));
00089         }
00090     }
00091 }
 All Data Structures Files Functions Variables