* (bug 943) RSS feed for Recentchangeslinked
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 8 Dec 2007 12:46:18 +0000 (12:46 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 8 Dec 2007 12:46:18 +0000 (12:46 +0000)
* Use $wgFeedClasses instead of hardcoding feed types in OutputPage.php
* Introduce $wgOut->setFeedAppendQuery()

RELEASE-NOTES
includes/OutputPage.php
includes/SkinTemplate.php
includes/SpecialRecentchangeslinked.php

index 7795acf..3f4ce41 100644 (file)
@@ -92,6 +92,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 12195) Undeleting pages now requires 'undelete' permission
 * (bug 11810) Localize displayed semicolons
 * (bug 11657) Support for Thai solar calendar
+* (bug 943) RSS feed for Recentchangeslinked
 
 === Bug fixes in 1.12 ===
 
index fcd3a8d..0462fd5 100644 (file)
@@ -23,6 +23,7 @@ class OutputPage {
        var $mIsArticleRelated;
        protected $mParserOptions; // lazy initialised, use parserOptions()
        var $mShowFeedLinks = false;
+       var $mFeedLinksAppendQuery = false;
        var $mEnableClientCache = true;
        var $mArticleBodyOnly = false;
        
@@ -232,6 +233,8 @@ class OutputPage {
        public function isPrintable() { return $this->mPrintable; }
        public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; }
        public function isSyndicated() { return $this->mShowFeedLinks; }
+       public function setFeedAppendQuery( $val ) { $this->mFeedLinksAppendQuery = $val; }
+       public function getFeedAppendQuery() { return $this->mFeedLinksAppendQuery; }
        public function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
        public function getOnloadHandler() { return $this->mOnloadHandler; }
        public function disable() { $this->mDoNothing = true; }
@@ -1286,20 +1289,24 @@ class OutputPage {
                }
                
                if( $this->isSyndicated() ) {
-                       # FIXME: centralize the mime-type and name information in Feed.php
                        # Use the page name for the title (accessed through $wgTitle since
                        # there's no other way).  In principle, this could lead to issues
                        # with having the same name for different feeds corresponding to
                        # the same page, but we can't avoid that at this low a level.
-                       global $wgTitle;
-                       $ret .= $this->feedLink(
-                               'rss',
-                               $wgRequest->appendQuery( 'feed=rss' ),
-                               wfMsg( 'page-rss-feed', $wgTitle->getPrefixedText() ) );
-                       $ret .= $this->feedLink(
-                               'atom',
-                               $wgRequest->appendQuery( 'feed=atom' ),
-                               wfMsg( 'page-atom-feed', $wgTitle->getPrefixedText() ) );
+                       global $wgTitle, $wgFeedClasses;
+                       
+                       if( is_string( $this->getFeedAppendQuery() ) ) {
+                               $appendQuery = "&" . $this->getFeedAppendQuery();
+                       } else {
+                               $appendQuery = "";
+                       }
+
+                       foreach( $wgFeedClasses as $format => $class ) {
+                               $ret .= $this->feedLink(
+                                       $format,
+                                       $wgRequest->appendQuery( "feed=rss{$appendQuery}" ),
+                                       wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) );
+                       }
                }
 
                # Recent changes feed should appear on every page
index 791137b..b6ada87 100644 (file)
@@ -226,9 +226,14 @@ class SkinTemplate extends Skin {
                                } else if ( $format == "rss" ) {
                                        $linktext = wfMsg( 'feed-rss' );
                                }
+                               if( is_string( $wgOut->getFeedAppendQuery() ) ) {
+                                       $appendQuery = "&" . $wgOut->getFeedAppendQuery();
+                               } else {
+                                       $appendQuery = "";
+                               }
                                $feeds[$format] = array(
                                        'text' => $linktext,
-                                       'href' => $wgRequest->appendQuery( "feed=$format" )
+                                       'href' => $wgRequest->appendQuery( "feed={$format}{$appendQuery}" )
                                );
                        }
                        $tpl->setRef( 'feeds', $feeds );
index 2a8ac32..bea3878 100644 (file)
@@ -14,7 +14,7 @@ require_once( 'SpecialRecentchanges.php' );
  * @param string $par parent page we will look at
  */
 function wfSpecialRecentchangeslinked( $par = NULL ) {
-       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
+       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle;
        $fname = 'wfSpecialRecentchangeslinked';
 
        $days = $wgRequest->getInt( 'days' );
@@ -37,6 +37,8 @@ function wfSpecialRecentchangeslinked( $par = NULL ) {
 
        $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $nt->getPrefixedText() ) );
        $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
+       $wgOut->setSyndicated();
+       $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) );
 
        if ( ! $days ) {
                $days = (int)$wgUser->getOption( 'rcdays', 7 );
@@ -152,6 +154,7 @@ $GROUPBY
        $s = $list->beginRecentChangesList();
        $count = $dbr->numRows( $res );
 
+       $rchanges = array();
        if ( $count ) {
                $counter = 1;
                while ( $limit ) {
@@ -162,6 +165,7 @@ $GROUPBY
                        $rc->counter = $counter++;
                        $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user) );
                        --$limit;
+                       $rchanges[] = $obj;
                }
        } else {
                $wgOut->addWikiText( wfMsg('recentchangeslinked-noresult') );
@@ -170,6 +174,24 @@ $GROUPBY
 
        $dbr->freeResult( $res );
        $wgOut->addHTML( $s );
+
+       global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
+       $feedFormat = $wgRequest->getVal( 'feed' );
+       if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
+               $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']';
+               $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
+                       htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
+               
+               require_once( "SpecialRecentchanges.php" );
+               rcDoOutputFeed( $rchanges, $feed );
+               
+               $wgOut->disable();
+               $feed->outHeader();
+               foreach( $feedItems as &$item ) {
+                       $feed->outItem( $item );
+               }
+               $feed->outFooter();
+       }
 }