2c0720d38b93d41cfdd8ff6ebc286b55ce7e8d2c
5 * @subpackage SpecialPage
11 function wfSpecialMovepage( $par = null ) {
12 global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
14 # check rights. We don't want newbies to move pages to prevents possible attack
15 if ( !$wgUser->isAllowed( 'move' ) or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
16 $wgOut->showErrorPage( "movenologin", "movenologintext" );
19 # We don't move protected pages
21 $wgOut->readOnlyPage();
25 $f = new MovePageForm( $par );
27 if ( 'success' == $action ) {
29 } else if ( 'submit' == $action && $wgRequest->wasPosted()
30 && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
40 * @subpackage SpecialPage
43 var $oldTitle, $newTitle, $reason; # Text input
44 var $moveTalk, $deleteAndMove;
46 function MovePageForm( $par ) {
48 $target = isset($par) ?
$par : $wgRequest->getVal( 'target' );
49 $this->oldTitle
= $wgRequest->getText( 'wpOldTitle', $target );
50 $this->newTitle
= $wgRequest->getText( 'wpNewTitle' );
51 $this->reason
= $wgRequest->getText( 'wpReason' );
52 $this->moveTalk
= $wgRequest->getBool( 'wpMovetalk', true );
53 $this->deleteAndMove
= $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
56 function showForm( $err ) {
57 global $wgOut, $wgUser;
59 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
61 $ot = Title
::newFromURL( $this->oldTitle
);
62 if( is_null( $ot ) ) {
63 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
66 $oldTitle = $ot->getPrefixedText();
68 $encOldTitle = htmlspecialchars( $oldTitle );
69 if( $this->newTitle
== '' ) {
70 # Show the current title as a default
71 # when the form is first opened.
72 $encNewTitle = $encOldTitle;
75 $nt = Title
::newFromURL( $this->newTitle
);
77 # If a title was supplied, probably from the move log revert
78 # link, check for validity. We can then show some diagnostic
79 # information and save a click.
80 $newerr = $ot->isValidMoveOperation( $nt );
81 if( is_string( $newerr ) ) {
86 $encNewTitle = htmlspecialchars( $this->newTitle
);
88 $encReason = htmlspecialchars( $this->reason
);
90 if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
91 $wgOut->addWikiText( wfMsg( 'delete_and_move_text', $encNewTitle ) );
92 $movepagebtn = wfMsgHtml( 'delete_and_move' );
93 $confirmText = wfMsgHtml( 'delete_and_move_confirm' );
94 $submitVar = 'wpDeleteAndMove';
98 <input type='checkbox' name='wpConfirm' id='wpConfirm' value=\"true\" />
100 <td align='left'><label for='wpConfirm'>{$confirmText}</label></td>
104 $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
105 $movepagebtn = wfMsgHtml( 'movepagebtn' );
106 $submitVar = 'wpMove';
110 $oldTalk = $ot->getTalkPage();
111 $considerTalk = ( !$ot->isTalkPage() && $oldTalk->exists() );
113 if ( $considerTalk ) {
114 $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
117 $movearticle = wfMsgHtml( 'movearticle' );
118 $newtitle = wfMsgHtml( 'newtitle' );
119 $movetalk = wfMsgHtml( 'movetalk' );
120 $movereason = wfMsgHtml( 'movereason' );
122 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
123 $action = $titleObj->escapeLocalURL( 'action=submit' );
124 $token = htmlspecialchars( $wgUser->editToken() );
127 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
128 $wgOut->addWikiText( '<p class="error">' . wfMsg($err) . "</p>\n" );
131 $moveTalkChecked = $this->moveTalk ?
' checked="checked"' : '';
134 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
137 <td align='right'>{$movearticle}:</td>
138 <td align='left'><strong>{$oldTitle}</strong></td>
141 <td align='right'><label for='wpNewTitle'>{$newtitle}:</label></td>
143 <input type='text' size='40' name='wpNewTitle' id='wpNewTitle' value=\"{$encNewTitle}\" />
144 <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
148 <td align='right' valign='top'><br /><label for='wpReason'>{$movereason}:</label></td>
149 <td align='left' valign='top'><br />
150 <textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>
154 if ( $considerTalk ) {
158 <input type='checkbox' id=\"wpMovetalk\" name=\"wpMovetalk\"{$moveTalkChecked} value=\"1\" />
160 <td><label for=\"wpMovetalk\">{$movetalk}</label></td>
168 <input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
172 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
177 function doSubmit() {
178 global $wgOut, $wgUser, $wgRequest;
179 $fname = "MovePageForm::doSubmit";
181 if ( $wgUser->pingLimiter( 'move' ) ) {
182 $wgOut->rateLimited();
186 # Variables beginning with 'o' for old article 'n' for new article
188 $ot = Title
::newFromText( $this->oldTitle
);
189 $nt = Title
::newFromText( $this->newTitle
);
191 # Delete to make way if requested
192 if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove
) {
193 $article = new Article( $nt );
194 // This may output an error message and exit
195 $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
198 # don't allow moving to pages with # in
199 if ( !$nt ||
$nt->getFragment() != '' ) {
200 $this->showForm( 'badtitletext' );
204 $error = $ot->moveTo( $nt, true, $this->reason
);
205 if ( $error !== true ) {
206 $this->showForm( $error );
210 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
212 # Move the talk page if relevant, if it exists, and if we've been told to
213 $ott = $ot->getTalkPage();
214 if( $ott->exists() ) {
215 if( $wgRequest->getVal( 'wpMovetalk' ) == 1 && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
216 $ntt = $nt->getTalkPage();
219 $error = $ott->moveTo( $ntt, true, $this->reason
);
220 if ( $error === true ) {
222 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
227 # Stay silent on the subject of talk.
231 $talkmoved = 'notalkpage';
234 # Give back result to user.
235 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
236 $success = $titleObj->getFullURL(
237 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
238 '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
239 '&talkmoved='.$talkmoved );
241 $wgOut->redirect( $success );
244 function showSuccess() {
245 global $wgOut, $wgRequest, $wgRawHtml;
247 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
248 $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
250 $oldText = $wgRequest->getVal('oldtitle');
251 $newText = $wgRequest->getVal('newtitle');
252 $talkmoved = $wgRequest->getVal('talkmoved');
254 $text = wfMsg( 'pagemovedtext', $oldText, $newText );
256 $allowHTML = $wgRawHtml;
258 $wgOut->addWikiText( $text );
259 $wgRawHtml = $allowHTML;
261 if ( $talkmoved == 1 ) {
262 $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
263 } elseif( 'articleexists' == $talkmoved ) {
264 $wgOut->addWikiText( wfMsg( 'talkexists' ) );
266 $oldTitle = Title
::newFromText( $oldText );
267 if ( !$oldTitle->isTalkPage() && $talkmoved != 'notalkpage' ) {
268 $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );