Use camel case for variable names in Article.php
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
1 <?php
2 /**
3 * Implements Special:Movepage
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that allows users to change page titles
26 *
27 * @ingroup SpecialPage
28 */
29 class MovePageForm extends UnlistedSpecialPage {
30 /** @var Title */
31 protected $oldTitle;
32
33 /** @var Title */
34 protected $newTitle;
35
36
37 /** @var string Text input */
38 protected $reason;
39
40 // Checks
41
42 /** @var bool */
43 protected $moveTalk;
44
45 /** @var bool */
46 protected $deleteAndMove;
47
48 /** @var bool */
49 protected $moveSubpages;
50
51 /** @var bool */
52 protected $fixRedirects;
53
54 /** @var bool */
55 protected $leaveRedirect;
56
57 /** @var bool */
58 protected $moveOverShared;
59
60 private $watch = false;
61
62 public function __construct() {
63 parent::__construct( 'Movepage' );
64 }
65
66 public function execute( $par ) {
67 $this->checkReadOnly();
68
69 $this->setHeaders();
70 $this->outputHeader();
71
72 $request = $this->getRequest();
73 $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
74
75 // Yes, the use of getVal() and getText() is wanted, see bug 20365
76
77 $oldTitleText = $request->getVal( 'wpOldTitle', $target );
78 $this->oldTitle = Title::newFromText( $oldTitleText );
79
80 if ( is_null( $this->oldTitle ) ) {
81 throw new ErrorPageError( 'notargettitle', 'notargettext' );
82 }
83 if ( !$this->oldTitle->exists() ) {
84 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
85 }
86
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 );
95
96 $user = $this->getUser();
97
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 );
104 }
105
106 $def = !$request->wasPosted();
107
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();
116
117 if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted()
118 && $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
119 ) {
120 $this->doSubmit();
121 } else {
122 $this->showForm( array() );
123 }
124 }
125
126 /**
127 * Show the form
128 *
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().
132 */
133 function showForm( $err ) {
134 global $wgContLang, $wgFixDoubleRedirects, $wgMaximumMovedPages;
135
136 $this->getSkin()->setRelevantTitle( $this->oldTitle );
137
138 $oldTitleLink = Linker::link( $this->oldTitle );
139
140 $out = $this->getOutput();
141 $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
142 $out->addModules( 'mediawiki.special.movePage' );
143
144 $newTitle = $this->newTitle;
145
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;
157 }
158 }
159
160 $user = $this->getUser();
161
162 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
163 && $newTitle->quickUserCan( 'delete', $user )
164 ) {
165 $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
166 $movepagebtn = $this->msg( 'delete_and_move' )->text();
167 $submitVar = 'wpDeleteAndMove';
168 $confirm = "
169 <tr>
170 <td></td>
171 <td class='mw-input'>" .
172 Xml::checkLabel(
173 $this->msg( 'delete_and_move_confirm' )->text(),
174 'wpConfirm',
175 'wpConfirm'
176 ) .
177 "</td>
178 </tr>";
179 $err = array();
180 } else {
181 if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
182 $out->wrapWikiMsg(
183 "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>",
184 'moveuserpage-warning'
185 );
186 } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
187 $out->wrapWikiMsg(
188 "<div class=\"error mw-movecategorypage-warning\">\n$1\n</div>",
189 'movecategorypage-warning'
190 );
191 }
192
193 $out->addWikiMsg( $wgFixDoubleRedirects ?
194 'movepagetext' :
195 'movepagetext-noredirectfixer'
196 );
197 $movepagebtn = $this->msg( 'movepagebtn' )->text();
198 $submitVar = 'wpMove';
199 $confirm = false;
200 }
201
202 if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
203 && $user->isAllowed( 'reupload-shared' )
204 ) {
205 $out->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() );
206 $submitVar = 'wpMoveOverSharedFile';
207 $err = array();
208 }
209
210 $oldTalk = $this->oldTitle->getTalkPage();
211 $oldTitleSubpages = $this->oldTitle->hasSubpages();
212 $oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
213
214 $canMoveSubpage = ( $oldTitleSubpages || $oldTitleTalkSubpages ) &&
215 !count( $this->oldTitle->getUserPermissionsErrors( 'move-subpages', $user ) );
216
217 # We also want to be able to move assoc. subpage talk-pages even if base page
218 # has no associated talk page, so || with $oldTitleTalkSubpages.
219 $considerTalk = !$this->oldTitle->isTalkPage() &&
220 ( $oldTalk->exists()
221 || ( $oldTitleTalkSubpages && $canMoveSubpage ) );
222
223 $dbr = wfGetDB( DB_SLAVE );
224 if ( $wgFixDoubleRedirects ) {
225 $hasRedirects = $dbr->selectField( 'redirect', '1',
226 array(
227 'rd_namespace' => $this->oldTitle->getNamespace(),
228 'rd_title' => $this->oldTitle->getDBkey(),
229 ), __METHOD__ );
230 } else {
231 $hasRedirects = false;
232 }
233
234 if ( $considerTalk ) {
235 $out->addWikiMsg( 'movepagetalktext' );
236 }
237
238 if ( count( $err ) ) {
239 $out->addHTML( "<div class='error'>\n" );
240 $action_desc = $this->msg( 'action-move' )->plain();
241 $out->addWikiMsg( 'permissionserrorstext-withaction', count( $err ), $action_desc );
242
243 if ( count( $err ) == 1 ) {
244 $errMsg = $err[0];
245 $errMsgName = array_shift( $errMsg );
246
247 if ( $errMsgName == 'hookaborted' ) {
248 $out->addHTML( "<p>{$errMsg[0]}</p>\n" );
249 } else {
250 $out->addWikiMsgArray( $errMsgName, $errMsg );
251 }
252 } else {
253 $errStr = array();
254
255 foreach ( $err as $errMsg ) {
256 if ( $errMsg[0] == 'hookaborted' ) {
257 $errStr[] = $errMsg[1];
258 } else {
259 $errMsgName = array_shift( $errMsg );
260 $errStr[] = $this->msg( $errMsgName, $errMsg )->parse();
261 }
262 }
263
264 $out->addHTML( '<ul><li>' . implode( "</li>\n<li>", $errStr ) . "</li></ul>\n" );
265 }
266 $out->addHTML( "</div>\n" );
267 }
268
269 if ( $this->oldTitle->isProtected( 'move' ) ) {
270 # Is the title semi-protected?
271 if ( $this->oldTitle->isSemiProtected( 'move' ) ) {
272 $noticeMsg = 'semiprotectedpagemovewarning';
273 $classes[] = 'mw-textarea-sprotected';
274 } else {
275 # Then it must be protected based on static groups (regular)
276 $noticeMsg = 'protectedpagemovewarning';
277 $classes[] = 'mw-textarea-protected';
278 }
279 $out->addHTML( "<div class='mw-warning-with-logexcerpt'>\n" );
280 $out->addWikiMsg( $noticeMsg );
281 LogEventsList::showLogExtract(
282 $out,
283 'protect',
284 $this->oldTitle,
285 '',
286 array( 'lim' => 1 )
287 );
288 $out->addHTML( "</div>\n" );
289 }
290
291 // Byte limit (not string length limit) for wpReason and wpNewTitleMain
292 // is enforced in the mediawiki.special.movePage module
293
294 $immovableNamespaces = array();
295
296 foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
297 if ( !MWNamespace::isMovable( $nsId ) ) {
298 $immovableNamespaces[] = $nsId;
299 }
300 }
301
302 $handler = ContentHandler::getForTitle( $this->oldTitle );
303
304 $out->addHTML(
305 Xml::openElement(
306 'form',
307 array(
308 'method' => 'post',
309 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ),
310 'id' => 'movepage'
311 )
312 ) .
313 Xml::openElement( 'fieldset' ) .
314 Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
315 Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) .
316 "<tr>
317 <td class='mw-label'>" .
318 $this->msg( 'movearticle' )->escaped() .
319 "</td>
320 <td class='mw-input'>
321 <strong>{$oldTitleLink}</strong>
322 </td>
323 </tr>
324 <tr>
325 <td class='mw-label'>" .
326 Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) .
327 "</td>
328 <td class='mw-input'>" .
329 Html::namespaceSelector(
330 array(
331 'selected' => $newTitle->getNamespace(),
332 'exclude' => $immovableNamespaces
333 ),
334 array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' )
335 ) .
336 Xml::input(
337 'wpNewTitleMain',
338 60,
339 $wgContLang->recodeForEdit( $newTitle->getText() ),
340 array(
341 'type' => 'text',
342 'id' => 'wpNewTitleMain',
343 'maxlength' => 255
344 )
345 ) .
346 Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) .
347 "</td>
348 </tr>
349 <tr>
350 <td class='mw-label'>" .
351 Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) .
352 "</td>
353 <td class='mw-input'>" .
354 Xml::input( 'wpReason', 60, $this->reason, array(
355 'type' => 'text',
356 'id' => 'wpReason',
357 'maxlength' => 200,
358 ) ) .
359 "</td>
360 </tr>"
361 );
362
363 if ( $considerTalk ) {
364 $out->addHTML( "
365 <tr>
366 <td></td>
367 <td class='mw-input'>" .
368 Xml::checkLabel(
369 $this->msg( 'movetalk' )->text(),
370 'wpMovetalk',
371 'wpMovetalk',
372 $this->moveTalk
373 ) .
374 "</td>
375 </tr>"
376 );
377 }
378
379 if ( $user->isAllowed( 'suppressredirect' ) ) {
380 if ( $handler->supportsRedirects() ) {
381 $isChecked = $this->leaveRedirect;
382 $options = array();
383 } else {
384 $isChecked = false;
385 $options = array(
386 'disabled' => 'disabled'
387 );
388 }
389 $out->addHTML( "
390 <tr>
391 <td></td>
392 <td class='mw-input' >" .
393 Xml::checkLabel(
394 $this->msg( 'move-leave-redirect' )->text(),
395 'wpLeaveRedirect',
396 'wpLeaveRedirect',
397 $isChecked,
398 $options
399 ) .
400 "</td>
401 </tr>"
402 );
403 }
404
405 if ( $hasRedirects ) {
406 $out->addHTML( "
407 <tr>
408 <td></td>
409 <td class='mw-input' >" .
410 Xml::checkLabel(
411 $this->msg( 'fix-double-redirects' )->text(),
412 'wpFixRedirects',
413 'wpFixRedirects',
414 $this->fixRedirects
415 ) .
416 "</td>
417 </tr>"
418 );
419 }
420
421 if ( $canMoveSubpage ) {
422 $out->addHTML( "
423 <tr>
424 <td></td>
425 <td class=\"mw-input\">" .
426 Xml::check(
427 'wpMovesubpages',
428 # Don't check the box if we only have talk subpages to
429 # move and we aren't moving the talk page.
430 $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ),
431 array( 'id' => 'wpMovesubpages' )
432 ) . '&#160;' .
433 Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ),
434 $this->msg(
435 ( $this->oldTitle->hasSubpages()
436 ? 'move-subpages'
437 : 'move-talk-subpages' )
438 )->numParams( $wgMaximumMovedPages )->params( $wgMaximumMovedPages )->parse()
439 ) .
440 "</td>
441 </tr>"
442 );
443 }
444
445 $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' )
446 || $user->isWatched( $this->oldTitle ) );
447 # Don't allow watching if user is not logged in
448 if ( $user->isLoggedIn() ) {
449 $out->addHTML( "
450 <tr>
451 <td></td>
452 <td class='mw-input'>" .
453 Xml::checkLabel(
454 $this->msg( 'move-watch' )->text(),
455 'wpWatch',
456 'watch',
457 $watchChecked
458 ) .
459 "</td>
460 </tr>" );
461 }
462
463 $out->addHTML( "
464 {$confirm}
465 <tr>
466 <td>&#160;</td>
467 <td class='mw-submit'>" .
468 Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
469 "</td>
470 </tr>" .
471 Xml::closeElement( 'table' ) .
472 Html::hidden( 'wpEditToken', $user->getEditToken() ) .
473 Xml::closeElement( 'fieldset' ) .
474 Xml::closeElement( 'form' ) .
475 "\n"
476 );
477
478 $this->showLogFragment( $this->oldTitle );
479 $this->showSubpages( $this->oldTitle );
480 }
481
482 function doSubmit() {
483 global $wgMaximumMovedPages, $wgFixDoubleRedirects;
484
485 $user = $this->getUser();
486
487 if ( $user->pingLimiter( 'move' ) ) {
488 throw new ThrottledError;
489 }
490
491 $ot = $this->oldTitle;
492 $nt = $this->newTitle;
493
494 # don't allow moving to pages with # in
495 if ( !$nt || $nt->hasFragment() ) {
496 $this->showForm( array( array( 'badtitletext' ) ) );
497
498 return;
499 }
500
501 # Show a warning if the target file exists on a shared repo
502 if ( $nt->getNamespace() == NS_FILE
503 && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) )
504 && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
505 && wfFindFile( $nt )
506 ) {
507 $this->showForm( array( array( 'file-exists-sharedrepo' ) ) );
508
509 return;
510 }
511
512 # Delete to make way if requested
513 if ( $this->deleteAndMove ) {
514 $permErrors = $nt->getUserPermissionsErrors( 'delete', $user );
515 if ( count( $permErrors ) ) {
516 # Only show the first error
517 $this->showForm( $permErrors );
518
519 return;
520 }
521
522 $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
523
524 // Delete an associated image if there is
525 if ( $nt->getNamespace() == NS_FILE ) {
526 $file = wfLocalFile( $nt );
527 if ( $file->exists() ) {
528 $file->delete( $reason, false );
529 }
530 }
531
532 $error = ''; // passed by ref
533 $page = WikiPage::factory( $nt );
534 $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user );
535 if ( !$deleteStatus->isGood() ) {
536 $this->showForm( $deleteStatus->getErrorsArray() );
537
538 return;
539 }
540 }
541
542 $handler = ContentHandler::getForTitle( $ot );
543
544 if ( !$handler->supportsRedirects() ) {
545 $createRedirect = false;
546 } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
547 $createRedirect = $this->leaveRedirect;
548 } else {
549 $createRedirect = true;
550 }
551
552 # Do the actual move.
553 $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
554 if ( $error !== true ) {
555 $this->showForm( $error );
556
557 return;
558 }
559
560 if ( $wgFixDoubleRedirects && $this->fixRedirects ) {
561 DoubleRedirectJob::fixRedirects( 'move', $ot, $nt );
562 }
563
564 $out = $this->getOutput();
565 $out->setPageTitle( $this->msg( 'pagemovedsub' ) );
566
567 $oldLink = Linker::link(
568 $ot,
569 null,
570 array( 'id' => 'movepage-oldlink' ),
571 array( 'redirect' => 'no' )
572 );
573 $newLink = Linker::linkKnown(
574 $nt,
575 null,
576 array( 'id' => 'movepage-newlink' )
577 );
578 $oldText = $ot->getPrefixedText();
579 $newText = $nt->getPrefixedText();
580
581 if ( $ot->exists() ) {
582 //NOTE: we assume that if the old title exists, it's because it was re-created as
583 // a redirect to the new title. This is not safe, but what we did before was
584 // even worse: we just determined whether a redirect should have been created,
585 // and reported that it was created if it should have, without any checks.
586 // Also note that isRedirect() is unreliable because of bug 37209.
587 $msgName = 'movepage-moved-redirect';
588 } else {
589 $msgName = 'movepage-moved-noredirect';
590 }
591
592 $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
593 $newLink )->params( $oldText, $newText )->parseAsBlock() );
594 $out->addWikiMsg( $msgName );
595
596 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this, &$ot, &$nt ) );
597
598 # Now we move extra pages we've been asked to move: subpages and talk
599 # pages. First, if the old page or the new page is a talk page, we
600 # can't move any talk pages: cancel that.
601 if ( $ot->isTalkPage() || $nt->isTalkPage() ) {
602 $this->moveTalk = false;
603 }
604
605 if ( count( $ot->getUserPermissionsErrors( 'move-subpages', $user ) ) ) {
606 $this->moveSubpages = false;
607 }
608
609 # Next make a list of id's. This might be marginally less efficient
610 # than a more direct method, but this is not a highly performance-cri-
611 # tical code path and readable code is more important here.
612 #
613 # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
614 # 4 might get confused. If so, consider rewriting as a UNION.
615 #
616 # If the target namespace doesn't allow subpages, moving with subpages
617 # would mean that you couldn't move them back in one operation, which
618 # is bad.
619 # @todo FIXME: A specific error message should be given in this case.
620
621 // @todo FIXME: Use Title::moveSubpages() here
622 $dbr = wfGetDB( DB_MASTER );
623 if ( $this->moveSubpages && (
624 MWNamespace::hasSubpages( $nt->getNamespace() ) || (
625 $this->moveTalk
626 && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
627 )
628 ) ) {
629 $conds = array(
630 'page_title' . $dbr->buildLike( $ot->getDBkey() . '/', $dbr->anyString() )
631 . ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
632 );
633 $conds['page_namespace'] = array();
634 if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
635 $conds['page_namespace'][] = $ot->getNamespace();
636 }
637 if ( $this->moveTalk &&
638 MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
639 ) {
640 $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
641 }
642 } elseif ( $this->moveTalk ) {
643 $conds = array(
644 'page_namespace' => $ot->getTalkPage()->getNamespace(),
645 'page_title' => $ot->getDBkey()
646 );
647 } else {
648 # Skip the query
649 $conds = null;
650 }
651
652 $extraPages = array();
653 if ( !is_null( $conds ) ) {
654 $extraPages = TitleArray::newFromResult(
655 $dbr->select( 'page',
656 array( 'page_id', 'page_namespace', 'page_title' ),
657 $conds,
658 __METHOD__
659 )
660 );
661 }
662
663 $extraOutput = array();
664 $count = 1;
665 foreach ( $extraPages as $oldSubpage ) {
666 if ( $ot->equals( $oldSubpage ) || $nt->equals( $oldSubpage ) ) {
667 # Already did this one.
668 continue;
669 }
670
671 $newPageName = preg_replace(
672 '#^' . preg_quote( $ot->getDBkey(), '#' ) . '#',
673 StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
674 $oldSubpage->getDBkey()
675 );
676
677 if ( $oldSubpage->isTalkPage() ) {
678 $newNs = $nt->getTalkPage()->getNamespace();
679 } else {
680 $newNs = $nt->getSubjectPage()->getNamespace();
681 }
682
683 # Bug 14385: we need makeTitleSafe because the new page names may
684 # be longer than 255 characters.
685 $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
686 if ( !$newSubpage ) {
687 $oldLink = Linker::linkKnown( $oldSubpage );
688 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink )
689 ->params( Title::makeName( $newNs, $newPageName ) )->escaped();
690 continue;
691 }
692
693 # This was copy-pasted from Renameuser, bleh.
694 if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
695 $link = Linker::linkKnown( $newSubpage );
696 $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
697 } else {
698 $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
699
700 if ( $success === true ) {
701 if ( $this->fixRedirects ) {
702 DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
703 }
704 $oldLink = Linker::link(
705 $oldSubpage,
706 null,
707 array(),
708 array( 'redirect' => 'no' )
709 );
710
711 $newLink = Linker::linkKnown( $newSubpage );
712 $extraOutput[] = $this->msg( 'movepage-page-moved' )
713 ->rawParams( $oldLink, $newLink )->escaped();
714 ++$count;
715
716 if ( $count >= $wgMaximumMovedPages ) {
717 $extraOutput[] = $this->msg( 'movepage-max-pages' )
718 ->numParams( $wgMaximumMovedPages )->escaped();
719 break;
720 }
721 } else {
722 $oldLink = Linker::linkKnown( $oldSubpage );
723 $newLink = Linker::link( $newSubpage );
724 $extraOutput[] = $this->msg( 'movepage-page-unmoved' )
725 ->rawParams( $oldLink, $newLink )->escaped();
726 }
727 }
728 }
729
730 if ( $extraOutput !== array() ) {
731 $out->addHTML( "<ul>\n<li>" . implode( "</li>\n<li>", $extraOutput ) . "</li>\n</ul>" );
732 }
733
734 # Deal with watches (we don't watch subpages)
735 WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user );
736 WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user );
737 }
738
739 function showLogFragment( $title ) {
740 $moveLogPage = new LogPage( 'move' );
741 $out = $this->getOutput();
742 $out->addHTML( Xml::element( 'h2', null, $moveLogPage->getName()->text() ) );
743 LogEventsList::showLogExtract( $out, 'move', $title );
744 }
745
746 function showSubpages( $title ) {
747 if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
748 return;
749 }
750
751 $subpages = $title->getSubpages();
752 $count = $subpages instanceof TitleArray ? $subpages->count() : 0;
753
754 $out = $this->getOutput();
755 $out->wrapWikiMsg( '== $1 ==', array( 'movesubpage', $count ) );
756
757 # No subpages.
758 if ( $count == 0 ) {
759 $out->addWikiMsg( 'movenosubpage' );
760
761 return;
762 }
763
764 $out->addWikiMsg( 'movesubpagetext', $this->getLanguage()->formatNum( $count ) );
765 $out->addHTML( "<ul>\n" );
766
767 foreach ( $subpages as $subpage ) {
768 $link = Linker::link( $subpage );
769 $out->addHTML( "<li>$link</li>\n" );
770 }
771 $out->addHTML( "</ul>\n" );
772 }
773
774 protected function getGroupName() {
775 return 'pagetools';
776 }
777 }