2 require_once( "LinksUpdate.php" );
4 function wfSpecialMovepage()
6 global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
8 # check rights. We don't want newbies to move pages to prevents possible attack
9 if ( 0 == $wgUser->getID() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
10 $wgOut->errorpage( "movenologin", "movenologintext" );
13 # We don't move protected pages
15 $wgOut->readOnlyPage();
19 $f = new MovePageForm();
21 if ( 'success' == $action ) { $f->showSuccess(); }
22 else if ( 'submit' == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
23 else { $f->showForm( '' ); }
27 var $oldTitle, $newTitle; # Text input
29 function MovePageForm() {
31 $this->oldTitle
= $wgRequest->getText( 'wpOldTitle', $wgRequest->getVal( 'target' ) );
32 $this->newTitle
= $wgRequest->getText( 'wpNewTitle' );
35 function showForm( $err )
37 global $wgOut, $wgUser, $wgLang;
39 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
41 if ( empty( $this->oldTitle
) ) {
42 $wgOut->errorpage( 'notargettitle', 'notargettext' );
46 $encOldTitle = htmlspecialchars( $this->oldTitle
);
47 $encNewTitle = htmlspecialchars( $this->newTitle
);
48 $ot = Title
::newFromURL( $this->oldTitle
);
49 $ott = $ot->getPrefixedText();
51 $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
52 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
53 $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
56 $ma = wfMsg( 'movearticle' );
57 $newt = wfMsg( 'newtitle' );
58 $mpb = wfMsg( 'movepagebtn' );
59 $movetalk = wfMsg( 'movetalk' );
61 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
62 $action = $titleObj->escapeLocalURL( 'action=submit' );
65 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
66 $wgOut->addHTML( '<p class="error">'.$err."</p>\n" );
69 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
72 <td align='right'>{$ma}:</td>
73 <td align='left'><strong>{$ott}</strong></td>
76 <td align='right'>{$newt}:</td>
78 <input type='text' size='40' name=\"wpNewTitle\" value=\"{$encNewTitle}\" />
79 <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
83 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
87 <input type='checkbox' name=\"wpMovetalk\" checked='checked' value=\"1\" />
96 <input type='submit' name=\"wpMove\" value=\"{$mpb}\" />
106 global $wgOut, $wgUser, $wgLang;
107 global $wgDeferredUpdateList, $wgMessageCache;
108 global $wgUseSquid, $wgRequest;
109 $fname = "MovePageForm::doSubmit";
111 # Variables beginning with 'o' for old article 'n' for new article
113 $ot = Title
::newFromText( $this->oldTitle
);
114 $nt = Title
::newFromText( $this->newTitle
);
116 $error = $ot->moveTo( $nt );
117 if ( $error !== true ) {
118 $this->showForm( wfMsg( $error ) );
123 # (1) the checkbox says to,
124 # (2) the namespaces are not themselves talk namespaces, and of course
127 $ons = $ot->getNamespace();
128 $nns = $nt->getNamespace();
130 if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
131 ( ! Namespace::isTalk( $ons ) ) &&
132 ( ! Namespace::isTalk( $nns ) ) ) {
134 # get old talk page namespace
135 $ons = Namespace::getTalk( $ons );
136 # get new talk page namespace
137 $nns = Namespace::getTalk( $nns );
139 # make talk page title objects
140 $ott = Title
::makeTitle( $ons, $ot->getDBkey() );
141 $ntt = Title
::makeTitle( $nns, $nt->getDBkey() );
144 $error = $ott->moveTo( $ntt );
145 if ( $error === true ) {
152 # Give back result to user.
154 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Movepage' );
155 $success = $titleObj->getFullURL(
156 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
157 '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) .
158 '&talkmoved='.$talkmoved );
160 $wgOut->redirect( $success );
163 function showSuccess()
165 global $wgOut, $wgUser, $wgRequest;
167 $wgOut->setPagetitle( wfMsg( 'movepage' ) );
168 $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
169 $oldtitle = $wgRequest->getVal('oldtitle');
170 $newtitle = $wgRequest->getVal('newtitle');
171 $talkmoved = $wgRequest->getVal('talkmoved');
173 $text = wfMsg( 'pagemovedtext', $oldtitle, $newtitle );
174 $wgOut->addWikiText( $text );
176 if ( $talkmoved == 1 ) {
177 $wgOut->addHTML( "\n<p>" . wfMsg( 'talkpagemoved' ) . "</p>\n" );
178 } elseif( 'articleexists' == $talkmoved ) {
179 $wgOut->addHTML( "\n<p><strong>" . wfMsg( 'talkexists' ) . "</strong></p>\n" );
181 $ot = Title
::newFromURL( $oldtitle );
182 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
183 $wgOut->addHTML( "\n<p>" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) . "</p>\n" );