* Reorganised the includes directory, creating subdirectories db, parser and specials
[lhc/web/wiklou.git] / includes / specials / Listredirects.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, 0 AS value FROM $page WHERE page_is_redirect = 1";
26 return( $sql );
27 }
28
29 function formatResult( $skin, $result ) {
30 global $wgContLang;
31
32 # Make a link to the redirect itself
33 $rd_title = Title::makeTitle( $result->namespace, $result->title );
34 $rd_link = $skin->makeLinkObj( $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 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
43 $targetLink = $skin->makeLinkObj( $target );
44 return "$rd_link $arr $targetLink";
45 } else {
46 return "<s>$rd_link</s>";
47 }
48 } else {
49 return "<s>$rd_link</s>";
50 }
51 }
52 }
53
54 function wfSpecialListredirects() {
55 list( $limit, $offset ) = wfCheckLimits();
56 $lrp = new ListredirectsPage();
57 $lrp->doQuery( $offset, $limit );
58 }