r40636 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40635‎ | r40636 | r40637 >
Date:06:50, 9 September 2008
Author:raymond
Status:old
Tags:
Comment:
* (bug 5619) Break messages used in Special:Statistics down further
* (bug 11029) Add link to Special:Listusers?group=sysop etc at
Special:Statistics
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialStatistics.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1199,10 +1199,20 @@
12001200 ),
12011201 'statistics' => array(
12021202 'statistics',
1203 - 'sitestats',
1204 - 'userstats',
1205 - 'sitestatstext',
1206 - 'userstatstext',
 1203+ 'statistics-header-pages',
 1204+ 'statistics-header-edits',
 1205+ 'statistics-header-views',
 1206+ 'statistics-header-users',
 1207+ 'statistics-articles',
 1208+ 'statistics-pages',
 1209+ 'statistics-files',
 1210+ 'statistics-edits',
 1211+ 'statistics-edits-average',
 1212+ 'statistics-views-total',
 1213+ 'statistics-views-peredit',
 1214+ 'statistics-jobqueue',
 1215+ 'statistics-users',
 1216+ 'statistics-users-active',
12071217 'statistics-mostpopular',
12081218 'statistics-footer',
12091219 ),
Index: trunk/phase3/skins/common/shared.css
@@ -237,7 +237,13 @@
238238 border: 1px dashed #aaa;
239239 }
240240
241 -table.mw-listgrouprights-table {
 241+/*
 242+ * Special:ListGroupRights styling
 243+ * Special:Statistics styling
 244+*/
 245+
 246+table.mw-listgrouprights-table,
 247+table.mw-statistics-table {
242248 border: 1px solid #ccc;
243249 border-collapse: collapse;
244250 }
@@ -246,11 +252,16 @@
247253 vertical-align: top;
248254 }
249255
250 -table.mw-listgrouprights-table td, table.mw-listgrouprights-table th {
 256+table.mw-listgrouprights-table td, table.mw-listgrouprights-table th,
 257+table.mw-statistics-table td, table.mw-statistics-table th {
251258 padding: 0.5em 0.2em 0.5em 0.2em;
252259 border: 1px solid #ccc;
253260 }
254261
 262+td.mw-statistics-numbers {
 263+ text-align: right;
 264+}
 265+
255266 /* Special:SpecialPages styling */
256267 h4.mw-specialpagesgroup {
257268 background-color: #dcdcdc;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1383,7 +1383,7 @@
13841384 * to ensure that client-side caches don't keep obsolete copies of global
13851385 * styles.
13861386 */
1387 -$wgStyleVersion = '173';
 1387+$wgStyleVersion = '174';
13881388
13891389
13901390 # Server-side caching:
Index: trunk/phase3/includes/specials/SpecialStatistics.php
@@ -14,7 +14,9 @@
1515 * @param mixed $par (not used)
1616 */
1717 function wfSpecialStatistics( $par = '' ) {
18 - global $wgOut, $wgLang, $wgRequest;
 18+ global $wgOut, $wgLang, $wgRequest, $wgUser, $wgContLang;
 19+ global $wgDisableCounters, $wgMiserMode, $wgImplicitGroups, $wgGroupPermissions;
 20+ $sk = $wgUser->getSkin();
1921 $dbr = wfGetDB( DB_SLAVE );
2022
2123 $views = SiteStats::views();
@@ -27,70 +29,140 @@
2830 $admins = SiteStats::numberingroup('sysop');
2931 $numJobs = SiteStats::jobs();
3032
 33+ # Staticic - views
 34+ $viewsStats = '';
 35+ if( !$wgDisableCounters ) {
 36+ $viewsStats = Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-views' ) ) .
 37+ formatRow( wfMsgExt( 'statistics-views-total', array( 'parseinline' ) ),
 38+ $wgLang->formatNum( $views ) ) .
 39+ formatRow( wfMsgExt( 'statistics-views-peredit', array( 'parseinline' ) ),
 40+ $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ) );
 41+ }
 42+
3143 if( $wgRequest->getVal( 'action' ) == 'raw' ) {
 44+ # Depreciated, kept for backwards compatibility
 45+ # http://lists.wikimedia.org/pipermail/wikitech-l/2008-August/039202.html
3246 $wgOut->disable();
3347 header( 'Pragma: nocache' );
3448 echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;";
3549 echo "activeusers=$activeUsers;admins=$admins;images=$images;jobs=$numJobs\n";
3650 return;
3751 } else {
38 - $text = "__NOTOC__\n";
39 - $text .= '==' . wfMsgNoTrans( 'sitestats' ) . "==\n";
40 - $text .= wfMsgExt( 'sitestatstext', array( 'parsemag' ),
41 - $wgLang->formatNum( $total ),
42 - $wgLang->formatNum( $good ),
43 - $wgLang->formatNum( $views ),
44 - $wgLang->formatNum( $edits ),
45 - $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ),
46 - $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ),
47 - $wgLang->formatNum( $numJobs ),
48 - $wgLang->formatNum( $images )
49 - )."\n";
 52+ $text = Xml::openElement( 'table', array( 'class' => 'mw-statistics-table' ) ) .
 53+ # Statistic - pages
 54+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-pages' ) ) .
 55+ formatRow( wfMsgExt( 'statistics-articles', array( 'parseinline' ) ),
 56+ $wgLang->formatNum( $good ) ) .
 57+ formatRow( wfMsgExt( 'statistics-pages', array( 'parseinline' ) ),
 58+ $wgLang->formatNum( $total ) ) .
 59+ formatRow( wfMsgExt( 'statistics-files', array( 'parseinline' ) ),
 60+ $wgLang->formatNum( $images ) ) .
5061
51 - $text .= "==" . wfMsgNoTrans( 'userstats' ) . "==\n";
52 - $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ),
53 - $wgLang->formatNum( $users ),
54 - $wgLang->formatNum( $admins ),
55 - '[[' . wfMsgForContent( 'grouppage-sysop' ) . ']]', # TODO somehow remove, kept for backwards compatibility
56 - $wgLang->formatNum( @sprintf( '%.2f', $admins / $users * 100 ) ),
57 - User::makeGroupLinkWiki( 'sysop' ),
58 - $wgLang->formatNum( $activeUsers )
59 - )."\n";
 62+ # Statistic - edits
 63+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-edits' ) ) .
 64+ formatRow( wfMsgExt( 'statistics-edits', array( 'parseinline' ) ),
 65+ $wgLang->formatNum( $edits ) ) .
 66+ formatRow( wfMsgExt( 'statistics-edits-average', array( 'parseinline' ) ),
 67+ $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ) ) .
 68+ formatRow( wfMsgExt( 'statistics-jobqueue', array( 'parseinline' ) ),
 69+ $wgLang->formatNum( $numJobs ) ) .
6070
61 - global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
62 - if( !$wgDisableCounters && !$wgMiserMode ) {
63 - $res = $dbr->select(
64 - 'page',
65 - array(
66 - 'page_namespace',
67 - 'page_title',
68 - 'page_counter',
69 - ),
70 - array(
71 - 'page_is_redirect' => 0,
72 - 'page_counter > 0',
73 - ),
74 - __METHOD__,
75 - array(
76 - 'ORDER BY' => 'page_counter DESC',
77 - 'LIMIT' => 10,
78 - )
79 - );
80 - if( $res->numRows() > 0 ) {
81 - $text .= "==" . wfMsgNoTrans( 'statistics-mostpopular' ) . "==\n";
82 - while( $row = $res->fetchObject() ) {
83 - $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
84 - if( $title instanceof Title )
85 - $text .= '* [[:' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum( $row->page_counter ) . ")\n";
 71+ # Statistic - users
 72+ Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-header-users' ) ) .
 73+ formatRow( wfMsgExt( 'statistics-users', array( 'parseinline' ) ),
 74+ $wgLang->formatNum( $users ) ) .
 75+ formatRow( wfMsgExt( 'statistics-users-active', array( 'parseinline' ) ),
 76+ $wgLang->formatNum( $activeUsers ) );
 77+
 78+ # Statistic - usergroups
 79+ foreach( $wgGroupPermissions as $group => $permissions ) {
 80+ # Skip generic * and implicit groups
 81+ if ( in_array( $group, $wgImplicitGroups ) || $group == '*' ) {
 82+ continue;
 83+ }
 84+ $groupname = htmlspecialchars( $group );
 85+ $msg = wfMsg( 'group-' . $groupname );
 86+ if ( wfEmptyMsg( 'group-' . $groupname, $msg ) || $msg == '' ) {
 87+ $groupnameLocalized = $groupname;
 88+ } else {
 89+ $groupnameLocalized = $msg;
 90+ }
 91+ $msg = wfMsgForContent( 'grouppage-' . $groupname );
 92+ if ( wfEmptyMsg( 'grouppage-' . $groupname, $msg ) || $msg == '' ) {
 93+ $grouppageLocalized = MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
 94+ } else {
 95+ $grouppageLocalized = $msg;
 96+ }
 97+ $grouppage = $sk->makeLink( $grouppageLocalized, $groupnameLocalized );
 98+ $grouplink = $sk->link( SpecialPage::getTitleFor( 'Listusers' ),
 99+ wfMsgHtml( 'listgrouprights-members' ),
 100+ array(),
 101+ array( 'group' => $group ),
 102+ 'known' );
 103+ $text .= formatRow( $grouppage . ' ' . $grouplink,
 104+ $wgLang->formatNum( SiteStats::numberingroup( $groupname ) ) );
 105+ }
 106+ }
 107+ $text .= $viewsStats;
 108+
 109+ # Statistic - popular pages
 110+ if( !$wgDisableCounters && !$wgMiserMode ) {
 111+ $res = $dbr->select(
 112+ 'page',
 113+ array(
 114+ 'page_namespace',
 115+ 'page_title',
 116+ 'page_counter',
 117+ ),
 118+ array(
 119+ 'page_is_redirect' => 0,
 120+ 'page_counter > 0',
 121+ ),
 122+ __METHOD__,
 123+ array(
 124+ 'ORDER BY' => 'page_counter DESC',
 125+ 'LIMIT' => 10,
 126+ )
 127+ );
 128+ if( $res->numRows() > 0 ) {
 129+ $text .= Xml::tags( 'th', array( 'colspan' => '2' ), wfMsg( 'statistics-mostpopular' ) );
 130+ while( $row = $res->fetchObject() ) {
 131+ $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
 132+ if( $title instanceof Title ) {
 133+ $text .= formatRow( $sk->link( $title ),
 134+ $wgLang->formatNum( $row->page_counter ) );
 135+
86136 }
87 - $res->free();
88137 }
 138+ $res->free();
89139 }
 140+ }
90141
91 - $footer = wfMsgNoTrans( 'statistics-footer' );
92 - if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' )
93 - $text .= "\n" . $footer;
 142+ $text .= Xml::closeElement( 'table' );
94143
95 - $wgOut->addWikiText( $text );
 144+ # Customizable footer
 145+ $footer = wfMsgNoTrans( 'statistics-footer' );
 146+ if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' ) {
 147+ $text .= "\n" . $footer;
96148 }
 149+
 150+ $wgOut->addHtml( $text );
97151 }
 152+
 153+/**
 154+ * Format a row
 155+ *
 156+ * @param string $text description of the row
 157+ * @param float $number a number
 158+ * @return string table row in HTML format
 159+ */
 160+function formatRow( $text, $number ) {
 161+ return '<tr>
 162+ <td>' .
 163+ $text .
 164+ '</td>
 165+ <td class="mw-statistics-numbers">' .
 166+ $number .
 167+ '</td>
 168+ </tr>';
 169+}
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1918,24 +1918,24 @@
19191919 'randomredirect-nopages' => 'There are no redirects in this namespace.',
19201920
19211921 # Statistics
1922 -'statistics' => 'Statistics',
1923 -'sitestats' => '{{SITENAME}} statistics',
1924 -'userstats' => 'User statistics',
1925 -'sitestatstext' => "There {{PLURAL:\$1|is '''1''' page|are '''\$1''' total pages}} in the database.
1926 -This includes \"talk\" pages, pages about {{SITENAME}}, minimal \"stub\" pages, redirects, and others that probably do not qualify as content pages.
1927 -Excluding those, there {{PLURAL:\$2|is '''1''' page that is a|are '''\$2''' pages that are}} probably legitimate content {{PLURAL:\$2|page|pages}}.
 1922+'statistics' => 'Statistics',
 1923+'statistics-header-pages' => 'Page statistics',
 1924+'statistics-header-edits' => 'Edit statistics',
 1925+'statistics-header-views' => 'View statistics',
 1926+'statistics-header-users' => 'User statistics',
 1927+'statistics-articles' => 'Articles',
 1928+'statistics-pages' => 'Pages <small>(this includes "talk" pages, pages about {{SITENAME}}, minimal "stub" pages, redirects, and others)</small>',
 1929+'statistics-files' => 'Uploaded files',
 1930+'statistics-edits' => 'Page edits since {{SITENAME}} was setup',
 1931+'statistics-edits-average' => 'Average edits per page',
 1932+'statistics-views-total' => 'Views total',
 1933+'statistics-views-peredit' => 'Views per edit',
 1934+'statistics-jobqueue' => '[http://www.mediawiki.org/wiki/Manual:Job_queue Job queue] length',
 1935+'statistics-users' => 'Registered [[Special:ListUsers|users]]',
 1936+'statistics-users-active' => 'Active users',
 1937+'statistics-mostpopular' => 'Most viewed pages',
 1938+'statistics-footer' => '', # do not translate or duplicate this message to other languages
19281939
1929 -'''\$8''' {{PLURAL:\$8|file has|files have}} been uploaded.
1930 -
1931 -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.
1932 -That comes to '''\$5''' average edits per page, and '''\$6''' views per edit.
1933 -
1934 -The [http://www.mediawiki.org/wiki/Manual:Job_queue job queue] length is '''\$7'''.",
1935 -'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.
1936 -There {{PLURAL:$6|is|are}} currently about '''$6''' active registered user {{PLURAL:$6|account|accounts}}.",
1937 -'statistics-mostpopular' => 'Most viewed pages',
1938 -'statistics-footer' => '', # do not translate or duplicate this message to other languages
1939 -
19401940 'disambiguations' => 'Disambiguation pages',
19411941 'disambiguations-summary' => '', # do not translate or duplicate this message to other languages
19421942 'disambiguationspage' => 'Template:disambig',
Index: trunk/phase3/RELEASE-NOTES
@@ -116,6 +116,9 @@
117117 * Category counts (e.g. from {{PAGESINCATEGORY:}}) should be more accurate for
118118 small categories
119119 * After logging in, automatically redirect to wherever you logged in from
 120+* (bug 5619) Break messages used in Special:Statistics down further
 121+* (bug 11029) Add link to Special:Listusers?group=sysop etc at
 122+ Special:Statistics
120123
121124 === Bug fixes in 1.14 ===
122125

Follow-up revisions

RevisionCommit summaryAuthorDate
r40637Clean up after r40636....siebrand07:19, 9 September 2008
r41057Fix regression from r40636: footer is now parsed againaaron06:52, 20 September 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r20304* (bug 5619) Split statistics messages for brighter output if...raymond23:08, 9 March 2007
r20363Revert of r20304....raymond08:48, 12 March 2007