* @param mixed $par (not used)
*/
function wfSpecialStatistics( $par = '' ) {
- global $wgOut, $wgLang, $wgRequest;
+ global $wgOut, $wgLang, $wgRequest, $wgUser, $wgContLang;
+ global $wgDisableCounters, $wgMiserMode, $wgImplicitGroups, $wgGroupPermissions;
+ $sk = $wgUser->getSkin();
$dbr = wfGetDB( DB_SLAVE );
$views = SiteStats::views();
$admins = SiteStats::numberingroup('sysop');
$numJobs = SiteStats::jobs();
+ # Staticic - views
+ $viewsStats = '';
+ if( !$wgDisableCounters ) {
+ $viewsStats = Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-views' ) ) .
+ formatRow( wfMsgExt( 'statistics-views-total', array( 'parseinline' ) ),
+ $wgLang->formatNum( $views ) ) .
+ formatRow( wfMsgExt( 'statistics-views-peredit', array( 'parseinline' ) ),
+ $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ) );
+ }
+
if( $wgRequest->getVal( 'action' ) == 'raw' ) {
+ # Depreciated, kept for backwards compatibility
+ # http://lists.wikimedia.org/pipermail/wikitech-l/2008-August/039202.html
$wgOut->disable();
header( 'Pragma: nocache' );
echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;";
echo "activeusers=$activeUsers;admins=$admins;images=$images;jobs=$numJobs\n";
return;
} else {
- $text = "__NOTOC__\n";
- $text .= '==' . wfMsgNoTrans( 'sitestats' ) . "==\n";
- $text .= wfMsgExt( 'sitestatstext', array( 'parsemag' ),
- $wgLang->formatNum( $total ),
- $wgLang->formatNum( $good ),
- $wgLang->formatNum( $views ),
- $wgLang->formatNum( $edits ),
- $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ),
- $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ),
- $wgLang->formatNum( $numJobs ),
- $wgLang->formatNum( $images )
- )."\n";
+ $text = Xml::openElement( 'table', array( 'class' => 'mw-statistics-table' ) ) .
+ # Statistic - pages
+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-pages' ) ) .
+ formatRow( wfMsgExt( 'statistics-articles', array( 'parseinline' ) ),
+ $wgLang->formatNum( $good ) ) .
+ formatRow( wfMsgExt( 'statistics-pages', array( 'parseinline' ) ),
+ $wgLang->formatNum( $total ) ) .
+ formatRow( wfMsgExt( 'statistics-files', array( 'parseinline' ) ),
+ $wgLang->formatNum( $images ) ) .
+
+ # Statistic - edits
+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-edits' ) ) .
+ formatRow( wfMsgExt( 'statistics-edits', array( 'parseinline' ) ),
+ $wgLang->formatNum( $edits ) ) .
+ formatRow( wfMsgExt( 'statistics-edits-average', array( 'parseinline' ) ),
+ $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ) ) .
+ formatRow( wfMsgExt( 'statistics-jobqueue', array( 'parseinline' ) ),
+ $wgLang->formatNum( $numJobs ) ) .
- $text .= "==" . wfMsgNoTrans( 'userstats' ) . "==\n";
- $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ),
- $wgLang->formatNum( $users ),
- $wgLang->formatNum( $admins ),
- '[[' . wfMsgForContent( 'grouppage-sysop' ) . ']]', # TODO somehow remove, kept for backwards compatibility
- $wgLang->formatNum( @sprintf( '%.2f', $admins / $users * 100 ) ),
- User::makeGroupLinkWiki( 'sysop' ),
- $wgLang->formatNum( $activeUsers )
- )."\n";
+ # Statistic - users
+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-users' ) ) .
+ formatRow( wfMsgExt( 'statistics-users', array( 'parseinline' ) ),
+ $wgLang->formatNum( $users ) ) .
+ formatRow( wfMsgExt( 'statistics-users-active', array( 'parseinline' ) ),
+ $wgLang->formatNum( $activeUsers ) );
+
+ # Statistic - usergroups
+ foreach( $wgGroupPermissions as $group => $permissions ) {
+ # Skip generic * and implicit groups
+ if ( in_array( $group, $wgImplicitGroups ) || $group == '*' ) {
+ continue;
+ }
+ $groupname = htmlspecialchars( $group );
+ $msg = wfMsg( 'group-' . $groupname );
+ if ( wfEmptyMsg( 'group-' . $groupname, $msg ) || $msg == '' ) {
+ $groupnameLocalized = $groupname;
+ } else {
+ $groupnameLocalized = $msg;
+ }
+ $msg = wfMsgForContent( 'grouppage-' . $groupname );
+ if ( wfEmptyMsg( 'grouppage-' . $groupname, $msg ) || $msg == '' ) {
+ $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
+ } else {
+ $grouppageLocalized = $msg;
+ }
+ $grouppage = $sk->makeLink( $grouppageLocalized, $groupnameLocalized );
+ $grouplink = $sk->link( SpecialPage::getTitleFor( 'Listusers' ),
+ wfMsgHtml( 'listgrouprights-members' ),
+ array(),
+ array( 'group' => $group ),
+ 'known' );
+ $text .= formatRow( $grouppage . ' ' . $grouplink,
+ $wgLang->formatNum( SiteStats::numberingroup( $groupname ) ) );
+ }
+ }
+ $text .= $viewsStats;
+
+ # Statistic - popular pages
+ if( !$wgDisableCounters && !$wgMiserMode ) {
+ $res = $dbr->select(
+ 'page',
+ array(
+ 'page_namespace',
+ 'page_title',
+ 'page_counter',
+ ),
+ array(
+ 'page_is_redirect' => 0,
+ 'page_counter > 0',
+ ),
+ __METHOD__,
+ array(
+ 'ORDER BY' => 'page_counter DESC',
+ 'LIMIT' => 10,
+ )
+ );
+ if( $res->numRows() > 0 ) {
+ $text .= Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-mostpopular' ) );
+ while( $row = $res->fetchObject() ) {
+ $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
+ if( $title instanceof Title ) {
+ $text .= formatRow( $sk->link( $title ),
+ $wgLang->formatNum( $row->page_counter ) );
- global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
- if( !$wgDisableCounters && !$wgMiserMode ) {
- $res = $dbr->select(
- 'page',
- array(
- 'page_namespace',
- 'page_title',
- 'page_counter',
- ),
- array(
- 'page_is_redirect' => 0,
- 'page_counter > 0',
- ),
- __METHOD__,
- array(
- 'ORDER BY' => 'page_counter DESC',
- 'LIMIT' => 10,
- )
- );
- if( $res->numRows() > 0 ) {
- $text .= "==" . wfMsgNoTrans( 'statistics-mostpopular' ) . "==\n";
- while( $row = $res->fetchObject() ) {
- $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- if( $title instanceof Title )
- $text .= '* [[:' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum( $row->page_counter ) . ")\n";
}
- $res->free();
}
+ $res->free();
}
+ }
- $footer = wfMsgNoTrans( 'statistics-footer' );
- if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' )
- $text .= "\n" . $footer;
+ $text .= Xml::closeElement( 'table' );
- $wgOut->addWikiText( $text );
+ # Customizable footer
+ $footer = wfMsgNoTrans( 'statistics-footer' );
+ if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' ) {
+ $text .= "\n" . $footer;
}
+
+ $wgOut->addHtml( $text );
+}
+
+/**
+ * Format a row
+ *
+ * @param string $text description of the row
+ * @param float $number a number
+ * @return string table row in HTML format
+ */
+function formatRow( $text, $number ) {
+ return '<tr>
+ <td>' .
+ $text .
+ '</td>
+ <td class="mw-statistics-numbers">' .
+ $number .
+ '</td>
+ </tr>';
}
'randomredirect-nopages' => 'There are no redirects in this namespace.',
# Statistics
-'statistics' => 'Statistics',
-'sitestats' => '{{SITENAME}} statistics',
-'userstats' => 'User statistics',
-'sitestatstext' => "There {{PLURAL:\$1|is '''1''' page|are '''\$1''' total pages}} in the database.
-This includes \"talk\" pages, pages about {{SITENAME}}, minimal \"stub\" pages, redirects, and others that probably do not qualify as content pages.
-Excluding those, there {{PLURAL:\$2|is '''1''' page that is a|are '''\$2''' pages that are}} probably legitimate content {{PLURAL:\$2|page|pages}}.
-
-'''\$8''' {{PLURAL:\$8|file has|files have}} been uploaded.
-
-There have been a total of '''\$3''' {{PLURAL:\$3|page view|page views}}, and '''\$4''' {{PLURAL:\$4|page edit|page edits}} since {{SITENAME}} was setup.
-That comes to '''\$5''' average edits per page, and '''\$6''' views per edit.
-
-The [http://www.mediawiki.org/wiki/Manual:Job_queue job queue] length is '''\$7'''.",
-'userstatstext' => "There {{PLURAL:$1|is '''1''' registered [[Special:ListUsers|user]]|are '''$1''' registered [[Special:ListUsers|users]]}}, of which '''$2''' (or '''$4%''') {{PLURAL:$2|has|have}} $5 rights.
-There {{PLURAL:$6|is|are}} currently about '''$6''' active registered user {{PLURAL:$6|account|accounts}}.",
-'statistics-mostpopular' => 'Most viewed pages',
-'statistics-footer' => '', # do not translate or duplicate this message to other languages
+'statistics' => 'Statistics',
+'statistics-header-pages' => 'Page statistics',
+'statistics-header-edits' => 'Edit statistics',
+'statistics-header-views' => 'View statistics',
+'statistics-header-users' => 'User statistics',
+'statistics-articles' => 'Articles',
+'statistics-pages' => 'Pages <small>(this includes "talk" pages, pages about {{SITENAME}}, minimal "stub" pages, redirects, and others)</small>',
+'statistics-files' => 'Uploaded files',
+'statistics-edits' => 'Page edits since {{SITENAME}} was setup',
+'statistics-edits-average' => 'Average edits per page',
+'statistics-views-total' => 'Views total',
+'statistics-views-peredit' => 'Views per edit',
+'statistics-jobqueue' => '[http://www.mediawiki.org/wiki/Manual:Job_queue Job queue] length',
+'statistics-users' => 'Registered [[Special:ListUsers|users]]',
+'statistics-users-active' => 'Active users',
+'statistics-mostpopular' => 'Most viewed pages',
+'statistics-footer' => '', # do not translate or duplicate this message to other languages
'disambiguations' => 'Disambiguation pages',
'disambiguations-summary' => '', # do not translate or duplicate this message to other languages