A basic xml feed support for the history page.
if you have any questions leave me a message on my talkpage
[[w:fr:Utilisateur:FoeNyx]] or contact me on #fr.wikipedia
Index: includes/PageHistory.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/PageHistory.php,v
retrieving revision 1.45
diff -u -r1.45 PageHistory.php
--- includes/PageHistory.php 3 Sep 2004 22:59:59 -0000 1.45
+++ includes/PageHistory.php 10 Sep 2004 12:24:35 -0000
@@ -7,6 +7,11 @@
*/
/**
+ * Classes to create xml feed (rss, atom)
+ */
+require_once( 'Feed.php' );
+
+/**
* @todo document
* @package MediaWiki
*/
@@ -23,9 +28,12 @@
function history() {
global $wgUser, $wgOut, $wgLang;
+ global $wgRequest, $wgFeedClasses;
- # If page hasn't changed, client can cache this
+ # Get query parameters
+ $feedFormat = $wgRequest->getVal( 'feed' );
+ # If page hasn't changed, client can cache this
if( $wgOut->checkLastModified( $this->mArticle->getTimestamp() ) ){
# Client cache fresh and headers sent, nothing more to do.
return;
@@ -39,8 +47,24 @@
$wgOut->setArticleRelated( true );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
+ # If there is no history
if( $this->mTitle->getArticleID() == 0 ) {
- $wgOut->addHTML( wfMsg( 'nohistory' ) );
+ if( isset($wgFeedClasses[$feedFormat]) ) {
+ #XML Feed (RSS or Atom)
+ $talkpage = $this->mTitle->getTalkPage();
+ $feed = new $wgFeedClasses[$feedFormat]
+ (
+ wfMsg( 'history' ) . " [". $talkpage->getText() . "]" ,
+ wfMsg( 'nohistory' ) ,
+ $this->mTitle->getFullUrl()
+ );
+ $feed->outHeader();
+ $feed->outFooter();
+ } else {
+ #XHTML output
+ $wgOut->setSyndicated( true );
+ $wgOut->addHTML( wfMsg( 'nohistory' ) );
+ }
wfProfileOut( $fname );
return;
}
@@ -81,43 +105,86 @@
$atend = ($revs < $limitplus);
- $this->mSkin = $wgUser->getSkin();
- $numbar = wfViewPrevNext(
- $offset, $limit,
- $this->mTitle->getPrefixedText(),
- 'action=history', $atend );
- $s = $numbar;
- if($this->linesonpage > 0) {
- $submitpart1 = '<input class="historysubmit" type="submit" accesskey="'.wfMsg('accesskey-compareselectedversions').
- '" title="'.wfMsg('tooltip-compareselectedversions').'" value="'.wfMsg('compareselectedversions').'"';
- $this->submitbuttonhtml1 = $submitpart1 . ' />';
- $this->submitbuttonhtml2 = $submitpart1 . ' id="historysubmit" />';
- }
- $s .= $this->beginHistoryList();
- $counter = 1;
- if( $offset == 0 ){
- $this->linesonpage++;
- $s .= $this->historyLine(
- $this->mArticle->getTimestamp(),
- $this->mArticle->getUser(),
- $this->mArticle->getUserText(), $namespace,
- $title, 0, $this->mArticle->getComment(),
- ( $this->mArticle->getMinorEdit() > 0 ),
- $counter++
- );
- }
- while ( $line = $db->fetchObject( $res ) ) {
- $s .= $this->historyLine(
- $line->old_timestamp, $line->old_user,
- $line->old_user_text, $namespace,
- $title, $line->old_id,
- $line->old_comment, ( $line->old_minor_edit > 0 ),
- $counter++
+ if( isset($wgFeedClasses[$feedFormat]) ) {
+ #XML Feed (RSS or Atom)
+ $artname = Title::makeName( $namespace, $title );
+ $feed = new $wgFeedClasses[$feedFormat]
+ (
+ wfMsg( 'history_short' ) . " [[". $artname . "]]" ,
+ "(" . wfMsg( "feedlinks" ) . $feedFormat . ") " .
+ wfMsg( 'history' ) . " \"". $artname . "\"" ,
+ $this->mTitle->getFullUrl() . "?action=history"
);
+ $feed->outHeader();
+
+ if( $offset == 0 ){
+ $item = new FeedItem(
+ wfMsg("currentrev"),
+ $this->mArticle->getComment(),
+ $this->mTitle->getFullURL(),
+ $this->mArticle->getTimestamp(),
+ $this->mArticle->getUserText(),
+ (( $this->mArticle->getMinorEdit() > 0 ) ? wfMsg("minoredit") : "" )
+ );
+ $feed->outItem( $item );
+ }
+ while ( $line = $db->fetchObject( $res ) ) {
+ $item = new FeedItem(
+ wfMsg("revisionasof", $wgLang->timeanddate( $line->old_timestamp, true ) ),
+ $line->old_comment,
+ $this->mTitle->getFullUrl() . "?oldid=" . $line->old_id,
+ $line->old_timestamp,
+ $line->old_user_text,
+ (( $line->old_minor_edit > 0 ) ? wfMsg("minoredit") : "" )
+ );
+ $feed->outItem( $item );
+ }
+ $feed->outFooter();
+ } else {
+ #XHTML output
+ $wgOut->setSyndicated( true );
+
+ $this->mSkin = $wgUser->getSkin();
+ $numbar = wfViewPrevNext(
+ $offset, $limit,
+ $this->mTitle->getPrefixedText(),
+ 'action=history', $atend );
+ $s = $numbar;
+
+ if($this->linesonpage > 0) {
+ $submitpart1 = '<input class="historysubmit" type="submit" accesskey="'.
+ wfMsg('accesskey-compareselectedversions').
+ '" title="'. wfMsg('tooltip-compareselectedversions').'" value="'.
+ wfMsg('compareselectedversions').'"';
+ $this->submitbuttonhtml1 = $submitpart1 . ' />';
+ $this->submitbuttonhtml2 = $submitpart1 . ' id="historysubmit" />';
+ }
+ $s .= $this->beginHistoryList();
+ $counter = 1;
+ if( $offset == 0 ){
+ $this->linesonpage++;
+ $s .= $this->historyLine(
+ $this->mArticle->getTimestamp(),
+ $this->mArticle->getUser(),
+ $this->mArticle->getUserText(), $namespace,
+ $title, 0, $this->mArticle->getComment(),
+ ( $this->mArticle->getMinorEdit() > 0 ),
+ $counter++
+ );
+ }
+ while ( $line = $db->fetchObject( $res ) ) {
+ $s .= $this->historyLine(
+ $line->old_timestamp, $line->old_user,
+ $line->old_user_text, $namespace,
+ $title, $line->old_id,
+ $line->old_comment, ( $line->old_minor_edit > 0 ),
+ $counter++
+ );
+ }
+ $s .= $this->endHistoryList( !$atend );
+ $s .= $numbar;
+ $wgOut->addHTML( $s );
}
- $s .= $this->endHistoryList( !$atend );
- $s .= $numbar;
- $wgOut->addHTML( $s );
wfProfileOut( $fname );
}