MediaWiki  1.32.5
StatOutputs.php
Go to the documentation of this file.
1 <?php
27 class StatsOutput {
28  function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
29  Wikimedia\suppressWarnings();
30  $return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
31  Wikimedia\restoreWarnings();
32 
33  return $return;
34  }
35 
36  # Override the following methods
37  function heading() {
38  }
39 
40  function footer() {
41  }
42 
43  function blockstart() {
44  }
45 
46  function blockend() {
47  }
48 
49  function element( $in, $heading = false ) {
50  }
51 }
52 
55  function heading() {
56  global $wgDummyLanguageCodes;
57  $version = SpecialVersion::getVersion( 'nodb' );
58  echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
59  echo "'''Note:''' These statistics can be generated by running " .
60  "<code>php maintenance/language/transstat.php</code>.\n\n";
61  echo "For additional information on specific languages (the message names, the actual " .
62  "problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n";
63  echo 'English (en) is excluded because it is the default localization';
64  if ( is_array( $wgDummyLanguageCodes ) ) {
65  $dummyCodes = [];
66  foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
67  $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
68  }
69  echo ', as well as the following languages that are not intended for ' .
70  'system message translations, usually because they redirect to other ' .
71  'language codes: ' . implode( ', ', $dummyCodes );
72  }
73  echo ".\n\n"; # dot to end sentence
74  echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
75  'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
76  }
77 
78  function footer() {
79  echo "|}\n";
80  }
81 
82  function blockstart() {
83  echo "|-\n";
84  }
85 
86  function blockend() {
87  echo '';
88  }
89 
90  function element( $in, $heading = false ) {
91  echo ( $heading ? '!' : '|' ) . "$in\n";
92  }
93 
94  function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
95  Wikimedia\suppressWarnings();
96  $v = round( 255 * $subset / $total );
97  Wikimedia\restoreWarnings();
98 
99  if ( $revert ) {
100  # Weigh reverse with factor 20 so coloring takes effect more quickly as
101  # this option is used solely for reporting 'bad' percentages.
102  $v = $v * 20;
103  if ( $v > 255 ) {
104  $v = 255;
105  }
106  $v = 255 - $v;
107  }
108  if ( $v < 128 ) {
109  # Red to Yellow
110  $red = 'FF';
111  $green = sprintf( '%02X', 2 * $v );
112  } else {
113  # Yellow to Green
114  $red = sprintf( '%02X', 2 * ( 255 - $v ) );
115  $green = 'FF';
116  }
117  $blue = '00';
118  $color = $red . $green . $blue;
119 
120  $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
121 
122  return 'style="background-color:#' . $color . ';"|' . $percent;
123  }
124 }
125 
128  function element( $in, $heading = false ) {
129  echo $in . "\t";
130  }
131 
132  function blockend() {
133  echo "\n";
134  }
135 }
136 
139  function element( $in, $heading = false ) {
140  echo $in . ";";
141  }
142 
143  function blockend() {
144  echo "\n";
145  }
146 }
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:940
CsvStatsOutput
csv output.
Definition: StatOutputs.php:138
StatsOutput\blockstart
blockstart()
Definition: StatOutputs.php:43
WikiStatsOutput\blockend
blockend()
Definition: StatOutputs.php:86
WikiStatsOutput\footer
footer()
Definition: StatOutputs.php:78
TextStatsOutput\blockend
blockend()
Definition: StatOutputs.php:132
StatsOutput\footer
footer()
Definition: StatOutputs.php:40
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
StatsOutput\blockend
blockend()
Definition: StatOutputs.php:46
TextStatsOutput
Output text.
Definition: StatOutputs.php:127
StatsOutput\formatPercent
formatPercent( $subset, $total, $revert=false, $accuracy=2)
Definition: StatOutputs.php:28
StatsOutput
A general output object.
Definition: StatOutputs.php:27
CsvStatsOutput\blockend
blockend()
Definition: StatOutputs.php:143
StatsOutput\element
element( $in, $heading=false)
Definition: StatOutputs.php:49
TextStatsOutput\element
element( $in, $heading=false)
Definition: StatOutputs.php:128
SpecialVersion\getVersion
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
Definition: SpecialVersion.php:271
WikiStatsOutput\element
element( $in, $heading=false)
Definition: StatOutputs.php:90
$revert
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging a wrapping ErrorException instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters create2 Corresponds to logging log_action database field and which is displayed in the UI & $revert
Definition: hooks.txt:2221
WikiStatsOutput\blockstart
blockstart()
Definition: StatOutputs.php:82
WikiStatsOutput\formatPercent
formatPercent( $subset, $total, $revert=false, $accuracy=2)
Definition: StatOutputs.php:94
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
WikiStatsOutput\heading
heading()
Definition: StatOutputs.php:55
CsvStatsOutput\element
element( $in, $heading=false)
Definition: StatOutputs.php:139
WikiStatsOutput
Outputs WikiText.
Definition: StatOutputs.php:54
StatsOutput\heading
heading()
Definition: StatOutputs.php:37
$wgDummyLanguageCodes
$wgDummyLanguageCodes
Functionally the same as $wgExtraLanguageCodes, but deprecated.
Definition: DefaultSettings.php:3019