Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / includes / specials / SpecialMovepage.php
blobcac324ac009dd0a7e3e44aaad7dcd107db53560f
1 <?php
2 /**
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
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * A special page that allows users to change page titles
27 * @ingroup SpecialPage
29 class MovePageForm extends UnlistedSpecialPage {
30 /** @var Title */
31 protected $oldTitle;
33 /** @var Title */
34 protected $newTitle;
37 /** @var string Text input */
38 protected $reason;
40 // Checks
42 /** @var bool */
43 protected $moveTalk;
45 /** @var bool */
46 protected $deleteAndMove;
48 /** @var bool */
49 protected $moveSubpages;
51 /** @var bool */
52 protected $fixRedirects;
54 /** @var bool */
55 protected $leaveRedirect;
57 /** @var bool */
58 protected $moveOverShared;
60 private $watch = false;
62 public function __construct() {
63 parent::__construct( 'Movepage' );
66 public function execute( $par ) {
67 $this->checkReadOnly();
69 $this->setHeaders();
70 $this->outputHeader();
72 $request = $this->getRequest();
73 $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
75 // Yes, the use of getVal() and getText() is wanted, see bug 20365
77 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
78 $this->oldTitle = Title::newFromText( $oldTitleText );
80 if ( is_null( $this->oldTitle ) ) {
81 throw new ErrorPageError( 'notargettitle', 'notargettext' );
83 if ( !$this->oldTitle->exists() ) {
84 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
87 $newTitleTextMain = $request->getText( 'wpNewTitleMain' );
88 $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() );
89 // Backwards compatibility for forms submitting here from other sources
90 // which is more common than it should be..
91 $newTitleText_bc = $request->getText( 'wpNewTitle' );
92 $this->newTitle = strlen( $newTitleText_bc ) > 0
93 ? Title::newFromText( $newTitleText_bc )
94 : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain );
96 $user = $this->getUser();
98 # Check rights
99 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
100 if ( count( $permErrors ) ) {
101 // Auto-block user's IP if the account was "hard" blocked
102 $user->spreadAnyEditBlock();
103 throw new PermissionsError( 'move', $permErrors );
106 $def = !$request->wasPosted();
108 $this->reason = $request->getText( 'wpReason' );
109 $this->moveTalk = $request->getBool( 'wpMovetalk', $def );
110 $this->fixRedirects = $request->getBool( 'wpFixRedirects', $def );
111 $this->leaveRedirect = $request->getBool( 'wpLeaveRedirect', $def );
112 $this->moveSubpages = $request->getBool( 'wpMovesubpages', false );
113 $this->deleteAndMove = $request->getBool( 'wpDeleteAndMove' ) && $request->getBool( 'wpConfirm' );
114 $this->moveOverShared = $request->getBool( 'wpMoveOverSharedFile', false );
115 $this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
117 if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted()
118 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
120 $this->doSubmit();
121 } else {
122 $this->showForm( array() );
127 * Show the form
129 * @param array $err Error messages. Each item is an error message.
130 * It may either be a string message name or array message name and
131 * parameters, like the second argument to OutputPage::wrapWikiMsg().
133 function showForm( $err ) {
134 global $wgContLang;
136 $this->getSkin()->setRelevantTitle( $this->oldTitle );
138 $oldTitleLink = Linker::link( $this->oldTitle );
140 $out = $this->getOutput();
141 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
142 $out->addModules( 'mediawiki.special.movePage' );
144 $newTitle = $this->newTitle;
146 if ( !$newTitle ) {
147 # Show the current title as a default
148 # when the form is first opened.
149 $newTitle = $this->oldTitle;
150 } elseif ( !count( $err ) ) {
151 # If a title was supplied, probably from the move log revert
152 # link, check for validity. We can then show some diagnostic
153 # information and save a click.
154 $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
155 if ( is_array( $newerr ) ) {
156 $err = $newerr;
160 $user = $this->getUser();
162 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
163 && $newTitle->quickUserCan( 'delete', $user )
165 $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
166 $movepagebtn = $this->msg( 'delete_and_move' )->text();
167 $submitVar = 'wpDeleteAndMove';
168 $confirm = true;
169 $err = array();
170 } else {
171 if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
172 $out->wrapWikiMsg(
173 "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>",
174 'moveuserpage-warning'
176 } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
177 $out->wrapWikiMsg(
178 "<div class=\"error mw-movecategorypage-warning\">\n$1\n</div>",
179 'movecategorypage-warning'
183 $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
184 'movepagetext' :
185 'movepagetext-noredirectfixer'
187 $movepagebtn = $this->msg( 'movepagebtn' )->text();
188 $submitVar = 'wpMove';
189 $confirm = false;
192 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
193 && $user->isAllowed( 'reupload-shared' )
195 $out->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() );
196 $submitVar = 'wpMoveOverSharedFile';
197 $err = array();
200 $oldTalk = $this->oldTitle->getTalkPage();
201 $oldTitleSubpages = $this->oldTitle->hasSubpages();
202 $oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
204 $canMoveSubpage = ( $oldTitleSubpages || $oldTitleTalkSubpages ) &&
205 !count( $this->oldTitle->getUserPermissionsErrors( 'move-subpages', $user ) );
207 # We also want to be able to move assoc. subpage talk-pages even if base page
208 # has no associated talk page, so || with $oldTitleTalkSubpages.
209 $considerTalk = !$this->oldTitle->isTalkPage() &&
210 ( $oldTalk->exists()
211 || ( $oldTitleTalkSubpages && $canMoveSubpage ) );
213 $dbr = wfGetDB( DB_SLAVE );
214 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) {
215 $hasRedirects = $dbr->selectField( 'redirect', '1',
216 array(
217 'rd_namespace' => $this->oldTitle->getNamespace(),
218 'rd_title' => $this->oldTitle->getDBkey(),
219 ), __METHOD__ );
220 } else {
221 $hasRedirects = false;
224 if ( $considerTalk ) {
225 $out->addWikiMsg( 'movepagetalktext' );
228 if ( count( $err ) ) {
229 $out->addHTML( "<div class='error'>\n" );
230 $action_desc = $this->msg( 'action-move' )->plain();
231 $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
233 if ( count( $err ) == 1 ) {
234 $errMsg = $err[0];
235 $errMsgName = array_shift( $errMsg );
237 if ( $errMsgName == 'hookaborted' ) {
238 $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
239 } else {
240 $out->addWikiMsgArray( $errMsgName, $errMsg );
242 } else {
243 $errStr = array();
245 foreach ( $err as $errMsg ) {
246 if ( $errMsg[0] == 'hookaborted' ) {
247 $errStr[] = $errMsg[1];
248 } else {
249 $errMsgName = array_shift( $errMsg );
250 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
254 $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
256 $out->addHTML( "</div>\n" );
259 if ( $this->oldTitle->isProtected( 'move' ) ) {
260 # Is the title semi-protected?
261 if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
262 $noticeMsg = 'semiprotectedpagemovewarning';
263 $classes[] = 'mw-textarea-sprotected';
264 } else {
265 # Then it must be protected based on static groups (regular)
266 $noticeMsg = 'protectedpagemovewarning';
267 $classes[] = 'mw-textarea-protected';
269 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
270 $out->addWikiMsg( $noticeMsg );
271 LogEventsList::showLogExtract(
272 $out,
273 'protect',
274 $this->oldTitle,
276 array( 'lim' => 1 )
278 $out->addHTML( "</div>\n" );
281 // Byte limit (not string length limit) for wpReason and wpNewTitleMain
282 // is enforced in the mediawiki.special.movePage module
284 $immovableNamespaces = array();
286 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
287 if ( !MWNamespace::isMovable( $nsId ) ) {
288 $immovableNamespaces[] = $nsId;
292 $handler = ContentHandler::getForTitle( $this->oldTitle );
294 $out->addHTML(
295 Xml::openElement(
296 'form',
297 array(
298 'method' => 'post',
299 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
300 'id' => 'movepage'
303 Xml::openElement( 'fieldset' ) .
304 Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
305 Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) )
308 $out->addHTML(
309 "<tr>
310 <td class='mw-label'>" .
311 $this->msg( 'movearticle' )->escaped() .
312 "</td>
313 <td class='mw-input'>
314 <strong>{$oldTitleLink}</strong>
315 </td>
316 </tr>
317 <tr>
318 <td class='mw-label'>" .
319 Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) .
320 "</td>
321 <td class='mw-input'>" .
322 Html::namespaceSelector(
323 array(
324 'selected' => $newTitle->getNamespace(),
325 'exclude' => $immovableNamespaces
327 array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
329 Xml::input(
330 'wpNewTitleMain',
332 $wgContLang->recodeForEdit( $newTitle->getText() ),
333 array(
334 'type' => 'text',
335 'id' => 'wpNewTitleMain',
336 'maxlength' => 255
339 Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
340 "</td>
341 </tr>
342 <tr>
343 <td class='mw-label'>" .
344 Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) .
345 "</td>
346 <td class='mw-input'>" .
347 Xml::input( 'wpReason', 60, $this->reason, array(
348 'type' => 'text',
349 'id' => 'wpReason',
350 'maxlength' => 200,
351 ) ) .
352 "</td>
353 </tr>"
356 if ( $considerTalk ) {
357 $out->addHTML( "
358 <tr>
359 <td></td>
360 <td class='mw-input'>" .
361 Xml::checkLabel(
362 $this->msg( 'movetalk' )->text(),
363 'wpMovetalk',
364 'wpMovetalk',
365 $this->moveTalk
367 "</td>
368 </tr>"
372 if ( $user->isAllowed( 'suppressredirect' ) ) {
373 if ( $handler->supportsRedirects() ) {
374 $isChecked = $this->leaveRedirect;
375 $options = array();
376 } else {
377 $isChecked = false;
378 $options = array(
379 'disabled' => 'disabled'
382 $out->addHTML( "
383 <tr>
384 <td></td>
385 <td class='mw-input'>" .
386 Xml::checkLabel(
387 $this->msg( 'move-leave-redirect' )->text(),
388 'wpLeaveRedirect',
389 'wpLeaveRedirect',
390 $isChecked,
391 $options
393 "</td>
394 </tr>"
398 if ( $hasRedirects ) {
399 $out->addHTML( "
400 <tr>
401 <td></td>
402 <td class='mw-input'>" .
403 Xml::checkLabel(
404 $this->msg( 'fix-double-redirects' )->text(),
405 'wpFixRedirects',
406 'wpFixRedirects',
407 $this->fixRedirects
409 "</td>
410 </tr>"
414 if ( $canMoveSubpage ) {
415 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
416 $out->addHTML( "
417 <tr>
418 <td></td>
419 <td class='mw-input'>" .
420 Xml::check(
421 'wpMovesubpages',
422 # Don't check the box if we only have talk subpages to
423 # move and we aren't moving the talk page.
424 $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ),
425 array( 'id' => 'wpMovesubpages' )
426 ) . '&#160;' .
427 Xml::tags(
428 'label',
429 array( 'for' => 'wpMovesubpages' ),
430 $this->msg(
431 ( $this->oldTitle->hasSubpages()
432 ? 'move-subpages'
433 : 'move-talk-subpages' )
434 )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse()
436 "</td>
437 </tr>"
441 $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
442 || $user->isWatched( $this->oldTitle ) );
443 # Don't allow watching if user is not logged in
444 if ( $user->isLoggedIn() ) {
445 $out->addHTML( "
446 <tr>
447 <td></td>
448 <td class='mw-input'>" .
449 Xml::checkLabel(
450 $this->msg( 'move-watch' )->text(),
451 'wpWatch',
452 'watch',
453 $watchChecked
455 "</td>
456 </tr>"
460 if ( $confirm ) {
461 $out->addHTML( "
462 <tr>
463 <td></td>
464 <td class='mw-input'>" .
465 Xml::checkLabel(
466 $this->msg( 'delete_and_move_confirm' )->text(),
467 'wpConfirm',
468 'wpConfirm'
470 "</td>
471 </tr>"
475 $out->addHTML( "
476 <tr>
477 <td></td>
478 <td class='mw-submit'>" .
479 Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
480 "</td>
481 </tr>"
484 $out->addHTML(
485 Xml::closeElement( 'table' ) .
486 Html::hidden( 'wpEditToken', $user->getEditToken() ) .
487 Xml::closeElement( 'fieldset' ) .
488 Xml::closeElement( 'form' ) .
489 "\n"
492 $this->showLogFragment( $this->oldTitle );
493 $this->showSubpages( $this->oldTitle );
496 function doSubmit() {
497 $user = $this->getUser();
499 if ( $user->pingLimiter( 'move' ) ) {
500 throw new ThrottledError;
503 $ot = $this->oldTitle;
504 $nt = $this->newTitle;
506 # don't allow moving to pages with # in
507 if ( !$nt || $nt->hasFragment() ) {
508 $this->showForm( array( array( 'badtitletext' ) ) );
510 return;
513 # Show a warning if the target file exists on a shared repo
514 if ( $nt->getNamespace() == NS_FILE
515 && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
516 && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
517 && wfFindFile( $nt )
519 $this->showForm( array( array( 'file-exists-sharedrepo' ) ) );
521 return;
524 # Delete to make way if requested
525 if ( $this->deleteAndMove ) {
526 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
527 if ( count( $permErrors ) ) {
528 # Only show the first error
529 $this->showForm( $permErrors );
531 return;
534 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
536 // Delete an associated image if there is
537 if ( $nt->getNamespace() == NS_FILE ) {
538 $file = wfLocalFile( $nt );
539 if ( $file->exists() ) {
540 $file->delete( $reason, false );
544 $error = ''; // passed by ref
545 $page = WikiPage::factory( $nt );
546 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
547 if ( !$deleteStatus->isGood() ) {
548 $this->showForm( $deleteStatus->getErrorsArray() );
550 return;
554 $handler = ContentHandler::getForTitle( $ot );
556 if ( !$handler->supportsRedirects() ) {
557 $createRedirect = false;
558 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
559 $createRedirect = $this->leaveRedirect;
560 } else {
561 $createRedirect = true;
564 # Do the actual move.
565 $mp = new MovePage( $ot, $nt );
566 $valid = $mp->isValidMove();
567 if ( !$valid->isOK() ) {
568 $this->showForm( $valid->getErrorsArray() );
569 return;
572 $permStatus = $mp->checkPermissions( $user, $this->reason );
573 if ( !$permStatus->isOK() ) {
574 $this->showForm( $permStatus->getErrorsArray() );
575 return;
578 $status = $mp->move( $user, $this->reason, $createRedirect );
579 if ( !$status->isOK() ) {
580 $this->showForm( $status->getErrorsArray() );
581 return;
584 if ( $this->getConfig()->get( 'FixDoubleRedirects' ) && $this->fixRedirects ) {
585 DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
588 $out = $this->getOutput();
589 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
591 $oldLink = Linker::link(
592 $ot,
593 null,
594 array( 'id' => 'movepage-oldlink' ),
595 array( 'redirect' => 'no' )
597 $newLink = Linker::linkKnown(
598 $nt,
599 null,
600 array( 'id' => 'movepage-newlink' )
602 $oldText = $ot->getPrefixedText();
603 $newText = $nt->getPrefixedText();
605 if ( $ot->exists() ) {
606 //NOTE: we assume that if the old title exists, it's because it was re-created as
607 // a redirect to the new title. This is not safe, but what we did before was
608 // even worse: we just determined whether a redirect should have been created,
609 // and reported that it was created if it should have, without any checks.
610 // Also note that isRedirect() is unreliable because of bug 37209.
611 $msgName = 'movepage-moved-redirect';
612 } else {
613 $msgName = 'movepage-moved-noredirect';
616 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
617 $newLink )->params( $oldText, $newText )->parseAsBlock() );
618 $out->addWikiMsg( $msgName );
620 Hooks::run( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
622 # Now we move extra pages we've been asked to move: subpages and talk
623 # pages. First, if the old page or the new page is a talk page, we
624 # can't move any talk pages: cancel that.
625 if ( $ot->isTalkPage() || $nt->isTalkPage() ) {
626 $this->moveTalk = false;
629 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
630 $this->moveSubpages = false;
633 # Next make a list of id's. This might be marginally less efficient
634 # than a more direct method, but this is not a highly performance-cri-
635 # tical code path and readable code is more important here.
637 # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
638 # 4 might get confused. If so, consider rewriting as a UNION.
640 # If the target namespace doesn't allow subpages, moving with subpages
641 # would mean that you couldn't move them back in one operation, which
642 # is bad.
643 # @todo FIXME: A specific error message should be given in this case.
645 // @todo FIXME: Use Title::moveSubpages() here
646 $dbr = wfGetDB( DB_MASTER );
647 if ( $this->moveSubpages && (
648 MWNamespace::hasSubpages( $nt->getNamespace() ) || (
649 $this->moveTalk
650 && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
652 ) ) {
653 $conds = array(
654 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
655 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
657 $conds['page_namespace'] = array();
658 if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
659 $conds['page_namespace'][] = $ot->getNamespace();
661 if ( $this->moveTalk &&
662 MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
664 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
666 } elseif ( $this->moveTalk ) {
667 $conds = array(
668 'page_namespace' => $ot->getTalkPage()->getNamespace(),
669 'page_title' => $ot->getDBkey()
671 } else {
672 # Skip the query
673 $conds = null;
676 $extraPages = array();
677 if ( !is_null( $conds ) ) {
678 $extraPages = TitleArray::newFromResult(
679 $dbr->select( 'page',
680 array( 'page_id', 'page_namespace', 'page_title' ),
681 $conds,
682 __METHOD__
687 $extraOutput = array();
688 $count = 1;
689 foreach ( $extraPages as $oldSubpage ) {
690 if ( $ot->equals( $oldSubpage ) || $nt->equals( $oldSubpage ) ) {
691 # Already did this one.
692 continue;
695 $newPageName = preg_replace(
696 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
697 StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
698 $oldSubpage->getDBkey()
701 if ( $oldSubpage->isSubpage() && ( $ot->isTalkPage() xor $nt->isTalkPage() ) ) {
702 // Moving a subpage from a subject namespace to a talk namespace or vice-versa
703 $newNs = $nt->getNamespace();
704 } elseif ( $oldSubpage->isTalkPage() ) {
705 $newNs = $nt->getTalkPage()->getNamespace();
706 } else {
707 $newNs = $nt->getSubjectPage()->getNamespace();
710 # Bug 14385: we need makeTitleSafe because the new page names may
711 # be longer than 255 characters.
712 $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
713 if ( !$newSubpage ) {
714 $oldLink = Linker::linkKnown( $oldSubpage );
715 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
716 ->params( Title::makeName( $newNs, $newPageName ) )->escaped();
717 continue;
720 # This was copy-pasted from Renameuser, bleh.
721 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
722 $link = Linker::linkKnown( $newSubpage );
723 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
724 } else {
725 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
727 if ( $success === true ) {
728 if ( $this->fixRedirects ) {
729 DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
731 $oldLink = Linker::link(
732 $oldSubpage,
733 null,
734 array(),
735 array( 'redirect' => 'no' )
738 $newLink = Linker::linkKnown( $newSubpage );
739 $extraOutput[] = $this->msg( 'movepage-page-moved' )
740 ->rawParams( $oldLink, $newLink )->escaped();
741 ++$count;
743 $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' );
744 if ( $count >= $maximumMovedPages ) {
745 $extraOutput[] = $this->msg( 'movepage-max-pages' )
746 ->numParams( $maximumMovedPages )->escaped();
747 break;
749 } else {
750 $oldLink = Linker::linkKnown( $oldSubpage );
751 $newLink = Linker::link( $newSubpage );
752 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
753 ->rawParams( $oldLink, $newLink )->escaped();
758 if ( $extraOutput !== array() ) {
759 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
762 # Deal with watches (we don't watch subpages)
763 WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user );
764 WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user );
767 function showLogFragment( $title ) {
768 $moveLogPage = new LogPage( 'move' );
769 $out = $this->getOutput();
770 $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
771 LogEventsList::showLogExtract( $out, 'move', $title );
774 function showSubpages( $title ) {
775 if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
776 return;
779 $subpages = $title->getSubpages();
780 $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
782 $out = $this->getOutput();
783 $out->wrapWikiMsg( '== $1 ==', array( 'movesubpage', $count ) );
785 # No subpages.
786 if ( $count == 0 ) {
787 $out->addWikiMsg( 'movenosubpage' );
789 return;
792 $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
793 $out->addHTML( "<ul>\n" );
795 foreach ( $subpages as $subpage ) {
796 $link = Linker::link( $subpage );
797 $out->addHTML( "<li>$link</li>\n" );
799 $out->addHTML( "</ul>\n" );
802 protected function getGroupName() {
803 return 'pagetools';