revert r106095, fix apparently not this simple
[lhc/web/wiklou.git] / includes / specials / SpecialWhatlinkshere.php
index a6dc6f5..e55374e 100644 (file)
@@ -83,11 +83,10 @@ class SpecialWhatLinksHere extends SpecialPage {
 
                $this->getSkin()->setRelevantTitle( $this->target );
 
-
                $this->selfTitle = $this->getTitle( $this->target->getPrefixedDBkey() );
 
-               $out->setPageTitleMsg( 'whatlinkshere-title', $this->target->getPrefixedText() );
-               $out->setSubtitle( wfMsg( 'whatlinkshere-backlink', Linker::link( $this->target, $this->target->getPrefixedText(), array(), array( 'redirect' => 'no'  ) ) ) );
+               $out->setPageTitle( $this->msg( 'whatlinkshere-title', $this->target->getPrefixedText() ) );
+               $out->addBacklinkSubtitle( $this->target );
 
                $this->showIndirectLinks( 0, $this->target, $opts->getValue( 'limit' ),
                        $opts->getValue( 'from' ), $opts->getValue( 'back' ) );
@@ -120,9 +119,9 @@ class SpecialWhatLinksHere extends SpecialPage {
                        'pl_title' => $target->getDBkey(),
                );
                if( $hideredirs ) {
-                       $plConds['page_is_redirect'] = 0;
+                       $plConds['rd_from'] = null;
                } elseif( $hidelinks ) {
-                       $plConds['page_is_redirect'] = 1;
+                       $plConds[] = 'rd_from is NOT NULL';
                }
 
                $tlConds = array(
@@ -157,24 +156,34 @@ class SpecialWhatLinksHere extends SpecialPage {
                $options[] = 'STRAIGHT_JOIN';
 
                $options['LIMIT'] = $queryLimit;
-               $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' );
+               $fields = array( 'page_id', 'page_namespace', 'page_title', 'rd_from' );
+
+               $joinConds = array( 'redirect' => array( 'LEFT JOIN', array(
+                       'rd_from = page_id',
+                       'rd_namespace' => $target->getNamespace(),
+                       'rd_title' => $target->getDBkey(),
+                       '(rd_interwiki is NULL) or (rd_interwiki = \'\')'
+               )));
 
                if( $fetchlinks ) {
                        $options['ORDER BY'] = 'pl_from';
-                       $plRes = $dbr->select( array( 'pagelinks', 'page' ), $fields,
-                               $plConds, __METHOD__, $options );
+                       $plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
+                               $plConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( !$hidetrans ) {
                        $options['ORDER BY'] = 'tl_from';
-                       $tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields,
-                               $tlConds, __METHOD__, $options );
+                       $tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
+                               $tlConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( !$hideimages ) {
                        $options['ORDER BY'] = 'il_from';
-                       $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
-                               $ilConds, __METHOD__, $options );
+                       $ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
+                               $ilConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( ( !$fetchlinks || !$dbr->numRows($plRes) ) && ( $hidetrans || !$dbr->numRows($tlRes) ) && ( $hideimages || !$dbr->numRows($ilRes) ) ) {
@@ -248,7 +257,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                foreach ( $rows as $row ) {
                        $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
 
-                       if ( $row->page_is_redirect && $level < 2 ) {
+                       if ( $row->rd_from && $level < 2 ) {
                                $out->addHTML( $this->listItem( $row, $nt, true ) );
                                $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved );
                                $out->addHTML( Xml::closeElement( 'li' ) );
@@ -269,7 +278,7 @@ class SpecialWhatLinksHere extends SpecialPage {
        }
 
        protected function listItem( $row, $nt, $notClose = false ) {
-               $dirmark = $this->getLang()->getDirMark();
+               $dirmark = $this->getLanguage()->getDirMark();
 
                # local message cache
                static $msgcache = null;
@@ -282,7 +291,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                        }
                }
 
-               if( $row->page_is_redirect ) {
+               if( $row->rd_from ) {
                        $query = array( 'redirect' => 'no' );
                } else {
                        $query = array();
@@ -298,7 +307,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                // Display properties (redirect or template)
                $propsText = '';
                $props = array();
-               if ( $row->page_is_redirect )
+               if ( $row->rd_from )
                        $props[] = $msgcache['isredirect'];
                if ( $row->is_template )
                        $props[] = $msgcache['istemplate'];
@@ -362,7 +371,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                }
 
                $limitLinks = array();
-               $lang = $this->getLang();
+               $lang = $this->getLanguage();
                foreach ( $this->limits as $limit ) {
                        $prettyLimit = htmlspecialchars( $lang->formatNum( $limit ) );
                        $overrides = array( 'limit' => $limit );
@@ -442,6 +451,6 @@ class SpecialWhatLinksHere extends SpecialPage {
                        $overrides = array( $type => !$chosen );
                        $links[] =  wfMsgHtml( "whatlinkshere-{$type}", $this->makeSelfLink( $msg, array_merge( $changed, $overrides ) ) );
                }
-               return Xml::fieldset( wfMsg( 'whatlinkshere-filters' ), $this->getLang()->pipeList( $links ) );
+               return Xml::fieldset( wfMsg( 'whatlinkshere-filters' ), $this->getLanguage()->pipeList( $links ) );
        }
 }