4 * @addtogroup SpecialPage
10 function wfSpecialStatistics() {
11 global $wgOut, $wgLang, $wgRequest;
12 $fname = 'wfSpecialStatistics';
14 $action = $wgRequest->getVal( 'action' );
16 $dbr = wfGetDB( DB_SLAVE
);
18 $views = SiteStats
::views();
19 $edits = SiteStats
::edits();
20 $good = SiteStats
::articles();
21 $images = SiteStats
::images();
22 $total = SiteStats
::pages();
23 $users = SiteStats
::users();
25 $admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), $fname );
26 $numJobs = $dbr->estimateRowCount('job');
28 if ($action == 'raw') {
30 header( 'Pragma: nocache' );
31 echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins;images=$images;jobs=$numJobs\n";
34 $text = '==' . wfMsg( 'sitestats' ) . "==\n" ;
35 $text .= wfMsgExt( 'sitestatstext', array ( 'parsemag' ),
36 $wgLang->formatNum( $total ),
37 $wgLang->formatNum( $good ),
38 $wgLang->formatNum( $views ),
39 $wgLang->formatNum( $edits ),
40 $wgLang->formatNum( sprintf( '%.2f', $total ?
$edits / $total : 0 ) ),
41 $wgLang->formatNum( sprintf( '%.2f', $edits ?
$views / $edits : 0 ) ),
42 $wgLang->formatNum( $numJobs ),
43 $wgLang->formatNum( $images )
46 $text .= "\n==" . wfMsg( 'userstats' ) . "==\n";
48 $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ),
49 $wgLang->formatNum( $users ),
50 $wgLang->formatNum( $admins ),
51 '[[' . wfMsgForContent( 'grouppage-sysop' ) . ']]', # TODO somehow remove, kept for backwards compatibility
52 $wgLang->formatNum( sprintf( '%.2f', $admins / $users * 100 ) ),
53 User
::makeGroupLinkWiki( 'sysop' )
56 $wgOut->addWikiText( $text );
58 global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
59 if( !$wgDisableCounters && !$wgMiserMode ) {
60 $page = $dbr->tableName( 'page' );
61 $sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC";
62 $sql = $dbr->limitResult($sql, 10, 0);
63 $res = $dbr->query( $sql, $fname );
65 $wgOut->addHtml( '<h2>' . wfMsgHtml( 'statistics-mostpopular' ) . '</h2>' );
66 $skin = $wgUser->getSkin();
67 $wgOut->addHtml( '<ol>' );
68 while( $row = $dbr->fetchObject( $res ) ) {
69 $link = $skin->makeKnownLinkObj( Title
::makeTitleSafe( $row->page_namespace
, $row->page_title
) );
70 $dirmark = $wgContLang->getDirMark();
71 $wgOut->addHtml( '<li>' . $link . $dirmark . ' [' . $wgLang->formatNum( $row->page_counter
) . ']</li>' );
73 $wgOut->addHtml( '</ol>' );
74 $dbr->freeResult( $res );
78 $footer = wfMsg( 'statistics-footer' );
79 if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' )
80 $wgOut->addWikiText( $footer );