http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89568

Revision: 89568
Author:   reedy
Date:     2011-06-06 15:07:23 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
Refactoring to r89566

Refactor out duplicate code to SpecialPage

Modified Paths:
--------------
    trunk/phase3/includes/SpecialPage.php
    trunk/phase3/includes/specials/SpecialContributions.php
    trunk/phase3/includes/specials/SpecialWatchlist.php

Modified: trunk/phase3/includes/SpecialPage.php
===================================================================
--- trunk/phase3/includes/SpecialPage.php       2011-06-06 15:01:27 UTC (rev 
89567)
+++ trunk/phase3/includes/SpecialPage.php       2011-06-06 15:07:23 UTC (rev 
89568)
@@ -657,6 +657,23 @@
        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 );
+               }
+       }
 }
 
 /**

Modified: trunk/phase3/includes/specials/SpecialContributions.php
===================================================================
--- trunk/phase3/includes/specials/SpecialContributions.php     2011-06-06 
15:01:27 UTC (rev 89567)
+++ trunk/phase3/includes/specials/SpecialContributions.php     2011-06-06 
15:07:23 UTC (rev 89568)
@@ -116,16 +116,8 @@
                }
 
                // Add RSS/atom links
-               global $wgFeedClasses;
-               $apiParams = array( 'action' => 'feedcontributions', 'user' => 
$wgUser->getName() );
-               $feedTemplate = wfScript( 'api' ) . '?';
+               $this->addFeedLinks( array( 'action' => 'feedcontributions', 
'user' => $wgUser->getName() ) );
 
-               foreach( $wgFeedClasses as $format => $class ) {
-                       $theseParams = $apiParams + array( 'feedformat' => 
$format );
-                       $url = $feedTemplate . wfArrayToCGI( $theseParams );
-                       $wgOut->addFeedLink( $format, $url );
-               }
-
                if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( 
$id ) ) ) {
 
                        $wgOut->addHTML( $this->getForm() );

Modified: trunk/phase3/includes/specials/SpecialWatchlist.php
===================================================================
--- trunk/phase3/includes/specials/SpecialWatchlist.php 2011-06-06 15:01:27 UTC 
(rev 89567)
+++ trunk/phase3/includes/specials/SpecialWatchlist.php 2011-06-06 15:07:23 UTC 
(rev 89568)
@@ -46,17 +46,9 @@
                        $wgUser->saveSettings();
                }
 
-               global $wgFeedClasses;
-               $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 
'allrev',
-                                                       'wlowner' => 
$wgUser->getName(), 'wltoken' => $wlToken );
-               $feedTemplate = wfScript( 'api' ) . '?';
+               $this->addFeedLinks( array( 'action' => 'feedwatchlist', 
'allrev' => 'allrev',
+                                                       'wlowner' => 
$wgUser->getName(), 'wltoken' => $wlToken ) );
 
-               foreach( $wgFeedClasses as $format => $class ) {
-                       $theseParams = $apiParams + array( 'feedformat' => 
$format );
-                       $url = $feedTemplate . wfArrayToCGI( $theseParams );
-                       $wgOut->addFeedLink( $format, $url );
-               }
-
                $skin = $this->getSkin();
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to