]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - includes/SpecialListredirects.php
MediaWiki 1.11.0
[autoinstalls/mediawiki.git] / includes / SpecialListredirects.php
1 <?php
2 /**
3  * @addtogroup SpecialPage
4  *
5  * @author Rob Church <robchur@gmail.com>
6  * @copyright © 2006 Rob Church
7  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
8  */
9
10 /**
11  * Special:Listredirects - Lists all the redirects on the wiki.
12  * @addtogroup SpecialPage
13  */
14 class ListredirectsPage extends QueryPage {
15
16         function getName() { return( 'Listredirects' ); }
17         function isExpensive() { return( true ); }
18         function isSyndicated() { return( false ); }
19         function sortDescending() { return( false ); }
20
21         function getSQL() {
22                 $dbr = wfGetDB( DB_SLAVE );
23                 $page = $dbr->tableName( 'page' );
24                 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, 0 AS value FROM $page WHERE page_is_redirect = 1";
25                 return( $sql );
26         }
27
28         function formatResult( $skin, $result ) {
29                 global $wgContLang;
30         
31                 # Make a link to the redirect itself
32                 $rd_title = Title::makeTitle( $result->namespace, $result->title );
33                 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
34                 $rd_link = $skin->makeKnownLinkObj( $rd_title, '', 'redirect=no' );
35
36                 # Find out where the redirect leads
37                 $revision = Revision::newFromTitle( $rd_title );
38                 if( $revision ) {
39                         # Make a link to the destination page
40                         $target = Title::newFromRedirect( $revision->getText() );
41                         if( $target ) {
42                                 $targetLink = $skin->makeLinkObj( $target );
43                         } else {
44                                 /** @todo Put in some decent error display here */
45                                 $targetLink = '*';
46                         }
47                 } else {
48                         /** @todo Put in some decent error display here */
49                         $targetLink = '*';
50                 }
51
52                 # Format the whole thing and return it
53                 return "$rd_link $arr $targetLink";
54
55         }
56
57 }
58
59 function wfSpecialListredirects() {
60         list( $limit, $offset ) = wfCheckLimits();
61         $lrp = new ListredirectsPage();
62         $lrp->doQuery( $offset, $limit );
63 }
64
65