4 * @addtogroup SpecialPage
9 * @addtogroup SpecialPage
11 class DoubleRedirectsPage
extends PageQueryPage
{
14 return 'DoubleRedirects';
17 function isExpensive( ) { return true; }
18 function isSyndicated() { return false; }
20 function getPageHeader( ) {
21 #FIXME : probably need to add a backlink to the maintenance page.
22 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
25 function getSQLText( &$dbr, $namespace = null, $title = null ) {
27 list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
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 $pagelinks AS la, $pagelinks AS lb, $page AS pa, $page AS pb, $page AS pc" .
36 " WHERE pa.page_is_redirect=1 AND pb.page_is_redirect=1" .
37 " AND la.pl_from=pa.page_id" .
38 " AND la.pl_namespace=pb.page_namespace" .
39 " AND la.pl_title=pb.page_title" .
40 " AND lb.pl_from=pb.page_id" .
41 " AND lb.pl_namespace=pc.page_namespace" .
42 " AND lb.pl_title=pc.page_title";
45 $encTitle = $dbr->addQuotes( $title );
46 $sql .= " AND pa.page_namespace=$namespace" .
47 " AND pa.page_title=$encTitle";
54 $dbr =& wfGetDB( DB_SLAVE
);
55 return $this->getSQLText( $dbr );
62 function formatResult( $skin, $result ) {
65 $fname = 'DoubleRedirectsPage::formatResult';
66 $titleA = Title
::makeTitle( $result->namespace, $result->title
);
68 if ( $result && !isset( $result->nsb
) ) {
69 $dbr =& wfGetDB( DB_SLAVE
);
70 $sql = $this->getSQLText( $dbr, $result->namespace, $result->title
);
71 $res = $dbr->query( $sql, $fname );
73 $result = $dbr->fetchObject( $res );
74 $dbr->freeResult( $res );
81 $titleB = Title
::makeTitle( $result->nsb
, $result->tb
);
82 $titleC = Title
::makeTitle( $result->nsc
, $result->tc
);
84 $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' );
85 $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
86 $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
87 $linkC = $skin->makeKnownLinkObj( $titleC );
88 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
90 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
97 function wfSpecialDoubleRedirects() {
98 list( $limit, $offset ) = wfCheckLimits();
100 $sdr = new DoubleRedirectsPage();
102 return $sdr->doQuery( $offset, $limit );