woops
[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 $page = $dbr->tableName( 'page' );
29 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, 0 AS value FROM $page WHERE page_is_redirect = 1";
30 return( $sql );
31 }
32
33 function formatResult( $skin, $result ) {
34 global $wgContLang;
35
36 # Make a link to the redirect itself
37 $rd_title = Title::makeTitle( $result->namespace, $result->title );
38 $rd_link = $skin->makeKnownLinkObj( $rd_title, '', 'redirect=no' );
39
40 # Find out where the redirect leads
41 $revision = Revision::newFromTitle( $rd_title );
42 if( $revision ) {
43 # Make a link to the destination page
44 $target = Title::newFromRedirect( $revision->getText() );
45 if( $target ) {
46 $targetLink = $skin->makeLinkObj( $target );
47 } else {
48 /** @todo Put in some decent error display here */
49 $targetLink = '*';
50 }
51 } else {
52 /** @todo Put in some decent error display here */
53 $targetLink = '*';
54 }
55
56 # Check the language; RTL wikis need a &larr;
57 $arr = $wgContLang->isRTL() ? ' &larr; ' : ' &rarr; ';
58
59 # Format the whole thing and return it
60 return( $rd_link . $arr . $targetLink );
61
62 }
63
64 }
65
66 function wfSpecialListredirects() {
67 list( $limit, $offset ) = wfCheckLimits();
68 $lrp = new ListredirectsPage();
69 $lrp->doQuery( $offset, $limit );
70 }
71
72 ?>