From: Sam Reed Date: Mon, 6 Jun 2011 15:07:23 +0000 (+0000) Subject: Refactoring to r89566 X-Git-Tag: 1.31.0-rc.0~29667 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=00806e78946bd285b0151699500976524d0c93ea;p=lhc%2Fweb%2Fwiklou.git Refactoring to r89566 Refactor out duplicate code to SpecialPage --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 2d5f541190..d5e698565f 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -657,6 +657,23 @@ class SpecialPage { public function msg( /* $args */ ) { return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->getFullTitle() ); } + + /** + * Adds RSS/atom links + * + * @param $params array + */ + protected function addFeedLinks( $params ) { + global $wgFeedClasses, $wgOut; + + $feedTemplate = wfScript( 'api' ) . '?'; + + foreach( $wgFeedClasses as $format => $class ) { + $theseParams = $params + array( 'feedformat' => $format ); + $url = $feedTemplate . wfArrayToCGI( $theseParams ); + $wgOut->addFeedLink( $format, $url ); + } + } } /** diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 92f4ab3a1f..a9afbc6487 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -116,15 +116,7 @@ class SpecialContributions extends SpecialPage { } // Add RSS/atom links - 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 ); - } + $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $wgUser->getName() ) ); if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) { diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 7389b0b73c..89e9e9081d 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -46,16 +46,8 @@ class SpecialWatchlist extends SpecialPage { $wgUser->saveSettings(); } - global $wgFeedClasses; - $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', - 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); - $feedTemplate = wfScript( 'api' ) . '?'; - - foreach( $wgFeedClasses as $format => $class ) { - $theseParams = $apiParams + array( 'feedformat' => $format ); - $url = $feedTemplate . wfArrayToCGI( $theseParams ); - $wgOut->addFeedLink( $format, $url ); - } + $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', + 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ) ); $skin = $this->getSkin(); $wgOut->setRobotPolicy( 'noindex,nofollow' );