- $encOldTitle = htmlspecialchars( $this->oldTitle );
- $encNewTitle = htmlspecialchars( $this->newTitle );
- $ot = Title::newFromURL( $this->oldTitle );
- $ott = $ot->getPrefixedText();
+ $encOldTitle = htmlspecialchars( $oldTitle );
+ if( $this->newTitle == '' ) {
+ # Show the current title as a default
+ # when the form is first opened.
+ $encNewTitle = $encOldTitle;
+ } else {
+ if( $err == '' ) {
+ $nt = Title::newFromURL( $this->newTitle );
+ if( $nt ) {
+ # If a title was supplied, probably from the move log revert
+ # link, check for validity. We can then show some diagnostic
+ # information and save a click.
+ $newerr = $ot->isValidMoveOperation( $nt );
+ if( is_string( $newerr ) ) {
+ $err = $newerr;
+ }
+ }
+ }
+ $encNewTitle = htmlspecialchars( $this->newTitle );
+ }
+ $encReason = htmlspecialchars( $this->reason );
+
+ if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
+ $wgOut->addWikiText( wfMsg( 'delete_and_move_text', $encNewTitle ) );
+ $movepagebtn = wfMsgHtml( 'delete_and_move' );
+ $submitVar = 'wpDeleteAndMove';
+ $err = '';
+ } else {
+ $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
+ $movepagebtn = wfMsgHtml( 'movepagebtn' );
+ $submitVar = 'wpMove';
+ }