* Removed messages in English, they'll be inherited from the parent.
[lhc/web/wiklou.git] / includes / SpecialDoubleRedirects.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 *
10 */
11 require_once('QueryPage.php');
12
13 /**
14 *
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18 class DoubleRedirectsPage extends PageQueryPage {
19
20 function getName() {
21 return 'DoubleRedirects';
22 }
23
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
26
27 function getPageHeader( ) {
28 #FIXME : probably need to add a backlink to the maintenance page.
29 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
30 }
31
32 function getSQL() {
33 $dbr =& wfGetDB( DB_SLAVE );
34 extract( $dbr->tableNames( 'page', 'links' ) );
35
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;
47 }
48
49 function getOrder() {
50 return '';
51 }
52
53 function formatResult( $skin, $result ) {
54 $fname = 'DoubleRedirectsPage::formatResult';
55 $titleA = Title::makeTitle( $result->namespace, $result->title );
56
57 if ( $result && !isset( $result->nsb ) ) {
58 $dbr =& wfGetDB( DB_SLAVE );
59 extract( $dbr->tableNames( 'page', 'links' ) );
60 $encTitle = $dbr->addQuotes( $result->title );
61
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 );
76 }
77 }
78 if ( !$result ) {
79 return '';
80 }
81
82 $titleB = Title::makeTitle( $result->nsb, $result->tb );
83 $titleC = Title::makeTitle( $result->nsc, $result->tc );
84
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 );
89
90 return "$linkA $edit &rarr; $linkB &rarr; $linkC";
91 }
92 }
93
94 /**
95 * constructor
96 */
97 function wfSpecialDoubleRedirects() {
98 list( $limit, $offset ) = wfCheckLimits();
99
100 $sdr = new DoubleRedirectsPage();
101
102 return $sdr->doQuery( $offset, $limit );
103
104 }
105 ?>