* (bug 5619) Break messages used in Special:Statistics down further
authorRaimond Spekking <raymond@users.mediawiki.org>
Tue, 9 Sep 2008 06:50:47 +0000 (06:50 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Tue, 9 Sep 2008 06:50:47 +0000 (06:50 +0000)
* (bug 11029) Add link to Special:Listusers?group=sysop etc at
  Special:Statistics

RELEASE-NOTES
includes/DefaultSettings.php
includes/specials/SpecialStatistics.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc
skins/common/shared.css

index e0a9bcf..4d3fd6e 100644 (file)
@@ -116,6 +116,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Category counts (e.g. from {{PAGESINCATEGORY:}}) should be more accurate for
   small categories
 * After logging in, automatically redirect to wherever you logged in from
+* (bug 5619) Break messages used in Special:Statistics down further
+* (bug 11029) Add link to Special:Listusers?group=sysop etc at
+  Special:Statistics
 
 === Bug fixes in 1.14 ===
 
index d3bcb70..ea7b48b 100644 (file)
@@ -1383,7 +1383,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '173';
+$wgStyleVersion = '174';
 
 
 # Server-side caching:
index 1dfe7f0..2378039 100644 (file)
@@ -14,7 +14,9 @@
  * @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();
@@ -27,70 +29,140 @@ function wfSpecialStatistics( $par = '' ) {
        $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>';
 }
index 11204d8..1da1990 100644 (file)
@@ -1918,23 +1918,23 @@ Remember to check for other links to the templates before deleting them.',
 '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
index 236bfc6..e5de67d 100644 (file)
@@ -1199,10 +1199,20 @@ $wgMessageStructure = array(
        ),
        'statistics' => array(
                'statistics',
-               'sitestats',
-               'userstats',
-               'sitestatstext',
-               'userstatstext',
+               'statistics-header-pages',
+               'statistics-header-edits',
+               'statistics-header-views',
+               'statistics-header-users',
+               'statistics-articles',
+               'statistics-pages',
+               'statistics-files',
+               'statistics-edits',
+               'statistics-edits-average',
+               'statistics-views-total',
+               'statistics-views-peredit',
+               'statistics-jobqueue',
+               'statistics-users',
+               'statistics-users-active',
                'statistics-mostpopular',
                'statistics-footer',
        ),
index 20d95ad..b54f22a 100644 (file)
@@ -237,7 +237,13 @@ td.os-suggest-result-hl {
     border: 1px dashed #aaa;
 }
 
-table.mw-listgrouprights-table  {
+/*
+ * Special:ListGroupRights styling
+ * Special:Statistics styling 
+*/
+
+table.mw-listgrouprights-table,
+table.mw-statistics-table {
        border: 1px solid #ccc;
        border-collapse: collapse;
 }
@@ -246,11 +252,16 @@ table.mw-listgrouprights-table tr  {
        vertical-align: top;
 }
 
-table.mw-listgrouprights-table td, table.mw-listgrouprights-table th {
+table.mw-listgrouprights-table td, table.mw-listgrouprights-table th,
+table.mw-statistics-table td, table.mw-statistics-table th {
        padding: 0.5em 0.2em 0.5em 0.2em;
        border: 1px solid #ccc;
 }
 
+td.mw-statistics-numbers {
+       text-align: right;
+}
+
 /* Special:SpecialPages styling */
 h4.mw-specialpagesgroup {
        background-color: #dcdcdc;