Installer is no longer hardcoded to xhtml doctype
[mediawiki.git] / includes / specials / SpecialDoubleRedirects.php
blob893fee9e700551f9cf247a4ec05331bf586348db
1 <?php
2 /**
3 * @file
4 * @ingroup 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 * @ingroup 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 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," ;
31 $sql .=
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";
43 if( $limitToTitle ) {
44 $encTitle = $dbr->addQuotes( $title );
45 $sql .= " AND pa.page_namespace=$namespace" .
46 " AND pa.page_title=$encTitle";
49 return $sql;
52 function getSQL() {
53 $dbr = wfGetDB( DB_SLAVE );
54 return $this->getSQLText( $dbr );
57 function getOrder() {
58 return '';
61 function formatResult( $skin, $result ) {
62 global $wgContLang;
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 );
71 if ( $res ) {
72 $result = $dbr->fetchObject( $res );
73 $dbr->freeResult( $res );
76 if ( !$result ) {
77 return '<s>' . $skin->link( $titleA, null, array(), array( 'redirect' => 'no' ) ) . '</s>';
80 $titleB = Title::makeTitle( $result->nsb, $result->tb );
81 $titleC = Title::makeTitle( $result->nsc, $result->tc );
83 $linkA = $skin->linkKnown(
84 $titleA,
85 null,
86 array(),
87 array( 'redirect' => 'no' )
89 $edit = $skin->linkKnown(
90 $titleA,
91 wfMsgExt( 'parentheses', array( 'escape' ), wfMsg( 'editlink' ) ),
92 array(),
93 array(
94 'redirect' => 'no',
95 'action' => 'edit'
98 $linkB = $skin->linkKnown(
99 $titleB,
100 null,
101 array(),
102 array( 'redirect' => 'no' )
104 $linkC = $skin->linkKnown( $titleC );
105 $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
107 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
112 * constructor
114 function wfSpecialDoubleRedirects() {
115 list( $limit, $offset ) = wfCheckLimits();
117 $sdr = new DoubleRedirectsPage();
119 return $sdr->doQuery( $offset, $limit );