X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Flanguage%2FStatOutputs.php;h=e9d8c86dd0c5c06cd67defea964ee97fe18fa38f;hb=ed60efc8eb3126e97c0098681bd9239faecf33c1;hp=169a4d410101ea6481853732543b956b6c6f7d69;hpb=dfde2d2232ebc529a685460ba258680aa8b0f951;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/language/StatOutputs.php b/maintenance/language/StatOutputs.php index 169a4d4101..e9d8c86dd0 100644 --- a/maintenance/language/StatOutputs.php +++ b/maintenance/language/StatOutputs.php @@ -1,12 +1,29 @@ - * @author Ashar Voultoiz + * @author Antoine Musso */ /** A general output object. Need to be overriden */ @@ -31,12 +48,21 @@ class statsOutput { /** Outputs WikiText */ class wikiStatsOutput extends statsOutput { function heading() { - global $IP; + global $wgDummyLanguageCodes; $version = SpecialVersion::getVersion( 'nodb' ); echo "'''Statistics are based on:''' " . $version . "\n\n"; echo "'''Note:''' These statistics can be generated by running php maintenance/language/transstat.php.\n\n"; echo "For additional information on specific languages (the message names, the actual problems, etc.), run php maintenance/language/checkLanguage.php --lang=foo.\n\n"; - 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"; + echo 'English (en) is excluded because it is the default localization'; + if ( is_array( $wgDummyLanguageCodes ) ) { + $dummyCodes = array(); + foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) { + $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')'; + } + echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes ); + } + echo ".\n\n"; # dot to end sentence + echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n"; } function footer() { echo "|}\n"; @@ -48,11 +74,17 @@ class wikiStatsOutput extends statsOutput { echo ''; } function element( $in, $heading = false ) { - echo ($heading ? '!' : '|') . "$in\n"; + echo ( $heading ? '!' : '|' ) . "$in\n"; } function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) { - $v = @round(255 * $subset / $total); + $v = @round( 255 * $subset / $total ); if ( $revert ) { + # Weigh reverse with factor 20 so coloring takes effect more quickly as + # this option is used solely for reporting 'bad' percentages. + $v = $v * 20; + if ( $v > 255 ) { + $v = 255; + } $v = 255 - $v; } if ( $v < 128 ) { @@ -61,21 +93,21 @@ class wikiStatsOutput extends statsOutput { $green = sprintf( '%02X', 2 * $v ); } else { # Yellow to Green - $red = sprintf('%02X', 2 * ( 255 - $v ) ); + $red = sprintf( '%02X', 2 * ( 255 - $v ) ); $green = 'FF'; } $blue = '00'; $color = $red . $green . $blue; - $percent = statsOutput::formatPercent( $subset, $total, $revert, $accuracy ); - return 'bgcolor="#'. $color .'"|'. $percent; + $percent = parent::formatPercent( $subset, $total, $revert, $accuracy ); + return 'style="background-color:#' . $color . ';"|' . $percent; } } /** Output text. To be used on a terminal for example. */ class textStatsOutput extends statsOutput { function element( $in, $heading = false ) { - echo $in."\t"; + echo $in . "\t"; } function blockend() { echo "\n";