Fix regression in even sizing of diff columns; forgot to restore a couple bits I...
[mediawiki.git] / includes / SpecialDoubleRedirects.php
blobe7b355c5864572b712320f57e76882073b537c78
1 <?php
2 /**
4 * @addtogroup SpecialPage
5 */
7 /**
8 * A special page listing redirects to redirecting page.
9 * The software will automatically not follow double redirects, to prevent loops.
10 * @addtogroup SpecialPage
12 class DoubleRedirectsPage extends PageQueryPage {
14 function getName() {
15 return 'DoubleRedirects';
18 function isExpensive( ) { return true; }
19 function isSyndicated() { return false; }
21 function getPageHeader( ) {
22 #FIXME : probably need to add a backlink to the maintenance page.
23 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
26 function getSQLText( &$dbr, $namespace = null, $title = null ) {
28 list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' );
30 $limitToTitle = !( $namespace === null && $title === null );
31 $sql = $limitToTitle ? "SELECT" : "SELECT 'DoubleRedirects' as type," ;
32 $sql .=
33 " pa.page_namespace as namespace, pa.page_title as title," .
34 " pb.page_namespace as nsb, pb.page_title as tb," .
35 " pc.page_namespace as nsc, pc.page_title as tc" .
36 " FROM $redirect AS ra, $redirect AS rb, $page AS pa, $page AS pb, $page AS pc" .
37 " WHERE ra.rd_from=pa.page_id" .
38 " AND ra.rd_namespace=pb.page_namespace" .
39 " AND ra.rd_title=pb.page_title" .
40 " AND rb.rd_from=pb.page_id" .
41 " AND rb.rd_namespace=pc.page_namespace" .
42 " AND rb.rd_title=pc.page_title";
44 if( $limitToTitle ) {
45 $encTitle = $dbr->addQuotes( $title );
46 $sql .= " AND pa.page_namespace=$namespace" .
47 " AND pa.page_title=$encTitle";
50 return $sql;
53 function getSQL() {
54 $dbr = wfGetDB( DB_SLAVE );
55 return $this->getSQLText( $dbr );
58 function getOrder() {
59 return '';
62 function formatResult( $skin, $result ) {
63 global $wgContLang;
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 );
72 if ( $res ) {
73 $result = $dbr->fetchObject( $res );
74 $dbr->freeResult( $res );
77 if ( !$result ) {
78 return '';
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}" );
94 /**
95 * constructor
97 function wfSpecialDoubleRedirects() {
98 list( $limit, $offset ) = wfCheckLimits();
100 $sdr = new DoubleRedirectsPage();
102 return $sdr->doQuery( $offset, $limit );