+/**
+ * Generate an Atom feed
+ */
+class AtomFeed extends ChannelFeed {
+ /**
+ * @todo document
+ */
+ function formatTime( $ts ) {
+ // need to use RFC 822 time format at least for rss2.0
+ return gmdate( 'Y-m-d\TH:i:s', wfTimestamp( TS_UNIX, $ts ) );
+ }
+
+ /**
+ * Outputs a basic header for Atom 1.0 feeds.
+ */
+ function outHeader() {
+ global $wgVersion;
+
+ $this->outXmlHeader();
+ ?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php print $this->getLanguage() ?>">
+ <id><?php print $this->getFeedId() ?></id>
+ <title><?php print $this->getTitle() ?></title>
+ <link rel="self" type="application/atom+xml" href="<?php print $this->getSelfUrl() ?>"/>
+ <link rel="alternate" type="text/html" href="<?php print $this->getUrl() ?>"/>
+ <updated><?php print $this->formatTime( wfTimestampNow() ) ?>Z</updated>
+ <subtitle><?php print $this->getDescription() ?></subtitle>
+ <generator>MediaWiki <?php print $wgVersion ?></generator>
+
+<?php
+ }
+
+ /**
+ * Atom 1.0 requires a unique, opaque IRI as a unique indentifier
+ * for every feed we create. For now just use the URL, but who
+ * can tell if that's right? If we put options on the feed, do we
+ * have to change the id? Maybe? Maybe not.
+ *
+ * @return string
+ * @private
+ */
+ function getFeedId() {
+ return $this->getSelfUrl();
+ }
+
+ /**
+ * Atom 1.0 requests a self-reference to the feed.
+ * @return string
+ * @private
+ */
+ function getSelfUrl() {
+ global $wgRequest;
+ return htmlspecialchars( $wgRequest->getFullRequestURL() );
+ }
+
+ /**
+ * Output a given item.
+ * @param $item
+ */
+ function outItem( $item ) {
+ global $wgMimeType;
+ ?>
+ <entry>
+ <id><?php print $item->getUrl() ?></id>
+ <title><?php print $item->getTitle() ?></title>
+ <link rel="alternate" type="<?php print $wgMimeType ?>" href="<?php print $item->getUrl() ?>"/>
+ <?php if( $item->getDate() ) { ?>
+ <updated><?php print $this->formatTime( $item->getDate() ) ?>Z</updated>
+ <?php } ?>
+
+ <summary type="html"><?php print $item->getDescription() ?></summary>
+ <?php if( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor() ?></name></author><?php }?>
+ </entry>
+
+<?php /* FIXME need to add comments
+ <?php if( $item->getComments() ) { ?><dc:comment><?php print $item->getComments() ?></dc:comment><?php }?>
+ */
+ }
+
+ /**
+ * Outputs the footer for Atom 1.0 feed (basicly '\</feed\>').
+ */
+ function outFooter() {?>
+ </feed><?php
+ }
+}
+
+?>