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