Index: trunk/extensions/FeaturedFeeds/ApiFeaturedFeeds.php |
— | — | @@ -23,7 +23,11 @@ |
24 | 24 | $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); |
25 | 25 | } |
26 | 26 | |
27 | | - $feeds = FeaturedFeeds::getFeeds( false ); |
| 27 | + $language = isset( $params['language'] ) ? $params['language'] : false; |
| 28 | + if ( $language !== false && !Language::isValidCode( $language ) ) { |
| 29 | + $this->dieUsage( 'Invalid language code', 'language-invalid' ); |
| 30 | + } |
| 31 | + $feeds = FeaturedFeeds::getFeeds( $language ); |
28 | 32 | $ourFeed = $feeds[$params['channel']]; |
29 | 33 | |
30 | 34 | $feedClass = new $wgFeedClasses[$params['feedformat']] ( |
— | — | @@ -49,6 +53,9 @@ |
50 | 54 | ApiBase::PARAM_TYPE => $availableFeeds, |
51 | 55 | ApiBase::PARAM_REQUIRED => true, |
52 | 56 | ), |
| 57 | + 'language' => array( |
| 58 | + ApiBase::PARAM_TYPE => 'string', |
| 59 | + ) |
53 | 60 | ); |
54 | 61 | } |
55 | 62 | |
— | — | @@ -56,6 +63,7 @@ |
57 | 64 | return array( |
58 | 65 | 'feedformat' => 'The format of the feed', |
59 | 66 | 'channel' => 'Feed channel', |
| 67 | + 'language' => 'Feed language code. Ignored by some feeds.' |
60 | 68 | ); |
61 | 69 | } |
62 | 70 | |
— | — | @@ -70,12 +78,28 @@ |
71 | 79 | } |
72 | 80 | |
73 | 81 | public function getExamples() { |
74 | | - return array( |
75 | | - 'api.php?action=featuredfeed&channel=featured', //@todo |
76 | | - ); |
| 82 | + global $wgVersion; |
| 83 | + // attempt to find a valid channel name |
| 84 | + // if none available, just use an example value |
| 85 | + $availableFeeds = array_keys( FeaturedFeeds::getFeeds( false ) ); |
| 86 | + $channel = reset( $availableFeeds ); |
| 87 | + if ( !$channel ) { |
| 88 | + $channel = 'featured'; |
| 89 | + } |
| 90 | + |
| 91 | + if ( version_compare( $wgVersion, '1.19alpha', '>=' ) ) { |
| 92 | + return array( |
| 93 | + "api.php?action=featuredfeed&channel=$channel" => "Retrieve feed for channel `$channel'", |
| 94 | + ); |
| 95 | + } else { |
| 96 | + return array( |
| 97 | + "Retrieve feed for channel `$channel'", |
| 98 | + " api.php?action=featuredfeed&channel=$channel", |
| 99 | + ); |
| 100 | + } |
77 | 101 | } |
78 | 102 | |
79 | 103 | public function getVersion() { |
80 | 104 | return __CLASS__ . ': $Id$'; |
81 | 105 | } |
82 | | -} |
\ No newline at end of file |
| 106 | +} |