Index: trunk/extensions/FeaturedFeeds/ApiFeaturedFeeds.php |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function execute() { |
19 | | - global $wgContLang; |
20 | 19 | wfProfileIn( __METHOD__ ); |
21 | 20 | |
22 | 21 | $params = $this->extractRequestParams(); |
— | — | @@ -32,12 +31,7 @@ |
33 | 32 | wfProfileOut( __METHOD__ ); |
34 | 33 | $this->dieUsage( 'Invalid language code', 'language-invalid' ); |
35 | 34 | } |
36 | | - $variant = isset( $params['variant'] ) ? $params['variant'] : false; |
37 | | - if ( $variant !== false && !in_array( $variant, $wgContLang->getVariants() ) ) { |
38 | | - wfProfileOut( __METHOD__ ); |
39 | | - $this->dieUsage( 'Invalid variant code', 'variant-invalid' ); |
40 | | - } |
41 | | - $feeds = FeaturedFeeds::getFeeds( $language, $variant ); |
| 35 | + $feeds = FeaturedFeeds::getFeeds( $language ); |
42 | 36 | $ourFeed = $feeds[$params['feed']]; |
43 | 37 | |
44 | 38 | $feedClass = new $wgFeedClasses[$params['feedformat']] ( |
— | — | @@ -58,7 +52,7 @@ |
59 | 53 | public function getAllowedParams() { |
60 | 54 | global $wgFeedClasses; |
61 | 55 | $feedFormatNames = array_keys( $wgFeedClasses ); |
62 | | - $availableFeeds = array_keys( FeaturedFeeds::getFeeds( false, false ) ); |
| 56 | + $availableFeeds = array_keys( FeaturedFeeds::getFeeds( false ) ); |
63 | 57 | return array ( |
64 | 58 | 'feedformat' => array( |
65 | 59 | ApiBase::PARAM_DFLT => 'rss', |
— | — | @@ -70,10 +64,7 @@ |
71 | 65 | ), |
72 | 66 | 'language' => array( |
73 | 67 | ApiBase::PARAM_TYPE => 'string', |
74 | | - ), |
75 | | - 'variant' => array( |
76 | | - ApiBase::PARAM_TYPE => 'string', |
77 | | - ), |
| 68 | + ) |
78 | 69 | ); |
79 | 70 | } |
80 | 71 | |
— | — | @@ -81,8 +72,7 @@ |
82 | 73 | return array( |
83 | 74 | 'feedformat' => 'The format of the feed', |
84 | 75 | 'feed' => 'Feed name', |
85 | | - 'language' => 'Feed language code. Ignored by some feeds.', |
86 | | - 'variant' => 'Feed variant code.', |
| 76 | + 'language' => 'Feed language code. Ignored by some feeds.' |
87 | 77 | ); |
88 | 78 | } |
89 | 79 | |
— | — | @@ -94,7 +84,6 @@ |
95 | 85 | return array_merge( parent::getPossibleErrors(), array( |
96 | 86 | array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ), |
97 | 87 | array( 'code' => 'language-invalid', 'info' => 'Invalid language code' ), |
98 | | - array( 'code' => 'variant-invalid', 'info' => 'Invalid variant code' ), |
99 | 88 | ) ); |
100 | 89 | } |
101 | 90 | |
— | — | @@ -102,7 +91,7 @@ |
103 | 92 | global $wgVersion; |
104 | 93 | // attempt to find a valid feed name |
105 | 94 | // if none available, just use an example value |
106 | | - $availableFeeds = array_keys( FeaturedFeeds::getFeeds( false, false ) ); |
| 95 | + $availableFeeds = array_keys( FeaturedFeeds::getFeeds( false ) ); |
107 | 96 | $feed = reset( $availableFeeds ); |
108 | 97 | if ( !$feed ) { |
109 | 98 | $feed = 'featured'; |
Index: trunk/extensions/FeaturedFeeds/FeaturedFeeds.body.php |
— | — | @@ -7,31 +7,27 @@ |
8 | 8 | * Returns the list of feeds |
9 | 9 | * |
10 | 10 | * @param $langCode string|bool Code of language to use or false if default |
11 | | - * @param $variantCode string|bool Code of variant to use or false if default or empty string if don't convert |
12 | 11 | * @return array Feeds in format of 'name' => array of FeedItem |
13 | 12 | */ |
14 | | - public static function getFeeds( $langCode, $variantCode ) { |
15 | | - global $wgMemc, $wgLangCode, $wgContLang; |
| 13 | + public static function getFeeds( $langCode ) { |
| 14 | + global $wgMemc, $wgLangCode; |
16 | 15 | |
17 | 16 | if ( !$langCode || self::allInContentLanguage() ) { |
18 | 17 | $langCode = $wgLangCode; |
19 | 18 | } |
20 | | - if ( $variantCode === false ) { |
21 | | - $variantCode = $wgContLang->getPreferredVariant(); |
22 | | - } |
23 | 19 | static $cache = array(); |
24 | | - if ( isset( $cache[$langCode][$variantCode] ) ) { |
25 | | - return $cache[$langCode][$variantCode]; |
| 20 | + if ( isset( $cache[$langCode] ) ) { |
| 21 | + return $cache[$langCode]; |
26 | 22 | } |
27 | 23 | |
28 | | - $key = self::getCacheKey( $langCode, $variantCode ); |
| 24 | + $key = self::getCacheKey( $langCode ); |
29 | 25 | $feeds = $wgMemc->get( $key ); |
30 | 26 | |
31 | 27 | if ( !$feeds ) { |
32 | | - $feeds = self::getFeedsInternal( $langCode, $variantCode ); |
| 28 | + $feeds = self::getFeedsInternal( $langCode ); |
33 | 29 | $wgMemc->set( $key, $feeds, self::getMaxAge() ); |
34 | 30 | } |
35 | | - $cache[$langCode][$variantCode] = $feeds; |
| 31 | + $cache[$langCode] = $feeds; |
36 | 32 | return $feeds; |
37 | 33 | } |
38 | 34 | |
— | — | @@ -40,8 +36,8 @@ |
41 | 37 | * @param String $langCode: Feed language code |
42 | 38 | * @return String |
43 | 39 | */ |
44 | | - private static function getCacheKey( $langCode, $variantCode ) { |
45 | | - return wfMemcKey( 'featured-feeds', $langCode, $variantCode ); |
| 40 | + private static function getCacheKey( $langCode ) { |
| 41 | + return wfMemcKey( 'featured-feeds', $langCode ); |
46 | 42 | } |
47 | 43 | |
48 | 44 | /** |
— | — | @@ -87,13 +83,9 @@ |
88 | 84 | * @return bool |
89 | 85 | */ |
90 | 86 | public static function beforePageDisplay( OutputPage &$out ) { |
91 | | - global $wgAdvertisedFeedTypes, $wgContLang; |
| 87 | + global $wgAdvertisedFeedTypes; |
92 | 88 | if ( $out->getTitle()->isMainPage() ) { |
93 | | - $feeds = self::getFeeds( |
94 | | - $out->getLanguage()->getCode(), |
95 | | - $wgContLang->getPreferredVariant() |
96 | | - ); |
97 | | - foreach ( $feeds as $feed ) { |
| 89 | + foreach ( self::getFeeds( $out->getLanguage()->getCode() ) as $feed ) { |
98 | 90 | foreach ( $wgAdvertisedFeedTypes as $type ) { |
99 | 91 | $out->addLink( array( |
100 | 92 | 'rel' => 'alternate', |
— | — | @@ -114,13 +106,10 @@ |
115 | 107 | * @return Boolean |
116 | 108 | */ |
117 | 109 | public static function skinTemplateOutputPageBeforeExec( &$sk, &$tpl ) { |
118 | | - global $wgDisplayFeedsInSidebar, $wgAdvertisedFeedTypes, $wgContLang; |
| 110 | + global $wgDisplayFeedsInSidebar, $wgAdvertisedFeedTypes; |
119 | 111 | |
120 | 112 | if ( $wgDisplayFeedsInSidebar && $sk->getContext()->getTitle()->isMainPage() ) { |
121 | | - $feeds = self::getFeeds( |
122 | | - $sk->getContext()->getLanguage()->getCode(), |
123 | | - $wgContLang->getPreferredVariant() |
124 | | - ); |
| 113 | + $feeds = self::getFeeds( $sk->getContext()->getLanguage()->getCode() ); |
125 | 114 | $links = array(); |
126 | 115 | $format = $wgAdvertisedFeedTypes[0]; // @fixme: |
127 | 116 | foreach ( $feeds as $feed ) { |
— | — | @@ -174,7 +163,7 @@ |
175 | 164 | * @return array |
176 | 165 | * @throws MWException |
177 | 166 | */ |
178 | | - private static function getFeedsInternal( $langCode, $variantCode ) { |
| 167 | + private static function getFeedsInternal( $langCode ) { |
179 | 168 | wfProfileIn( __METHOD__ ); |
180 | 169 | $feedDefs = self::getFeedDefinitions(); |
181 | 170 | |
— | — | @@ -182,7 +171,7 @@ |
183 | 172 | $requestedLang = Language::factory( $langCode ); |
184 | 173 | $parser = new Parser(); |
185 | 174 | foreach ( $feedDefs as $name => $opts ) { |
186 | | - $feed = new FeaturedFeedChannel( $name, $opts, $requestedLang, $variantCode ); |
| 175 | + $feed = new FeaturedFeedChannel( $name, $opts, $requestedLang ); |
187 | 176 | if ( !$feed->isOK() ) { |
188 | 177 | continue; |
189 | 178 | } |
— | — | @@ -263,7 +252,7 @@ |
264 | 253 | public $shortTitle; |
265 | 254 | public $description; |
266 | 255 | |
267 | | - public function __construct( $name, $options, $lang, $variant ) { |
| 256 | + public function __construct( $name, $options, $lang ) { |
268 | 257 | global $wgContLang; |
269 | 258 | if ( !self::$parserOptions ) { |
270 | 259 | self::$parserOptions = new ParserOptions(); |
— | — | @@ -277,7 +266,6 @@ |
278 | 267 | } else { |
279 | 268 | $this->language = $wgContLang; |
280 | 269 | } |
281 | | - $this->variant = $variant; |
282 | 270 | } |
283 | 271 | |
284 | 272 | private function msg( $key ) { |
— | — | @@ -298,19 +286,13 @@ |
299 | 287 | } |
300 | 288 | |
301 | 289 | public function init() { |
302 | | - global $wgContLang; |
| 290 | + global $wgLanguageCode; |
303 | 291 | if ( $this->title !== false ) { |
304 | 292 | return; |
305 | 293 | } |
306 | 294 | $this->title = $this->msg( $this->options['title'] )->text(); |
307 | 295 | $this->shortTitle = $this->msg( $this->options['short-title'] ); |
308 | 296 | $this->description = $this->msg( $this->options['description'] )->text(); |
309 | | - // Convert the messages if the content language has variants. |
310 | | - if ( $wgContLang->hasVariants() && $this->variant ) { |
311 | | - $this->title = $wgContLang->mConverter->convertTo( $this->title, $this->variant ); |
312 | | - $this->shortTitle = $wgContLang->mConverter->convertTo( $this->shortTitle, $this->variant ); |
313 | | - $this->description = $wgContLang->mConverter->convertTo( $this->description, $this->variant ); |
314 | | - } |
315 | 297 | $pageMsg = $this->msg( $this->options['page'] )->params( $this->language->getCode() ); |
316 | 298 | if ( $pageMsg->isDisabled() ) { |
317 | 299 | return; |
— | — | @@ -340,7 +322,6 @@ |
341 | 323 | * @return FeaturedFeedItem |
342 | 324 | */ |
343 | 325 | public function getFeedItem( $date ) { |
344 | | - global $wgContLang; |
345 | 326 | self::$parserOptions->setTimestamp( $date ); |
346 | 327 | self::$parserOptions->setUserLang( $this->language ); |
347 | 328 | |
— | — | @@ -358,19 +339,16 @@ |
359 | 340 | return false; |
360 | 341 | } |
361 | 342 | $text = self::$parser->parse( $text, $title, self::$parserOptions )->getText(); |
362 | | - $special = SpecialPage::getTitleFor( 'FeedItem' , |
| 343 | + $url = SpecialPage::getTitleFor( 'FeedItem' , |
363 | 344 | $this->name . '/' . wfTimestamp( TS_MW, $date ) . '/' . $this->language->getCode() |
364 | | - ); |
365 | | - $entry = self::$parser->transformMsg( $this->entryName, self::$parserOptions ); |
366 | | - if ( $wgContLang->hasVariants() && $this->variant ) { |
367 | | - $text = $wgContLang->mConverter->convertTo( $text, $this->variant ); |
368 | | - $entry = $wgContLang->mConverter->convertTo( $entry, $this->variant ); |
369 | | - $url = $special->getFullURL( array( 'variant' => $this->variant ) ); |
370 | | - } else { |
371 | | - $url = $special->getFullURL(); |
372 | | - } |
| 345 | + )->getFullURL(); |
373 | 346 | |
374 | | - return new FeaturedFeedItem( $entry, wfExpandUrl( $url ), $text, $date ); |
| 347 | + return new FeaturedFeedItem( |
| 348 | + self::$parser->transformMsg( $this->entryName, self::$parserOptions ), |
| 349 | + wfExpandUrl( $url ), |
| 350 | + $text, |
| 351 | + $date |
| 352 | + ); |
375 | 353 | } |
376 | 354 | |
377 | 355 | /** |
— | — | @@ -390,9 +368,6 @@ |
391 | 369 | if ( $this->options['inUserLanguage'] && $this->language->getCode() != $wgContLang->getCode() ) { |
392 | 370 | $options['language'] = $this->language->getCode(); |
393 | 371 | } |
394 | | - if ( $wgContLang->hasVariants() && $this->variant ) { |
395 | | - $options['variant'] = $this->variant; |
396 | | - } |
397 | 372 | return wfScript( 'api' ) . '?' . wfArrayToCGI( $options ); |
398 | 373 | } |
399 | 374 | } |
Index: trunk/extensions/FeaturedFeeds/SpecialFeedItem.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | return; |
17 | 17 | } |
18 | 18 | list( $feedName, $date, $langCode ) = $parts; |
19 | | - $feeds = FeaturedFeeds::getFeeds( $langCode, '' ); |
| 19 | + $feeds = FeaturedFeeds::getFeeds( $langCode ); |
20 | 20 | if ( !isset( $feeds[$feedName] ) ) { |
21 | 21 | $out->showErrorPage( 'error', 'ffeed-feed-not-found', array( $feedName ) ); |
22 | 22 | return; |
— | — | @@ -54,10 +54,8 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | private function displayItem( FeaturedFeedItem $item ) { |
58 | | - global $wgContLang; |
59 | 58 | $out = $this->getOutput(); |
60 | | - // The language converter converts page content automatically but not page title. |
61 | | - $out->setPageTitle( $wgContLang->convert( $item->getRawTitle() ) ); |
| 59 | + $out->setPageTitle( $item->getRawTitle() ); |
62 | 60 | $out->addHTML( $item->getRawText() ); |
63 | 61 | } |
64 | 62 | } |