r101994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101993‎ | r101994 | r101995 >
Date:14:41, 4 November 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Handle better the case when no groups have been configured - bug 31633.
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/Translate.i18n.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageGroups.php
@@ -1152,6 +1152,7 @@
11531153 }
11541154
11551155 // Sort top-level groups according to labels, not ids
 1156+ $labels = array();
11561157 foreach ( $structure as $id => $data ) {
11571158 // Either it is a group itself, or the first group of the array
11581159 $nid = is_array( $data ) ? key( $data ) : $id;
Index: trunk/extensions/Translate/Translate.i18n.php
@@ -19,6 +19,7 @@
2020
2121 'translate-grouplisting' => 'This is the list of all translatable groups.
2222 Click the message group name to view a list of untranslated messages.',
 23+ 'translate-grouplisting-empty' => 'No message groups have been configured for translation.',
2324
2425 'translate-task-view' => 'View all messages from',
2526 'translate-task-untranslated' => 'View all untranslated messages from',
Index: trunk/extensions/Translate/specials/SpecialTranslate.php
@@ -60,7 +60,7 @@
6161 $errors = array();
6262
6363 if ( $this->options['group'] === '' ) {
64 - $wgOut->addHTML( $this->groupInformation() );
 64+ $this->groupInformation();
6565 return;
6666 }
6767
@@ -404,15 +404,21 @@
405405 }
406406
407407 public function groupInformation() {
408 - $out = '';
 408+ global $wgOut;
409409 $structure = MessageGroups::getGroupStructure();
 410+ if ( !$structure ) {
 411+ $wgOut->addWikiMsg( 'translate-grouplisting-empty' );
 412+ return;
 413+ }
410414
 415+ $wgOut->addWikiMsg( 'translate-grouplisting' );
 416+
 417+ $out = '';
411418 foreach ( $structure as $blocks ) {
412419 $out .= $this->formatGroupInformation( $blocks );
413420 }
414421
415 - $header = wfMsgExt( 'translate-grouplisting', 'parse' );
416 - return $header . "\n" . Html::rawElement( 'table', array( 'class' => 'mw-sp-translate-grouplist wikitable' ), $out );
 422+ $wgOut->addHtml( Html::rawElement( 'table', array( 'class' => 'mw-sp-translate-grouplist wikitable' ), $out ) );
417423 }
418424
419425 public function formatGroupInformation( $blocks, $level = 2 ) {

Status & tagging log