[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/library/rssbuilder/ -> class.RSS_V_100.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_100 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('rdf:RDF');
  22          $this->xml->appendChild($root);
  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          $root->setAttribute('xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  26          $channel = $this->xml->createElement('channel');
  27          $root->appendChild($channel);
  28  
  29          if ($this->rssdata->getTitle() != FALSE) {
  30              $title = $this->xml->createElement('title');
  31              $title->appendChild($this->xml->createTextNode($this->rssdata->getTitle()));
  32              $channel->appendChild($title);
  33          } // end if
  34  
  35          if ($this->rssdata->getAbout() != FALSE) {
  36              $about = $this->xml->createTextNode($this->rssdata->getAbout());
  37              $channel->setAttribute('rdf:about', $this->rssdata->getAbout());
  38  
  39              $link = $this->xml->createElement('link');
  40              $link->appendChild($about->cloneNode());
  41              $channel->appendChild($link);
  42          } // end if
  43  
  44          if ($this->rssdata->getDescription() != FALSE) {
  45              $description = $this->xml->createElement('description');
  46              $description->appendChild($this->xml->createCDATASection($this->rssdata->getDescription()));
  47              $channel->appendChild($description);
  48          } // end if
  49  
  50          if ($this->rssdata->getDCPublisher() != FALSE) {
  51              $publisher = $this->xml->createElement('dc:publisher');
  52              $publisher->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
  53              $channel->appendChild($publisher);
  54          } // end if
  55  
  56          if ($this->rssdata->getDCCreator() != FALSE) {
  57              $creator = $this->xml->createElement('dc:creator');
  58              $creator->appendChild($this->xml->createTextNode($this->rssdata->getDCCreator()));
  59              $channel->appendChild($creator);
  60          } // end if
  61  
  62          if ($this->rssdata->getDCDate() != FALSE) {
  63              $date = $this->xml->createTextNode(date('r', $this->rssdata->getDCDate()));
  64              $pub_date = $this->xml->createElement('dc:date');
  65              $pub_date->appendChild($date);
  66              $channel->appendChild($pub_date);
  67          } // end if
  68  
  69          if ($this->rssdata->getDCLanguage() != FALSE) {
  70              $language = $this->xml->createElement('dc:language');
  71              $language->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
  72              $channel->appendChild($language);
  73          } // end if
  74  
  75          if ($this->rssdata->getDCRights() != FALSE) {
  76              $copyright = $this->xml->createElement('dc:rights');
  77              $copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
  78              $channel->appendChild($copyright);
  79          } // end if
  80  
  81          if ($this->rssdata->getDCCoverage() != FALSE) {
  82              $coverage = $this->xml->createElement('dc:coverage');
  83              $coverage->appendChild($this->xml->createTextNode($this->rssdata->getDCCoverage()));
  84              $channel->appendChild($coverage);
  85          } // end if
  86  
  87          if ($this->rssdata->getDCContributor() != FALSE) {
  88              $contributor = $this->xml->createElement('dc:contributor');
  89              $contributor->appendChild($this->xml->createTextNode($this->rssdata->getDCContributor()));
  90              $channel->appendChild($contributor);
  91          } // end if
  92  
  93          if ($this->rssdata->getSYPeriod() != FALSE) {
  94              $period = $this->xml->createElement('sy:updatePeriod');
  95              $period->appendChild($this->xml->createTextNode($this->rssdata->getSYPeriod()));
  96              $channel->appendChild($period);
  97          } // end if
  98  
  99          if ($this->rssdata->getSYFrequency() != FALSE) {
 100              $frequency = $this->xml->createElement('sy:updateFrequency');
 101              $frequency->appendChild($this->xml->createTextNode($this->rssdata->getSYFrequency()));
 102              $channel->appendChild($frequency);
 103          } // end if
 104  
 105          if ($this->rssdata->getSYBase() != FALSE) {
 106              $basedate = $this->xml->createTextNode(date('r', $this->rssdata->getSYBase()));
 107              $base = $this->xml->createElement('sy:updateBase');
 108              $base->appendChild($basedate);
 109              $channel->appendChild($base);
 110          } // end if
 111  
 112          if ($this->rssdata->getImageLink() != FALSE) {
 113              $image = $this->xml->createElement('image');
 114              $channel->appendChild($image);
 115              $image->setAttribute('rdf:about', $this->rssdata->getImageLink());
 116              $image->appendChild($title->cloneNode(TRUE));
 117              $url = $this->xml->createElement('url');
 118              $url->appendChild($this->xml->createTextNode($this->rssdata->getImageLink()));
 119              $image->appendChild($url);
 120              $image->appendChild($link->cloneNode(TRUE));
 121              $image->appendChild($description->cloneNode(TRUE));
 122          } // end if
 123  
 124          $items = $this->xml->createElement('items');
 125          $channel->appendChild($items);
 126          $sequence = $this->xml->createElement('rdf:Seq');
 127          $items->appendChild($sequence);
 128  
 129          foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
 130              $li = '$li_' . $id;
 131              $$li = $this->xml->createElement('rdf:li');
 132              $$li->setAttribute('resource', $rss_item->getLink());
 133              $sequence->appendChild($$li);
 134          } // end foreach
 135  
 136          foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
 137              $item = '$item_' . $id;
 138              $$item = $this->xml->createElement('item');
 139              $$item->setAttribute(' rdf:about', $rss_item->getLink());
 140              $root->appendChild($$item);
 141  
 142              $item_title = '$item_title_' . $id;
 143              $$item_title = $this->xml->createElement('title');
 144              $$item_title->appendChild($this->xml->createTextNode($rss_item->getTitle()));
 145              $$item->appendChild($$item_title);
 146  
 147              $item_author = '$item_author_' . $id;
 148              $$item_author = $this->xml->createElement('author');
 149              $$item_author->appendChild($this->xml->createTextNode($rss_item->getAuthor()));
 150              $$item->appendChild($$item_author);
 151  
 152              $item_link = '$item_link_' . $id;
 153              $$item_link = $this->xml->createElement('link');
 154              $$item_link->appendChild($this->xml->createTextNode($rss_item->getLink()));
 155              $$item->appendChild($$item_link);
 156  
 157              $item_desc = '$item_desc_' . $id;
 158              $$item_desc = $this->xml->createElement('description');
 159              $$item_desc->appendChild($this->xml->createCDATASection($rss_item->getDescription()));
 160              $$item->appendChild($$item_desc);
 161  
 162              $item_sub = '$item_sub_' . $id;
 163              $$item_sub = $this->xml->createElement('dc:subject');
 164              $$item_sub->appendChild($this->xml->createTextNode($rss_item->getSubject()));
 165              $$item->appendChild($$item_sub);
 166  
 167              $item_date = '$item_date_' . $id;
 168              $date_string = $this->xml->createTextNode(date('r', $rss_item->getItemDate()));
 169              $$item_date = $this->xml->createElement('dc:date');
 170              $$item_date->appendChild($date_string);
 171              $$item->appendChild($$item_date);
 172  
 173              $item_pic = '$item_pic_' . $id;
 174              $$item_pic = $this->xml->createElement('dc:image');
 175              $$item_pic->appendChild($this->xml->createTextNode($rss_item->getImage()));
 176              $$item->appendChild($$item_pic);
 177          } // end foreach
 178      } // function
 179  } // end class
 180  ?>


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