]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialAncientpages.php
MediaWiki 1.16.1-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialAncientpages.php
1 <?php
2 /**
3  * @file
4  * @ingroup SpecialPage
5  */
6
7 /**
8  * Implements Special:Ancientpages
9  * @ingroup SpecialPage
10  */
11 class AncientPagesPage extends QueryPage {
12
13         function getName() {
14                 return "Ancientpages";
15         }
16
17         function isExpensive() {
18                 return true;
19         }
20
21         function isSyndicated() { return false; }
22
23         function getSQL() {
24                 global $wgDBtype;
25                 $db = wfGetDB( DB_SLAVE );
26                 $page = $db->tableName( 'page' );
27                 $revision = $db->tableName( 'revision' );
28
29                 switch ($wgDBtype) {
30                         case 'mysql': 
31                                 $epoch = 'UNIX_TIMESTAMP(rev_timestamp)'; 
32                                 break;
33                         case 'ibm_db2':
34                                 // TODO implement proper conversion to a Unix epoch
35                                 $epoch = 'rev_timestamp';
36                                 break;
37                         case 'oracle': 
38                                 $epoch = '((trunc(rev_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)'; 
39                                 break;
40                         case 'sqlite':
41                                 $epoch = 'rev_timestamp';
42                                 break;
43                         default:
44                                 $epoch = 'EXTRACT(epoch FROM rev_timestamp)';
45                 }
46
47                 return
48                         "SELECT 'Ancientpages' as type,
49                                         page_namespace as namespace,
50                                 page_title as title,
51                                 $epoch as value
52                         FROM $page, $revision
53                         WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0
54                           AND page_latest=rev_id";
55         }
56
57         function sortDescending() {
58                 return false;
59         }
60
61         function formatResult( $skin, $result ) {
62                 global $wgLang, $wgContLang;
63
64                 $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true );
65                 $title = Title::makeTitle( $result->namespace, $result->title );
66                 $link = $skin->linkKnown(
67                         $title,
68                         htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
69                 );
70                 return wfSpecialList($link, htmlspecialchars($d) );
71         }
72 }
73
74 function wfSpecialAncientpages() {
75         list( $limit, $offset ) = wfCheckLimits();
76
77         $app = new AncientPagesPage();
78
79         $app->doQuery( $offset, $limit );
80 }