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->errorpage( "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->errorpage( '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 if ( !$ot->isTalkPage() ) {
111 $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
114 $movearticle = wfMsgHtml( 'movearticle' );
115 $newtitle = wfMsgHtml( 'newtitle' );
116 $movetalk = wfMsgHtml( 'movetalk' );
117 $movereason = wfMsgHtml( 'movereason' );
119 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
120 $action = $titleObj->escapeLocalURL( 'action=submit' );
121 $token = htmlspecialchars( $wgUser->editToken() );
124 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
125 $wgOut->addWikiText( '<p class="error">' . wfMsg($err) . "</p>\n" );
128 $moveTalkChecked = $this->moveTalk ?
' checked="checked"' : '';
131 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
134 <td align='right'>{$movearticle}:</td>
135 <td align='left'><strong>{$oldTitle}</strong></td>
138 <td align='right'><label for='wpNewTitle'>{$newtitle}:</label></td>
140 <input type='text' size='40' name='wpNewTitle' id='wpNewTitle' value=\"{$encNewTitle}\" />
141 <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
145 <td align='right' valign='top'><br /><label for='wpReason'>{$movereason}:</label></td>
146 <td align='left' valign='top'><br />
147 <textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>
151 if ( ! $ot->isTalkPage() ) {
155 <input type='checkbox' id=\"wpMovetalk\" name=\"wpMovetalk\"{$moveTalkChecked} value=\"1\" />
157 <td><label for=\"wpMovetalk\">{$movetalk}</label></td>
165 <input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
169 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
174 function doSubmit() {
175 global $wgOut, $wgUser, $wgRequest;
176 $fname = "MovePageForm::doSubmit";
178 if ( $wgUser->pingLimiter( 'move' ) ) {
179 $wgOut->rateLimited();
183 # Variables beginning with 'o' for old article 'n' for new article
185 $ot = Title
::newFromText( $this->oldTitle
);
186 $nt = Title
::newFromText( $this->newTitle
);
188 # Delete to make way if requested
189 if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove
) {
190 $article = new Article( $nt );
191 // This may output an error message and exit
192 $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
195 # don't allow moving to pages with # in
196 if ( !$nt ||
$nt->getFragment() != '' ) {
197 $this->showForm( 'badtitletext' );
201 $error = $ot->moveTo( $nt, true, $this->reason
);
202 if ( $error !== true ) {
203 $this->showForm( $error );
207 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
210 # (1) the checkbox says to,
211 # (2) the namespaces are not themselves talk namespaces, and of course
213 if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
214 !$ot->isTalkPage() &&
215 !$nt->isTalkPage() ) {
217 $ott = $ot->getTalkPage();
218 $ntt = $nt->getTalkPage();
221 $error = $ott->moveTo( $ntt, true, $this->reason
);
222 if ( $error === true ) {
224 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
229 # Stay silent on the subject of talk.
233 # Give back result to user.
234 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
235 $success = $titleObj->getFullURL(
236 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
237 '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
238 '&talkmoved='.$talkmoved );
240 $wgOut->redirect( $success );
243 function showSuccess() {
244 global $wgOut, $wgRequest, $wgRawHtml;
246 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
247 $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
249 $oldText = $wgRequest->getVal('oldtitle');
250 $newText = $wgRequest->getVal('newtitle');
251 $talkmoved = $wgRequest->getVal('talkmoved');
253 $text = wfMsg( 'pagemovedtext', $oldText, $newText );
255 $allowHTML = $wgRawHtml;
257 $wgOut->addWikiText( $text );
258 $wgRawHtml = $allowHTML;
260 if ( $talkmoved == 1 ) {
261 $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
262 } elseif( 'articleexists' == $talkmoved ) {
263 $wgOut->addWikiText( wfMsg( 'talkexists' ) );
265 $oldTitle = Title
::newFromText( $oldText );
266 if ( !$oldTitle->isTalkPage() ) {
267 $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );