35 parent::__construct(
'Statistics' );
41 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
50 $text = Xml::openElement(
'table', [
'class' =>
'wikitable mw-statistics-table' ] );
61 # Statistic - usergroups
72 $text .= Xml::closeElement(
'table' );
77 $text .=
"\n" .
$footer->parse();
92 private function formatRow( $text, $number, $trExtraParams = [],
93 $descMsg =
'', $descMsgParam =
''
96 $msg = $this->
msg( $descMsg, $descMsgParam );
97 if ( !$msg->isDisabled() ) {
98 $descriptionHtml = $this->
msg(
'parentheses' )->rawParams( $msg->parse() )
100 $text .=
"<br />" . Html::rawElement(
102 [
'class' =>
'mw-statistic-desc' ],
108 return Html::rawElement(
'tr', $trExtraParams,
109 Html::rawElement(
'td', [], $text ) .
110 Html::rawElement(
'td', [
'class' =>
'mw-statistics-numbers' ], $number )
123 $pageStatsHtml = Xml::openElement(
'tr' ) .
124 Xml::tags(
'th', [
'colspan' =>
'2' ], $this->
msg(
'statistics-header-pages' )
126 Xml::closeElement(
'tr' ) .
129 ? $this->
msg(
'statistics-articles' )->escaped()
131 $specialAllPagesTitle,
132 $this->
msg(
'statistics-articles' )->text(),
133 [], [
'hideredirects' => 1 ] ),
135 [
'class' =>
'mw-statistics-articles' ],
136 'statistics-articles-desc' ) .
138 $this->msg(
'statistics-pages' )->text() ),
140 [
'class' =>
'mw-statistics-pages' ],
141 'statistics-pages-desc' );
144 if ( $this->images !== 0 || $this->
getConfig()->get(
'EnableUploads' ) ) {
147 $this->msg(
'statistics-files' )->text() ),
148 $this->getLanguage()->formatNum( $this->images ),
149 [
'class' =>
'mw-statistics-files' ],
'statistics-files-desc' );
152 return $pageStatsHtml;
156 return Xml::openElement(
'tr' ) .
157 Xml::tags(
'th', [
'colspan' =>
'2' ],
158 $this->
msg(
'statistics-header-edits' )->parse() ) .
159 Xml::closeElement(
'tr' ) .
160 $this->
formatRow( $this->
msg(
'statistics-edits' )->parse(),
162 [
'class' =>
'mw-statistics-edits' ]
164 $this->
formatRow( $this->
msg(
'statistics-edits-average' )->parse(),
166 sprintf(
'%.2f', $this->total ? $this->edits / $this->total : 0 )
167 ), [
'class' =>
'mw-statistics-edits-average' ]
172 return Xml::openElement(
'tr' ) .
173 Xml::tags(
'th', [
'colspan' =>
'2' ],
174 $this->
msg(
'statistics-header-users' )->parse() ) .
175 Xml::closeElement(
'tr' ) .
176 $this->
formatRow( $this->
msg(
'statistics-users' )->parse() .
' ' .
179 $this->
msg(
'listgrouprights-members' )->text()
182 [
'class' =>
'mw-statistics-users' ]
184 $this->
formatRow( $this->
msg(
'statistics-users-active' )->parse() .
' ' .
187 $this->
msg(
'listgrouprights-members' )->text()
189 $this->
getLanguage()->formatNum( $this->activeUsers ),
190 [
'class' =>
'mw-statistics-users-active' ],
191 'statistics-users-active-desc',
193 $this->
getConfig()->
get(
'ActiveUserDays' ) )
200 foreach ( $this->
getConfig()->
get(
'GroupPermissions' ) as $group => $permissions ) {
201 # Skip generic * and implicit groups
202 if ( in_array( $group, $this->
getConfig()->
get(
'ImplicitGroups' ) )
206 $groupnameLocalized = UserGroupMembership::getGroupName( $group );
207 $linkTarget = UserGroupMembership::getGroupPage( $group )
208 ?: Title::makeTitleSafe(
NS_PROJECT, $group );
216 $grouppage = htmlspecialchars( $groupnameLocalized );
221 $this->
msg(
'listgrouprights-members' )->text(),
223 [
'group' => $group ]
225 # Add a class when a usergroup contains no members to allow hiding these rows
228 if ( $countUsers == 0 ) {
229 $classZero =
' statistics-group-zero';
231 $text .= $this->
formatRow( $grouppage .
' ' . $grouplink,
233 [
'class' =>
'statistics-group-' . Sanitizer::escapeClass( $group ) .
250 foreach ( $stats as
$header => $items ) {
252 if ( is_array( $items ) ) {
254 if (
$header !==
'statistics-header-hooks' ) {
259 foreach ( $items as $key => $value ) {
260 if ( is_array( $value ) ) {
261 $name = $value[
'name'];
262 $number = $value[
'number'];
264 $name = $this->
msg( $key )->parse();
270 $this->
getLanguage()->formatNum( htmlspecialchars( $number ) ),
271 [
'class' =>
'mw-statistics-hook',
'id' =>
'mw-' . $key ]
276 if ( $return ===
'' ) {
281 $return .= $this->
getOtherStats( [
'statistics-header-hooks' =>
296 return Xml::openElement(
'tr' ) .
297 Xml::tags(
'th', [
'colspan' =>
'2' ], $this->
msg(
$header )->parse() ) .
298 Xml::closeElement(
'tr' );
static numberingroup( $group)
Find the number of users in a given user group.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getContext()
Gets the context this SpecialPage is executed in.
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
Special page lists various statistics, including the contents of site_stats, plus page view details i...
getOtherStats(array $stats)
Conversion of external statistics into an internal representation Following a ([<header-message>][<it...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getPageStats()
Each of these methods is pretty self-explanatory, get a particular row for the table of statistics.
formatRowHeader( $header)
Format row header.
formatRow( $text, $number, $trExtraParams=[], $descMsg='', $descMsgParam='')
Format a row.
execute( $par)
Default execute method Checks user permissions.