Initial revision
[lhc/web/wiklou.git] / includes / SpecialPopularpages.php
1 <?
2
3 function wfSpecialPopularpages()
4 {
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
6 global $limit, $offset; # From query string
7 $fname = "wfSpecialPopularpages";
8
9 global $wgMiserMode;
10 if ( $wgMiserMode ) {
11 $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
12 return;
13 }
14
15 if ( ! $limit ) {
16 $limit = $wgUser->getOption( "rclimit" );
17 if ( ! $limit ) { $limit = 50; }
18 }
19 if ( ! $offset ) { $offset = 0; }
20
21 $sql = "SELECT DISTINCT cur_title, cur_counter FROM cur " .
22 "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
23 "cur_counter DESC LIMIT {$offset}, {$limit}";
24 $res = wfQuery( $sql, $fname );
25
26 $sk = $wgUser->getSkin();
27
28 $top = wfShowingResults( $offset, $limit );
29 $wgOut->addHTML( "<p>{$top}\n" );
30
31 $sl = wfViewPrevNext( $offset, $limit,
32 $wgLang->specialPage( "Popularpages" ) );
33 $wgOut->addHTML( "<br>{$sl}\n" );
34
35 $s = "<ol start=" . ( $offset + 1 ) . ">";
36 while ( $obj = wfFetchObject( $res ) ) {
37 $nv = str_replace( "$1", $obj->cur_counter, wfMsg( "nviews" ) );
38 $link = $sk->makeKnownLink( $obj->cur_title, "" );
39 $s .= "<li>{$link} ({$nv})</li>\n";
40 }
41 wfFreeResult( $res );
42 $s .= "</ol>";
43 $wgOut->addHTML( $s );
44 $wgOut->addHTML( "<p>{$sl}\n" );
45 }
46
47 ?>