From: andymw Date: Sun, 9 Oct 2016 05:53:24 +0000 (-0700) Subject: Display both subject and talk subpages for Special:MovePage X-Git-Tag: 1.31.0-rc.0~5099^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=0b18e221a4ea1b40706f505c713b550ef592be02;p=lhc%2Fweb%2Fwiklou.git Display both subject and talk subpages for Special:MovePage Editors were only able to see current page subpages, not subpages of the corresponding talk page (if there is one). Consolidate display routine in showSubpagesList. Conditionally show as needed Adds 'movesubpagetalktext' to en.json for description of second bulleted list. Bug: T140026 Change-Id: Id5bb52411ab8249eda180b13aef7d8884064b5db --- diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 7b7661d037..298d6c4edb 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -783,32 +783,57 @@ class MovePageForm extends UnlistedSpecialPage { LogEventsList::showLogExtract( $out, 'move', $title ); } + /** + * Show subpages of the page being moved. Section is not shown if both current + * namespace does not support subpages and no talk subpages were found. + * + * @param Title $title Page being moved. + */ function showSubpages( $title ) { - if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) { + $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() ); + $subpages = $title->getSubpages(); + $count = $subpages instanceof TitleArray ? $subpages->count() : 0; + + $titleIsTalk = $title->isTalkPage(); + $subpagesTalk = $title->getTalkPage()->getSubpages(); + $countTalk = $subpagesTalk instanceof TitleArray ? $subpagesTalk->count() : 0; + $totalCount = $count + $countTalk; + + if ( !$nsHasSubpages && $countTalk == 0 ) { return; } - $subpages = $title->getSubpages(); - $count = $subpages instanceof TitleArray ? $subpages->count() : 0; + $this->getOutput()->wrapWikiMsg( + '== $1 ==', + [ 'movesubpage', ( $titleIsTalk ? $count : $totalCount ) ] + ); + + if ( $nsHasSubpages ) { + $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true ); + } + if ( !$titleIsTalk && $countTalk > 0 ) { + $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' ); + } + } + + function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) { $out = $this->getOutput(); - $out->wrapWikiMsg( '== $1 ==', [ 'movesubpage', $count ] ); # No subpages. - if ( $count == 0 ) { + if ( $pagecount == 0 && $noSubpageMsg ) { $out->addWikiMsg( 'movenosubpage' ); - return; } - $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) ); + $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) ); $out->addHTML( "