ecc764d176c04293140b92107b58ebfb0a59f847
[lhc/web/wiklou.git] / includes / specials / SpecialListredirects.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 * @ingroup SpecialPage
23 *
24 * @author Rob Church <robchur@gmail.com>
25 * @copyright © 2006 Rob Church
26 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
27 */
28
29 /**
30 * Special:Listredirects - Lists all the redirects on the wiki.
31 * @ingroup SpecialPage
32 */
33 class ListredirectsPage extends QueryPage {
34
35 function getName() { return( 'Listredirects' ); }
36 function isExpensive() { return( true ); }
37 function isSyndicated() { return( false ); }
38 function sortDescending() { return( false ); }
39
40 function getSQL() {
41 $dbr = wfGetDB( DB_SLAVE );
42 $page = $dbr->tableName( 'page' );
43 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace,
44 0 AS value FROM $page WHERE page_is_redirect = 1";
45 return( $sql );
46 }
47
48 function formatResult( $skin, $result ) {
49 global $wgContLang;
50
51 # Make a link to the redirect itself
52 $rd_title = Title::makeTitle( $result->namespace, $result->title );
53 $rd_link = $skin->link(
54 $rd_title,
55 null,
56 array(),
57 array( 'redirect' => 'no' )
58 );
59
60 # Find out where the redirect leads
61 $revision = Revision::newFromTitle( $rd_title );
62 if( $revision ) {
63 # Make a link to the destination page
64 $target = Title::newFromRedirect( $revision->getText() );
65 if( $target ) {
66 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
67 $targetLink = $skin->link( $target );
68 return "$rd_link $arr $targetLink";
69 } else {
70 return "<del>$rd_link</del>";
71 }
72 } else {
73 return "<del>$rd_link</del>";
74 }
75 }
76 }
77
78 function wfSpecialListredirects() {
79 list( $limit, $offset ) = wfCheckLimits();
80 $lrp = new ListredirectsPage();
81 $lrp->doQuery( $offset, $limit );
82 }