MediaWiki REL1_37
StatOutputs.php
Go to the documentation of this file.
1<?php
27
32 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
33 Wikimedia\suppressWarnings();
34 $return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total );
35 Wikimedia\restoreWarnings();
36
37 return $return;
38 }
39
40 public function heading() {
41 }
42
43 public function footer() {
44 }
45
46 public function blockstart() {
47 }
48
49 public function blockend() {
50 }
51
52 public function element( $in, $heading = false ) {
53 }
54}
55
58 public function heading() {
60 $version = SpecialVersion::getVersion( 'nodb' );
61 echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n";
62 echo 'English (en) is excluded because it is the default localization';
63 if ( is_array( $wgDummyLanguageCodes ) ) {
64 $dummyCodes = [];
65 foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) {
66 $dummyCodes[] = MediaWikiServices::getInstance()
67 ->getLanguageNameUtils()
68 ->getLanguageName( $dummyCode ) . ' (' . $dummyCode . ')';
69 }
70 echo ', as well as the following languages that are not intended for ' .
71 'system message translations, usually because they redirect to other ' .
72 'language codes: ' . implode( ', ', $dummyCodes );
73 }
74 # dot to end sentence
75 echo ".\n\n";
76 echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' .
77 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n";
78 }
79
80 public function footer() {
81 echo "|}\n";
82 }
83
84 public function blockstart() {
85 echo "|-\n";
86 }
87
88 public function blockend() {
89 echo '';
90 }
91
92 public function element( $in, $heading = false ) {
93 echo ( $heading ? '!' : '|' ) . "$in\n";
94 }
95
96 public function formatPercent( $subset, $total, $revert = false, $accuracy = 2 ) {
97 Wikimedia\suppressWarnings();
98 $v = round( 255 * $subset / $total );
99 Wikimedia\restoreWarnings();
100
101 if ( $revert ) {
102 # Weigh reverse with factor 20 so coloring takes effect more quickly as
103 # this option is used solely for reporting 'bad' percentages.
104 $v = $v * 20;
105 if ( $v > 255 ) {
106 $v = 255;
107 }
108 $v = 255 - $v;
109 }
110 if ( $v < 128 ) {
111 # Red to Yellow
112 $red = 'FF';
113 $green = sprintf( '%02X', 2 * $v );
114 } else {
115 # Yellow to Green
116 $red = sprintf( '%02X', 2 * ( 255 - $v ) );
117 $green = 'FF';
118 }
119 $blue = '00';
120 $color = $red . $green . $blue;
121
122 $percent = parent::formatPercent( $subset, $total, $revert, $accuracy );
123
124 return 'style="background-color:#' . $color . ';"|' . $percent;
125 }
126}
127
130 public function element( $in, $heading = false ) {
131 echo $in . "\t";
132 }
133
134 public function blockend() {
135 echo "\n";
136 }
137}
138
141 public function element( $in, $heading = false ) {
142 echo $in . ";";
143 }
144
145 public function blockend() {
146 echo "\n";
147 }
148}
$wgDummyLanguageCodes
Functionally the same as $wgExtraLanguageCodes, but deprecated.
csv output.
element( $in, $heading=false)
MediaWikiServices is the service locator for the application scope of MediaWiki.
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)