From 979619f4b3c2aa4ba05d35dabdefd8e5ce67cb3a Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 6 Jun 2011 14:56:47 +0000 Subject: [PATCH] Followup r89564 Strip out the ?feed= functionality, update urls to point at the API! --- includes/specials/SpecialContributions.php | 116 ++------------------- 1 file changed, 8 insertions(+), 108 deletions(-) diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index f4c3905168..92f4ab3a1f 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -116,10 +116,14 @@ class SpecialContributions extends SpecialPage { } // Add RSS/atom links - $this->setSyndicated(); - $feedType = $wgRequest->getVal( 'feed' ); - if( $feedType ) { - return $this->feed( $feedType ); + global $wgFeedClasses; + $apiParams = array( 'action' => 'feedcontributions', 'user' => $wgUser->getName() ); + $feedTemplate = wfScript( 'api' ) . '?'; + + foreach( $wgFeedClasses as $format => $class ) { + $theseParams = $apiParams + array( 'feedformat' => $format ); + $url = $feedTemplate . wfArrayToCGI( $theseParams ); + $wgOut->addFeedLink( $format, $url ); } if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) { @@ -150,7 +154,6 @@ class SpecialContributions extends SpecialPage { } $wgOut->preventClickjacking( $pager->getPreventClickjacking() ); - # Show the appropriate "footer" message - WHOIS tools, etc. if( $target != 'newbies' ) { $message = 'sp-contributions-footer'; @@ -173,12 +176,6 @@ class SpecialContributions extends SpecialPage { } } - protected function setSyndicated() { - global $wgOut; - $wgOut->setSyndicated( true ); - $wgOut->setFeedAppendQuery( wfArrayToCGI( $this->opts ) ); - } - /** * Generates the subheading with links * @param $nt Title object for the target @@ -411,103 +408,6 @@ class SpecialContributions extends SpecialPage { Xml::closeElement( 'form' ); return $f; } - - /** - * Output a subscription feed listing recent edits to this page. - * @param $type String - */ - protected function feed( $type ) { - global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut; - - if( !$wgFeed ) { - $wgOut->addWikiMsg( 'feed-unavailable' ); - return; - } - - if( !isset( $wgFeedClasses[$type] ) ) { - $wgOut->addWikiMsg( 'feed-invalid' ); - return; - } - - $feed = new $wgFeedClasses[$type]( - $this->feedTitle(), - wfMsgExt( 'tagline', 'parsemag' ), - $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target']) - ); - - // Already valid title - $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] ); - $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText(); - - $pager = new ContribsPager( array( - 'target' => $target, - 'namespace' => $this->opts['namespace'], - 'year' => $this->opts['year'], - 'month' => $this->opts['month'], - 'tagFilter' => $this->opts['tagFilter'], - 'deletedOnly' => $this->opts['deletedOnly'], - 'topOnly' => $this->opts['topOnly'], - 'showSizeDiff' => $this->opts['showSizeDiff'], - ) ); - - $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit ); - - $feed->outHeader(); - if( $pager->getNumRows() > 0 ) { - foreach ( $pager->mResult as $row ) { - $feed->outItem( $this->feedItem( $row ) ); - } - } - $feed->outFooter(); - } - - protected function feedTitle() { - global $wgLanguageCode, $wgSitename; - $desc = $this->getDescription(); - return "$wgSitename - $desc [$wgLanguageCode]"; - } - - protected function feedItem( $row ) { - $title = Title::MakeTitle( intval( $row->page_namespace ), $row->page_title ); - if( $title ) { - $date = $row->rev_timestamp; - $comments = $title->getTalkPage()->getFullURL(); - $revision = Revision::newFromTitle( $title, $row->rev_id ); - - return new FeedItem( - $title->getPrefixedText(), - $this->feedItemDesc( $revision ), - $title->getFullURL(), - $date, - $this->feedItemAuthor( $revision ), - $comments - ); - } else { - return null; - } - } - - /** - * @param $revision Revision - * @return string - */ - protected function feedItemAuthor( $revision ) { - return $revision->getUserText(); - } - - /** - * @param $revision Revision - * @return string - */ - protected function feedItemDesc( $revision ) { - if( $revision ) { - return '

' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) . - htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) . - "

\n
\n
" . - nl2br( htmlspecialchars( $revision->getText() ) ) . "
"; - } - return ''; - } } /** -- 2.20.1