efcd6b60e1687634690b86369828262e6f2f6c65
[lhc/web/wiklou.git] / includes / specials / SpecialAncientpages.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * @file
22 * Implements Special:Ancientpages
23 * @ingroup SpecialPage
24 */
25 class AncientPagesPage extends QueryPage {
26
27 function getName() {
28 return "Ancientpages";
29 }
30
31 function isExpensive() {
32 return true;
33 }
34
35 function isSyndicated() { return false; }
36
37 function getSQL() {
38 global $wgDBtype;
39 $db = wfGetDB( DB_SLAVE );
40 $page = $db->tableName( 'page' );
41 $revision = $db->tableName( 'revision' );
42
43 switch ($wgDBtype) {
44 case 'mysql':
45 $epoch = 'UNIX_TIMESTAMP(rev_timestamp)';
46 break;
47 case 'ibm_db2':
48 // TODO implement proper conversion to a Unix epoch
49 $epoch = 'rev_timestamp';
50 break;
51 case 'oracle':
52 $epoch = '((trunc(rev_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
53 break;
54 case 'sqlite':
55 $epoch = 'rev_timestamp';
56 break;
57 case 'mssql':
58 $epoch = 'DATEDIFF(s,CONVERT(datetime,\'1/1/1970\'),rev_timestamp)';
59 break;
60 default:
61 $epoch = 'EXTRACT(epoch FROM rev_timestamp)';
62 }
63
64 return
65 "SELECT 'Ancientpages' as type,
66 page_namespace as namespace,
67 page_title as title,
68 $epoch as value
69 FROM $page, $revision
70 WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0
71 AND page_latest=rev_id";
72 }
73
74 function sortDescending() {
75 return false;
76 }
77
78 function formatResult( $skin, $result ) {
79 global $wgLang, $wgContLang;
80
81 $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true );
82 $title = Title::makeTitle( $result->namespace, $result->title );
83 $link = $skin->linkKnown(
84 $title,
85 htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
86 );
87 return wfSpecialList($link, htmlspecialchars($d) );
88 }
89 }
90
91 function wfSpecialAncientpages() {
92 list( $limit, $offset ) = wfCheckLimits();
93
94 $app = new AncientPagesPage();
95
96 $app->doQuery( $offset, $limit );
97 }