* Support for table name prefixes throughout the code. No support yet for converting...
[lhc/web/wiklou.git] / includes / SpecialAncientpages.php
index a93a4eb..6029f06 100644 (file)
@@ -1,40 +1,50 @@
-<?
+<?php
 
-include_once( "QueryPage.php" );
+require_once( "QueryPage.php" );
 
 class AncientPagesPage extends QueryPage {
 
-    function getName() {
-       return "Ancientpages";
-    }
-    
-    function isExpensive() {
-       return 0;
-    }
-
-    function getSQL( $offset, $limit ) {
-       return "SELECT cur_title, cur_timestamp " . 
-         "FROM cur USE INDEX (cur_timestamp) " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
-         " ORDER BY cur_timestamp LIMIT {$offset}, {$limit}";
-    }
-    
-    function formatResult( $skin, $result ) {
-       global $wgLang;
+       function getName() {
+               return "Ancientpages";
+       }
+
+       function isExpensive() {
+               return parent::isExpensive() ;
+       }
+
+       function getSQL() {
+               $db =& wfGetDB( DB_SLAVE );
+               $cur = $db->tableName( 'cur' );
+               $use_index = $db->useIndexClause( 'cur_timestamp' );
+               return
+                       "SELECT 'Ancientpages' as type,
+                                       cur_namespace as namespace,
+                               cur_title as title,
+                               UNIX_TIMESTAMP(cur_timestamp) as value
+                       FROM $cur $use_index
+                       WHERE cur_namespace=0 AND cur_is_redirect=0";
+       }
        
-       $d = $wgLang->timeanddate( $result->cur_timestamp, true );
-       $link = $skin->makeKnownLink( $result->cur_title, "" );
-       return "{$link} ({$d})";
-    }
+       function sortDescending() {
+               return false;
+       }
+
+       function formatResult( $skin, $result ) {
+               global $wgLang;
+
+               $d = $wgLang->timeanddate( wfUnix2Timestamp( $result->value ), true );
+               $link = $skin->makeKnownLink( $result->title, "" );
+               return "{$link} ({$d})";
+       }
 }
 
 function wfSpecialAncientpages()
 {
-    list( $limit, $offset ) = wfCheckLimits();
-    
-    $app = new AncientPagesPage();
-    
-    $app->doQuery( $offset, $limit );
+       list( $limit, $offset ) = wfCheckLimits();
+
+       $app = new AncientPagesPage();
+
+       $app->doQuery( $offset, $limit );
 }
 
 ?>