From: Victor Vasiliev Date: Sat, 8 Dec 2007 12:46:18 +0000 (+0000) Subject: * (bug 943) RSS feed for Recentchangeslinked X-Git-Tag: 1.31.0-rc.0~50492 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=9c97f4ff6f4239e9f3d92a8dee9029f707ddfc94;p=lhc%2Fweb%2Fwiklou.git * (bug 943) RSS feed for Recentchangeslinked * Use $wgFeedClasses instead of hardcoding feed types in OutputPage.php * Introduce $wgOut->setFeedAppendQuery() --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7795acf88b..3f4ce410a5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/OutputPage.php b/includes/OutputPage.php index fcd3a8d14f..0462fd53c9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 791137b31f..b6ada873d8 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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 ); diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index 2a8ac32d1a..bea3878b2e 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -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(); + } }