r57342 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57341‎ | r57342 | r57343 >
Date:19:27, 3 October 2009
Author:siebrand
Status:deferred
Tags:
Comment:
Update documentation and add a somewhat working --most feature. Score calculation still has to be added.
Modified paths:
  • /trunk/extensions/Translate/scripts/groupStatistics.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/groupStatistics.php
@@ -92,7 +92,11 @@
9393 }
9494
9595 if ( isset( $options['help'] ) ) showUsage();
96 -if ( !isset( $options['groups'] ) ) showUsage();
 96+
 97+// Show help and exit if '--most' does not have a valid value and no groups set
 98+if ( !isset( $localisedWeights[$options['most']] ) && !isset( $options['groups'] ) ) {
 99+ showUsage();
 100+}
97101 if ( !isset( $options['output'] ) ) $options['output'] = 'default';
98102
99103 /** Print a usage message*/
@@ -109,9 +113,9 @@
110114 * 'metawiki' : MediaWiki syntax used for Meta-Wiki.
111115 * 'text' : Text with tabs.
112116 --most : [SCOPE]: report on the 50 most spoken languages. Skipzero is
113 - ignored. If a valid scope is defined, the group list is
114 - ignored and the localisation levels are weighted and
115 - reported.
 117+ ignored. If a valid scope is defined, the group list
 118+ and fuzzy are ignored and the localisation levels are
 119+ weighted and reported.
116120 * mediawiki:
117121 core-mostused (30%)
118122 core (30%)
@@ -158,9 +162,18 @@
159163 $skipLanguages = array_map( 'trim', explode( ',', $options['skiplanguages'] ) );
160164 }
161165
 166+$reportScore = false;
 167+if ( isset( $options['most'] ) && isset( $localisedWeights[$options['most']] ) ) {
 168+ $reportScore = true;
 169+}
 170+
162171 // Get groups from input
163172 $groups = array();
164 -$reqGroups = array_map( 'trim', explode( ',', $options['groups'] ) );
 173+if( $reportScore ) {
 174+ $reqGroups = array_keys( $localisedWeights[$options['most']] );
 175+} else {
 176+ $reqGroups = array_map( 'trim', explode( ',', $options['groups'] ) );
 177+}
165178
166179 // List of all groups
167180 $allGroups = MessageGroups::singleton()->getGroups();
@@ -199,6 +212,9 @@
200213 if( isset( $options['most'] ) && isset( $options['speakers'] ) ) {
201214 $out->element( 'Speakers', true );
202215 }
 216+/*if( $reportScore ) {
 217+ $out->element( 'Score', true );
 218+}*/
203219 foreach ( $groups as $g ) {
204220 // Add unprocessed description of group as heading
205221 $out->element( $g->getLabel(), true );
@@ -327,8 +343,15 @@
328344 $out->element( number_format( $mostSpokenLanguages[$code][3] ) );
329345 }
330346
 347+ // Fill the score field
 348+ /*if( $reportScore ) {
 349+ $weights = $localisedWeights[$options['most']];
 350+ }*/
 351+
331352 // Fill fields for groups
332353 foreach ( $columns as $fields ) {
 354+ //var_dump( $fields, true );
 355+ //exit(1);
333356 list( $invert, $upper, $total ) = $fields;
334357 $c = $out->formatPercent( $upper, $total, $invert, /* Decimals */ 2 );
335358 $out->element( $c );

Status & tagging log