PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/MantisBT/library/rssbuilder/class.RSS_V_100.inc.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 180 lines | 143 code | 27 blank | 10 comment | 28 complexity | 69dd768decab39a7fc8073e6c9db93f8 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  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. function __construct(RSSBuilder &$rssdata) {
  15. parent::__construct($rssdata);
  16. } // end constructor
  17. protected function generateXML() {
  18. parent::generateXML();
  19. $root = $this->xml->createElement('rdf:RDF');
  20. $this->xml->appendChild($root);
  21. $root->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
  22. $root->setAttribute('xmlns:sy', 'http://purl.org/rss/1.0/modules/syndication/');
  23. $root->setAttribute('xmlns:rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  24. $channel = $this->xml->createElement('channel');
  25. $root->appendChild($channel);
  26. if ($this->rssdata->getTitle() != FALSE) {
  27. $title = $this->xml->createElement('title');
  28. $title->appendChild($this->xml->createTextNode($this->rssdata->getTitle()));
  29. $channel->appendChild($title);
  30. } // end if
  31. if ($this->rssdata->getAbout() != FALSE) {
  32. $about = $this->xml->createTextNode($this->rssdata->getAbout());
  33. $channel->setAttribute('rdf:about', $this->rssdata->getAbout());
  34. $link = $this->xml->createElement('link');
  35. $link->appendChild($about->cloneNode());
  36. $channel->appendChild($link);
  37. } // end if
  38. if ($this->rssdata->getDescription() != FALSE) {
  39. $description = $this->xml->createElement('description');
  40. $description->appendChild($this->xml->createCDATASection($this->rssdata->getDescription()));
  41. $channel->appendChild($description);
  42. } // end if
  43. if ($this->rssdata->getDCPublisher() != FALSE) {
  44. $publisher = $this->xml->createElement('dc:publisher');
  45. $publisher->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
  46. $channel->appendChild($publisher);
  47. } // end if
  48. if ($this->rssdata->getDCCreator() != FALSE) {
  49. $creator = $this->xml->createElement('dc:creator');
  50. $creator->appendChild($this->xml->createTextNode($this->rssdata->getDCCreator()));
  51. $channel->appendChild($creator);
  52. } // end if
  53. if ($this->rssdata->getDCDate() != FALSE) {
  54. $date = $this->xml->createTextNode(date('r', $this->rssdata->getDCDate()));
  55. $pub_date = $this->xml->createElement('dc:date');
  56. $pub_date->appendChild($date);
  57. $channel->appendChild($pub_date);
  58. } // end if
  59. if ($this->rssdata->getDCLanguage() != FALSE) {
  60. $language = $this->xml->createElement('dc:language');
  61. $language->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
  62. $channel->appendChild($language);
  63. } // end if
  64. if ($this->rssdata->getDCRights() != FALSE) {
  65. $copyright = $this->xml->createElement('dc:rights');
  66. $copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
  67. $channel->appendChild($copyright);
  68. } // end if
  69. if ($this->rssdata->getDCCoverage() != FALSE) {
  70. $coverage = $this->xml->createElement('dc:coverage');
  71. $coverage->appendChild($this->xml->createTextNode($this->rssdata->getDCCoverage()));
  72. $channel->appendChild($coverage);
  73. } // end if
  74. if ($this->rssdata->getDCContributor() != FALSE) {
  75. $contributor = $this->xml->createElement('dc:contributor');
  76. $contributor->appendChild($this->xml->createTextNode($this->rssdata->getDCContributor()));
  77. $channel->appendChild($contributor);
  78. } // end if
  79. if ($this->rssdata->getSYPeriod() != FALSE) {
  80. $period = $this->xml->createElement('sy:updatePeriod');
  81. $period->appendChild($this->xml->createTextNode($this->rssdata->getSYPeriod()));
  82. $channel->appendChild($period);
  83. } // end if
  84. if ($this->rssdata->getSYFrequency() != FALSE) {
  85. $frequency = $this->xml->createElement('sy:updateFrequency');
  86. $frequency->appendChild($this->xml->createTextNode($this->rssdata->getSYFrequency()));
  87. $channel->appendChild($frequency);
  88. } // end if
  89. if ($this->rssdata->getSYBase() != FALSE) {
  90. $basedate = $this->xml->createTextNode(date('r', $this->rssdata->getSYBase()));
  91. $base = $this->xml->createElement('sy:updateBase');
  92. $base->appendChild($basedate);
  93. $channel->appendChild($base);
  94. } // end if
  95. if ($this->rssdata->getImageLink() != FALSE) {
  96. $image = $this->xml->createElement('image');
  97. $channel->appendChild($image);
  98. $image->setAttribute('rdf:about', $this->rssdata->getImageLink());
  99. $image->appendChild($title->cloneNode(TRUE));
  100. $url = $this->xml->createElement('url');
  101. $url->appendChild($this->xml->createTextNode($this->rssdata->getImageLink()));
  102. $image->appendChild($url);
  103. $image->appendChild($link->cloneNode(TRUE));
  104. $image->appendChild($description->cloneNode(TRUE));
  105. } // end if
  106. $items = $this->xml->createElement('items');
  107. $channel->appendChild($items);
  108. $sequence = $this->xml->createElement('rdf:Seq');
  109. $items->appendChild($sequence);
  110. foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
  111. $li = '$li_' . $id;
  112. $$li = $this->xml->createElement('rdf:li');
  113. $$li->setAttribute('resource', $rss_item->getLink());
  114. $sequence->appendChild($$li);
  115. } // end foreach
  116. foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
  117. $item = '$item_' . $id;
  118. $$item = $this->xml->createElement('item');
  119. $$item->setAttribute(' rdf:about', $rss_item->getLink());
  120. $root->appendChild($$item);
  121. $item_title = '$item_title_' . $id;
  122. $$item_title = $this->xml->createElement('title');
  123. $$item_title->appendChild($this->xml->createTextNode($rss_item->getTitle()));
  124. $$item->appendChild($$item_title);
  125. $item_author = '$item_author_' . $id;
  126. $$item_author = $this->xml->createElement('author');
  127. $$item_author->appendChild($this->xml->createTextNode($rss_item->getAuthor()));
  128. $$item->appendChild($$item_author);
  129. $item_link = '$item_link_' . $id;
  130. $$item_link = $this->xml->createElement('link');
  131. $$item_link->appendChild($this->xml->createTextNode($rss_item->getLink()));
  132. $$item->appendChild($$item_link);
  133. $item_desc = '$item_desc_' . $id;
  134. $$item_desc = $this->xml->createElement('description');
  135. $$item_desc->appendChild($this->xml->createCDATASection($rss_item->getDescription()));
  136. $$item->appendChild($$item_desc);
  137. $item_sub = '$item_sub_' . $id;
  138. $$item_sub = $this->xml->createElement('dc:subject');
  139. $$item_sub->appendChild($this->xml->createTextNode($rss_item->getSubject()));
  140. $$item->appendChild($$item_sub);
  141. $item_date = '$item_date_' . $id;
  142. $date_string = $this->xml->createTextNode(date('r', $rss_item->getItemDate()));
  143. $$item_date = $this->xml->createElement('dc:date');
  144. $$item_date->appendChild($date_string);
  145. $$item->appendChild($$item_date);
  146. $item_pic = '$item_pic_' . $id;
  147. $$item_pic = $this->xml->createElement('dc:image');
  148. $$item_pic->appendChild($this->xml->createTextNode($rss_item->getImage()));
  149. $$item->appendChild($$item_pic);
  150. } // end foreach
  151. } // function
  152. } // end class
  153. ?>