3 * Statistic output classes.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup MaintenanceLanguage
22 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
23 * @author Antoine Musso <hashar at free dot fr>
26 /** A general output object. Need to be overriden */
28 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
29 return @sprintf
( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
32 # Override the following methods
39 function blockstart() {
45 function element( $in, $heading = false ) {
49 /** Outputs WikiText */
50 class WikiStatsOutput
extends statsOutput
{
52 global $wgDummyLanguageCodes;
53 $version = SpecialVersion
::getVersion( 'nodb' );
54 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
55 echo "'''Note:''' These statistics can be generated by running " .
56 "<code>php maintenance/language/transstat.php</code>.\n\n";
57 echo "For additional information on specific languages (the message names, the actual " .
58 "problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
59 echo 'English (en) is excluded because it is the default localization';
60 if ( is_array( $wgDummyLanguageCodes ) ) {
61 $dummyCodes = array();
62 foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
63 $dummyCodes[] = Language
::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
65 echo ', as well as the following languages that are not intended for ' .
66 'system message translations, usually because they redirect to other ' .
67 'language codes: ' . implode( ', ', $dummyCodes );
69 echo ".\n\n"; # dot to end sentence
70 echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
71 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
78 function blockstart() {
86 function element( $in, $heading = false ) {
87 echo ( $heading ?
'!' : '|' ) . "$in\n";
90 function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
91 $v = @round
( 255 * $subset / $total );
93 # Weigh reverse with factor 20 so coloring takes effect more quickly as
94 # this option is used solely for reporting 'bad' percentages.
104 $green = sprintf( '%02X', 2 * $v );
107 $red = sprintf( '%02X', 2 * ( 255 - $v ) );
111 $color = $red . $green . $blue;
113 $percent = parent
::formatPercent( $subset, $total, $revert, $accuracy );
115 return 'style="background-color:#' . $color . ';"|' . $percent;
119 /** Output text. To be used on a terminal for example. */
120 class TextStatsOutput
extends statsOutput
{
121 function element( $in, $heading = false ) {
125 function blockend() {
130 /** csv output. Some people love excel */
131 class CsvStatsOutput
extends statsOutput
{
132 function element( $in, $heading = false ) {
136 function blockend() {