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