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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<?php
// ----------------------------------------------------------------------
// phpWiki
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Lawrence Akka
// Purpose of file: Plugin and associated classes
// for outputting RecentChanges in RSS 0.91 format
// ----------------------------------------------------------------------
rcs_id('$Id: RSSWriter091.php,v 1.10 2005/08/06 13:06:22 rurban Exp $');
include_once("lib/RssWriter.php");
class RSSWriter091 extends RSSWriter
{
function RSSWriter091()
{
$this->XmlElement('rss', array('version' => "0.91"));
$this->_items = array();
}
/**
* Finish construction of RSS.
*/
function finish()
{
if (isset($this->_finished))
return;
$channel = &$this->_channel;
$items = &$this->_items;
if ($items)
{
foreach ($items as $i)
$channel->pushContent($i);
}
$this->pushContent($channel);
$this->__spew();
$this->_finished = true;
}
/**
* Create a new RDF <em>typedNode</em>.
*/
function __node($type, $properties, $uri = false) {
return new XmlElement($type, '',
$this->__elementize($properties));
}
/**
* Write output to HTTP client.
*/
function __spew() {
header("Content-Type: application/xml; charset=" . RSS_ENCODING);
printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", RSS_ENCODING);
print("<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n");
print("\"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n");
$this->printXML();
}
}
class _RecentChanges_RssFormatter091
extends _RecentChanges_RSSFormatter
// This class should probably go at then of RecentChanges.php
{
function format ($changes)
{
// include_once('lib/RssWriter.php');
$rss = new RssWriter091;
$rss->channel($this->channel_properties());
if (($props = $this->image_properties()))
$rss->image($props);
if (($props = $this->textinput_properties()))
$rss->textinput($props);
while ($rev = $changes->next()) {
$rss->addItem($this->item_properties($rev),
$this->pageURI($rev));
}
global $request;
$request->discardOutput();
$rss->finish();
printf("\n<!-- Generated by PhpWiki:\n%s-->\n", $GLOBALS['RCS_IDS']);
$request->finish(); // NORETURN!!!!
}
function channel_properties ()
{
global $request;
$rc_url = WikiURL($request->getArg('pagename'), false, 'absurl');
return array('title' => WIKI_NAME,
'description' => _("RecentChanges"),
'link' => $rc_url,
'language' => 'en-US');
/* FIXME: language should come from $LANG (or other config variable). */
/* FIXME: other things one might like in <channel>:
* managingEditor
* webmaster
* lastBuildDate
* copyright
*/
}
function item_properties ($rev)
{
$page = $rev->getPage();
$pagename = $page->getName();
return array( 'title' => SplitPagename($pagename),
'description' => $this->summary($rev),
'link' => $this->pageURL($rev)
);
}
}
// (c-file-style: "gnu")
// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>
|