00001 <?php 00002 if (!defined('MEDIAWIKI')) die(); 00013 class statsOutput { 00014 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) { 00015 return @sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total ); 00016 } 00017 00018 # Override the following methods 00019 function heading() { 00020 } 00021 function footer() { 00022 } 00023 function blockstart() { 00024 } 00025 function blockend() { 00026 } 00027 function element( $in, $heading = false ) { 00028 } 00029 } 00030 00032 class wikiStatsOutput extends statsOutput { 00033 function heading() { 00034 global $IP; 00035 $version = SpecialVersion::getVersion( $IP ); 00036 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n"; 00037 echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n"; 00038 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"; 00039 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"; 00040 } 00041 function footer() { 00042 echo "|}\n"; 00043 } 00044 function blockstart() { 00045 echo "|-\n"; 00046 } 00047 function blockend() { 00048 echo ''; 00049 } 00050 function element( $in, $heading = false ) { 00051 echo ($heading ? '!' : '|') . "$in\n"; 00052 } 00053 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) { 00054 $v = @round(255 * $subset / $total); 00055 if ( $revert ) { 00056 $v = 255 - $v; 00057 } 00058 if ( $v < 128 ) { 00059 # Red to Yellow 00060 $red = 'FF'; 00061 $green = sprintf( '%02X', 2 * $v ); 00062 } else { 00063 # Yellow to Green 00064 $red = sprintf('%02X', 2 * ( 255 - $v ) ); 00065 $green = 'FF'; 00066 } 00067 $blue = '00'; 00068 $color = $red . $green . $blue; 00069 00070 $percent = statsOutput::formatPercent( $subset, $total, $revert, $accuracy ); 00071 return 'bgcolor="#'. $color .'"|'. $percent; 00072 } 00073 } 00074 00076 class metawikiStatsOutput extends wikiStatsOutput { 00077 function heading() { 00078 echo "See [[MediaWiki localisation]] to learn how you can help translating MediaWiki.\n\n"; 00079 parent::heading(); 00080 } 00081 function footer() { 00082 parent::footer(); 00083 echo "\n[[Category:Localisation|Statistics]]\n"; 00084 } 00085 } 00086 00088 class textStatsOutput extends statsOutput { 00089 function element( $in, $heading = false ) { 00090 echo $in."\t"; 00091 } 00092 function blockend() { 00093 echo "\n"; 00094 } 00095 } 00096 00098 class csvStatsOutput extends statsOutput { 00099 function element( $in, $heading = false ) { 00100 echo $in . ";"; 00101 } 00102 function blockend() { 00103 echo "\n"; 00104 } 00105 }