(bug 10268) Added linktodiffs parameter on action=feedwatchlist
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 27 Nov 2010 19:24:48 +0000 (19:24 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 27 Nov 2010 19:24:48 +0000 (19:24 +0000)
CREDITS
RELEASE-NOTES
includes/api/ApiFeedWatchlist.php

diff --git a/CREDITS b/CREDITS
index e683744..42ef046 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -135,6 +135,7 @@ following names for their contribution to the product.
 * svip
 * Tisane
 * Umherirrender
+* Ville Stadista
 * Zachary Hauri
 
 == Translators ==
index 8959b6b..364dbc3 100644 (file)
@@ -539,6 +539,7 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
 * (bug 26089) add block expiration to blockinfo
 * (bug 26125) prop=imageinfo&iiprop=size now returns the page count if the 
   file is a multi-page file
+* (bug 10268) Added linktodiffs parameter on action=feedwatchlist
 
 === Languages updated in 1.17 ===
 
index 31462a3..f572ae6 100644 (file)
@@ -49,6 +49,8 @@ class ApiFeedWatchlist extends ApiBase {
                return new ApiFormatFeedWrapper( $this->getMain() );
        }
 
+       private $linkToDiffs = false;
+
        /**
         * Make a nested call to the API to request watchlist items in the last $hours.
         * Wrap the result as an RSS/Atom feed.
@@ -81,6 +83,12 @@ class ApiFeedWatchlist extends ApiBase {
                                $fauxReqArr['wltoken'] = $params['wltoken'];
                        }
 
+                       // Support linking to diffs instead of article
+                       if ( $params['linktodiffs'] ) {
+                               $this->linkToDiffs = true;
+                               $fauxReqArr['wlprop'] .= '|ids';
+                       }
+
                        // Check for 'allrev' parameter, and if found, show all revisions to each page on wl.
                        if ( !is_null( $params['allrev'] ) ) {
                                $fauxReqArr['wlallrev'] = '';
@@ -135,7 +143,11 @@ class ApiFeedWatchlist extends ApiBase {
        private function createFeedItem( $info ) {
                $titleStr = $info['title'];
                $title = Title::newFromText( $titleStr );
-               $titleUrl = $title->getFullURL();
+               if ( $this->linkToDiffs and isset( $info['revid'] ) ) {
+                       $titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) );
+               } else {
+                       $titleUrl = $title->getFullURL();
+               }
                $comment = isset( $info['comment'] ) ? $info['comment'] : null;
                $timestamp = $info['timestamp'];
                $user = $info['user'];
@@ -165,7 +177,8 @@ class ApiFeedWatchlist extends ApiBase {
                        ),
                        'wltoken' => array(
                                ApiBase::PARAM_TYPE => 'string'
-                       )
+                       ),
+                       'linktodiffs' => false,
                );
        }
 
@@ -174,8 +187,9 @@ class ApiFeedWatchlist extends ApiBase {
                        'feedformat' => 'The format of the feed',
                        'hours'      => 'List pages modified within this many hours from now',
                        'allrev'     => 'Include multiple revisions of the same page within given timeframe',
-                       'wlowner'     => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}token if it's not you)",
-                       'wltoken'    => 'Security token that requested user set in their preferences'
+                       'wlowner'    => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}token if it's not you)",
+                       'wltoken'    => 'Security token that requested user set in their preferences',
+                       'linktodiffs'      => 'Link to change differences instead of article pages'
                );
        }
 
@@ -185,7 +199,8 @@ class ApiFeedWatchlist extends ApiBase {
 
        protected function getExamples() {
                return array(
-                       'api.php?action=feedwatchlist'
+                       'api.php?action=feedwatchlist',
+                       'api.php?action=feedwatchlist&allrev=allrev&linktodiffs=&hours=6'
                );
        }