summaryrefslogtreecommitdiff
path: root/includes/api/ApiFeedWatchlist.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiFeedWatchlist.php')
-rw-r--r--includes/api/ApiFeedWatchlist.php41
1 files changed, 31 insertions, 10 deletions
diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php
index e1ba61f6..75ce7ca0 100644
--- a/includes/api/ApiFeedWatchlist.php
+++ b/includes/api/ApiFeedWatchlist.php
@@ -1,6 +1,6 @@
<?php
/**
- * API for MediaWiki 1.8+
+ *
*
* Created on Oct 13, 2006
*
@@ -56,11 +56,19 @@ class ApiFeedWatchlist extends ApiBase {
* Wrap the result as an RSS/Atom feed.
*/
public function execute() {
- global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode;
+ global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode;
try {
$params = $this->extractRequestParams();
+ if( !$wgFeed ) {
+ $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' );
+ }
+
+ if( !isset( $wgFeedClasses[ $params['feedformat'] ] ) ) {
+ $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' );
+ }
+
// limit to the number of hours going from now back
$endTime = wfTimestamp( TS_MW, time() - intval( $params['hours'] * 60 * 60 ) );
@@ -90,7 +98,7 @@ class ApiFeedWatchlist extends ApiBase {
}
// Check for 'allrev' parameter, and if found, show all revisions to each page on wl.
- if ( !is_null( $params['allrev'] ) ) {
+ if ( $params['allrev'] ) {
$fauxReqArr['wlallrev'] = '';
}
@@ -109,10 +117,12 @@ class ApiFeedWatchlist extends ApiBase {
$feedItems[] = $this->createFeedItem( $info );
}
- $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'watchlist' ) . ' [' . $wgLanguageCode . ']';
+ $msg = wfMsgForContent( 'watchlist' );
+
+ $feedTitle = $wgSitename . ' - ' . $msg . ' [' . $wgLanguageCode . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
- $feed = new $wgFeedClasses[$params['feedformat']] ( $feedTitle, htmlspecialchars( wfMsgForContent( 'watchlist' ) ), $feedUrl );
+ $feed = new $wgFeedClasses[$params['feedformat']] ( $feedTitle, htmlspecialchars( $msg ), $feedUrl );
ApiFormatFeedWrapper::setResult( $this->getResult(), $feed, $feedItems );
@@ -171,7 +181,7 @@ class ApiFeedWatchlist extends ApiBase {
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => 72,
),
- 'allrev' => null,
+ 'allrev' => false,
'wlowner' => array(
ApiBase::PARAM_TYPE => 'user'
),
@@ -189,22 +199,33 @@ class ApiFeedWatchlist extends ApiBase {
'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',
- 'linktodiffs'=> 'Link to change differences instead of article pages'
+ 'linktodiffs' => 'Link to change differences instead of article pages'
);
}
public function getDescription() {
- return 'This module returns a watchlist feed';
+ return 'Returns a watchlist feed';
+ }
+
+ public function getPossibleErrors() {
+ return array_merge( parent::getPossibleErrors(), array(
+ array( 'code' => 'feed-unavailable', 'info' => 'Syndication feeds are not available' ),
+ array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ),
+ ) );
}
protected function getExamples() {
return array(
'api.php?action=feedwatchlist',
- 'api.php?action=feedwatchlist&allrev=allrev&linktodiffs=&hours=6'
+ 'api.php?action=feedwatchlist&allrev=&linktodiffs=&hours=6'
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Watchlist_feed';
+ }
+
public function getVersion() {
- return __CLASS__ . ': $Id: ApiFeedWatchlist.php 77674 2010-12-03 19:47:22Z catrope $';
+ return __CLASS__ . ': $Id: ApiFeedWatchlist.php 104449 2011-11-28 15:52:04Z reedy $';
}
}