MediaWiki
REL1_19
|
00001 <?php 00002 if ( !defined( 'MEDIAWIKI' ) ) die(); 00028 class statsOutput { 00029 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) { 00030 return @sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total ); 00031 } 00032 00033 # Override the following methods 00034 function heading() { 00035 } 00036 function footer() { 00037 } 00038 function blockstart() { 00039 } 00040 function blockend() { 00041 } 00042 function element( $in, $heading = false ) { 00043 } 00044 } 00045 00047 class wikiStatsOutput extends statsOutput { 00048 function heading() { 00049 global $wgDummyLanguageCodes, $wgContLang; 00050 $version = SpecialVersion::getVersion( 'nodb' ); 00051 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n"; 00052 echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n"; 00053 echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n"; 00054 echo 'English (en) is excluded because it is the default localization'; 00055 if( is_array( $wgDummyLanguageCodes ) ) { 00056 $dummyCodes = array(); 00057 foreach( $wgDummyLanguageCodes as $dummyCode => $correctCode ) { 00058 $dummyCodes[] = $wgContLang->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')'; 00059 } 00060 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 ); 00061 } 00062 echo ".\n\n"; # dot to end sentence 00063 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"; 00064 } 00065 function footer() { 00066 echo "|}\n"; 00067 } 00068 function blockstart() { 00069 echo "|-\n"; 00070 } 00071 function blockend() { 00072 echo ''; 00073 } 00074 function element( $in, $heading = false ) { 00075 echo ( $heading ? '!' : '|' ) . "$in\n"; 00076 } 00077 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) { 00078 $v = @round( 255 * $subset / $total ); 00079 if ( $revert ) { 00080 # Weigh reverse with factor 20 so coloring takes effect more quickly as 00081 # this option is used solely for reporting 'bad' percentages. 00082 $v = $v * 20; 00083 if ( $v > 255 ) $v = 255; 00084 $v = 255 - $v; 00085 } 00086 if ( $v < 128 ) { 00087 # Red to Yellow 00088 $red = 'FF'; 00089 $green = sprintf( '%02X', 2 * $v ); 00090 } else { 00091 # Yellow to Green 00092 $red = sprintf( '%02X', 2 * ( 255 - $v ) ); 00093 $green = 'FF'; 00094 } 00095 $blue = '00'; 00096 $color = $red . $green . $blue; 00097 00098 $percent = parent::formatPercent( $subset, $total, $revert, $accuracy ); 00099 return 'bgcolor="#' . $color . '"|' . $percent; 00100 } 00101 } 00102 00104 class textStatsOutput extends statsOutput { 00105 function element( $in, $heading = false ) { 00106 echo $in . "\t"; 00107 } 00108 function blockend() { 00109 echo "\n"; 00110 } 00111 } 00112 00114 class csvStatsOutput extends statsOutput { 00115 function element( $in, $heading = false ) { 00116 echo $in . ";"; 00117 } 00118 function blockend() { 00119 echo "\n"; 00120 } 00121 }