4 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
6 * This file is a part of Codendi.
8 * Codendi is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Codendi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
27 function RSS($channel) {
28 $this->channel = $channel;
29 $this->items = array();
32 function addItem($item) {
33 $this->items[] = $item;
37 $channel_elements = array('title', 'description', 'link', 'language', 'rating', 'image', 'textinput', 'copyright', 'pubDate', 'lastBuildDate', 'docs', 'managingEditor', 'webMaster', 'skipHours', 'skipDays');
38 $image_elements = array('title', 'description', 'link', 'url', 'width', 'height');
39 $textinput_elements = array('title', 'description', 'link', 'name');
40 $item_elements = array('title', 'description', 'link', 'dc:creator', 'pubDate', 'guid');
41 header("Content-Type: text/xml");
42 echo '<?xml version="1.0" encoding="UTF-8" ?>'. "\n";
43 echo '<?xml-stylesheet type="text/xsl" href="/export/rss.xsl" ?>'. "\n";
44 echo '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">';
46 foreach($channel_elements as $channel_element) {
47 if (isset($this->channel[$channel_element])) {
48 echo '<'. $channel_element .'>';
49 $special = $channel_element.'_elements';
50 if (isset($$special)) {
51 foreach($$special as $element) {
52 if (isset($this->channel[$channel_element][$element])) {
53 echo '<'. $element .'>';
54 echo $this->channel[$channel_element][$element];
55 echo '</'. $element .'>';
59 echo $this->channel[$channel_element];
61 echo '</'. $channel_element .'>';
64 foreach($this->items as $item) {
66 foreach($item_elements as $item_element) {
67 if (isset($item[$item_element])) {
68 echo '<'. $item_element .'>';
69 echo $item[$item_element];
70 echo '</'. $item_element .'>';