X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedWatchlist.php;h=fdbdcc33de560265b65f76315720ea604120db87;hb=101de1bd7fa94b03b3c1d2c0e182eac334e8902d;hp=6c793b36c825d4c8810cbecce59687a8769f4a9c;hpb=4084d54474a3782a8c01896b7a0f623deec0200b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 6c793b36c8..fdbdcc33de 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -33,6 +33,9 @@ */ class ApiFeedWatchlist extends ApiBase { + private $linkToDiffs = false; + private $watchlistModule = null; + /** * This module uses a custom feed wrapper printer. * @@ -42,8 +45,6 @@ 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. @@ -86,6 +87,9 @@ class ApiFeedWatchlist extends ApiBase { if ( $params['wlexcludeuser'] !== null ) { $fauxReqArr['wlexcludeuser'] = $params['wlexcludeuser']; } + if ( $params['wlshow'] !== null ) { + $fauxReqArr['wlshow'] = $params['wlshow']; + } // Support linking to diffs instead of article if ( $params['linktodiffs'] ) { @@ -168,10 +172,18 @@ class ApiFeedWatchlist extends ApiBase { return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user ); } - public function getAllowedParams() { + private function getWatchlistModule() { + if ( $this->watchlistModule === null ) { + $this->watchlistModule = $this->getMain()->getModuleManager()->getModule( 'query' ) + ->getModuleManager()->getModule( 'watchlist' ); + } + return $this->watchlistModule; + } + + public function getAllowedParams( $flags = 0 ) { global $wgFeedClasses; $feedFormatNames = array_keys( $wgFeedClasses ); - return array ( + $ret = array( 'feedformat' => array( ApiBase::PARAM_DFLT => 'rss', ApiBase::PARAM_TYPE => $feedFormatNames @@ -182,29 +194,36 @@ class ApiFeedWatchlist extends ApiBase { ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => 72, ), - 'allrev' => false, - 'wlowner' => array( - ApiBase::PARAM_TYPE => 'user' - ), - 'wltoken' => array( - ApiBase::PARAM_TYPE => 'string' - ), - 'wlexcludeuser' => array( - ApiBase::PARAM_TYPE => 'user' - ), 'linktodiffs' => false, ); + if ( $flags ) { + $wlparams = $this->getWatchlistModule()->getAllowedParams( $flags ); + $ret['allrev'] = $wlparams['allrev']; + $ret['wlowner'] = $wlparams['owner']; + $ret['wltoken'] = $wlparams['token']; + $ret['wlshow'] = $wlparams['show']; + $ret['wlexcludeuser'] = $wlparams['excludeuser']; + } else { + $ret['allrev'] = null; + $ret['wlowner'] = null; + $ret['wltoken'] = null; + $ret['wlshow'] = null; + $ret['wlexcludeuser'] = null; + } + return $ret; } public function getParamDescription() { + $wldescr = $this->getWatchlistModule()->getParamDescription(); return array( '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()}wltoken if it's not you)", - 'wltoken' => 'Security token that requested user set in their preferences', - 'wlexcludeuser' => 'A user whose edits should not be shown in the watchlist', + 'hours' => 'List pages modified within this many hours from now', 'linktodiffs' => 'Link to change differences instead of article pages', + 'allrev' => $wldescr['allrev'], + 'wlowner' => $wldescr['owner'], + 'wltoken' => $wldescr['token'], + 'wlshow' => $wldescr['show'], + 'wlexcludeuser' => $wldescr['excludeuser'], ); }