X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedWatchlist.php;h=983b6a81f2220c0692cbf8fcc7a6ae6a1cefae30;hb=97afe30296d3ee6eed0e3f68c3886ce1685b5ca0;hp=545b94d767c96e3db6c9642fcd039c641d5bb275;hpb=27ca77bdd2512a27c58547d810a5206cc4c12b22;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 545b94d767..983b6a81f2 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -34,7 +34,6 @@ class ApiFeedWatchlist extends ApiBase { private $watchlistModule = null; - private $linkToDiffs = false; private $linkToSections = false; /** @@ -51,16 +50,16 @@ class ApiFeedWatchlist extends ApiBase { * Wrap the result as an RSS/Atom feed. */ public function execute() { - global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode; - + $config = $this->getConfig(); + $feedClasses = $config->get( 'FeedClasses' ); try { $params = $this->extractRequestParams(); - if ( !$wgFeed ) { + if ( !$config->get( 'Feed' ) ) { $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' ); } - if ( !isset( $wgFeedClasses[$params['feedformat']] ) ) { + if ( !isset( $feedClasses[$params['feedformat']] ) ) { $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); } @@ -73,10 +72,10 @@ class ApiFeedWatchlist extends ApiBase { 'meta' => 'siteinfo', 'siprop' => 'general', 'list' => 'watchlist', - 'wlprop' => 'title|user|comment|timestamp', + 'wlprop' => 'title|user|comment|timestamp|ids', 'wldir' => 'older', // reverse order - from newest to oldest 'wlend' => $endTime, // stop at this time - 'wllimit' => min( 50, $wgFeedLimit ) + 'wllimit' => min( 50, $this->getConfig()->get( 'FeedLimit' ) ) ); if ( $params['wlowner'] !== null ) { @@ -95,12 +94,6 @@ class ApiFeedWatchlist extends ApiBase { $fauxReqArr['wltype'] = $params['wltype']; } - // Support linking to diffs instead of article - if ( $params['linktodiffs'] ) { - $this->linkToDiffs = true; - $fauxReqArr['wlprop'] .= '|ids'; - } - // Support linking directly to sections when possible // (possible only if section name is present in comment) if ( $params['linktosections'] ) { @@ -129,10 +122,10 @@ class ApiFeedWatchlist extends ApiBase { $msg = wfMessage( 'watchlist' )->inContentLanguage()->text(); - $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']'; + $feedTitle = $this->getConfig()->get( 'Sitename' ) . ' - ' . $msg . ' [' . $this->getConfig()->get( 'LanguageCode' ) . ']'; $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL(); - $feed = new $wgFeedClasses[$params['feedformat']] ( + $feed = new $feedClasses[$params['feedformat']] ( $feedTitle, htmlspecialchars( $msg ), $feedUrl @@ -144,14 +137,14 @@ class ApiFeedWatchlist extends ApiBase { $this->getMain()->setCacheMaxAge( 0 ); // @todo FIXME: Localise brackets - $feedTitle = $wgSitename . ' - Error - ' . + $feedTitle = $this->getConfig()->get( 'Sitename' ) . ' - Error - ' . wfMessage( 'watchlist' )->inContentLanguage()->text() . - ' [' . $wgLanguageCode . ']'; + ' [' . $this->getConfig()->get( 'LanguageCode' ) . ']'; $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL(); $feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss'; $msg = wfMessage( 'watchlist' )->inContentLanguage()->escaped(); - $feed = new $wgFeedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl ); + $feed = new $feedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl ); if ( $e instanceof UsageException ) { $errorCode = $e->getCodeString(); @@ -173,7 +166,7 @@ class ApiFeedWatchlist extends ApiBase { private function createFeedItem( $info ) { $titleStr = $info['title']; $title = Title::newFromText( $titleStr ); - if ( $this->linkToDiffs && isset( $info['revid'] ) ) { + if ( isset( $info['revid'] ) ) { $titleUrl = $title->getFullURL( array( 'diff' => $info['revid'] ) ); } else { $titleUrl = $title->getFullURL(); @@ -212,8 +205,7 @@ class ApiFeedWatchlist extends ApiBase { } public function getAllowedParams( $flags = 0 ) { - global $wgFeedClasses; - $feedFormatNames = array_keys( $wgFeedClasses ); + $feedFormatNames = array_keys( $this->getConfig()->get( 'FeedClasses' ) ); $ret = array( 'feedformat' => array( ApiBase::PARAM_DFLT => 'rss', @@ -225,7 +217,6 @@ class ApiFeedWatchlist extends ApiBase { ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => 72, ), - 'linktodiffs' => false, 'linktosections' => false, ); if ( $flags ) { @@ -254,7 +245,6 @@ class ApiFeedWatchlist extends ApiBase { return array( 'feedformat' => 'The format of the feed', 'hours' => 'List pages modified within this many hours from now', - 'linktodiffs' => 'Link to change differences instead of article pages', 'linktosections' => 'Link directly to changed sections if possible', 'allrev' => $wldescr['allrev'], 'wlowner' => $wldescr['owner'], @@ -279,7 +269,7 @@ class ApiFeedWatchlist extends ApiBase { public function getExamples() { return array( 'api.php?action=feedwatchlist', - 'api.php?action=feedwatchlist&allrev=&linktodiffs=&hours=6' + 'api.php?action=feedwatchlist&allrev=&hours=6' ); }