Revert r28215: incorrectly moved files
[lhc/web/wiklou.git] / includes / SpecialAncientpages.php
index 60c736a..dee8fbd 100644 (file)
@@ -1,45 +1,63 @@
-<?
+<?php
+/**
+ *
+ * @addtogroup SpecialPage
+ */
+
+/**
+ * Implements Special:Ancientpages
+ * @addtogroup SpecialPage
+ */
+class AncientPagesPage extends QueryPage {
+
+       function getName() {
+               return "Ancientpages";
+       }
 
-function wfSpecialAncientpages()
-{
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       $fname = "wfSpecialAncientpages";
+       function isExpensive() {
+               return true;
+       }
 
-       list( $limit, $offset ) = wfCheckLimits();
+       function isSyndicated() { return false; }
+
+       function getSQL() {
+               global $wgDBtype;
+               $db = wfGetDB( DB_SLAVE );
+               $page = $db->tableName( 'page' );
+               $revision = $db->tableName( 'revision' );
+               #$use_index = $db->useIndexClause( 'cur_timestamp' ); # FIXME! this is gone
+               $epoch = $wgDBtype == 'mysql' ? 'UNIX_TIMESTAMP(rev_timestamp)' :
+                       'EXTRACT(epoch FROM rev_timestamp)';
+               return
+                       "SELECT 'Ancientpages' as type,
+                                       page_namespace as namespace,
+                               page_title as title,
+                               $epoch as value
+                       FROM $page, $revision
+                       WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0
+                         AND page_latest=rev_id";
+       }
+
+       function sortDescending() {
+               return false;
+       }
+
+       function formatResult( $skin, $result ) {
+               global $wgLang, $wgContLang;
 
-       $sql = "SELECT cur_title,cur_user,cur_user_text,cur_comment," .
-         "cur_timestamp FROM cur USE INDEX (cur_timestamp) " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
-         " ORDER BY cur_timestamp LIMIT {$offset}, {$limit}";
-       $res = wfQuery( $sql, DB_READ, $fname );
-
-       $top = wfShowingResults( $offset, $limit );
-       $wgOut->addHTML( "<p>{$top}\n" );
-
-       $sl = wfViewPrevNext( $offset, $limit,
-         $wgLang->specialPage( "Ancientpages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
-
-       $sk = $wgUser->getSkin();
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
-               $u = $obj->cur_user;
-               $ut = $obj->cur_user_text;
-               $c = wfEscapeHTML( $obj->cur_comment );
-               if ( 0 == $u ) { $ul = $ut; }
-               else { $ul = $sk->makeLink( $wgLang->getNsText(2).":{$ut}", $ut ); }
-
-               $d = $wgLang->timeanddate( $obj->cur_timestamp, true );
-               $link = $sk->makeKnownLink( $obj->cur_title, "" );
-               $s .= "<li>{$d} {$link} . . {$ul}";
-
-               if ( "" != $c && "*" != $c ) { $s .= " <em>({$c})</em>"; }
-               $s .= "</li>\n";
+               $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true );
+               $title = Title::makeTitle( $result->namespace, $result->title );
+               $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) );
+               return wfSpecialList($link, $d);
        }
-       wfFreeResult( $res );
-       $s .= "</ol>";
-       $wgOut->addHTML( $s );
-       $wgOut->addHTML( "<p>{$sl}\n" );
 }
 
-?>
+function wfSpecialAncientpages() {
+       list( $limit, $offset ) = wfCheckLimits();
+
+       $app = new AncientPagesPage();
+
+       $app->doQuery( $offset, $limit );
+}
+
+