Using a better method to get the English language file.
[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 * @package MediaWiki
13 * @subpackage SpecialPage
14 */
15
16 class ListredirectsPage extends QueryPage {
17
18 function getName() { return( 'Listredirects' ); }
19 function isExpensive() { return( true ); }
20 function isSyndicated() { return( false ); }
21 function sortDescending() { return( false ); }
22
23 function getSQL() {
24 $dbr =& wfGetDB( DB_SLAVE );
25 $page = $dbr->tableName( 'page' );
26 $sql = "SELECT 'Listredirects' AS type, page_title AS title, page_namespace AS namespace, 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->makeKnownLinkObj( $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 $targetLink = $skin->makeLinkObj( $target );
44 } else {
45 /** @todo Put in some decent error display here */
46 $targetLink = '*';
47 }
48 } else {
49 /** @todo Put in some decent error display here */
50 $targetLink = '*';
51 }
52
53 # Check the language; RTL wikis need a &larr;
54 $arr = $wgContLang->isRTL() ? ' &larr; ' : ' &rarr; ';
55 $arr .= $wgContLang->getDirMark();
56
57 # Format the whole thing and return it
58 return( $rd_link . $arr . $targetLink );
59
60 }
61
62 }
63
64 function wfSpecialListredirects() {
65 list( $limit, $offset ) = wfCheckLimits();
66 $lrp = new ListredirectsPage();
67 $lrp->doQuery( $offset, $limit );
68 }
69
70 ?>