MediaWiki REL1_39
StatOutputs.php
Go to the documentation of this file.
1<?php
27use Wikimedia\AtEase\AtEase;
28
33 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
34 AtEase::suppressWarnings();
35 $return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
36 AtEase::restoreWarnings();
37
38 return $return;
39 }
40
41 public function heading() {
42 }
43
44 public function footer() {
45 }
46
47 public function blockstart() {
48 }
49
50 public function blockend() {
51 }
52
53 public function element( $in, $heading = false ) {
54 }
55}
56
59 public function heading() {
61 $version = SpecialVersion::getVersion( 'nodb' );
62 echo "'''Statistics are based on:''' <code>" . $version . "</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[] = MediaWikiServices::getInstance()
68 ->getLanguageNameUtils()
69 ->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
70 }
71 echo ', as well as the following languages that are not intended for ' .
72 'system message translations, usually because they redirect to other ' .
73 'language codes: ' . implode( ', ', $dummyCodes );
74 }
75 # dot to end sentence
76 echo ".\n\n";
77 echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
78 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
79 }
80
81 public function footer() {
82 echo "|}\n";
83 }
84
85 public function blockstart() {
86 echo "|-\n";
87 }
88
89 public function blockend() {
90 echo '';
91 }
92
93 public function element( $in, $heading = false ) {
94 echo ( $heading ? '!' : '|' ) . "$in\n";
95 }
96
97 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
98 AtEase::suppressWarnings();
99 $v = round( 255 * $subset / $total );
100 AtEase::restoreWarnings();
101
102 if ( $revert ) {
103 # Weigh reverse with factor 20 so coloring takes effect more quickly as
104 # this option is used solely for reporting 'bad' percentages.
105 $v = $v * 20;
106 if ( $v > 255 ) {
107 $v = 255;
108 }
109 $v = 255 - $v;
110 }
111 if ( $v < 128 ) {
112 # Red to Yellow
113 $red = 'FF';
114 $green = sprintf( '%02X', 2 * $v );
115 } else {
116 # Yellow to Green
117 $red = sprintf( '%02X', 2 * ( 255 - $v ) );
118 $green = 'FF';
119 }
120 $blue = '00';
121 $color = $red . $green . $blue;
122
123 $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
124
125 return 'style="background-color:#' . $color . ';"|' . $percent;
126 }
127}
128
131 public function element( $in, $heading = false ) {
132 echo $in . "\t";
133 }
134
135 public function blockend() {
136 echo "\n";
137 }
138}
139
142 public function element( $in, $heading = false ) {
143 echo $in . ";";
144 }
145
146 public function blockend() {
147 echo "\n";
148 }
149}
csv output.
element( $in, $heading=false)
Service locator for MediaWiki core services.
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
A general output object.
formatPercent( $subset, $total, $revert=false, $accuracy=2)
element( $in, $heading=false)
Output text.
element( $in, $heading=false)
Outputs WikiText.
element( $in, $heading=false)
formatPercent( $subset, $total, $revert=false, $accuracy=2)
$wgDummyLanguageCodes
Config variable stub for the DummyLanguageCodes setting, for use by phpdoc and IDEs.