37 parent::__construct(
'Statistics' );
42 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
51 $text =
Xml::openElement(
'table', [
'class' =>
'wikitable mw-statistics-table' ] );
62 # Statistic - usergroups
76 $text .=
"\n" .
$footer->parse();
91 private function formatRow( $text, $number, $trExtraParams = [],
92 $descMsg =
'', $descMsgParam =
''
95 $msg = $this->
msg( $descMsg, $descMsgParam );
96 if ( !$msg->isDisabled() ) {
97 $descriptionHtml = $this->
msg(
'parentheses' )->rawParams( $msg->parse() )
99 $text .=
"<br />" . Html::rawElement(
101 [
'class' =>
'mw-statistic-desc' ],
107 return Html::rawElement(
'tr', $trExtraParams,
108 Html::rawElement(
'td', [], $text ) .
109 Html::rawElement(
'td', [
'class' =>
'mw-statistics-numbers' ], $number )
123 Xml::tags(
'th', [
'colspan' =>
'2' ], $this->
msg(
'statistics-header-pages' )
127 $specialAllPagesTitle,
128 $this->msg(
'statistics-articles' )->text(),
129 [], [
'hideredirects' => 1 ] ),
131 [
'class' =>
'mw-statistics-articles' ],
132 'statistics-articles-desc' ) .
134 $this->msg(
'statistics-pages' )->text() ),
136 [
'class' =>
'mw-statistics-pages' ],
137 'statistics-pages-desc' );
140 if ( $this->images !== 0 || $this->
getConfig()->get(
'EnableUploads' ) ) {
143 $this->msg(
'statistics-files' )->text() ),
145 [
'class' =>
'mw-statistics-files' ] );
148 return $pageStatsHtml;
154 $this->
msg(
'statistics-header-edits' )->parse() ) .
156 $this->
formatRow( $this->
msg(
'statistics-edits' )->parse(),
158 [
'class' =>
'mw-statistics-edits' ]
160 $this->
formatRow( $this->
msg(
'statistics-edits-average' )->parse(),
162 sprintf(
'%.2f', $this->total ? $this->edits / $this->total : 0 )
163 ), [
'class' =>
'mw-statistics-edits-average' ]
170 $this->
msg(
'statistics-header-users' )->parse() ) .
172 $this->
formatRow( $this->
msg(
'statistics-users' )->parse() .
' ' .
175 $this->
msg(
'listgrouprights-members' )->text()
178 [
'class' =>
'mw-statistics-users' ]
180 $this->
formatRow( $this->
msg(
'statistics-users-active' )->parse() .
' ' .
183 $this->
msg(
'listgrouprights-members' )->text()
185 $this->
getLanguage()->formatNum( $this->activeUsers ),
186 [
'class' =>
'mw-statistics-users-active' ],
187 'statistics-users-active-desc',
189 $this->
getConfig()->
get(
'ActiveUserDays' ) )
196 foreach ( $this->
getConfig()->
get(
'GroupPermissions' ) as $group => $permissions ) {
197 # Skip generic * and implicit groups
198 if ( in_array( $group, $this->
getConfig()->
get(
'ImplicitGroups' ) )
202 $groupname = htmlspecialchars( $group );
203 $msg = $this->
msg(
'group-' . $groupname );
204 if ( $msg->isBlank() ) {
205 $groupnameLocalized = $groupname;
207 $groupnameLocalized = $msg->text();
209 $msg = $this->
msg(
'grouppage-' . $groupname )->inContentLanguage();
210 if ( $msg->isBlank() ) {
211 $grouppageLocalized = MediaWikiServices::getInstance()->getNamespaceInfo()->
212 getCanonicalName(
NS_PROJECT ) .
':' . $groupname;
214 $grouppageLocalized = $msg->text();
224 $grouppage = htmlspecialchars( $groupnameLocalized );
229 $this->
msg(
'listgrouprights-members' )->text(),
231 [
'group' => $group ]
233 # Add a class when a usergroup contains no members to allow hiding these rows
236 if ( $countUsers == 0 ) {
237 $classZero =
' statistics-group-zero';
239 $text .= $this->
formatRow( $grouppage .
' ' . $grouplink,
241 [
'class' =>
'statistics-group-' . Sanitizer::escapeClass( $group ) .
258 foreach ( $stats as
$header => $items ) {
260 if ( is_array( $items ) ) {
262 if (
$header !==
'statistics-header-hooks' ) {
267 foreach ( $items as $key => $value ) {
268 if ( is_array( $value ) ) {
269 $name = $value[
'name'];
270 $number = $value[
'number'];
272 $name = $this->
msg( $key )->parse();
278 $this->
getLanguage()->formatNum( htmlspecialchars( $number ) ),
279 [
'class' =>
'mw-statistics-hook',
'id' =>
'mw-' . $key ]
284 if ( $return ===
'' ) {
289 $return .= $this->
getOtherStats( [
'statistics-header-hooks' =>