* Don't show hist link if hidden
[lhc/web/wiklou.git] / includes / SpecialMovepage.php
index 938cefa..3fa6746 100644 (file)
@@ -47,7 +47,7 @@ function wfSpecialMovepage( $par = null ) {
 class MovePageForm {
        var $oldTitle, $newTitle, $reason; # Text input
        var $moveTalk, $deleteAndMove;
-       
+
        private $watch = false;
 
        function MovePageForm( $par ) {
@@ -67,26 +67,27 @@ class MovePageForm {
 
        function showForm( $err, $hookErr = '' ) {
                global $wgOut, $wgUser, $wgContLang;
-               
-               $start = $wgContLang->isRTL() ? 'right' : 'left';
-               $end = $wgContLang->isRTL() ? 'left' : 'right';
-
-               $wgOut->setPagetitle( wfMsg( 'movepage' ) );
 
                $ot = Title::newFromURL( $this->oldTitle );
                if( is_null( $ot ) ) {
                        $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
                        return;
                }
+
+               $start = $wgContLang->isRTL() ? 'right' : 'left';
+               $end = $wgContLang->isRTL() ? 'left' : 'right';
                $sk = $wgUser->getSkin();
+
                $oldTitleLink = $sk->makeLinkObj( $ot );
                $oldTitle = $ot->getPrefixedText();
 
-               $encOldTitle = htmlspecialchars( $oldTitle );
+               $wgOut->setPagetitle( wfMsg( 'move-page', $oldTitle ) );
+               $wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) );
+
                if( $this->newTitle == '' ) {
                        # Show the current title as a default
                        # when the form is first opened.
-                       $encNewTitle = $encOldTitle;
+                       $newTitle = $oldTitle;
                } else {
                        if( $err == '' ) {
                                $nt = Title::newFromURL( $this->newTitle );
@@ -100,22 +101,24 @@ class MovePageForm {
                                        }
                                }
                        }
-                       $encNewTitle = htmlspecialchars( $this->newTitle );
+                       $newTitle = $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' );
+                       $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle );
+                       $movepagebtn = wfMsg( 'delete_and_move' );
                        $submitVar = 'wpDeleteAndMove';
                        $confirm = "
                                <tr>
-                                       <td></td><td>" . Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) . "</td>
+                                       <td></td>
+                                       <td>" .
+                                               Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) .
+                                       "</td>
                                </tr>";
                        $err = '';
                } else {
-                       $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
-                       $movepagebtn = wfMsgHtml( 'movepagebtn' );
+                       $wgOut->addWikiMsg( 'movepagetext' );
+                       $movepagebtn = wfMsg( 'movepagebtn' );
                        $submitVar = 'wpMove';
                        $confirm = false;
                }
@@ -124,77 +127,95 @@ class MovePageForm {
                $considerTalk = ( !$ot->isTalkPage() && $oldTalk->exists() );
 
                if ( $considerTalk ) {
-                       $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
+                       $wgOut->addWikiMsg( 'movepagetalktext' );
                }
 
-               $movearticle = wfMsgHtml( 'movearticle' );
-               $newtitle = wfMsgHtml( 'newtitle' );
-               $movereason = wfMsgHtml( 'movereason' );
-
                $titleObj = SpecialPage::getTitleFor( 'Movepage' );
-               $action = $titleObj->escapeLocalURL( 'action=submit' );
                $token = htmlspecialchars( $wgUser->editToken() );
 
                if ( $err != '' ) {
                        $wgOut->setSubtitle( wfMsg( 'formerror' ) );
                        $errMsg = "";
                        if( $err == 'hookaborted' ) {
-                               $errMsg = $hookErr;
+                               $errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n";
+                       } else if (is_array($err)) {
+                               $errMsg = '<p><strong class="error">' . call_user_func_array( 'wfMsgWikiHtml', $err ) . "</strong></p>\n";
                        } else {
-                               $errMsg = '<p class="error">' . wfMsgWikiHtml( $err ) . "</p>\n";
+                               $errMsg = '<p><strong class="error">' . wfMsgWikiHtml( $err ) . "</strong></p>\n";
                        }
                        $wgOut->addHTML( $errMsg );
                }
 
                $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
 
-               $wgOut->addHTML( "
-<form id=\"movepage\" method=\"post\" action=\"{$action}\">
-       <table border='0'>
-               <tr>
-                       <td align='$end'>{$movearticle}</td>
-                       <td align='$start'><strong>{$oldTitleLink}</strong></td>
-               </tr>
-               <tr>
-                       <td align='$end'><label for='wpNewTitle'>{$newtitle}</label></td>
-                       <td align='$start'>
-                               <input type='text' size='40' name='wpNewTitle' id='wpNewTitle' value=\"{$encNewTitle}\" />
-                               <input type='hidden' name=\"wpOldTitle\" value=\"{$encOldTitle}\" />
-                       </td>
-               </tr>
-               <tr>
-                       <td align='$end' valign='top'><br /><label for='wpReason'>{$movereason}</label></td>
-                       <td align='$start' valign='top'><br />
-                               <textarea cols='60' rows='2' name='wpReason' id='wpReason'>{$encReason}</textarea>
-                       </td>
-               </tr>" );
+               $wgOut->addHTML(
+                        Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
+                        Xml::openElement( 'fieldset' ) .
+                        Xml::element( 'legend', null, wfMsg( 'move-page-legend' ) ) .
+                        Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-movepage-table' ) ) .
+                        "<tr>
+                               <td align='$end'>" .
+                                       wfMsgHtml( 'movearticle' ) .
+                               "</td>
+                               <td align='$start'>
+                                       <strong>{$oldTitleLink}</strong>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td align='$end'>" .
+                                       Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) .
+                               "</td>
+                               <td align='$start'>" .
+                                       Xml::input( 'wpNewTitle', 40, $newTitle, array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) .
+                                       Xml::hidden( 'wpOldTitle', $oldTitle ) .
+                               "</td>
+                       </tr>
+                       <tr>
+                               <td align='$end' valign='top'><br />" .
+                                       Xml::label( wfMsg( 'movereason' ), 'wpReason' ) .
+                               "</td>
+                               <td align='$start' valign='top'><br />" .
+                                       Xml::openElement( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2 ) ) .
+                                       htmlspecialchars( $this->reason ) .
+                                       Xml::closeElement( 'textarea' ) .
+                               "</td>
+                       </tr>"
+               );
 
                if ( $considerTalk ) {
                        $wgOut->addHTML( "
-               <tr>
-                       <td></td><td>" . Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . "</td>
-               </tr>" );
+                               <tr>
+                                       <td></td>
+                                       <td>" . 
+                                               Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . 
+                                       "</td>
+                               </tr>"
+                       );
                }
 
                $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching();
-               $watch  = '<tr>';
-               $watch .= '<td></td><td>' . Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) . '</td>';
-               $watch .= '</tr>';
-               $wgOut->addHtml( $watch );
-
                $wgOut->addHTML( "
-               {$confirm}
-               <tr>
-                       <td>&nbsp;</td>
-                       <td align='$start'>
-                               <input type='submit' name=\"{$submitVar}\" value=\"{$movepagebtn}\" />
-                       </td>
-               </tr>
-       </table>
-       <input type='hidden' name='wpEditToken' value=\"{$token}\" />
-</form>\n" );
-
-       $this->showLogFragment( $ot, $wgOut );
+                       <tr>
+                               <td></td>
+                               <td>" .
+                                       Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
+                               "</td>
+                       </tr>
+                               {$confirm}
+                       <tr>
+                               <td>&nbsp;</td>
+                               <td align='$start'>" .
+                                       Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
+                               "</td>
+                       </tr>" .
+                       Xml::closeElement( 'table' ) .
+                       Xml::hidden( 'wpEditToken', $token ) .
+                       Xml::closeElement( 'fieldset' ) .
+                       Xml::closeElement( 'form' ) .
+                       "\n"
+               );
+
+               $this->showLogFragment( $ot, $wgOut );
 
        }
 
@@ -214,6 +235,15 @@ class MovePageForm {
                # Delete to make way if requested
                if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove ) {
                        $article = new Article( $nt );
+                       
+                       # Disallow deletions of big articles
+                       $bigHistory = $article->isBigDeletion();
+                       if( $bigHistory && !$nt->userCan( 'bigdelete' ) ) {
+                               global $wgLang, $wgDeleteRevisionsLimit;
+                               $this->showForm( array('delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
+                               return;
+                       }
+                       
                        // This may output an error message and exit
                        $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
                }
@@ -243,12 +273,12 @@ class MovePageForm {
                if( $ott->exists() ) {
                        if( $this->moveTalk && !$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 ) )       ;
+                                       wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) );
                                } else {
                                        $talkmoved = $error;
                                }
@@ -259,7 +289,7 @@ class MovePageForm {
                } else {
                        $talkmoved = 'notalkpage';
                }
-               
+
                # Deal with watches
                if( $this->watch ) {
                        $wgUser->addWatch( $ot );
@@ -281,45 +311,41 @@ class MovePageForm {
 
        function showSuccess() {
                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' ) );
+
+               $wgOut->setPagetitle( wfMsg( 'pagemovedsub' ) );
 
                $talkmoved = $wgRequest->getVal( 'talkmoved' );
                $oldUrl = $old->getFullUrl( 'redirect=no' );
-               $newUrl = $new->getFullURl();
-               $oldText = wfEscapeWikiText( $old->getPrefixedText() );
-               $newText = wfEscapeWikiText( $new->getPrefixedText() );
+               $newUrl = $new->getFullUrl();
+               $oldText = $old->getPrefixedText();
+               $newText = $new->getPrefixedText();
                $oldLink = "<span class='plainlinks'>[$oldUrl $oldText]</span>";
                $newLink = "<span class='plainlinks'>[$newUrl $newText]</span>";
 
-               $s = wfMsg( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
+               $s = wfMsgNoTrans( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
 
                if ( $talkmoved == 1 ) {
-                       $s .= "\n\n" . wfMsg( 'talkpagemoved' );
+                       $s .= "\n\n" . wfMsgNoTrans( 'talkpagemoved' );
                } elseif( 'articleexists' == $talkmoved ) {
-                       $s .= "\n\n" . wfMsg( 'talkexists' );
+                       $s .= "\n\n" . wfMsgNoTrans( 'talkexists' );
                } else {
                        if( !$old->isTalkPage() && $talkmoved != 'notalkpage' ) {
-                               $s .= "\n\n" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) );
+                               $s .= "\n\n" . wfMsgNoTrans( 'talkpagenotmoved', wfMsgNoTrans( $talkmoved ) );
                        }
                }
                $wgOut->addWikiText( $s );
        }
-       
+
        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 );
+               $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'move' ) ) );
+               LogEventsList::showLogExtract( $out, 'move', $title->getPrefixedText() );
        }
-       
-}
 
+}