Moved the bulk of dbsource() to Database.php. Added support for updating wikis with...
[mediawiki.git] / includes / SpecialListredirects.php
blob1ac7de48abc44d9aae41cac1a45d32b5b113483a
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage SpecialPage
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 */
11 /* */
12 require_once 'QueryPage.php';
14 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
19 class ListredirectsPage extends QueryPage {
21 function getName() { return( 'listredirects' ); }
22 function isExpensive() { return( true ); }
23 function isSyndicated() { return( false ); }
24 function sortDescending() { return( false ); }
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' );
32 function formatResult( $skin, $result ) {
33 global $wgContLang;
35 # Make a link to the redirect itself
36 $rd_title = Title::makeTitle( $result->namespace, $result->title );
37 $rd_link = $skin->makeKnownLinkObj( $rd_title, '', 'redirect=no' );
39 # Find out where the redirect leads
40 $revision = Revision::newFromTitle( $rd_title );
41 if( $revision ) {
42 # Make a link to the destination page
43 $target = Title::newFromRedirect( $revision->getText() );
44 if( $target ) {
45 $targetLink = $skin->makeKnownLinkObj( $target );
46 } else {
47 /** @todo Put in some decent error display here */
48 $targetLink = '*';
50 } else {
51 /** @todo Put in some decent error display here */
52 $targetLink = '*';
55 # Format the whole thing and return it
56 return( $rd_link . ' &rarr; ' . $targetLink );
62 function wfSpecialListredirects() {
63 list( $limit, $offset ) = wfCheckLimits();
64 $lrp = new ListredirectsPage();
65 $lrp->doQuery( $offset, $limit );