Display both subject and talk subpages for Special:MovePage
authorandymw <andymwwm@gmail.com>
Sun, 9 Oct 2016 05:53:24 +0000 (22:53 -0700)
committerandymw <andymwwm@gmail.com>
Sun, 9 Oct 2016 07:09:07 +0000 (00:09 -0700)
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
languages/i18n/en.json
languages/i18n/qqq.json

index 7b7661d..298d6c4 100644 (file)
@@ -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( "<ul>\n" );
 
                $linkBatch = new LinkBatch( $subpages );
                $linkBatch->setCaller( __METHOD__ );
                $linkBatch->execute();
-
                $linkRenderer = $this->getLinkRenderer();
+
                foreach ( $subpages as $subpage ) {
                        $link = $linkRenderer->makeLink( $subpage );
                        $out->addHTML( "<li>$link</li>\n" );
index d10749d..36f7461 100644 (file)
        "movelogpagetext": "Below is a list of all page moves.",
        "movesubpage": "{{PLURAL:$1|Subpage|Subpages}}",
        "movesubpagetext": "This page has $1 {{PLURAL:$1|subpage|subpages}} shown below.",
+       "movesubpagetalktext": "The corresponding talk page has $1 {{PLURAL:$1|subpage|subpages}} shown below.",
        "movenosubpage": "This page has no subpages.",
        "movereason": "Reason:",
        "move-redirect-text": "",
index 96f8c38..a124d83 100644 (file)
        "movepage-max-pages": "PROBABLY (A GUESS): when moving a page, you can select an option of moving its subpages, but there is a maximum that can be moved automatically.\n\nParameters:\n* $1 - maximum moved pages, defined in the variable [[mw:Special:MyLanguage/Manual:$wgMaximumMovedPages|$wgMaximumMovedPages]]",
        "movelogpage": "{{doc-logpage}}\n\nTitle of [[Special:Log/move]]. Used as heading on that page, and in the dropdown menu on log pages.",
        "movelogpagetext": "Text on the special page 'Move log'.",
-       "movesubpage": "This is a section header on [[Special:MovePage]], below is a list of subpages.\n\nParameters:\n* $1 - number of subpages\nSee also:\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetext|with subpages}}",
-       "movesubpagetext": "Used in [[Special:MovePage]]. Parameters:\n* $1 - number of subpages\nSee also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}",
-       "movenosubpage": "See also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetext|with subpages}}",
+       "movesubpage": "This is a section header on [[Special:MovePage]], below is a list of subpages.\n\nParameters:\n* $1 - number of subpages\nSee also:\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetext|with subpages}}\n* {{msg-mw|movesubpagetalktext|with talk subpages}}",
+       "movesubpagetext": "Used in [[Special:MovePage]]. Parameters:\n* $1 - number of subpages\nSee also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetalktext|with talk subpages}}",
+       "movesubpagetalktext": "Used in [[Special:MovePage]] when corresponding talk page has subpages. Parameters:\n* $1 - number of subpages\nSee also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}",
+       "movenosubpage": "See also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetext|with subpages}}\n* {{msg-mw|movesubpagetalktext|with talk subpages}}",
        "movereason": "Used in [[Special:MovePage]]. The text for the inputbox to give a reason for the page move.\n\nSee also:\n* {{msg-mw|Move-page-legend|legend for the form}}\n* {{msg-mw|newtitle|label for new title}}\n* {{msg-mw|Movetalk|label for checkbox}}\n* {{msg-mw|Move-leave-redirect|label for checkbox}}\n* {{msg-mw|Fix-double-redirects|label for checkbox}}\n* {{msg-mw|Move-subpages|label for checkbox}}\n* {{msg-mw|Move-talk-subpages|label for checkbox}}\n* {{msg-mw|Move-watch|label for checkbox}}\n{{Identical|Reason}}",
        "move-redirect-text": "{{ignored}}The text that's added to a redirected page when that redirect is created.",
        "category-move-redirect-override": "{{ignored}}The text that's added to a redirected category page when that redirect is created.",