* (bug 6061) Improper escaping in some html forms
[mediawiki.git] / includes / SpecialDoubleRedirects.php
blobaf02269e13d5c6aa6ffa5b7d1c1c4873e92a8864
1 <?php
2 /**
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 require_once('QueryPage.php');
13 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
18 class DoubleRedirectsPage extends PageQueryPage {
20 function getName() {
21 return 'DoubleRedirects';
24 function isExpensive( ) { return true; }
25 function isSyndicated() { return false; }
27 function getPageHeader( ) {
28 #FIXME : probably need to add a backlink to the maintenance page.
29 return '<p>'.wfMsg("doubleredirectstext")."</p><br />\n";
32 function getSQLText( &$dbr, $namespace = null, $title = null ) {
34 extract( $dbr->tableNames( 'page', 'pagelinks' ) );
36 $limitToTitle = !( $namespace === null && $title === null );
37 $sql = $limitToTitle ? "SELECT" : "SELECT 'DoubleRedirects' as type," ;
38 $sql .=
39 " pa.page_namespace as namespace, pa.page_title as title," .
40 " pb.page_namespace as nsb, pb.page_title as tb," .
41 " pc.page_namespace as nsc, pc.page_title as tc" .
42 " FROM $pagelinks AS la, $pagelinks AS lb, $page AS pa, $page AS pb, $page AS pc" .
43 " WHERE pa.page_is_redirect=1 AND pb.page_is_redirect=1" .
44 " AND la.pl_from=pa.page_id" .
45 " AND la.pl_namespace=pb.page_namespace" .
46 " AND la.pl_title=pb.page_title" .
47 " AND lb.pl_from=pb.page_id" .
48 " AND lb.pl_namespace=pc.page_namespace" .
49 " AND lb.pl_title=pc.page_title";
51 if( $limitToTitle ) {
52 $encTitle = $dbr->addQuotes( $title );
53 $sql .= " AND pa.page_namespace=$namespace" .
54 " AND pa.page_title=$encTitle";
57 return $sql;
60 function getSQL() {
61 $dbr =& wfGetDB( DB_SLAVE );
62 return $this->getSQLText( $dbr );
65 function getOrder() {
66 return '';
69 function formatResult( $skin, $result ) {
70 global $wgContLang;
72 $fname = 'DoubleRedirectsPage::formatResult';
73 $titleA = Title::makeTitle( $result->namespace, $result->title );
75 if ( $result && !isset( $result->nsb ) ) {
76 $dbr =& wfGetDB( DB_SLAVE );
77 $sql = $this->getSQLText( $dbr, $result->namespace, $result->title );
78 $res = $dbr->query( $sql, $fname );
79 if ( $res ) {
80 $result = $dbr->fetchObject( $res );
81 $dbr->freeResult( $res );
84 if ( !$result ) {
85 return '';
88 $titleB = Title::makeTitle( $result->nsb, $result->tb );
89 $titleC = Title::makeTitle( $result->nsc, $result->tc );
91 $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' );
92 $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
93 $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
94 $linkC = $skin->makeKnownLinkObj( $titleC );
95 $arr = $wgContLang->isRTL() ? '&larr;' : '&rarr;';
97 return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
102 * constructor
104 function wfSpecialDoubleRedirects() {
105 list( $limit, $offset ) = wfCheckLimits();
107 $sdr = new DoubleRedirectsPage();
109 return $sdr->doQuery( $offset, $limit );