forked from mantisbt/mantisbt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.RSS_V_091.inc.php
117 lines (101 loc) · 4.27 KB
/
class.RSS_V_091.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
require_once 'class.RSSBase.inc.php';
/**
* Class for creating an RSS-feed
* @author Michael Wimmer <[email protected]>
* @category flaimo-php
* @copyright Copyright © 2002-2008, Michael Wimmer
* @license GNU General Public License v3
* @link http://code.google.com/p/flaimo-php/
* @package RSS
* @version 2.2.1
*/
class RSS_V_091 extends RSS_V_abstract {
function __construct(RSSBuilder &$rssdata) {
parent::__construct($rssdata);
} // end constructor
protected function generateXML() {
parent::generateXML();
$root = $this->xml->createElement('rss');
$this->xml->appendChild($root);
$root->setAttribute('version', '0.91');
$channel = $this->xml->createElement('channel');
$root->appendChild($channel);
if ($this->rssdata->getDCRights() != FALSE) {
$copyright = $this->xml->createElement('copyright');
$copyright->appendChild($this->xml->createTextNode($this->rssdata->getDCRights()));
$channel->appendChild($copyright);
} // end if
if ($this->rssdata->getDCDate() != FALSE) {
$date = $this->xml->createTextNode(date('r', $this->rssdata->getDCDate()));
$pub_date = $this->xml->createElement('pubDate');
$lb_date = $this->xml->createElement('lastBuildDate');
$pub_date->appendChild($date);
$lb_date->appendChild($date->cloneNode());
$channel->appendChild($pub_date);
$channel->appendChild($lb_date);
} // end if
if ($this->rssdata->getAbout() != FALSE) {
$docs = $this->xml->createElement('docs');
$link = $this->xml->createElement('link');
$about_text = $this->xml->createTextNode($this->rssdata->getAbout());
$docs->appendChild($about_text);
$link->appendChild($about_text->cloneNode());
$channel->appendChild($docs);
$channel->appendChild($link);
} // end if
if ($this->rssdata->getDescription() != FALSE) {
$description = $this->xml->createElement('description');
$description->appendChild($this->xml->createTextNode($this->rssdata->getDescription()));
$channel->appendChild($description);
} // end if
if ($this->rssdata->getTitle() != FALSE) {
$title = $this->xml->createElement('title');
$title->appendChild($this->xml->createTextNode($this->rssdata->getTitle()));
$channel->appendChild($title);
} // end if
if ($this->rssdata->getImageLink() != FALSE) {
$image = $this->xml->createElement('image');
$channel->appendChild($image);
$image->appendChild($title->cloneNode(TRUE));
$url = $this->xml->createElement('url');
$url->appendChild($this->xml->createTextNode($this->rssdata->getImageLink()));
$image->appendChild($url);
$image->appendChild($link->cloneNode(TRUE));
$image->appendChild($description->cloneNode(TRUE));
} // end if
if ($this->rssdata->getDCPublisher() != FALSE) {
$managingEditor = $this->xml->createElement('managingEditor');
$managingEditor->appendChild($this->xml->createTextNode($this->rssdata->getDCPublisher()));
$channel->appendChild($managingEditor);
} // end if
if ($this->rssdata->getDCCreator() != FALSE) {
$webMaster = $this->xml->createElement('webMaster');
$webMaster->appendChild($this->xml->createTextNode($this->rssdata->getDCCreator()));
$channel->appendChild($webMaster);
} // end if
if ($this->rssdata->getDCLanguage() != FALSE) {
$language = $this->xml->createElement('language');
$language->appendChild($this->xml->createTextNode($this->rssdata->getDCLanguage()));
$channel->appendChild($language);
} // end if
foreach ($this->rssdata->getRSSItemList() as $id => $rss_item) {
$item = '$item_' . $id;
$$item = $this->xml->createElement('item');
$channel->appendChild($$item);
$item_title = '$item_title_' . $id;
$$item_title = $this->xml->createElement('title');
$$item_title->appendChild($this->xml->createTextNode($rss_item->getTitle()));
$$item->appendChild($$item_title);
$item_link = '$item_link_' . $id;
$$item_link = $this->xml->createElement('link');
$$item_link->appendChild($this->xml->createTextNode($rss_item->getLink()));
$$item->appendChild($$item_link);
$item_desc = '$item_desc_' . $id;
$$item_desc = $this->xml->createElement('description');
$$item_desc->appendChild($this->xml->createTextNode($rss_item->getDescription()));
$$item->appendChild($$item_desc);
} // end foreach
} // function
} // end class
?>