* (bug 1996) Special page to list redirects
[lhc/web/wiklou.git] / includes / SpecialListredirects.php
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage SpecialPage
5 *
6 * @author Rob Church <robchur@gmail.com>
7 * @copyright © 2006 Rob Church
8 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 */
10
11 /* */
12 require_once 'QueryPage.php';
13
14 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18
19 class ListredirectsPage extends QueryPage {
20
21 function getName() { return( 'listredirects' ); }
22 function isExpensive() { return( true ); }
23 function isSyndicated() { return( false ); }
24 function sortDescending() { return( false ); }
25
26 function getSQL() {
27 $dbr =& wfGetDB( DB_SLAVE );
28 extract( $dbr->tableNames( 'page' ) );
29 return( 'SELECT page_title AS title, page_namespace AS namespace, page_namespace AS value FROM ' . $page . ' WHERE page_is_redirect = 1' );
30 }
31
32 function formatResult( $skin, $result ) {
33 global $wgContLang;
34
35 # Make a link to the redirect itself
36 $rd_title = Title::makeTitle( $result->namespace, $result->title );
37 $rd_link_text = htmlspecialchars( $wgContLang->convert( $rd_title->getPrefixedText() ) );
38 $rd_link = $skin->makeKnownLink( $rd_title->getPrefixedText(), $rd_link_text, 'redirect=no' );
39
40 # Find out where the redirect leads
41 $rd_page = new Article( &$rd_title, 0 );
42 $rd_text = $rd_page->getContent( true ); # Don't follow the redirect
43
44 # Make a link to the destination page
45 $tp_title = Title::newFromRedirect( $rd_text );
46 $tp_link_text = htmlspecialchars( $tp_title->getPrefixedText() );
47 $tp_link = $skin->makeKnownLink( $tp_title->getPrefixedText(), $tp_link_text );
48
49 # Format the whole thing and return it
50 return( $rd_link . ' &rarr; ' . $tp_link );
51 }
52
53 }
54
55 function wfSpecialListredirects() {
56 list( $limit, $offset ) = wfCheckLimits();
57 $lrp = new ListredirectsPage();
58 $lrp->doQuery( $offset, $limit );
59 }
60
61 ?>