Reverting r16861; incompatible change to message texts, breaks a lot of toggle displa...
[lhc/web/wiklou.git] / includes / SpecialMovepage.php
index bfc2af9..e33c153 100644 (file)
 function wfSpecialMovepage( $par = null ) {
        global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
 
-       # check rights. We don't want newbies to move pages to prevents possible attack
-       if ( !$wgUser->isAllowed( 'move' ) or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
-               $wgOut->errorpage( "movenologin", "movenologintext" );
+       # Check rights
+       if ( !$wgUser->isAllowed( 'move' ) ) {
+               $wgOut->showErrorPage( 'movenologin', 'movenologintext' );
                return;
        }
-       # We don't move protected pages
+
+       # Don't allow blocked users to move pages
+       if ( $wgUser->isBlocked() ) {
+               $wgOut->blockedPage();
+               return;
+       }
+
+       # Check for database lock
        if ( wfReadOnly() ) {
                $wgOut->readOnlyPage();
                return;
@@ -60,7 +67,7 @@ class MovePageForm {
 
                $ot = Title::newFromURL( $this->oldTitle );
                if( is_null( $ot ) ) {
-                       $wgOut->errorpage( 'notargettitle', 'notargettext' );
+                       $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
                $oldTitle = $ot->getPrefixedText();
@@ -107,7 +114,10 @@ class MovePageForm {
                        $confirm = false;
                }
 
-               if ( !$ot->isTalkPage() ) {
+               $oldTalk = $ot->getTalkPage();
+               $considerTalk = ( !$ot->isTalkPage() && $oldTalk->exists() );
+
+               if ( $considerTalk ) {
                        $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
                }
 
@@ -148,7 +158,7 @@ class MovePageForm {
                        </td>
                </tr>" );
 
-               if ( ! $ot->isTalkPage() ) {
+               if ( $considerTalk ) {
                        $wgOut->addHTML( "
                <tr>
                        <td align='right'>
@@ -169,6 +179,8 @@ class MovePageForm {
        <input type='hidden' name='wpEditToken' value=\"{$token}\" />
 </form>\n" );
 
+       $this->showLogFragment( $ot, $wgOut );
+
        }
 
        function doSubmit() {
@@ -206,28 +218,26 @@ class MovePageForm {
 
                wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
 
-               # Move talk page if
-               # (1) the checkbox says to,
-               # (2) the namespaces are not themselves talk namespaces, and of course
-               # (3) it exists.
-               if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
-                    !$ot->isTalkPage() &&
-                    !$nt->isTalkPage() ) {
-
-                       $ott = $ot->getTalkPage();
-                       $ntt = $nt->getTalkPage();
-
-                       # Attempt the move
-                       $error = $ott->moveTo( $ntt, true, $this->reason );
-                       if ( $error === true ) {
-                               $talkmoved = 1;
-                               wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) )       ;
+               # Move the talk page if relevant, if it exists, and if we've been told to
+               $ott = $ot->getTalkPage();
+               if( $ott->exists() ) {
+                       if( $wgRequest->getVal( 'wpMovetalk' ) == 1 && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
+                               $ntt = $nt->getTalkPage();
+       
+                               # Attempt the move
+                               $error = $ott->moveTo( $ntt, true, $this->reason );
+                               if ( $error === true ) {
+                                       $talkmoved = 1;
+                                       wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) )       ;
+                               } else {
+                                       $talkmoved = $error;
+                               }
                        } else {
-                               $talkmoved = $error;
+                               # Stay silent on the subject of talk.
+                               $talkmoved = '';
                        }
                } else {
-                       # Stay silent on the subject of talk.
-                       $talkmoved = '';
+                       $talkmoved = 'notalkpage';
                }
 
                # Give back result to user.
@@ -242,31 +252,39 @@ class MovePageForm {
 
        function showSuccess() {
                global $wgOut, $wgRequest, $wgRawHtml;
-
+               
                $wgOut->setPagetitle( wfMsg( 'movepage' ) );
                $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
-               $oldtitle = $wgRequest->getVal('oldtitle');
-               $newtitle = $wgRequest->getVal('newtitle');
-               $talkmoved = $wgRequest->getVal('talkmoved');
 
-               $text = wfMsg( 'pagemovedtext', $oldtitle, $newtitle );
+               $oldText = wfEscapeWikiText( $wgRequest->getVal('oldtitle') );
+               $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') );
+               $talkmoved = $wgRequest->getVal('talkmoved');
 
-               # Temporarily disable raw html wikitext option out of XSS paranoia
-               $marchingantofdoom = $wgRawHtml;
+               $text = wfMsg( 'pagemovedtext', $oldText, $newText );
+               
+               $allowHTML = $wgRawHtml;
                $wgRawHtml = false;
                $wgOut->addWikiText( $text );
-               $wgRawHtml = $marchingantofdoom;
+               $wgRawHtml = $allowHTML;
 
                if ( $talkmoved == 1 ) {
                        $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
                } elseif( 'articleexists' == $talkmoved ) {
                        $wgOut->addWikiText( wfMsg( 'talkexists' ) );
                } else {
-                       $ot = Title::newFromURL( $oldtitle );
-                       if ( ! $ot->isTalkPage() ) {
+                       $oldTitle = Title::newFromText( $oldText );
+                       if ( isset( $oldTitle ) && !$oldTitle->isTalkPage() && $talkmoved != 'notalkpage' ) {
                                $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );
                        }
                }
        }
+       
+       function showLogFragment( $title, &$out ) {
+               $out->addHtml( wfElement( 'h2', NULL, LogPage::logName( 'move' ) ) );
+               $request = new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'move' ) );
+               $viewer = new LogViewer( new LogReader( $request ) );
+               $viewer->showList( $out );
+       }
+       
 }
 ?>