2 if (!defined('MEDIAWIKI')) die();
4 * Statistic output classes.
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * @author Ashar Voultoiz <thoane@altern.org>
10 /** A general output object. Need to be overriden */
12 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
13 return @sprintf
( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
16 # Override the following methods
21 function blockstart() {
25 function element( $in, $heading = false ) {
29 /** Outputs WikiText */
30 class wikiStatsOutput
extends statsOutput
{
33 $version = SpecialVersion
::getVersion( $IP );
34 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
35 echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n";
36 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";
37 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";
42 function blockstart() {
48 function element( $in, $heading = false ) {
49 echo ($heading ?
'!' : '|') . " $in\n";
51 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
52 $v = @round
(255 * $subset / $total);
59 $green = sprintf( '%02X', 2 * $v );
62 $red = sprintf('%02X', 2 * ( 255 - $v ) );
66 $color = $red . $green . $blue;
68 $percent = statsOutput
::formatPercent( $subset, $total, $revert, $accuracy );
69 return 'bgcolor="#'. $color .'" | '. $percent;
73 /** Outputs WikiText and appends category and text only used for Meta-Wiki */
74 class metawikiStatsOutput
extends wikiStatsOutput
{
76 echo "See [[MediaWiki localisation]] to learn how you can help translating MediaWiki.\n\n";
81 echo "\n[[Category:Localisation|Statistics]]\n";
85 /** Output text. To be used on a terminal for example. */
86 class textStatsOutput
extends statsOutput
{
87 function element( $in, $heading = false ) {
95 /** csv output. Some people love excel */
96 class csvStatsOutput
extends statsOutput
{
97 function element( $in, $heading = false ) {
100 function blockend() {