[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/rssbuilder/ -> class.RSS_V_200.inc.php (source)

   1  <?php
   2  require_once  'class.RSSBase.inc.php';
   3  /**
   4  * Class for creating an RSS-feed
   5  * @author Michael Wimmer <flaimo@gmail.com>
   6  * @category flaimo-php
   7  * @copyright Copyright © 2002-2008, Michael Wimmer
   8  * @license GNU General Public License v3
   9  * @link http://code.google.com/p/flaimo-php/
  10  * @package RSS
  11  * @version 2.2.1
  12  */
  13  class RSS_V_200 extends RSS_V_abstract {
  14  
  15  	function __construct(RSSBuilder &$rssdata) {
  16          parent::__construct($rssdata);
  17      } // end constructor
  18  
  19  	protected function generateXML() {
  20          parent::generateXML();
  21          $root = $this->xml->createElement('rss');
  22          $root->setAttribute('version', '2.0');
  23          $root->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
  24          $root->setAttribute('xmlns:sy', 'http://purl.org/rss/1.0/modules/syndication/');
  25          $this->xml->appendChild($root);
  26          $channel = $this->xml->createElement('channel');
  27          $root->appendChild($channel);
  28  
  29          if ($this->rssdata->getDCRights() != FALSE) {
  30              $copyright = $this->xml->createElement('copyright');
  31              $copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
  32              $channel->appendChild($copyright);
  33          } // end if
  34  
  35          if ($this->rssdata->getDCDate() != FALSE) {
  36              $date = $this->xml->createTextNode(date('Y-m-d\TH:i:sO', $this->rssdata->getDCDate()));
  37              $pub_date = $this->xml->createElement('pubDate');
  38              $last_build = $this->xml->createElement('lastBuildDate');
  39              $pub_date->appendChild($date);
  40              $last_build->appendChild($date->cloneNode());
  41              $channel->appendChild($pub_date);
  42              $channel->appendChild($last_build);
  43          } // end if
  44  
  45          if ($this->rssdata->getAbout() != FALSE) {
  46              $about = $this->xml->createTextNode($this->rssdata->getAbout());
  47              $link = $this->xml->createElement('link');
  48              $docs = $this->xml->createElement('docs');
  49              $docs->appendChild($about);
  50              $link->appendChild($about->cloneNode());
  51              $channel->appendChild($docs);
  52              $channel->appendChild($link);
  53          } // end if
  54  
  55          if ($this->rssdata->getDescription() != FALSE) {
  56              $description = $this->xml->createElement('description');
  57              $description->appendChild($this->xml->createCDATASection($this->rssdata->getDescription()));
  58              $channel->appendChild($description);
  59          } // end if
  60  
  61          if ($this->rssdata->getTitle() != FALSE) {
  62              $title = $this->xml->createElement('title');
  63              $title->appendChild($this->xml->createTextNode($this->rssdata->getTitle()));
  64              $channel->appendChild($title);
  65          } // end if
  66  
  67          if ($this->rssdata->getImageLink() != FALSE) {
  68              $image = $this->xml->createElement('image');
  69              $channel->appendChild($image);
  70              $image->appendChild($title->cloneNode(TRUE));
  71              $url = $this->xml->createElement('url');
  72              $url->appendChild($this->xml->createTextNode($this->rssdata->getImageLink()));
  73              $image->appendChild($url);
  74              $image->appendChild($link->cloneNode(TRUE));
  75              $image->appendChild($description->cloneNode(TRUE));
  76          } // end if
  77  
  78          if ($this->rssdata->getDCPublisher() != FALSE) {
  79              $managingEditor = $this->xml->createElement('managingEditor');
  80              $managingEditor->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
  81              $channel->appendChild($managingEditor);
  82          } // end if
  83  
  84          if ($this->rssdata->getDCCreator() != FALSE) {
  85              $webmaster_string = $this->xml->createTextNode($this->rssdata->getDCCreator());
  86              $webMaster = $this->xml->createElement('webMaster');
  87              $generator = $this->xml->createElement('generator');
  88              $webMaster->appendChild($webmaster_string);
  89              $generator->appendChild($webmaster_string->cloneNode());
  90              $channel->appendChild($webMaster);
  91              $channel->appendChild($generator);
  92          } // end if
  93  
  94          if ($this->rssdata->getDCLanguage() != FALSE) {
  95              $language = $this->xml->createElement('language');
  96              $language->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
  97              $channel->appendChild($language);
  98          } // end if
  99  
 100          if ($this->rssdata->getCategory() != FALSE) {
 101              $category = $this->xml->createElement('category');
 102              $category->appendChild($this->xml->createTextNode($this->rssdata->getCategory()));
 103              $channel->appendChild($category);
 104          } // end if
 105  
 106          if ($this->rssdata->getCache() != FALSE) {
 107              $cache = $this->xml->createElement('ttl');
 108              $cache->appendChild($this->xml->createTextNode($this->rssdata->getCache()));
 109              $channel->appendChild($cache);
 110          } // end if
 111  
 112          if ($this->rssdata->getDCPublisher() != FALSE) {
 113              $publisher = $this->xml->createElement('dc:publisher');
 114              $publisher->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
 115              $channel->appendChild($publisher);
 116          } // end if
 117  
 118          if ($this->rssdata->getDCCreator() != FALSE) {
 119              $creator = $this->xml->createElement('dc:creator');
 120              $creator->appendChild($this->xml->createTextNode($this->rssdata->getDCCreator()));
 121              $channel->appendChild($creator);
 122          } // end if
 123  
 124          if ($this->rssdata->getDCDate() != FALSE) {
 125              $date = $this->xml->createTextNode(date('Y-m-d\TH:i:sO', $this->rssdata->getDCDate()));
 126              $pub_date = $this->xml->createElement('dc:date');
 127              $pub_date->appendChild($date);
 128              $channel->appendChild($pub_date);
 129          } // end if
 130  
 131          if ($this->rssdata->getDCLanguage() != FALSE) {
 132              $language_dc = $this->xml->createElement('dc:language');
 133              $language_dc->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
 134              $channel->appendChild($language_dc);
 135          } // end if
 136  
 137          if ($this->rssdata->getDCRights() != FALSE) {
 138              $copyright = $this->xml->createElement('dc:rights');
 139              $copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
 140              $channel->appendChild($copyright);
 141          } // end if
 142  
 143          if ($this->rssdata->getDCContributor() != FALSE) {
 144              $contributor = $this->xml->createElement('dc:contributor');
 145              $contributor->appendChild($this->xml->createTextNode($this->rssdata->getDCContributor()));
 146              $channel->appendChild($contributor);
 147          } // end if
 148  
 149          if ($this->rssdata->getSYPeriod() != FALSE) {
 150              $period = $this->xml->createElement('sy:updatePeriod');
 151              $period->appendChild($this->xml->createTextNode($this->rssdata->getSYPeriod()));
 152              $channel->appendChild($period);
 153          } // end if
 154  
 155          if ($this->rssdata->getSYFrequency() != FALSE) {
 156              $frequency = $this->xml->createElement('sy:updateFrequency');
 157              $frequency->appendChild($this->xml->createTextNode($this->rssdata->getSYFrequency()));
 158              $channel->appendChild($frequency);
 159          } // end if
 160  
 161          if ($this->rssdata->getSYBase() != FALSE) {
 162              $basedate = $this->xml->createTextNode(date('r', $this->rssdata->getSYBase()));
 163              $base = $this->xml->createElement('sy:updateBase');
 164              $base->appendChild($basedate);
 165              $channel->appendChild($base);
 166          } // end if
 167  
 168          foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
 169              $item = '$item_' . $id;
 170              $$item = $this->xml->createElement('item');
 171              $channel->appendChild($$item);
 172  
 173              $item_title = '$item_title_' . $id;
 174              $$item_title = $this->xml->createElement('title');
 175              $$item_title->appendChild($this->xml->createTextNode($rss_item->getTitle()));
 176              $$item->appendChild($$item_title);
 177  
 178              $item_author = '$item_author_' . $id;
 179              $$item_author = $this->xml->createElement('author');
 180              $$item_author->appendChild($this->xml->createTextNode($rss_item->getAuthor()));
 181              $$item->appendChild($$item_author);
 182  
 183              $item_link = '$item_link_' . $id;
 184              $$item_link = $this->xml->createElement('link');
 185              $$item_link->appendChild($this->xml->createTextNode($rss_item->getLink()));
 186              $$item->appendChild($$item_link);
 187  
 188              $item_desc = '$item_desc_' . $id;
 189              $$item_desc = $this->xml->createElement('description');
 190              $$item_desc->appendChild($this->xml->createCDATASection($rss_item->getDescription()));
 191              $$item->appendChild($$item_desc);
 192  
 193              $item_sub = '$item_sub_' . $id;
 194              $$item_sub = $this->xml->createElement('category');
 195              $$item_sub->appendChild($this->xml->createTextNode($rss_item->getSubject()));
 196              $$item->appendChild($$item_sub);
 197  
 198              $item_date = '$item_date_' . $id;
 199              $item_date_string = '$item_date_string_' . $id;
 200              $$item_date_string = $this->xml->createTextNode(date('r', $rss_item->getItemDate()));
 201              $$item_date = $this->xml->createElement('pubDate');
 202              $$item_date->appendChild($$item_date_string);
 203              $$item->appendChild($$item_date);
 204  
 205              $item_guid = '$item_guid_' . $id;
 206              $$item_guid = $this->xml->createElement('guid');
 207              $$item_guid->appendChild($this->xml->createTextNode($rss_item->getLink()));
 208              $$item->appendChild($$item_guid);
 209  
 210              if ( $rss_item->getComments() != FALSE ) {
 211                  $item_comments = '$item_comments_' . $id;
 212                  $$item_comments = $this->xml->createElement('comments');
 213                  $$item_comments->appendChild($this->xml->createTextNode($rss_item->getComments()));
 214                  $$item->appendChild($$item_comments);            
 215              } // end if
 216  
 217          } // end foreach
 218      } // function
 219  } // end class
 220  ?>


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7