3 * Implements Special:Movepage
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * A special page that allows users to change page titles
27 * @ingroup SpecialPage
29 class MovePageForm
extends UnlistedSpecialPage
{
31 protected $oldTitle = null;
36 /** @var string Text input */
45 protected $deleteAndMove;
48 protected $moveSubpages;
51 protected $fixRedirects;
54 protected $leaveRedirect;
57 protected $moveOverShared;
59 private $watch = false;
61 public function __construct() {
62 parent
::__construct( 'Movepage' );
65 public function doesWrites() {
69 public function execute( $par ) {
70 $this->useTransactionalTimeLimit();
72 $this->checkReadOnly();
75 $this->outputHeader();
77 $request = $this->getRequest();
78 $target = !is_null( $par ) ?
$par : $request->getVal( 'target' );
80 // Yes, the use of getVal() and getText() is wanted, see T22365
82 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
83 $this->oldTitle
= Title
::newFromText( $oldTitleText );
85 if ( !$this->oldTitle
) {
86 // Either oldTitle wasn't passed, or newFromText returned null
87 throw new ErrorPageError( 'notargettitle', 'notargettext' );
89 if ( !$this->oldTitle
->exists() ) {
90 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
93 $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
94 $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle
->getNamespace() );
95 // Backwards compatibility for forms submitting here from other sources
96 // which is more common than it should be..
97 $newTitleText_bc = $request->getText( 'wpNewTitle' );
98 $this->newTitle
= strlen( $newTitleText_bc ) > 0
99 ? Title
::newFromText( $newTitleText_bc )
100 : Title
::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
102 $user = $this->getUser();
105 $permErrors = $this->oldTitle
->getUserPermissionsErrors( 'move', $user );
106 if ( count( $permErrors ) ) {
107 // Auto-block user's IP if the account was "hard" blocked
108 DeferredUpdates
::addCallableUpdate( function () use ( $user ) {
109 $user->spreadAnyEditBlock();
111 throw new PermissionsError( 'move', $permErrors );
114 $def = !$request->wasPosted();
116 $this->reason
= $request->getText( 'wpReason' );
117 $this->moveTalk
= $request->getBool( 'wpMovetalk', $def );
118 $this->fixRedirects
= $request->getBool( 'wpFixRedirects', $def );
119 $this->leaveRedirect
= $request->getBool( 'wpLeaveRedirect', $def );
120 $this->moveSubpages
= $request->getBool( 'wpMovesubpages' );
121 $this->deleteAndMove
= $request->getBool( 'wpDeleteAndMove' );
122 $this->moveOverShared
= $request->getBool( 'wpMoveOverSharedFile' );
123 $this->watch
= $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
125 if ( $request->getVal( 'action' ) == 'submit' && $request->wasPosted()
126 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
130 $this->showForm( [] );
137 * @param array $err Error messages. Each item is an error message.
138 * It may either be a string message name or array message name and
139 * parameters, like the second argument to OutputPage::wrapWikiMsg().
140 * @param bool $isPermError Whether the error message is about user permissions.
142 function showForm( $err, $isPermError = false ) {
143 $this->getSkin()->setRelevantTitle( $this->oldTitle
);
145 $out = $this->getOutput();
146 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle
->getPrefixedText() ) );
147 $out->addModuleStyles( 'mediawiki.special' );
148 $out->addModules( 'mediawiki.special.movePage' );
149 $this->addHelpLink( 'Help:Moving a page' );
151 $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
153 'movepagetext-noredirectfixer'
156 if ( $this->oldTitle
->getNamespace() == NS_USER
&& !$this->oldTitle
->isSubpage() ) {
158 "<div class=\"warningbox mw-moveuserpage-warning\">\n$1\n</div>",
159 'moveuserpage-warning'
161 } elseif ( $this->oldTitle
->getNamespace() == NS_CATEGORY
) {
163 "<div class=\"warningbox mw-movecategorypage-warning\">\n$1\n</div>",
164 'movecategorypage-warning'
168 $deleteAndMove = false;
169 $moveOverShared = false;
171 $newTitle = $this->newTitle
;
174 # Show the current title as a default
175 # when the form is first opened.
176 $newTitle = $this->oldTitle
;
177 } elseif ( !count( $err ) ) {
178 # If a title was supplied, probably from the move log revert
179 # link, check for validity. We can then show some diagnostic
180 # information and save a click.
181 $newerr = $this->oldTitle
->isValidMoveOperation( $newTitle );
182 if ( is_array( $newerr ) ) {
187 $user = $this->getUser();
189 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
190 && $newTitle->quickUserCan( 'delete', $user )
193 "<div class='warningbox'>\n$1\n</div>\n",
194 [ 'delete_and_move_text', $newTitle->getPrefixedText() ]
196 $deleteAndMove = true;
200 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
201 && $user->isAllowed( 'reupload-shared' )
204 "<div class='warningbox'>\n$1\n</div>\n",
206 'move-over-sharedrepo',
207 $newTitle->getPrefixedText()
210 $moveOverShared = true;
214 $oldTalk = $this->oldTitle
->getTalkPage();
215 $oldTitleSubpages = $this->oldTitle
->hasSubpages();
216 $oldTitleTalkSubpages = $this->oldTitle
->getTalkPage()->hasSubpages();
218 $canMoveSubpage = ( $oldTitleSubpages ||
$oldTitleTalkSubpages ) &&
219 !count( $this->oldTitle
->getUserPermissionsErrors( 'move-subpages', $user ) );
221 # We also want to be able to move assoc. subpage talk-pages even if base page
222 # has no associated talk page, so || with $oldTitleTalkSubpages.
223 $considerTalk = !$this->oldTitle
->isTalkPage() &&
225 ||
( $oldTitleTalkSubpages && $canMoveSubpage ) );
227 $dbr = wfGetDB( DB_REPLICA
);
228 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
229 $hasRedirects = $dbr->selectField( 'redirect', '1',
231 'rd_namespace' => $this->oldTitle
->getNamespace(),
232 'rd_title' => $this->oldTitle
->getDBkey(),
235 $hasRedirects = false;
238 if ( count( $err ) ) {
239 if ( $isPermError ) {
240 $action_desc = $this->msg( 'action-move' )->plain();
241 $errMsgHtml = $this->msg( 'permissionserrorstext-withaction',
242 count( $err ), $action_desc )->parseAsBlock();
244 $errMsgHtml = $this->msg( 'cannotmove', count( $err ) )->parseAsBlock();
247 if ( count( $err ) == 1 ) {
249 $errMsgName = array_shift( $errMsg );
251 if ( $errMsgName == 'hookaborted' ) {
252 $errMsgHtml .= "<p>{$errMsg[0]}</p>\n";
254 $errMsgHtml .= $this->msg( $errMsgName, $errMsg )->parseAsBlock();
259 foreach ( $err as $errMsg ) {
260 if ( $errMsg[0] == 'hookaborted' ) {
261 $errStr[] = $errMsg[1];
263 $errMsgName = array_shift( $errMsg );
264 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
268 $errMsgHtml .= '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n";
270 $out->addHTML( Html
::errorBox( $errMsgHtml ) );
273 if ( $this->oldTitle
->isProtected( 'move' ) ) {
274 # Is the title semi-protected?
275 if ( $this->oldTitle
->isSemiProtected( 'move' ) ) {
276 $noticeMsg = 'semiprotectedpagemovewarning';
277 $classes[] = 'mw-textarea-sprotected';
279 # Then it must be protected based on static groups (regular)
280 $noticeMsg = 'protectedpagemovewarning';
281 $classes[] = 'mw-textarea-protected';
283 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
284 $out->addWikiMsg( $noticeMsg );
285 LogEventsList
::showLogExtract(
292 $out->addHTML( "</div>\n" );
295 // Length limit for wpReason and wpNewTitleMain is enforced in the
296 // mediawiki.special.movePage module
298 $immovableNamespaces = [];
299 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
300 if ( !MWNamespace
::isMovable( $nsId ) ) {
301 $immovableNamespaces[] = $nsId;
305 $handler = ContentHandler
::getForTitle( $this->oldTitle
);
310 $fields[] = new OOUI\
FieldLayout(
311 new MediaWiki\Widget\
ComplexTitleInputWidget( [
312 'id' => 'wpNewTitle',
314 'id' => 'wpNewTitleNs',
315 'name' => 'wpNewTitleNs',
316 'value' => $newTitle->getNamespace(),
317 'exclude' => $immovableNamespaces,
320 'id' => 'wpNewTitleMain',
321 'name' => 'wpNewTitleMain',
322 'value' => $newTitle->getText(),
323 // Inappropriate, since we're expecting the user to input a non-existent page's title
324 'suggestions' => false,
329 'label' => $this->msg( 'newtitle' )->text(),
334 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
335 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
336 // Unicode codepoints (or 255 UTF-8 bytes for old schema).
337 $conf = $this->getConfig();
338 $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD
;
339 $fields[] = new OOUI\
FieldLayout(
340 new OOUI\
TextInputWidget( [
341 'name' => 'wpReason',
343 'maxLength' => $oldCommentSchema ?
200 : CommentStore
::COMMENT_CHARACTER_LIMIT
,
345 'value' => $this->reason
,
348 'label' => $this->msg( 'movereason' )->text(),
353 if ( $considerTalk ) {
354 $fields[] = new OOUI\
FieldLayout(
355 new OOUI\
CheckboxInputWidget( [
356 'name' => 'wpMovetalk',
357 'id' => 'wpMovetalk',
359 'selected' => $this->moveTalk
,
362 'label' => $this->msg( 'movetalk' )->text(),
363 'help' => new OOUI\
HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
364 'helpInline' => true,
366 'id' => 'wpMovetalk-field',
371 if ( $user->isAllowed( 'suppressredirect' ) ) {
372 if ( $handler->supportsRedirects() ) {
373 $isChecked = $this->leaveRedirect
;
379 $fields[] = new OOUI\
FieldLayout(
380 new OOUI\
CheckboxInputWidget( [
381 'name' => 'wpLeaveRedirect',
382 'id' => 'wpLeaveRedirect',
384 'selected' => $isChecked,
385 'disabled' => $isDisabled,
388 'label' => $this->msg( 'move-leave-redirect' )->text(),
394 if ( $hasRedirects ) {
395 $fields[] = new OOUI\
FieldLayout(
396 new OOUI\
CheckboxInputWidget( [
397 'name' => 'wpFixRedirects',
398 'id' => 'wpFixRedirects',
400 'selected' => $this->fixRedirects
,
403 'label' => $this->msg( 'fix-double-redirects' )->text(),
409 if ( $canMoveSubpage ) {
410 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
411 $fields[] = new OOUI\
FieldLayout(
412 new OOUI\
CheckboxInputWidget( [
413 'name' => 'wpMovesubpages',
414 'id' => 'wpMovesubpages',
416 # Don't check the box if we only have talk subpages to
417 # move and we aren't moving the talk page.
418 'selected' => $this->moveSubpages
&& ( $this->oldTitle
->hasSubpages() ||
$this->moveTalk
),
421 'label' => new OOUI\
HtmlSnippet(
423 ( $this->oldTitle
->hasSubpages()
425 : 'move-talk-subpages' )
426 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
433 # Don't allow watching if user is not logged in
434 if ( $user->isLoggedIn() ) {
435 $watchChecked = $user->isLoggedIn() && ( $this->watch ||
$user->getBoolOption( 'watchmoves' )
436 ||
$user->isWatched( $this->oldTitle
) );
437 $fields[] = new OOUI\
FieldLayout(
438 new OOUI\
CheckboxInputWidget( [
440 'id' => 'watch', # ew
442 'selected' => $watchChecked,
445 'label' => $this->msg( 'move-watch' )->text(),
452 if ( $moveOverShared ) {
453 $hiddenFields .= Html
::hidden( 'wpMoveOverSharedFile', '1' );
456 if ( $deleteAndMove ) {
457 $fields[] = new OOUI\
FieldLayout(
458 new OOUI\
CheckboxInputWidget( [
459 'name' => 'wpDeleteAndMove',
460 'id' => 'wpDeleteAndMove',
464 'label' => $this->msg( 'delete_and_move_confirm' )->text(),
470 $fields[] = new OOUI\
FieldLayout(
471 new OOUI\
ButtonInputWidget( [
473 'value' => $this->msg( 'movepagebtn' )->text(),
474 'label' => $this->msg( 'movepagebtn' )->text(),
475 'flags' => [ 'primary', 'progressive' ],
483 $fieldset = new OOUI\
FieldsetLayout( [
484 'label' => $this->msg( 'move-page-legend' )->text(),
485 'id' => 'mw-movepage-table',
489 $form = new OOUI\
FormLayout( [
491 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
494 $form->appendContent(
496 new OOUI\
HtmlSnippet(
498 Html
::hidden( 'wpOldTitle', $this->oldTitle
->getPrefixedText() ) .
499 Html
::hidden( 'wpEditToken', $user->getEditToken() )
504 new OOUI\
PanelLayout( [
505 'classes' => [ 'movepage-wrapper' ],
513 $this->showLogFragment( $this->oldTitle
);
514 $this->showSubpages( $this->oldTitle
);
517 function doSubmit() {
518 $user = $this->getUser();
520 if ( $user->pingLimiter( 'move' ) ) {
521 throw new ThrottledError
;
524 $ot = $this->oldTitle
;
525 $nt = $this->newTitle
;
527 # don't allow moving to pages with # in
528 if ( !$nt ||
$nt->hasFragment() ) {
529 $this->showForm( [ [ 'badtitletext' ] ] );
534 # Show a warning if the target file exists on a shared repo
535 if ( $nt->getNamespace() == NS_FILE
536 && !( $this->moveOverShared
&& $user->isAllowed( 'reupload-shared' ) )
537 && !RepoGroup
::singleton()->getLocalRepo()->findFile( $nt )
540 $this->showForm( [ [ 'file-exists-sharedrepo' ] ] );
545 # Delete to make way if requested
546 if ( $this->deleteAndMove
) {
547 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
548 if ( count( $permErrors ) ) {
549 # Only show the first error
550 $this->showForm( $permErrors, true );
555 $page = WikiPage
::factory( $nt );
557 // Small safety margin to guard against concurrent edits
558 if ( $page->isBatchedDelete( 5 ) ) {
559 $this->showForm( [ [ 'movepage-delete-first' ] ] );
564 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
566 // Delete an associated image if there is
567 if ( $nt->getNamespace() == NS_FILE
) {
568 $file = wfLocalFile( $nt );
569 $file->load( File
::READ_LATEST
);
570 if ( $file->exists() ) {
571 $file->delete( $reason, false, $user );
575 $error = ''; // passed by ref
576 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
577 if ( !$deleteStatus->isGood() ) {
578 $this->showForm( $deleteStatus->getErrorsArray() );
584 $handler = ContentHandler
::getForTitle( $ot );
586 if ( !$handler->supportsRedirects() ) {
587 $createRedirect = false;
588 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
589 $createRedirect = $this->leaveRedirect
;
591 $createRedirect = true;
594 # Do the actual move.
595 $mp = new MovePage( $ot, $nt );
596 $valid = $mp->isValidMove();
597 if ( !$valid->isOK() ) {
598 $this->showForm( $valid->getErrorsArray() );
602 $permStatus = $mp->checkPermissions( $user, $this->reason
);
603 if ( !$permStatus->isOK() ) {
604 $this->showForm( $permStatus->getErrorsArray(), true );
608 $status = $mp->move( $user, $this->reason
, $createRedirect );
609 if ( !$status->isOK() ) {
610 $this->showForm( $status->getErrorsArray() );
614 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects
) {
615 DoubleRedirectJob
::fixRedirects( 'move', $ot, $nt );
618 $out = $this->getOutput();
619 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
621 $linkRenderer = $this->getLinkRenderer();
622 $oldLink = $linkRenderer->makeLink(
625 [ 'id' => 'movepage-oldlink' ],
626 [ 'redirect' => 'no' ]
628 $newLink = $linkRenderer->makeKnownLink(
631 [ 'id' => 'movepage-newlink' ]
633 $oldText = $ot->getPrefixedText();
634 $newText = $nt->getPrefixedText();
636 if ( $ot->exists() ) {
637 // NOTE: we assume that if the old title exists, it's because it was re-created as
638 // a redirect to the new title. This is not safe, but what we did before was
639 // even worse: we just determined whether a redirect should have been created,
640 // and reported that it was created if it should have, without any checks.
641 // Also note that isRedirect() is unreliable because of T39209.
642 $msgName = 'movepage-moved-redirect';
644 $msgName = 'movepage-moved-noredirect';
647 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
648 $newLink )->params( $oldText, $newText )->parseAsBlock() );
649 $out->addWikiMsg( $msgName );
651 // Avoid PHP 7.1 warning from passing $this by reference
653 Hooks
::run( 'SpecialMovepageAfterMove', [ &$movePage, &$ot, &$nt ] );
655 # Now we move extra pages we've been asked to move: subpages and talk
656 # pages. First, if the old page or the new page is a talk page, we
657 # can't move any talk pages: cancel that.
658 if ( $ot->isTalkPage() ||
$nt->isTalkPage() ) {
659 $this->moveTalk
= false;
662 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
663 $this->moveSubpages
= false;
667 * Next make a list of id's. This might be marginally less efficient
668 * than a more direct method, but this is not a highly performance-cri-
669 * tical code path and readable code is more important here.
671 * If the target namespace doesn't allow subpages, moving with subpages
672 * would mean that you couldn't move them back in one operation, which
674 * @todo FIXME: A specific error message should be given in this case.
677 // @todo FIXME: Use Title::moveSubpages() here
678 $dbr = wfGetDB( DB_MASTER
);
679 if ( $this->moveSubpages
&& (
680 MWNamespace
::hasSubpages( $nt->getNamespace() ) ||
(
682 && MWNamespace
::hasSubpages( $nt->getTalkPage()->getNamespace() )
686 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
687 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
689 $conds['page_namespace'] = [];
690 if ( MWNamespace
::hasSubpages( $nt->getNamespace() ) ) {
691 $conds['page_namespace'][] = $ot->getNamespace();
693 if ( $this->moveTalk
&&
694 MWNamespace
::hasSubpages( $nt->getTalkPage()->getNamespace() )
696 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
698 } elseif ( $this->moveTalk
) {
700 'page_namespace' => $ot->getTalkPage()->getNamespace(),
701 'page_title' => $ot->getDBkey()
709 if ( !is_null( $conds ) ) {
710 $extraPages = TitleArray
::newFromResult(
711 $dbr->select( 'page',
712 [ 'page_id', 'page_namespace', 'page_title' ],
721 foreach ( $extraPages as $oldSubpage ) {
722 if ( $ot->equals( $oldSubpage ) ||
$nt->equals( $oldSubpage ) ) {
723 # Already did this one.
727 $newPageName = preg_replace(
728 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
729 StringUtils
::escapeRegexReplacement( $nt->getDBkey() ), # T23234
730 $oldSubpage->getDBkey()
733 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
734 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
735 $newNs = $nt->getNamespace();
736 } elseif ( $oldSubpage->isTalkPage() ) {
737 $newNs = $nt->getTalkPage()->getNamespace();
739 $newNs = $nt->getSubjectPage()->getNamespace();
742 # T16385: we need makeTitleSafe because the new page names may
743 # be longer than 255 characters.
744 $newSubpage = Title
::makeTitleSafe( $newNs, $newPageName );
745 if ( !$newSubpage ) {
746 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
747 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
748 ->params( Title
::makeName( $newNs, $newPageName ) )->escaped();
752 # This was copy-pasted from Renameuser, bleh.
753 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
754 $link = $linkRenderer->makeKnownLink( $newSubpage );
755 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
757 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason
, $createRedirect );
759 if ( $success === true ) {
760 if ( $this->fixRedirects
) {
761 DoubleRedirectJob
::fixRedirects( 'move', $oldSubpage, $newSubpage );
763 $oldLink = $linkRenderer->makeLink(
767 [ 'redirect' => 'no' ]
770 $newLink = $linkRenderer->makeKnownLink( $newSubpage );
771 $extraOutput[] = $this->msg( 'movepage-page-moved' )
772 ->rawParams( $oldLink, $newLink )->escaped();
775 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
776 if ( $count >= $maximumMovedPages ) {
777 $extraOutput[] = $this->msg( 'movepage-max-pages' )
778 ->numParams( $maximumMovedPages )->escaped();
782 $oldLink = $linkRenderer->makeKnownLink( $oldSubpage );
783 $newLink = $linkRenderer->makeLink( $newSubpage );
784 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
785 ->rawParams( $oldLink, $newLink )->escaped();
790 if ( $extraOutput !== [] ) {
791 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
794 # Deal with watches (we don't watch subpages)
795 WatchAction
::doWatchOrUnwatch( $this->watch
, $ot, $user );
796 WatchAction
::doWatchOrUnwatch( $this->watch
, $nt, $user );
799 function showLogFragment( $title ) {
800 $moveLogPage = new LogPage( 'move' );
801 $out = $this->getOutput();
802 $out->addHTML( Xml
::element( 'h2', null, $moveLogPage->getName()->text() ) );
803 LogEventsList
::showLogExtract( $out, 'move', $title );
807 * Show subpages of the page being moved. Section is not shown if both current
808 * namespace does not support subpages and no talk subpages were found.
810 * @param Title $title Page being moved.
812 function showSubpages( $title ) {
813 $nsHasSubpages = MWNamespace
::hasSubpages( $title->getNamespace() );
814 $subpages = $title->getSubpages();
815 $count = $subpages instanceof TitleArray ?
$subpages->count() : 0;
817 $titleIsTalk = $title->isTalkPage();
818 $subpagesTalk = $title->getTalkPage()->getSubpages();
819 $countTalk = $subpagesTalk instanceof TitleArray ?
$subpagesTalk->count() : 0;
820 $totalCount = $count +
$countTalk;
822 if ( !$nsHasSubpages && $countTalk == 0 ) {
826 $this->getOutput()->wrapWikiMsg(
828 [ 'movesubpage', ( $titleIsTalk ?
$count : $totalCount ) ]
831 if ( $nsHasSubpages ) {
832 $this->showSubpagesList( $subpages, $count, 'movesubpagetext', true );
835 if ( !$titleIsTalk && $countTalk > 0 ) {
836 $this->showSubpagesList( $subpagesTalk, $countTalk, 'movesubpagetalktext' );
840 function showSubpagesList( $subpages, $pagecount, $wikiMsg, $noSubpageMsg = false ) {
841 $out = $this->getOutput();
844 if ( $pagecount == 0 && $noSubpageMsg ) {
845 $out->addWikiMsg( 'movenosubpage' );
849 $out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
850 $out->addHTML( "<ul>\n" );
852 $linkBatch = new LinkBatch( $subpages );
853 $linkBatch->setCaller( __METHOD__
);
854 $linkBatch->execute();
855 $linkRenderer = $this->getLinkRenderer();
857 foreach ( $subpages as $subpage ) {
858 $link = $linkRenderer->makeLink( $subpage );
859 $out->addHTML( "<li>$link</li>\n" );
861 $out->addHTML( "</ul>\n" );
865 * Return an array of subpages beginning with $search that this special page will accept.
867 * @param string $search Prefix to search for
868 * @param int $limit Maximum number of results to return (usually 10)
869 * @param int $offset Number of results to skip (usually 0)
870 * @return string[] Matching subpages
872 public function prefixSearchSubpages( $search, $limit, $offset ) {
873 return $this->prefixSearchString( $search, $limit, $offset );
876 protected function getGroupName() {