8 * A special page listing redirects to redirecting page.
9 * The software will automatically not follow double redirects, to prevent loops.
10 * @ingroup SpecialPage
12 class DoubleRedirectsPage
extends PageQueryPage
{
15 return 'DoubleRedirects';
18 function isExpensive( ) { return true; }
19 function isSyndicated() { return false; }
21 function getPageHeader( ) {
22 return wfMsgExt( 'doubleredirectstext', array( 'parse' ) );
25 function getSQLText( &$dbr, $namespace = null, $title = null ) {
27 list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' );
29 $limitToTitle = !( $namespace === null && $title === null );
30 $sql = $limitToTitle ?
"SELECT" : "SELECT 'DoubleRedirects' as type," ;
32 " pa.page_namespace as namespace, pa.page_title as title," .
33 " pb.page_namespace as nsb, pb.page_title as tb," .
34 " pc.page_namespace as nsc, pc.page_title as tc" .
35 " FROM $redirect AS ra, $redirect AS rb, $page AS pa, $page AS pb, $page AS pc" .
36 " WHERE ra.rd_from=pa.page_id" .
37 " AND ra.rd_namespace=pb.page_namespace" .
38 " AND ra.rd_title=pb.page_title" .
39 " AND rb.rd_from=pb.page_id" .
40 " AND rb.rd_namespace=pc.page_namespace" .
41 " AND rb.rd_title=pc.page_title";
44 $encTitle = $dbr->addQuotes( $title );
45 $sql .= " AND pa.page_namespace=$namespace" .
46 " AND pa.page_title=$encTitle";
53 $dbr = wfGetDB( DB_SLAVE
);
54 return $this->getSQLText( $dbr );
61 function formatResult( $skin, $result ) {
64 $fname = 'DoubleRedirectsPage::formatResult';
65 $titleA = Title
::makeTitle( $result->namespace, $result->title
);
67 if ( $result && !isset( $result->nsb
) ) {
68 $dbr = wfGetDB( DB_SLAVE
);
69 $sql = $this->getSQLText( $dbr, $result->namespace, $result->title
);
70 $res = $dbr->query( $sql, $fname );
72 $result = $dbr->fetchObject( $res );
73 $dbr->freeResult( $res );
77 return '<s>' . $skin->makeLinkObj( $titleA, '', 'redirect=no' ) . '</s>';
80 $titleB = Title
::makeTitle( $result->nsb
, $result->tb
);
81 $titleC = Title
::makeTitle( $result->nsc
, $result->tc
);
83 $linkA = $skin->makeKnownLinkObj( $titleA, '', 'redirect=no' );
84 $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
85 $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
86 $linkC = $skin->makeKnownLinkObj( $titleC );
87 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
89 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
96 function wfSpecialDoubleRedirects() {
97 list( $limit, $offset ) = wfCheckLimits();
99 $sdr = new DoubleRedirectsPage();
101 return $sdr->doQuery( $offset, $limit );