r89568 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89567‎ | r89568 | r89569 >
Date:15:07, 6 June 2011
Author:reedy
Status:ok
Tags:
Comment:
Refactoring to r89566

Refactor out duplicate code to SpecialPage
Modified paths:
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -116,16 +116,8 @@
117117 }
118118
119119 // Add RSS/atom links
120 - global $wgFeedClasses;
121 - $apiParams = array( 'action' => 'feedcontributions', 'user' => $wgUser->getName() );
122 - $feedTemplate = wfScript( 'api' ) . '?';
 120+ $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $wgUser->getName() ) );
123121
124 - foreach( $wgFeedClasses as $format => $class ) {
125 - $theseParams = $apiParams + array( 'feedformat' => $format );
126 - $url = $feedTemplate . wfArrayToCGI( $theseParams );
127 - $wgOut->addFeedLink( $format, $url );
128 - }
129 -
130122 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
131123
132124 $wgOut->addHTML( $this->getForm() );
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -46,17 +46,9 @@
4747 $wgUser->saveSettings();
4848 }
4949
50 - global $wgFeedClasses;
51 - $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
52 - 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken );
53 - $feedTemplate = wfScript( 'api' ) . '?';
 50+ $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
 51+ 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ) );
5452
55 - foreach( $wgFeedClasses as $format => $class ) {
56 - $theseParams = $apiParams + array( 'feedformat' => $format );
57 - $url = $feedTemplate . wfArrayToCGI( $theseParams );
58 - $wgOut->addFeedLink( $format, $url );
59 - }
60 -
6153 $skin = $this->getSkin();
6254 $wgOut->setRobotPolicy( 'noindex,nofollow' );
6355
Index: trunk/phase3/includes/SpecialPage.php
@@ -657,6 +657,23 @@
658658 public function msg( /* $args */ ) {
659659 return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->getFullTitle() );
660660 }
 661+
 662+ /**
 663+ * Adds RSS/atom links
 664+ *
 665+ * @param $params array
 666+ */
 667+ protected function addFeedLinks( $params ) {
 668+ global $wgFeedClasses, $wgOut;
 669+
 670+ $feedTemplate = wfScript( 'api' ) . '?';
 671+
 672+ foreach( $wgFeedClasses as $format => $class ) {
 673+ $theseParams = $params + array( 'feedformat' => $format );
 674+ $url = $feedTemplate . wfArrayToCGI( $theseParams );
 675+ $wgOut->addFeedLink( $format, $url );
 676+ }
 677+ }
661678 }
662679
663680 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r90847Followup r89566, r89568, make links point to the user whom the contributions ...reedy19:33, 26 June 2011
r98408Follow-up r89568: use local context instead of $wgOutialex15:07, 29 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89566Followup r89564...reedy14:56, 6 June 2011

Status & tagging log