From 0b18e221a4ea1b40706f505c713b550ef592be02 Mon Sep 17 00:00:00 2001 From: andymw Date: Sat, 8 Oct 2016 22:53:24 -0700 Subject: [PATCH] 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 --- includes/specials/SpecialMovepage.php | 41 +++++++++++++++++++++------ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 7 +++-- 3 files changed, 38 insertions(+), 11 deletions(-) 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( "