2007-12-23 20:10:50 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Statistic output classes.
|
|
|
|
|
*
|
2010-12-16 19:15:12 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup MaintenanceLanguage
|
2007-12-23 20:10:50 +00:00
|
|
|
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
2011-10-24 09:08:13 +00:00
|
|
|
* @author Antoine Musso <hashar at free dot fr>
|
2007-12-23 20:10:50 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-12-12 08:41:27 +00:00
|
|
|
/** A general output object. Need to be overridden */
|
2013-11-11 15:43:58 +00:00
|
|
|
class StatsOutput {
|
2007-12-23 20:10:50 +00:00
|
|
|
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\suppressWarnings();
|
2013-11-11 15:49:37 +00:00
|
|
|
$return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\restoreWarnings();
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2013-11-11 15:49:37 +00:00
|
|
|
return $return;
|
2007-12-23 20:10:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Override the following methods
|
|
|
|
|
function heading() {
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function footer() {
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockstart() {
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockend() {
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function element( $in, $heading = false ) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Outputs WikiText */
|
2013-11-23 17:41:59 +00:00
|
|
|
class WikiStatsOutput extends StatsOutput {
|
2007-12-23 20:10:50 +00:00
|
|
|
function heading() {
|
2012-03-08 20:56:26 +00:00
|
|
|
global $wgDummyLanguageCodes;
|
2009-05-07 07:47:46 +00:00
|
|
|
$version = SpecialVersion::getVersion( 'nodb' );
|
2007-12-23 20:10:50 +00:00
|
|
|
echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
|
2013-11-11 15:13:11 +00:00
|
|
|
echo "'''Note:''' These statistics can be generated by running " .
|
|
|
|
|
"<code>php maintenance/language/transstat.php</code>.\n\n";
|
|
|
|
|
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";
|
2011-06-24 00:07:57 +00:00
|
|
|
echo 'English (en) is excluded because it is the default localization';
|
2013-04-18 18:48:44 +00:00
|
|
|
if ( is_array( $wgDummyLanguageCodes ) ) {
|
2011-07-01 01:42:48 +00:00
|
|
|
$dummyCodes = array();
|
2013-04-18 18:48:44 +00:00
|
|
|
foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
|
2012-03-08 20:56:26 +00:00
|
|
|
$dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
|
2011-06-24 00:07:57 +00:00
|
|
|
}
|
2013-11-11 15:13:11 +00:00
|
|
|
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 );
|
2011-06-24 00:07:57 +00:00
|
|
|
}
|
|
|
|
|
echo ".\n\n"; # dot to end sentence
|
2013-11-11 15:13:11 +00:00
|
|
|
echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
|
|
|
|
|
'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
|
2007-12-23 20:10:50 +00:00
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function footer() {
|
|
|
|
|
echo "|}\n";
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockstart() {
|
|
|
|
|
echo "|-\n";
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockend() {
|
|
|
|
|
echo '';
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function element( $in, $heading = false ) {
|
2010-05-22 16:50:39 +00:00
|
|
|
echo ( $heading ? '!' : '|' ) . "$in\n";
|
2007-12-23 20:10:50 +00:00
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\suppressWarnings();
|
2013-11-11 15:49:37 +00:00
|
|
|
$v = round( 255 * $subset / $total );
|
2015-06-10 18:29:05 +00:00
|
|
|
MediaWiki\restoreWarnings();
|
2013-11-11 15:49:37 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
if ( $revert ) {
|
2010-08-03 18:42:14 +00:00
|
|
|
# Weigh reverse with factor 20 so coloring takes effect more quickly as
|
|
|
|
|
# this option is used solely for reporting 'bad' percentages.
|
|
|
|
|
$v = $v * 20;
|
2013-04-18 18:48:44 +00:00
|
|
|
if ( $v > 255 ) {
|
|
|
|
|
$v = 255;
|
|
|
|
|
}
|
2007-12-23 20:10:50 +00:00
|
|
|
$v = 255 - $v;
|
|
|
|
|
}
|
|
|
|
|
if ( $v < 128 ) {
|
|
|
|
|
# Red to Yellow
|
|
|
|
|
$red = 'FF';
|
|
|
|
|
$green = sprintf( '%02X', 2 * $v );
|
|
|
|
|
} else {
|
|
|
|
|
# Yellow to Green
|
2010-05-22 16:50:39 +00:00
|
|
|
$red = sprintf( '%02X', 2 * ( 255 - $v ) );
|
2007-12-23 20:10:50 +00:00
|
|
|
$green = 'FF';
|
|
|
|
|
}
|
|
|
|
|
$blue = '00';
|
|
|
|
|
$color = $red . $green . $blue;
|
|
|
|
|
|
2010-08-06 14:12:41 +00:00
|
|
|
$percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2012-11-18 02:52:39 +00:00
|
|
|
return 'style="background-color:#' . $color . ';"|' . $percent;
|
2007-12-23 20:10:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Output text. To be used on a terminal for example. */
|
2013-11-23 17:41:59 +00:00
|
|
|
class TextStatsOutput extends StatsOutput {
|
2007-12-23 20:10:50 +00:00
|
|
|
function element( $in, $heading = false ) {
|
2010-05-22 16:50:39 +00:00
|
|
|
echo $in . "\t";
|
2007-12-23 20:10:50 +00:00
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockend() {
|
|
|
|
|
echo "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** csv output. Some people love excel */
|
2013-11-23 17:41:59 +00:00
|
|
|
class CsvStatsOutput extends StatsOutput {
|
2007-12-23 20:10:50 +00:00
|
|
|
function element( $in, $heading = false ) {
|
|
|
|
|
echo $in . ";";
|
|
|
|
|
}
|
2013-11-11 14:37:52 +00:00
|
|
|
|
2007-12-23 20:10:50 +00:00
|
|
|
function blockend() {
|
|
|
|
|
echo "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|