Go to the documentation of this file.
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() )
101 [
'class' =>
'mw-statistic-desc' ],
123 Xml::tags(
'th', [
'colspan' =>
'2' ], $this->
msg(
'statistics-header-pages' )
127 $specialAllPagesTitle,
128 $this->msg(
'statistics-articles' )->text(),
129 [], [
'hideredirects' => 1 ] ),
130 $this->getLanguage()->formatNum( $this->good ),
131 [
'class' =>
'mw-statistics-articles' ],
132 'statistics-articles-desc' ) .
134 $this->msg(
'statistics-pages' )->text() ),
135 $this->getLanguage()->formatNum( $this->total ),
136 [
'class' =>
'mw-statistics-pages' ],
137 'statistics-pages-desc' );
140 if ( $this->images !== 0 || $this->
getConfig()->
get(
'EnableUploads' ) ) {
143 $this->msg(
'statistics-files' )->text() ),
144 $this->getLanguage()->formatNum( $this->images ),
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,
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' =>
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getOutput()
Get the OutputPage being used for this instance.
Special page lists various statistics, including the contents of site_stats, plus page view details i...
static numberingroup( $group)
Find the number of users in a given user group.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
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,...
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
getLanguage()
Shortcut to get user's language.
static openElement( $element, $attribs=null)
This opens an XML element.
getConfig()
Shortcut to get main config object.
execute( $par)
Default execute method Checks user permissions.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getContext()
Gets the context this SpecialPage is executed in.
formatRow( $text, $number, $trExtraParams=[], $descMsg='', $descMsgParam='')
Format a row.
Parent class for all special pages.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
static closeElement( $element)
Shortcut to close an XML element.
formatRowHeader( $header)
Format row header.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
getPageStats()
Each of these methods is pretty self-explanatory, get a particular row for the table of statistics.
getOtherStats(array $stats)
Conversion of external statistics into an internal representation Following a ([<header-message>][<it...
MediaWiki Linker LinkRenderer null $linkRenderer
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.