* Clarified the difference between wfMsg and wfMsgForContent
[mediawiki.git] / includes / SpecialDoubleRedirects.php
blob9c0563e5ab8e286dba3f5905ad0b269cbe509513
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
9 *
11 require_once('QueryPage.php');
13 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
18 class DoubleRedirectsPage extends PageQueryPage {
20 function getName() {
21 return 'DoubleRedirects';
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
27 function getPageHeader( ) {
28 #FIXME : probably need to add a backlink to the maintenance page.
29 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
32 function getSQL() {
33 $dbr =& wfGetDB( DB_SLAVE );
34 extract( $dbr->tableNames( 'page', 'links' ) );
36 $sql = "SELECT 'DoubleRedirects' as type," .
37 " pa.page_namespace as namespace, pa.page_title as title," .
38 " pb.page_namespace as nsb, pb.page_title as tb," .
39 " pc.page_namespace as nsc, pc.page_title as tc" .
40 " FROM $links AS la, $links AS lb, $page AS pa, $page AS pb, $page AS pc" .
41 " WHERE pa.page_is_redirect=1 AND pb.page_is_redirect=1" .
42 " AND la.l_from=pa.page_id" .
43 " AND la.l_to=pb.page_id" .
44 " AND lb.l_from=pb.page_id" .
45 " AND lb.l_to=pc.page_id";
46 return $sql;
49 function getOrder() {
50 return '';
53 function formatResult( $skin, $result ) {
54 $fname = 'DoubleRedirectsPage::formatResult';
55 $titleA = Title::makeTitle( $result->namespace, $result->title );
57 if ( $result && !isset( $result->nsb ) ) {
58 $dbr =& wfGetDB( DB_SLAVE );
59 extract( $dbr->tableNames( 'page', 'links' ) );
60 $encTitle = $dbr->addQuotes( $result->title );
62 $sql = "SELECT pa.page_namespace as namespace, pa.page_title as title," .
63 " pb.page_namespace as nsb, pb.page_title as tb," .
64 " pc.page_namespace as nsc, pc.page_title as tc" .
65 " FROM $links AS la, $links AS lb, $page AS pa, $page AS pb, $page AS pc" .
66 " WHERE pa.page_is_redirect=1 AND pb.page_is_redirect=1" .
67 " AND la.l_from=pa.page_id" .
68 " AND la.l_to=pb.page_id" .
69 " AND lb.l_from=pb.page_id" .
70 " AND lb.l_to=pc.page_id" .
71 " AND pa.page_namespace={$result->namespace}" .
72 " AND pa.page_title=$encTitle";
73 $res = $dbr->query( $sql, $fname );
74 if ( $res ) {
75 $result = $dbr->fetchObject( $res );
78 if ( !$result ) {
79 return '';
82 $titleB = Title::makeTitle( $result->nsb, $result->tb );
83 $titleC = Title::makeTitle( $result->nsc, $result->tc );
85 $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' );
86 $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
87 $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
88 $linkC = $skin->makeKnownLinkObj( $titleC );
90 return "$linkA $edit &rarr; $linkB &rarr; $linkC";
94 /**
95 * constructor
97 function wfSpecialDoubleRedirects() {
98 list( $limit, $offset ) = wfCheckLimits();
100 $sdr = new DoubleRedirectsPage();
102 return $sdr->doQuery( $offset, $limit );