Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php |
— | — | @@ -26,8 +26,11 @@ |
27 | 27 | } |
28 | 28 | |
29 | 29 | function execute( $par ) { |
30 | | - global $wgRequest, $wgOut; |
| 30 | + global $wgRequest, $wgOut, $wgUser; |
31 | 31 | |
| 32 | + $this->linker = $wgUser->getSkin(); |
| 33 | + $this->translate = SpecialPage::getTitleFor( 'Translate' ); |
| 34 | + |
32 | 35 | $this->setHeaders(); |
33 | 36 | $this->outputHeader(); |
34 | 37 | |
— | — | @@ -48,7 +51,6 @@ |
49 | 52 | } |
50 | 53 | |
51 | 54 | if ( !$code ) { |
52 | | - global $wgUser; |
53 | 55 | |
54 | 56 | if ( $wgUser->isLoggedIn() ) { |
55 | 57 | global $wgLang; |
— | — | @@ -318,13 +320,16 @@ |
319 | 321 | } |
320 | 322 | |
321 | 323 | protected function loadPercentages( $cache, $group, $code ) { |
322 | | - $incache = $cache->get( $group->getId(), $code ); |
323 | | - if ( $incache !== false ) { |
324 | | - return $incache; |
| 324 | + wfProfileIn( __METHOD__ ); |
| 325 | + $id = $group->getId(); |
| 326 | + |
| 327 | + |
| 328 | + $result = $cache->get( $id, $code ); |
| 329 | + if ( is_array( $result ) ) { |
| 330 | + wfProfileOut( __METHOD__ ); |
| 331 | + return $result; |
325 | 332 | } |
326 | 333 | |
327 | | - wfProfileIn( __METHOD__ ); |
328 | | - |
329 | 334 | // Initialise messages. |
330 | 335 | $collection = $group->initCollection( $code ); |
331 | 336 | // Takes too much memory and only hides inconsistent import state |
— | — | @@ -344,14 +349,13 @@ |
345 | 350 | |
346 | 351 | $result = array( $fuzzy, $translated, $total ); |
347 | 352 | |
348 | | - $cache->set( $group->getId(), $code, $result ); |
| 353 | + $cache->set( $id, $code, $result ); |
349 | 354 | |
350 | 355 | static $i = 0; |
351 | | - if ( $i++ % 10 === 0 ) { |
| 356 | + if ( $i++ % 50 === 0 ) { |
352 | 357 | $cache->commit(); |
353 | 358 | } |
354 | 359 | |
355 | | - unset( $collection ); |
356 | 360 | wfProfileOut( __METHOD__ ); |
357 | 361 | |
358 | 362 | return $result; |
— | — | @@ -375,26 +379,27 @@ |
376 | 380 | } |
377 | 381 | |
378 | 382 | protected function makeGroupLink( $group, $code, $params ) { |
379 | | - global $wgOut, $wgUser; |
| 383 | + global $wgOut; |
380 | 384 | |
381 | | - $specialTranslate = SpecialPage::getTitleFor( 'Translate' ); |
382 | | - $skin = $wgUser->getSkin(); |
383 | | - |
384 | 385 | $queryParameters = $params + array( |
385 | 386 | 'group' => $group->getId(), |
386 | 387 | 'language' => $code |
387 | 388 | ); |
388 | 389 | |
389 | 390 | $attributes = array( |
390 | | - 'title' => strip_tags( $wgOut->parse( $group->getDescription(), false ) ) |
| 391 | + 'title' => $this->getGroupDescription( $group ) |
391 | 392 | ); |
392 | 393 | |
393 | | - $translateGroupLink = $skin->link( |
394 | | - $specialTranslate, $this->getGroupLabel( $group ), $attributes, $queryParameters |
| 394 | + $translateGroupLink = $this->linker->link( |
| 395 | + $this->translate, $this->getGroupLabel( $group ), $attributes, $queryParameters |
395 | 396 | ); |
396 | 397 | |
397 | 398 | return $translateGroupLink; |
| 399 | + } |
398 | 400 | |
| 401 | + protected function getGroupDescription( $group ) { |
| 402 | + global $wgLang; |
| 403 | + return MessageCache::singleton()->transform( $group->getDescription(), true, $wgLang, $this->getTitle() ); |
399 | 404 | } |
400 | 405 | |
401 | 406 | protected function isBlacklisted( $groupId, $code ) { |