2 include_once( "LinksUpdate.php" );
4 function wfSpecialMovepage()
6 global $wgUser, $wgOut, $wgRequest, $action;
8 if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) {
9 $wgOut->errorpage( "movenologin", "movenologintext" );
13 $wgOut->readOnlyPage();
17 $f = new MovePageForm();
19 if ( "success" == $action ) { $f->showSuccess(); }
20 else if ( "submit" == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
21 else { $f->showForm( "" ); }
25 var $oldTitle, $newTitle; # Text input
27 function MovePageForm() {
29 $this->oldTitle
= $wgRequest->getText( 'wpOldTitle', $wgRequest->getVal( 'target' ) );
30 $this->newTitle
= $wgRequest->getText( 'wpNewTitle' );
33 function showForm( $err )
35 global $wgOut, $wgUser, $wgLang;
37 $wgOut->setPagetitle( wfMsg( "movepage" ) );
39 if ( empty( $this->oldTitle
) ) {
40 $wgOut->errorpage( "notargettitle", "notargettext" );
44 $encOldTitle = htmlspecialchars( $this->oldTitle
);
45 $encNewTitle = htmlspecialchars( $this->newTitle
);
46 $ot = Title
::newFromURL( $this->oldTitle
);
47 $ott = $ot->getPrefixedText();
49 $wgOut->addWikiText( wfMsg( "movepagetext" ) );
50 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
51 $wgOut->addWikiText( "\n\n" . wfMsg( "movepagetalktext" ) );
54 $ma = wfMsg( "movearticle" );
55 $newt = wfMsg( "newtitle" );
56 $mpb = wfMsg( "movepagebtn" );
57 $movetalk = wfMsg( "movetalk" );
59 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Movepage" );
60 $action = $titleObj->escapeLocalURL( "action=submit" );
63 $wgOut->setSubtitle( wfMsg( "formerror" ) );
64 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
67 <form id=\"movepage\" method=\"post\" action=\"{$action}\">
69 <td align=right>{$ma}:</td>
70 <td align=left><strong>{$ott}</strong></td>
72 <td align=right>{$newt}:</td>
74 <input type=text size=40 name=\"wpNewTitle\" value=\"{$encNewTitle}\">
75 <input type=hidden name=\"wpOldTitle\" value=\"{$encOldTitle}\">
79 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
83 <input type=checkbox name=\"wpMovetalk\" checked value=\"1\">
84 </td><td>{$movetalk}</td>
89 <td> </td><td align=left>
90 <input type=submit name=\"wpMove\" value=\"{$mpb}\">
98 global $wgOut, $wgUser, $wgLang;
99 global $wgDeferredUpdateList, $wgMessageCache;
101 $fname = "MovePageForm::doSubmit";
103 $ot = Title
::newFromText( $this->oldTitle
);
104 $nt = Title
::newFromText( $this->newTitle
);
106 $error = $ot->moveTo( $nt );
107 if ( $error !== true ) {
108 $this->showForm( wfMsg( $error ) );
113 # (1) the checkbox says to,
114 # (2) the namespaces are not themselves talk namespaces, and of course
117 $ons = $ot->getNamespace();
118 $nns = $nt->getNamespace();
120 if ( ( 1 == $_REQUEST['wpMovetalk'] ) &&
121 ( ! Namespace::isTalk( $ons ) ) &&
122 ( ! Namespace::isTalk( $nns ) ) ) {
124 # get old talk page namespace
125 $ons = Namespace::getTalk( $ons );
126 # get new talk page namespace
127 $nns = Namespace::getTalk( $nns );
129 # make talk page title objects
130 $ott = Title
::makeTitle( $ons, $ot->getDBkey() );
131 $ntt = Title
::makeTitle( $nns, $nt->getDBkey() );
134 $error = $ott->moveTo( $ntt );
135 if ( $error === true ) {
142 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Movepage" );
143 $success = $titleObj->getFullURL(
144 "action=success&oldtitle=" . wfUrlencode( $ot->getPrefixedText() ) .
145 "&newtitle=" . wfUrlencode( $nt->getPrefixedText() ) .
146 "&talkmoved={$talkmoved}" );
148 $wgOut->redirect( $success );
151 function showSuccess()
153 global $wgOut, $wgUser;
155 $wgOut->setPagetitle( wfMsg( "movepage" ) );
156 $wgOut->setSubtitle( wfMsg( "pagemovedsub" ) );
158 $text = wfMsg( "pagemovedtext", $_REQUEST['oldtitle'], $_REQUEST['newtitle'] );
159 $wgOut->addWikiText( $text );
161 $talkmoved = $_REQUEST['talkmoved'];
162 if ( 1 == $talkmoved ) {
163 $wgOut->addHTML( "\n<p>" . wfMsg( "talkpagemoved" ) );
164 } elseif( 'articleexists' == $talkmoved ) {
165 $wgOut->addHTML( "\n<p><strong>" . wfMsg( "talkexists" ) . "</strong>" );
167 $ot = Title
::newFromURL( $_REQUEST['oldtitle'] );
168 if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
169 $wgOut->addHTML( "\n<p>" . wfMsg( "talkpagenotmoved", wfMsg( $talkmoved ) ) );