]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialListredirects.php
MediaWiki 1.17.1-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialListredirects.php
1 <?php
2 /**
3  * Implements Special:Listredirects
4  *
5  * Copyright © 2006 Rob Church
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  * http://www.gnu.org/copyleft/gpl.html
21  *
22  * @file
23  * @ingroup SpecialPage
24  * @author Rob Church <robchur@gmail.com>
25  */
26
27 /**
28  * Special:Listredirects - Lists all the redirects on the wiki.
29  * @ingroup SpecialPage
30  */
31 class ListredirectsPage extends QueryPage {
32
33         function getName() { return( 'Listredirects' ); }
34         function isExpensive() { return( true ); }
35         function isSyndicated() { return( false ); }
36         function sortDescending() { return( false ); }
37
38         function getSQL() {
39                 $dbr = wfGetDB( DB_SLAVE );
40                 $page = $dbr->tableName( 'page' );
41                 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, 
42                         0 AS value FROM $page WHERE page_is_redirect = 1";
43                 return( $sql );
44         }
45
46         function formatResult( $skin, $result ) {
47                 global $wgContLang;
48
49                 # Make a link to the redirect itself
50                 $rd_title = Title::makeTitle( $result->namespace, $result->title );
51                 $rd_link = $skin->link(
52                         $rd_title,
53                         null,
54                         array(),
55                         array( 'redirect' => 'no' )
56                 );
57
58                 # Find out where the redirect leads
59                 $revision = Revision::newFromTitle( $rd_title );
60                 if( $revision ) {
61                         # Make a link to the destination page
62                         $target = Title::newFromRedirect( $revision->getText() );
63                         if( $target ) {
64                                 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
65                                 $targetLink = $skin->link( $target );
66                                 return "$rd_link $arr $targetLink";
67                         } else {
68                                 return "<del>$rd_link</del>";
69                         }
70                 } else {
71                         return "<del>$rd_link</del>";
72                 }
73         }
74 }
75
76 function wfSpecialListredirects() {
77         list( $limit, $offset ) = wfCheckLimits();
78         $lrp = new ListredirectsPage();
79         $lrp->doQuery( $offset, $limit );
80 }