Fix bug 9246 by watching a page when the upload\reupload "Watch this page" checkbox...
[lhc/web/wiklou.git] / includes / SpecialMovepage.php
index 1a22fbc..7a003bb 100644 (file)
@@ -12,7 +12,7 @@ function wfSpecialMovepage( $par = null ) {
 
        # Check rights
        if ( !$wgUser->isAllowed( 'move' ) ) {
-               $wgOut->showErrorPage( 'movenologin', 'movenologintext' );
+               $wgOut->showPermissionsErrorPage( array( $wgUser->isAnon() ? 'movenologintext' : 'movenotallowed' ) );
                return;
        }
 
@@ -65,7 +65,7 @@ class MovePageForm {
                $this->watch = $wgRequest->getCheck( 'wpWatch' );
        }
 
-       function showForm( $err ) {
+       function showForm( $err, $hookErr = '' ) {
                global $wgOut, $wgUser, $wgContLang;
                
                $start = $wgContLang->isRTL() ? 'right' : 'left';
@@ -78,6 +78,8 @@ class MovePageForm {
                        $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
+               $sk = $wgUser->getSkin();
+               $oldTitleLink = $sk->makeLinkObj( $ot );
                $oldTitle = $ot->getPrefixedText();
 
                $encOldTitle = htmlspecialchars( $oldTitle );
@@ -135,7 +137,13 @@ class MovePageForm {
 
                if ( $err != '' ) {
                        $wgOut->setSubtitle( wfMsg( 'formerror' ) );
-                       $wgOut->addWikiText( '<p class="error">' . wfMsg($err) . "</p>\n" );
+                       $errMsg = "";
+                       if( $err == 'hookaborted' ) {
+                               $errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n";
+                       } else {
+                               $errMsg = '<p><strong class="error">' . wfMsgWikiHtml( $err ) . "</strong></p>\n";
+                       }
+                       $wgOut->addHTML( $errMsg );
                }
 
                $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
@@ -145,7 +153,7 @@ class MovePageForm {
        <table border='0'>
                <tr>
                        <td align='$end'>{$movearticle}</td>
-                       <td align='$start'><strong>{$oldTitle}</strong></td>
+                       <td align='$start'><strong>{$oldTitleLink}</strong></td>
                </tr>
                <tr>
                        <td align='$end'><label for='wpNewTitle'>{$newtitle}</label></td>
@@ -186,7 +194,7 @@ class MovePageForm {
        <input type='hidden' name='wpEditToken' value=\"{$token}\" />
 </form>\n" );
 
-       $this->showLogFragment( $ot, $wgOut );
+               $this->showLogFragment( $ot, $wgOut );
 
        }
 
@@ -216,6 +224,12 @@ class MovePageForm {
                        return;
                }
 
+               $hookErr = null;
+               if( !wfRunHooks( 'AbortMove', array( $ot, $nt, $wgUser, &$hookErr ) ) ) {
+                       $this->showForm( 'hookaborted', $hookErr );
+                       return;
+               }
+
                $error = $ot->moveTo( $nt, true, $this->reason );
                if ( $error !== true ) {
                        $this->showForm( $error );
@@ -266,27 +280,38 @@ class MovePageForm {
        }
 
        function showSuccess() {
-               global $wgOut, $wgRequest, $wgRawHtml;
+               global $wgOut, $wgRequest, $wgUser;
+               
+               $old = Title::newFromText( $wgRequest->getVal( 'oldtitle' ) );
+               $new = Title::newFromText( $wgRequest->getVal( 'newtitle' ) );
+               
+               if( is_null( $old ) || is_null( $new ) ) {
+                       throw new ErrorPageError( 'badtitle', 'badtitletext' );
+               }
                
                $wgOut->setPagetitle( wfMsg( 'movepage' ) );
                $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
 
-               $oldText = wfEscapeWikiText( $wgRequest->getVal('oldtitle') );
-               $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') );
-               $talkmoved = $wgRequest->getVal('talkmoved');
+               $talkmoved = $wgRequest->getVal( 'talkmoved' );
+               $oldUrl = $old->getFullUrl( 'redirect=no' );
+               $newUrl = $new->getFullURl();
+               $oldText = wfEscapeWikiText( $old->getPrefixedText() );
+               $newText = wfEscapeWikiText( $new->getPrefixedText() );
+               $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>";
+               $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>";
 
-               $wgOut->addHtml( wfMsgExt( 'pagemovedtext', array( 'parse' ), $oldText, $newText ) );
+               $s = wfMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
 
                if ( $talkmoved == 1 ) {
-                       $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
+                       $s .= "\n\n" . wfMsg( 'talkpagemoved' );
                } elseif( 'articleexists' == $talkmoved ) {
-                       $wgOut->addWikiText( wfMsg( 'talkexists' ) );
+                       $s .= "\n\n" . wfMsg( 'talkexists' );
                } else {
-                       $oldTitle = Title::newFromText( $oldText );
-                       if ( isset( $oldTitle ) && !$oldTitle->isTalkPage() && $talkmoved != 'notalkpage' ) {
-                               $wgOut->addWikiText( wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) );
+                       if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) {
+                               $s .= "\n\n" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) );
                        }
                }
+               $wgOut->addWikiText( $s );
        }
        
        function showLogFragment( $title, &$out ) {
@@ -297,4 +322,4 @@ class MovePageForm {
        }
        
 }
-?>
+