3c9d32689206723cb104478fce372e0d6267ce4f
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' );
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 $submitVar = 'wpDeleteAndMove';
96 $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
97 $movepagebtn = wfMsgHtml( 'movepagebtn' );
98 $submitVar = 'wpMove';
101 if ( !$ot->isTalkPage() ) {
102 $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
105 $movearticle = wfMsgHtml( 'movearticle' );
106 $newtitle = wfMsgHtml( 'newtitle' );
107 $movetalk = wfMsgHtml( 'movetalk' );
108 $movereason = wfMsgHtml( 'movereason' );
110 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
111 $action = $titleObj->escapeLocalURL( 'action=submit' );
112 $token = htmlspecialchars( $wgUser->editToken() );
115 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
116 $wgOut->addWikiText( '<p class="error">' . wfMsg($err) . "</p>\n" );
119 $moveTalkChecked = $this->moveTalk ?
' checked="checked"' : '';
122 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
125 <td align='right'>{$movearticle}:</td>
126 <td align='left'><strong>{$oldTitle}</strong></td>
129 <td align='right'><label for='wpNewTitle'>{$newtitle}:</label></td>
131 <input type='text' size='40' name='wpNewTitle' id='wpNewTitle' value=\"{$encNewTitle}\" />
132 <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
136 <td align='right' valign='top'><br /><label for='wpReason'>{$movereason}:</label></td>
137 <td align='left' valign='top'><br />
138 <textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>
142 if ( ! $ot->isTalkPage() ) {
146 <input type='checkbox' id=\"wpMovetalk\" name=\"wpMovetalk\"{$moveTalkChecked} value=\"1\" />
148 <td><label for=\"wpMovetalk\">{$movetalk}</label></td>
155 <input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
159 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
164 function doSubmit() {
165 global $wgOut, $wgUser, $wgRequest;
166 $fname = "MovePageForm::doSubmit";
168 if ( $wgUser->pingLimiter( 'move' ) ) {
169 $wgOut->rateLimited();
173 # Variables beginning with 'o' for old article 'n' for new article
175 $ot = Title
::newFromText( $this->oldTitle
);
176 $nt = Title
::newFromText( $this->newTitle
);
178 # Delete to make way if requested
179 if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove
) {
180 $article = new Article( $nt );
181 // This may output an error message and exit
182 $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
185 # don't allow moving to pages with # in
186 if ( !$nt ||
$nt->getFragment() != '' ) {
187 $this->showForm( 'badtitletext' );
191 $error = $ot->moveTo( $nt, true, $this->reason
);
192 if ( $error !== true ) {
193 $this->showForm( $error );
197 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
200 # (1) the checkbox says to,
201 # (2) the namespaces are not themselves talk namespaces, and of course
203 if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
204 !$ot->isTalkPage() &&
205 !$nt->isTalkPage() ) {
207 $ott = $ot->getTalkPage();
208 $ntt = $nt->getTalkPage();
211 $error = $ott->moveTo( $ntt, true, $this->reason
);
212 if ( $error === true ) {
214 wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
219 # Stay silent on the subject of talk.
223 # Give back result to user.
224 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
225 $success = $titleObj->getFullURL(
226 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
227 '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
228 '&talkmoved='.$talkmoved );
230 $wgOut->redirect( $success );
233 function showSuccess() {
234 global $wgOut, $wgRequest, $wgRawHtml;
236 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
237 $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
238 $oldtitle = $wgRequest->getVal('oldtitle');
239 $newtitle = $wgRequest->getVal('newtitle');
240 $talkmoved = $wgRequest->getVal('talkmoved');
242 $text = wfMsg( 'pagemovedtext', $oldtitle, $newtitle );
244 # Temporarily disable raw html wikitext option out of XSS paranoia
245 $marchingantofdoom = $wgRawHtml;
247 $wgOut->addWikiText( $text );
248 $wgRawHtml = $marchingantofdoom;
250 if ( $talkmoved == 1 ) {
251 $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
252 } elseif( 'articleexists' == $talkmoved ) {
253 $wgOut->addWikiText( wfMsg( 'talkexists' ) );
255 $ot = Title
::newFromURL( $oldtitle );
256 if ( ! $ot->isTalkPage() ) {
257 $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );