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