2 // ----------------------------------------------------------------------
4 // ----------------------------------------------------------------------
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License (GPL)
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
18 // ----------------------------------------------------------------------
19 // Original Author of file: Lawrence Akka
20 // Purpose of file: Plugin and associated classes
21 // for outputting RecentChanges in RSS 0.91 format
22 // ----------------------------------------------------------------------
24 rcs_id('$Id: RSSWriter091.php,v 1.8 2004-05-18 16:23:39 rurban Exp $');
26 include_once "lib/RssWriter.php";
27 class RSSWriter091 extends RSSWriter
29 function RSSWriter091()
31 $this->XmlElement('rss', array('version' => "0.91"));
32 $this->_items = array();
35 * Finish construction of RSS.
39 if (isset($this->_finished))
42 $channel = &$this->_channel;
43 $items = &$this->_items;
47 foreach ($items as $i)
48 $channel->pushContent($i);
50 $this->pushContent($channel);
52 $this->_finished = true;
56 * Create a new RDF <em>typedNode</em>.
58 function __node($type, $properties, $uri = false) {
59 return new XmlElement($type, '',
60 $this->__elementize($properties));
64 * Write output to HTTP client.
67 header("Content-Type: application/xml; charset=" . RSS_ENCODING);
68 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", RSS_ENCODING);
69 print("<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n");
70 print("\"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n");
79 class _RecentChanges_RssFormatter091
80 extends _RecentChanges_RSSFormatter
81 // This class should probably go at then of RecentChanges.php
83 function format ($changes)
85 // include_once('lib/RssWriter.php');
86 $rss = new RssWriter091;
89 $rss->channel($this->channel_properties());
91 if (($props = $this->image_properties()))
93 if (($props = $this->textinput_properties()))
94 $rss->textinput($props);
96 while ($rev = $changes->next()) {
97 $rss->addItem($this->item_properties($rev),
98 $this->pageURI($rev));
102 $request->discardOutput();
104 printf("\n<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
105 $request->finish(); // NORETURN!!!!
109 function channel_properties ()
113 $rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
115 return array('title' => WIKI_NAME,
116 'description' => _("RecentChanges"),
118 'language' => 'en-US');
120 /* FIXME: language should come from $LANG (or other config variable). */
122 /* FIXME: other things one might like in <channel>:
131 function item_properties ($rev)
133 $page = $rev->getPage();
134 $pagename = $page->getName();
136 return array( 'title' => SplitPagename($pagename),
137 'description' => $this->summary($rev),
138 'link' => $this->pageURL($rev)
144 // (c-file-style: "gnu")
149 // c-hanging-comment-ender-p: nil
150 // indent-tabs-mode: nil