X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialDoubleRedirects.php;h=7e4ec36099334b63dba8fc2f673869d31ab56873;hb=f059e0952407f368a6fbcccefe57982c4d63ba2a;hp=20937b2e512e67b9c6239f09ad7ef9efcf783b0b;hpb=ba2afcd9fa9b1f3f6a865da054068466164fd2fa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialDoubleRedirects.php b/includes/SpecialDoubleRedirects.php index 20937b2e51..7e4ec36099 100644 --- a/includes/SpecialDoubleRedirects.php +++ b/includes/SpecialDoubleRedirects.php @@ -1,59 +1,92 @@ '.wfMsg("doubleredirectstext")."


\n"; + return wfMsgExt( 'doubleredirectstext', array( 'parse' ) ); } - function getSQL() { - $dbr =& wfGetDB( DB_SLAVE ); - extract( $dbr->tableNames( 'cur', 'links' ) ); - - $sql = "SELECT ca.cur_namespace as ns_a, ca.cur_title as title_a," . - " cb.cur_namespace as ns_b, cb.cur_title as title_b," . - " cb.cur_text AS rt " . - "FROM $links,$cur AS ca,$cur AS cb ". - "WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id " . - " AND l_from=ca.cur_id " ; + function getSQLText( &$dbr, $namespace = null, $title = null ) { + + list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' ); + + $limitToTitle = !( $namespace === null && $title === null ); + $sql = $limitToTitle ? "SELECT" : "SELECT 'DoubleRedirects' as type," ; + $sql .= + " pa.page_namespace as namespace, pa.page_title as title," . + " pb.page_namespace as nsb, pb.page_title as tb," . + " pc.page_namespace as nsc, pc.page_title as tc" . + " FROM $redirect AS ra, $redirect AS rb, $page AS pa, $page AS pb, $page AS pc" . + " WHERE ra.rd_from=pa.page_id" . + " AND ra.rd_namespace=pb.page_namespace" . + " AND ra.rd_title=pb.page_title" . + " AND rb.rd_from=pb.page_id" . + " AND rb.rd_namespace=pc.page_namespace" . + " AND rb.rd_title=pc.page_title"; + + if( $limitToTitle ) { + $encTitle = $dbr->addQuotes( $title ); + $sql .= " AND pa.page_namespace=$namespace" . + " AND pa.page_title=$encTitle"; + } + return $sql; } + + function getSQL() { + $dbr = wfGetDB( DB_SLAVE ); + return $this->getSQLText( $dbr ); + } function getOrder() { return ''; } - + function formatResult( $skin, $result ) { - global $wgLang ; - $ns = $wgLang->getNamespaces() ; - $from = $skin->makeKnownLink( $ns[$result->ns_a].':'.$result->title_a ,'', 'redirect=no' ); - $edit = $skin->makeBrokenLink( $ns[$result->ns_a].':'.$result->title_a , "(".wfMsg("qbedit").")" , 'redirect=no'); - $to = $skin->makeKnownLink( $ns[$result->ns_b].':'.$result->title_b ,''); - $content = $result->rt; - - return "$from $edit => $to ($content)"; + global $wgContLang; + + $fname = 'DoubleRedirectsPage::formatResult'; + $titleA = Title::makeTitle( $result->namespace, $result->title ); + + if ( $result && !isset( $result->nsb ) ) { + $dbr = wfGetDB( DB_SLAVE ); + $sql = $this->getSQLText( $dbr, $result->namespace, $result->title ); + $res = $dbr->query( $sql, $fname ); + if ( $res ) { + $result = $dbr->fetchObject( $res ); + $dbr->freeResult( $res ); + } + } + if ( !$result ) { + return '' . $skin->makeLinkObj( $titleA, '', 'redirect=no' ) . ''; + } + + $titleB = Title::makeTitle( $result->nsb, $result->tb ); + $titleC = Title::makeTitle( $result->nsc, $result->tc ); + + $linkA = $skin->makeKnownLinkObj( $titleA, '', 'redirect=no' ); + $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no'); + $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' ); + $linkC = $skin->makeKnownLinkObj( $titleC ); + $arr = $wgContLang->getArrow() . $wgContLang->getDirMark(); + + return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" ); } } @@ -62,10 +95,10 @@ class DoubleRedirectsPage extends PageQueryPage { */ function wfSpecialDoubleRedirects() { list( $limit, $offset ) = wfCheckLimits(); - + $sdr = new DoubleRedirectsPage(); - + return $sdr->doQuery( $offset, $limit ); } -?> +