$wgFeedClasses = array(
"rss" => "RSSFeed",
- # "atom" => "AtomFeed",
+ "atom" => "AtomFeed",
);
class FeedItem {
var $Date = "";
var $Author = "";
- function FeedItem( $Title, $Description, $Url, $Date = "", $Author = "" ) {
+ function FeedItem( $Title, $Description, $Url, $Date = "", $Author = "", $Comments = "" ) {
$this->Title = $Title;
$this->Description = $Description;
$this->Url = $Url;
$this->Date = $Date;
$this->Author = $Author;
+ $this->Comments = $Comments;
}
/* Static... */
function getAuthor() {
return $this->xmlEncode( $this->Author );
}
+ function getComments() {
+ return $this->xmlEncode( $this->Comments );
+ }
}
class ChannelFeed extends FeedItem {
}
class RSSFeed extends ChannelFeed {
+
function formatTime( $ts ) {
- // need to use RFC 822 time format
- return gmdate( "r", wfTimestamp2Unix( $ts ) );
+ return gmdate( "D, d M Y H:i:s \G\M\T", wfTimestamp2Unix( $ts ) );
}
function outHeader() {
<description><?php print $item->getDescription() ?></description>
<?php if( $item->getDate() ) { ?><pubDate><?php print $this->formatTime( $item->getDate() ) ?></pubDate><?php } ?>
<?php if( $item->getAuthor() ) { ?><author><?php print $item->getAuthor() ?></author><?php }?>
-
+ <?php if( $item->getComments() ) { ?><comments><?php print $item->getComments() ?></comments><?php }?>
</item>
<?php
}
}
}
+class AtomFeed extends ChannelFeed {
+ function formatTime( $ts ) {
+ // need to use RFC 822 time format at least for rss2.0
+ return gmdate( "Y-m-d\TH:i:s", wfTimestamp2Unix( $ts ) );
+ }
+
+ function outHeader() {
+ global $wgVersion, $wgOut;
+
+ # We take over from $wgOut, excepting its cache header info
+ $wgOut->disable();
+ header( "Content-type: application/xml; charset=UTF-8" );
+ $wgOut->sendCacheControl();
+
+ print '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n";
+ ?><feed version="0.3" xml:lang="<?php print $this->getLanguage()."-".$this->getLanguage() ?>">
+ <title><?php print $this->getTitle() ?></title>
+ <link rel="alternate" type="text/html" href="<?php print $this->getUrl() ?>"/>
+ <modified><?php print $this->formatTime( wfTimestampNow() ) ?>Z</modified>
+ <tagline><?php print $this->getDescription() ?></tagline>
+ <generator>MediaWiki <?php print $wgVersion ?></generator>
+
+<?php
+ }
+
+ function outItem( $item ) {
+ ?>
+ <entry>
+ <title><?php print $item->getTitle() ?></title>
+ <link rel="alternate" type="text/html" href="<?php print $item->getUrl() ?>"/>
+ <?php if( $item->getDate() ) { ?>
+ <modified><?php print $this->formatTime( $item->getDate() ) ?>Z</modified>
+ <issued><?php print $this->formatTime( $item->getDate() ) ?></issued>
+ <created><?php print $this->formatTime( $item->getDate() ) ?>Z</created><?php } ?>
+
+ <summary type="text/plain"><?php print $item->getDescription() ?></summary>
+ <?php if( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor() ?></name><url></url><email></email></author><?php }?>
+ <comment>foobar</comment>
+ </entry>
+
+<?php /* FIXME need to add comments
+ <?php if( $item->getComments() ) { ?><dc:comment><?php print $item->getComments() ?></dc:comment><?php }?>
+ */
+ }
+
+ function outFooter() {?>
+ </feed><?php
+ }
+}
+
?>
\ No newline at end of file
function doFeed( $class = "" ) {
global $wgFeedClasses;
global $wgOut, $wgLanguageCode, $wgLang;
- if( $class == "rss" ) {
- $feed = new RSSFeed(
+ if( isset($wgFeedClasses[$class]) ) {
+ $feed = new $wgFeedClasses[$class](
$this->feedTitle(),
$this->feedDesc(),
$this->feedUrl() );
} elseif( isset( $row->rc_cur_timestamp ) ) {
$date = $row->rc_cur_timestamp;
}
+
+ $comments = "";
+ if( isset( $row->cur_comment ) ) {
+ $comments = $row->cur_comment;
+ } elseif( isset( $row->old_comment ) ) {
+ $comments = $row->old_comment;
+ } elseif( isset( $row->rc_cur_comment ) ) {
+ $comments = $row->rc_cur_comment;
+ }
+
return new FeedItem(
$title->getText(),
$this->feedItemDesc( $row ),
$title->getFullURL(),
$date,
- $this->feedItemAuthor( $row ) );
+ $this->feedItemAuthor( $row ),
+ $comments);
} else {
return NULL;
}
}
function feedItemAuthor( $row ) {
+ /* old code
$fields = array( "cur_user_text", "old_user_text", "rc_user_text" );
foreach( $fields as $field ) {
if( isset( $row->$field ) ) return $row->field;
}
+
+ new code follow, that's an ugly hack to fix things: */
+ if( isset( $row->cur_user_text ) ) return $row->cur_user_text;
+ if( isset( $row->old_user_text ) ) return $row->old_user_text;
+ if( isset( $row->rc_user_text ) ) return $row->rc_user_text;
return "";
}
'tooltip-anontalk' => 'Discussion des éditions faites à partir de cette adresse ip [alt-n]',
'tooltip-anonuserpage' => 'La page d\'utilisateur pour l\'adresse ip depuis laquelle vous éditez [alt-.]',
'tooltip-article' => 'Voir l\'article [alt-a]',
+'tooltip-atom' => 'Flux Atom pour cette page',
'tooltip-contributions' => 'Voir la liste des contributions de cet utilisateur',
'tooltip-currentevents' => 'Trouver des informations sur les évenements actuels',
'tooltip-delete' => 'Supprimer cette page [alt-d]',