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