]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialListredirects.php
MediaWiki 1.15.4-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialListredirects.php
1 <?php
2 /**
3  * @file
4  * @ingroup 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  * Special:Listredirects - Lists all the redirects on the wiki.
13  * @ingroup SpecialPage
14  */
15 class ListredirectsPage extends QueryPage {
16
17         function getName() { return( 'Listredirects' ); }
18         function isExpensive() { return( true ); }
19         function isSyndicated() { return( false ); }
20         function sortDescending() { return( false ); }
21
22         function getSQL() {
23                 $dbr = wfGetDB( DB_SLAVE );
24                 $page = $dbr->tableName( 'page' );
25                 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, 
26                         0 AS value FROM $page WHERE page_is_redirect = 1";
27                 return( $sql );
28         }
29
30         function formatResult( $skin, $result ) {
31                 global $wgContLang;
32
33                 # Make a link to the redirect itself
34                 $rd_title = Title::makeTitle( $result->namespace, $result->title );
35                 $rd_link = $skin->makeLinkObj( $rd_title, '', 'redirect=no' );
36
37                 # Find out where the redirect leads
38                 $revision = Revision::newFromTitle( $rd_title );
39                 if( $revision ) {
40                         # Make a link to the destination page
41                         $target = Title::newFromRedirect( $revision->getText() );
42                         if( $target ) {
43                                 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
44                                 $targetLink = $skin->makeLinkObj( $target );
45                                 return "$rd_link $arr $targetLink";
46                         } else {
47                                 return "<s>$rd_link</s>";
48                         }
49                 } else {
50                         return "<s>$rd_link</s>";
51                 }
52         }
53 }
54
55 function wfSpecialListredirects() {
56         list( $limit, $offset ) = wfCheckLimits();
57         $lrp = new ListredirectsPage();
58         $lrp->doQuery( $offset, $limit );
59 }