With &debugmsg=1, PHP output a warning because the link trail no longer
[lhc/web/wiklou.git] / includes / SpecialPopularpages.php
index 8522b12..23ad570 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-include_once( "QueryPage.php" );
+require_once( "QueryPage.php" );
 
 class PopularPagesPage extends QueryPage {
 
@@ -9,18 +9,27 @@ class PopularPagesPage extends QueryPage {
        }
 
        function isExpensive() {
-               return 1;
+               # cur_counter is not indexed
+               return true;
        }
 
-       function getSQL( $offset, $limit ) {
-               return "SELECT cur_title, cur_counter FROM cur " .
-                 "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
-                 "cur_counter DESC LIMIT {$offset}, {$limit}";
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               $cur = $dbr->tableName( 'cur' );
+
+               return
+                       "SELECT 'Popularpages' as type,
+                               cur_namespace as namespace,
+                               cur_title as title,
+                               cur_counter as value
+                       FROM $cur
+                       WHERE cur_namespace=0 AND cur_is_redirect=0";
        }
 
        function formatResult( $skin, $result ) {
-               $link = $skin->makeKnownLink( $result->cur_title, "" );
-               $nv = wfMsg( "nviews", $result->cur_counter );
+               global $wgLang;
+               $link = $skin->makeKnownLink( $result->title, "" );
+               $nv = wfMsg( "nviews", $wgLang->formatNum( $result->value ) );
                return "{$link} ({$nv})";
        }
 }