* (bug 9026) Incorrect heading numbering when viewing Special:Statistics with "auto...
[lhc/web/wiklou.git] / includes / SpecialStatistics.php
1 <?php
2
3 /**
4 *
5 * @addtogroup SpecialPage
6 */
7
8 /**
9 * Show the special page
10 *
11 * @param mixed $par (not used)
12 */
13 function wfSpecialStatistics( $par = '' ) {
14 global $wgOut, $wgLang, $wgRequest;
15 $dbr = wfGetDB( DB_SLAVE );
16
17 $views = SiteStats::views();
18 $edits = SiteStats::edits();
19 $good = SiteStats::articles();
20 $images = SiteStats::images();
21 $total = SiteStats::pages();
22 $users = SiteStats::users();
23 $admins = SiteStats::admins();
24 $numJobs = SiteStats::jobs();
25
26 if( $wgRequest->getVal( 'action' ) == 'raw' ) {
27 $wgOut->disable();
28 header( 'Pragma: nocache' );
29 echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins;images=$images;jobs=$numJobs\n";
30 return;
31 } else {
32 $text = '==' . wfMsg( 'sitestats' ) . "==\n";
33 $text .= wfMsgExt( 'sitestatstext', array( 'parsemag' ),
34 $wgLang->formatNum( $total ),
35 $wgLang->formatNum( $good ),
36 $wgLang->formatNum( $views ),
37 $wgLang->formatNum( $edits ),
38 $wgLang->formatNum( sprintf( '%.2f', $total ? $edits / $total : 0 ) ),
39 $wgLang->formatNum( sprintf( '%.2f', $edits ? $views / $edits : 0 ) ),
40 $wgLang->formatNum( $numJobs ),
41 $wgLang->formatNum( $images )
42 );
43
44 $text .= "\n==" . wfMsg( 'userstats' ) . "==\n";
45 $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ),
46 $wgLang->formatNum( $users ),
47 $wgLang->formatNum( $admins ),
48 '[[' . wfMsgForContent( 'grouppage-sysop' ) . ']]', # TODO somehow remove, kept for backwards compatibility
49 $wgLang->formatNum( sprintf( '%.2f', $admins / $users * 100 ) ),
50 User::makeGroupLinkWiki( 'sysop' )
51 );
52
53 global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
54 if( !$wgDisableCounters && !$wgMiserMode ) {
55 $res = $dbr->select(
56 'page',
57 array(
58 'page_namespace',
59 'page_title',
60 'page_counter',
61 ),
62 array(
63 'page_is_redirect' => 0,
64 'page_counter > 0',
65 ),
66 __METHOD__,
67 array(
68 'ORDER BY' => 'page_counter DESC',
69 'LIMIT' => 10,
70 )
71 );
72 if( $res->numRows() > 0 ) {
73 $text .= '==' . wfMsg( 'statistics-mostpopular' ) . "==\n";
74 while( $row = $res->fetchObject() ) {
75 $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
76 if( $title instanceof Title )
77 $text .= '* [[' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum( $row->page_counter ) . ")\n";
78 }
79 $res->free();
80 }
81 }
82
83 $footer = wfMsg( 'statistics-footer' );
84 if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' )
85 $text .= $footer;
86
87 $wgOut->addWikiText( $text );
88 }
89
90 }