Make Special:Whatlinkshere.php transcludable
authoraalekhN <aalekh1993@rediffmail.com>
Thu, 9 Jan 2014 21:57:27 +0000 (03:27 +0530)
committerBrian Wolff <bawolff+wn@gmail.com>
Fri, 21 Mar 2014 02:44:38 +0000 (02:44 +0000)
This commit makes Special:Whatlinkshere transcludable by extending
SpecialWhatLinksHere with IncludableSpecialPage. It also adds a condition
in the showIndirectLinks function to avoid displaying the form when the
page is being transcluded.

Bug: 35486
Change-Id: I49d6be57a9a780f9f959cb4356c5ac026db81775

includes/specials/SpecialWhatlinkshere.php

index 789ea76..176fbd4 100644 (file)
@@ -26,7 +26,7 @@
  *
  * @ingroup SpecialPage
  */
-class SpecialWhatLinksHere extends SpecialPage {
+class SpecialWhatLinksHere extends IncludableSpecialPage {
 
        /**
         * @var FormOptions
@@ -88,9 +88,7 @@ class SpecialWhatLinksHere extends SpecialPage {
 
                $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' ) );
+               $this->showIndirectLinks( 0, $this->target, $opts->getValue( 'limit' ), $opts->getValue( 'from' ), $opts->getValue( 'back' ) );
        }
 
        /**
@@ -188,15 +186,16 @@ class SpecialWhatLinksHere extends SpecialPage {
 
                if ( ( !$fetchlinks || !$plRes->numRows() ) && ( $hidetrans || !$tlRes->numRows() ) && ( $hideimages || !$ilRes->numRows() ) ) {
                        if ( 0 == $level ) {
-                               $out->addHTML( $this->whatlinkshereForm() );
-
-                               // Show filters only if there are links
-                               if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
-                                       $out->addHTML( $this->getFilterPanel() );
+                               if ( !$this->including() ) {
+                                       $out->addHTML( $this->whatlinkshereForm() );
+
+                                       // Show filters only if there are links
+                                       if ( $hidelinks || $hidetrans || $hideredirs || $hideimages ) {
+                                               $out->addHTML( $this->getFilterPanel() );
+                                       }
+                                       $errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
+                                       $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
                                }
-
-                               $errMsg = is_int( $namespace ) ? 'nolinkshere-ns' : 'nolinkshere';
-                               $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
                        }
                        return;
                }
@@ -246,14 +245,15 @@ class SpecialWhatLinksHere extends SpecialPage {
                $prevId = $from;
 
                if ( $level == 0 ) {
-                       $out->addHTML( $this->whatlinkshereForm() );
-                       $out->addHTML( $this->getFilterPanel() );
-                       $out->addWikiMsg( 'linkshere', $this->target->getPrefixedText() );
+                       if ( !$this->including() ) {
+                               $out->addHTML( $this->whatlinkshereForm() );
+                               $out->addHTML( $this->getFilterPanel() );
+                               $out->addWikiMsg( 'linkshere', $this->target->getPrefixedText() );
 
-                       $prevnext = $this->getPrevNext( $prevId, $nextId );
-                       $out->addHTML( $prevnext );
+                               $prevnext = $this->getPrevNext( $prevId, $nextId );
+                               $out->addHTML( $prevnext );
+                       }
                }
-
                $out->addHTML( $this->listStart( $level ) );
                foreach ( $rows as $row ) {
                        $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
@@ -270,7 +270,9 @@ class SpecialWhatLinksHere extends SpecialPage {
                $out->addHTML( $this->listEnd() );
 
                if ( $level == 0 ) {
-                       $out->addHTML( $prevnext );
+                       if( !$this->including() ){
+                               $out->addHTML( $prevnext );
+                       }
                }
        }