PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 117 lines | 91 code | 16 blank | 10 comment | 18 complexity | e55a61246c0d90caa927818db1bbbf35 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_091 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('rss');
  20. $this->xml->appendChild($root);
  21. $root->setAttribute('version', '0.91');
  22. $channel = $this->xml->createElement('channel');
  23. $root->appendChild($channel);
  24. if ($this->rssdata->getDCRights() != FALSE) {
  25. $copyright = $this->xml->createElement('copyright');
  26. $copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
  27. $channel->appendChild($copyright);
  28. } // end if
  29. if ($this->rssdata->getDCDate() != FALSE) {
  30. $date = $this->xml->createTextNode(date('r', $this->rssdata->getDCDate()));
  31. $pub_date = $this->xml->createElement('pubDate');
  32. $lb_date = $this->xml->createElement('lastBuildDate');
  33. $pub_date->appendChild($date);
  34. $lb_date->appendChild($date->cloneNode());
  35. $channel->appendChild($pub_date);
  36. $channel->appendChild($lb_date);
  37. } // end if
  38. if ($this->rssdata->getAbout() != FALSE) {
  39. $docs = $this->xml->createElement('docs');
  40. $link = $this->xml->createElement('link');
  41. $about_text = $this->xml->createTextNode($this->rssdata->getAbout());
  42. $docs->appendChild($about_text);
  43. $link->appendChild($about_text->cloneNode());
  44. $channel->appendChild($docs);
  45. $channel->appendChild($link);
  46. } // end if
  47. if ($this->rssdata->getDescription() != FALSE) {
  48. $description = $this->xml->createElement('description');
  49. $description->appendChild($this->xml->createTextNode($this->rssdata->getDescription()));
  50. $channel->appendChild($description);
  51. } // end if
  52. if ($this->rssdata->getTitle() != FALSE) {
  53. $title = $this->xml->createElement('title');
  54. $title->appendChild($this->xml->createTextNode($this->rssdata->getTitle()));
  55. $channel->appendChild($title);
  56. } // end if
  57. if ($this->rssdata->getImageLink() != FALSE) {
  58. $image = $this->xml->createElement('image');
  59. $channel->appendChild($image);
  60. $image->appendChild($title->cloneNode(TRUE));
  61. $url = $this->xml->createElement('url');
  62. $url->appendChild($this->xml->createTextNode($this->rssdata->getImageLink()));
  63. $image->appendChild($url);
  64. $image->appendChild($link->cloneNode(TRUE));
  65. $image->appendChild($description->cloneNode(TRUE));
  66. } // end if
  67. if ($this->rssdata->getDCPublisher() != FALSE) {
  68. $managingEditor = $this->xml->createElement('managingEditor');
  69. $managingEditor->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
  70. $channel->appendChild($managingEditor);
  71. } // end if
  72. if ($this->rssdata->getDCCreator() != FALSE) {
  73. $webMaster = $this->xml->createElement('webMaster');
  74. $webMaster->appendChild($this->xml->createTextNode($this->rssdata->getDCCreator()));
  75. $channel->appendChild($webMaster);
  76. } // end if
  77. if ($this->rssdata->getDCLanguage() != FALSE) {
  78. $language = $this->xml->createElement('language');
  79. $language->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
  80. $channel->appendChild($language);
  81. } // end if
  82. foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
  83. $item = '$item_' . $id;
  84. $$item = $this->xml->createElement('item');
  85. $channel->appendChild($$item);
  86. $item_title = '$item_title_' . $id;
  87. $$item_title = $this->xml->createElement('title');
  88. $$item_title->appendChild($this->xml->createTextNode($rss_item->getTitle()));
  89. $$item->appendChild($$item_title);
  90. $item_link = '$item_link_' . $id;
  91. $$item_link = $this->xml->createElement('link');
  92. $$item_link->appendChild($this->xml->createTextNode($rss_item->getLink()));
  93. $$item->appendChild($$item_link);
  94. $item_desc = '$item_desc_' . $id;
  95. $$item_desc = $this->xml->createElement('description');
  96. $$item_desc->appendChild($this->xml->createTextNode($rss_item->getDescription()));
  97. $$item->appendChild($$item_desc);
  98. } // end foreach
  99. } // function
  100. } // end class
  101. ?>