Index: trunk/extensions/Translate/scripts/groupStatistics.php |
— | — | @@ -89,6 +89,10 @@ |
90 | 90 | function heading() { |
91 | 91 | echo '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%"' . "\n"; |
92 | 92 | } |
| 93 | + |
| 94 | + function summaryheading() { |
| 95 | + echo "\n\n" . '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;"' . "\n"; |
| 96 | + } |
93 | 97 | } |
94 | 98 | |
95 | 99 | if ( isset( $options['help'] ) ) showUsage(); |
— | — | @@ -130,6 +134,8 @@ |
131 | 135 | --nol10n : do not add localised language name if I18ntags is installed. |
132 | 136 | --continent : add a continent column. Only available when output is |
133 | 137 | 'wiki' or not specified. |
| 138 | + --summary : add a summary with counts and scores per continent category |
| 139 | + and totals. Only available for a valid 'most' value. |
134 | 140 | |
135 | 141 | END; |
136 | 142 | STDERR( $msg ); |
— | — | @@ -301,6 +307,12 @@ |
302 | 308 | unset($collection); |
303 | 309 | } |
304 | 310 | |
| 311 | +// init summary array |
| 312 | +if( isset( $options['summary'] ) ) { |
| 313 | + $summarise = true; |
| 314 | + $summary = array(); |
| 315 | +} |
| 316 | + |
305 | 317 | foreach ( $languages as $code => $name ) { |
306 | 318 | // Skip list |
307 | 319 | if ( !isset( $options['most'] ) && in_array( $code, $skipLanguages ) ) { |
— | — | @@ -378,6 +390,18 @@ |
379 | 391 | // Report a round numbers |
380 | 392 | $score = number_format( $score, 0 ); |
381 | 393 | |
| 394 | + if( $summarise ) { |
| 395 | + $continent = $mostSpokenLanguages[$code][2]; |
| 396 | + if( isset( $summary[$continent] ) ) { |
| 397 | + $newcount = $summary[$continent][0] + 1; |
| 398 | + $newscore = $summary[$continent][1] + $score; |
| 399 | + } else { |
| 400 | + $newcount = 1; |
| 401 | + $newscore = $score; |
| 402 | + } |
| 403 | + |
| 404 | + $summary[$continent] = array( $newcount, $newscore ); |
| 405 | + } |
382 | 406 | $out->element( $score ); |
383 | 407 | } |
384 | 408 | |
— | — | @@ -390,5 +414,45 @@ |
391 | 415 | $out->blockend(); |
392 | 416 | } |
393 | 417 | |
394 | | -# Finally output footer |
395 | 418 | $out->footer(); |
| 419 | + |
| 420 | +if( $reportScore && isset( $options['summary'] ) ) { |
| 421 | + $out->summaryheading(); |
| 422 | + |
| 423 | + $out->blockstart(); |
| 424 | + |
| 425 | + $out->element( 'Continent', true ); |
| 426 | + $out->element( 'Count', true ); |
| 427 | + $out->element( 'Avg. score', true ); |
| 428 | + |
| 429 | + $out->blockend(); |
| 430 | + |
| 431 | + ksort( $summary ); |
| 432 | + |
| 433 | + $totals = array( 0, 0 ); |
| 434 | + |
| 435 | + foreach ( $summary as $key => $values ) { |
| 436 | + $out->blockstart(); |
| 437 | + |
| 438 | + if( $key == 'multiple' ) { |
| 439 | + $out->element( 'Multiple' ); |
| 440 | + } else { |
| 441 | + $out->element( "{{int:timezoneregion-" . $key . "}}" ); |
| 442 | + } |
| 443 | + $out->element( $values[0] ); |
| 444 | + $out->element( number_format( $values[1]/$values[0] ) ); |
| 445 | + |
| 446 | + $out->blockend(); |
| 447 | + |
| 448 | + $totals[0] += $values[0]; |
| 449 | + $totals[1] += $values[1]; |
| 450 | + } |
| 451 | + |
| 452 | + $out->blockstart(); |
| 453 | + $out->element( 'Total' ); |
| 454 | + $out->element( $totals[0] ); |
| 455 | + $out->element( number_format( $totals[1]/$totals[0] ) ); |
| 456 | + $out->blockend(); |
| 457 | + |
| 458 | + $out->footer(); |
| 459 | +} |