Index: trunk/phase3/includes/SpecialStatistics.php |
— | — | @@ -9,9 +9,11 @@ |
10 | 10 | * constructor |
11 | 11 | */ |
12 | 12 | function wfSpecialStatistics() { |
13 | | - global $wgUser, $wgOut, $wgLang; |
| 13 | + global $wgUser, $wgOut, $wgLang, $wgRequest; |
14 | 14 | $fname = 'wfSpecialStatistics'; |
15 | 15 | |
| 16 | + $action = $wgRequest->getVal( 'action' ); |
| 17 | + |
16 | 18 | $dbr =& wfGetDB( DB_SLAVE ); |
17 | 19 | extract( $dbr->tableNames( 'page', 'site_stats', 'user', 'user_groups' ) ); |
18 | 20 | |
— | — | @@ -38,38 +40,45 @@ |
39 | 41 | } |
40 | 42 | |
41 | 43 | if ( isset( $row->ss_users ) ) { |
42 | | - $totalUsers = $row->ss_users; |
| 44 | + $users = $row->ss_users; |
43 | 45 | } else { |
44 | 46 | $sql = "SELECT MAX(user_id) AS total FROM $user"; |
45 | 47 | $res = $dbr->query( $sql, $fname ); |
46 | 48 | $userRow = $dbr->fetchObject( $res ); |
47 | | - $totalUsers = $userRow->total; |
| 49 | + $users = $userRow->total; |
48 | 50 | } |
49 | 51 | |
50 | | - |
51 | | - $text = '==' . wfMsg( 'sitestats' ) . "==\n" ; |
52 | | - $text .= wfMsg( 'sitestatstext', |
53 | | - $wgLang->formatNum( $total ), |
54 | | - $wgLang->formatNum( $good ), |
55 | | - $wgLang->formatNum( $views ), |
56 | | - $wgLang->formatNum( $edits ), |
57 | | - $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ), |
58 | | - $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ) ); |
59 | | - |
60 | | - $text .= "\n==" . wfMsg( 'userstats' ) . "==\n"; |
61 | | - |
62 | 52 | $sql = "SELECT COUNT(*) AS total FROM $user_groups WHERE ug_group='sysop'"; |
63 | 53 | $res = $dbr->query( $sql, $fname ); |
64 | 54 | $row = $dbr->fetchObject( $res ); |
65 | 55 | $admins = $row->total; |
66 | | - |
67 | | - $text .= wfMsg( 'userstatstext', |
68 | | - $wgLang->formatNum( $totalUsers ), |
69 | | - $wgLang->formatNum( $admins ), |
70 | | - '[[' . wfMsg( 'administrators' ) . ']]', |
71 | | - // should logically be after #admins, danm backwards compatability! |
72 | | - $wgLang->formatNum( round( $admins / $total * 100, 2 ) ) |
73 | | - ); |
74 | | - $wgOut->addWikiText( $text ); |
| 56 | + |
| 57 | + if ($action == 'raw') { |
| 58 | + $wgOut->disable(); |
| 59 | + header( 'Pragma: nocache' ); |
| 60 | + echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins\n"; |
| 61 | + return; |
| 62 | + } else { |
| 63 | + $text = '==' . wfMsg( 'sitestats' ) . "==\n" ; |
| 64 | + $text .= wfMsg( 'sitestatstext', |
| 65 | + $wgLang->formatNum( $total ), |
| 66 | + $wgLang->formatNum( $good ), |
| 67 | + $wgLang->formatNum( $views ), |
| 68 | + $wgLang->formatNum( $edits ), |
| 69 | + $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ), |
| 70 | + $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ) ); |
| 71 | + |
| 72 | + $text .= "\n==" . wfMsg( 'userstats' ) . "==\n"; |
| 73 | + |
| 74 | + $text .= wfMsg( 'userstatstext', |
| 75 | + $wgLang->formatNum( $users ), |
| 76 | + $wgLang->formatNum( $admins ), |
| 77 | + '[[' . wfMsg( 'administrators' ) . ']]', |
| 78 | + // should logically be after #admins, danm backwards compatability! |
| 79 | + $wgLang->formatNum( round( $admins / $total * 100, 2 ) ) |
| 80 | + ); |
| 81 | + |
| 82 | + $wgOut->addWikiText( $text ); |
| 83 | + } |
75 | 84 | } |
76 | 85 | ?> |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -315,6 +315,8 @@ |
316 | 316 | * Special:Watchlist/edit now has namespace subheadings |
317 | 317 | * (bug 1714) the "Save page" button now has right margin to seperate it from |
318 | 318 | "Show preview" and "Show changes" |
| 319 | +* Special:Statistics now supports action=raw, useful for bots designed to |
| 320 | + harwest e.g. article counts from multiple wikis. |
319 | 321 | |
320 | 322 | === Caveats === |
321 | 323 | |