MediaWiki master
StatOutputs.php
Go to the documentation of this file.
1<?php
13
25 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
26 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
27 $return = @sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
28
29 return $return;
30 }
31
32 public function heading() {
33 }
34
35 public function footer() {
36 }
37
38 public function blockstart() {
39 }
40
41 public function blockend() {
42 }
43
48 public function element( $in, $heading = false ) {
49 }
50}
51
54 public function heading() {
56 $version = SpecialVersion::getVersion( 'nodb' );
57 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
58 echo 'English (en) is excluded because it is the default localization';
59 if ( is_array( $wgDummyLanguageCodes ) ) {
60 $dummyCodes = [];
61 foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
62 $dummyCodes[] = $this->getServiceContainer()
63 ->getLanguageNameUtils()
64 ->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
65 }
66 echo ', as well as the following languages that are not intended for ' .
67 'system message translations, usually because they redirect to other ' .
68 'language codes: ' . implode( ', ', $dummyCodes );
69 }
70 # dot to end sentence
71 echo ".\n\n";
72 echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
73 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
74 }
75
76 public function footer() {
77 echo "|}\n";
78 }
79
80 public function blockstart() {
81 echo "|-\n";
82 }
83
84 public function blockend() {
85 echo '';
86 }
87
89 public function element( $in, $heading = false ) {
90 echo ( $heading ? '!' : '|' ) . "$in\n";
91 }
92
94 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
95 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
96 $v = @round( 255 * $subset / $total );
97
98 if ( $revert ) {
99 # Weigh reverse with factor 20 so coloring takes effect more quickly as
100 # this option is used solely for reporting 'bad' percentages.
101 $v = $v * 20;
102 if ( $v > 255 ) {
103 $v = 255;
104 }
105 $v = 255 - $v;
106 }
107 if ( $v < 128 ) {
108 # Red to Yellow
109 $red = 'FF';
110 $green = sprintf( '%02X', 2 * $v );
111 } else {
112 # Yellow to Green
113 $red = sprintf( '%02X', 2 * ( 255 - $v ) );
114 $green = 'FF';
115 }
116 $blue = '00';
117 $color = $red . $green . $blue;
118
119 $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
120
121 return 'style="background-color:#' . $color . ';"|' . $percent;
122 }
123}
124
128 public function element( $in, $heading = false ) {
129 echo $in . "\t";
130 }
131
132 public function blockend() {
133 echo "\n";
134 }
135}
136
140 public function element( $in, $heading = false ) {
141 echo $in . ";";
142 }
143
144 public function blockend() {
145 echo "\n";
146 }
147}
csv output.
element( $in, $heading=false)
Version information about MediaWiki (core, extensions, libs), PHP, and the database.
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)
string
$wgDummyLanguageCodes
Config variable stub for the DummyLanguageCodes setting, for use by phpdoc and IDEs.