From 3b0ff98ff695465cbd04e5348cf7a29e50c1c5f7 Mon Sep 17 00:00:00 2001 From: aalekhN Date: Fri, 10 Jan 2014 03:27:27 +0530 Subject: [PATCH] Make Special:Whatlinkshere.php transcludable 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 | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 789ea765bd..176fbd4f76 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -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 ); + } } } -- 2.20.1