X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSpecialMovepage.php;h=33f043d6992c96222bc7720c180e71a21f6c2dbd;hb=228f097d954469673634ea47c08ccc9adddca7dd;hp=6a3e03e329f6d93fa810b288dd598ec884907051;hpb=c771fc9c96aacb44b86ade5ecca68334c5d8213f;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php
index 6a3e03e329..33f043d699 100644
--- a/includes/SpecialMovepage.php
+++ b/includes/SpecialMovepage.php
@@ -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;
}
@@ -41,13 +41,13 @@ function wfSpecialMovepage( $par = null ) {
}
/**
- *
+ * HTML form for Special:Movepage
* @addtogroup SpecialPage
*/
class MovePageForm {
var $oldTitle, $newTitle, $reason; # Text input
var $moveTalk, $deleteAndMove;
-
+
private $watch = false;
function MovePageForm( $par ) {
@@ -65,23 +65,27 @@ class MovePageForm {
$this->watch = $wgRequest->getCheck( 'wpWatch' );
}
- function showForm( $err ) {
+ function showForm( $err, $hookErr = '' ) {
global $wgOut, $wgUser;
- $wgOut->setPagetitle( wfMsg( 'movepage' ) );
-
$ot = Title::newFromURL( $this->oldTitle );
if( is_null( $ot ) ) {
$wgOut->showErrorPage( 'notargettitle', 'notargettext' );
return;
}
+
+ $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 );
@@ -95,26 +99,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' );
- $confirmText = wfMsgHtml( 'delete_and_move_confirm' );
+ $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle );
+ $movepagebtn = wfMsg( 'delete_and_move' );
$submitVar = 'wpDeleteAndMove';
$confirm = "
-
-
- |
- |
+ |
+ " .
+ Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) .
+ " |
";
$err = '';
} else {
- $wgOut->addWikiText( wfMsg( 'movepagetext' ) );
- $movepagebtn = wfMsgHtml( 'movepagebtn' );
+ $wgOut->addWikiMsg( 'movepagetext' );
+ $movepagebtn = wfMsg( 'movepagebtn' );
$submitVar = 'wpMove';
$confirm = false;
}
@@ -123,76 +125,91 @@ class MovePageForm {
$considerTalk = ( !$ot->isTalkPage() && $oldTalk->exists() );
if ( $considerTalk ) {
- $wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
+ $wgOut->addWikiMsg( 'movepagetalktext' );
}
- $movearticle = wfMsgHtml( 'movearticle' );
- $newtitle = wfMsgHtml( 'newtitle' );
- $movetalk = wfMsgHtml( 'movetalk' );
- $movereason = wfMsgHtml( 'movereason' );
-
$titleObj = SpecialPage::getTitleFor( 'Movepage' );
- $action = $titleObj->escapeLocalURL( 'action=submit' );
$token = htmlspecialchars( $wgUser->editToken() );
if ( $err != '' ) {
$wgOut->setSubtitle( wfMsg( 'formerror' ) );
- $wgOut->addWikiText( '' . wfMsg($err) . "
\n" );
+ $errMsg = "";
+ if( $err == 'hookaborted' ) {
+ $errMsg = "$hookErr
\n";
+ } else if (is_array($err)) {
+ $errMsg = '' . call_user_func_array( 'wfMsgWikiHtml', $err ) . "
\n";
+ } else {
+ $errMsg = '' . wfMsgWikiHtml( $err ) . "
\n";
+ }
+ $wgOut->addHTML( $errMsg );
}
- $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : '';
-
- $wgOut->addHTML( "
-\n" );
-
- $this->showLogFragment( $ot, $wgOut );
+
+ |
+ " .
+ Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
+ " |
+
+ {$confirm}
+
+ |
+ " .
+ Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) .
+ " |
+
" .
+ Xml::closeElement( 'table' ) .
+ Xml::hidden( 'wpEditToken', $token ) .
+ Xml::closeElement( 'fieldset' ) .
+ Xml::closeElement( 'form' ) .
+ "\n"
+ );
+
+ $this->showLogFragment( $ot, $wgOut );
}
@@ -212,6 +229,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' ) );
}
@@ -222,6 +248,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 );
@@ -235,12 +267,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;
}
@@ -251,7 +283,7 @@ class MovePageForm {
} else {
$talkmoved = 'notalkpage';
}
-
+
# Deal with watches
if( $this->watch ) {
$wgUser->addWatch( $ot );
@@ -272,40 +304,42 @@ class MovePageForm {
}
function showSuccess() {
- global $wgOut, $wgRequest, $wgRawHtml;
-
- $wgOut->setPagetitle( wfMsg( 'movepage' ) );
- $wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
-
- $oldText = wfEscapeWikiText( $wgRequest->getVal('oldtitle') );
- $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') );
- $talkmoved = $wgRequest->getVal('talkmoved');
-
- $text = wfMsg( 'pagemovedtext', $oldText, $newText );
-
- $allowHTML = $wgRawHtml;
- $wgRawHtml = false;
- $wgOut->addWikiText( $text );
- $wgRawHtml = $allowHTML;
+ 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( 'pagemovedsub' ) );
+
+ $talkmoved = $wgRequest->getVal( 'talkmoved' );
+ $oldUrl = $old->getFullUrl( 'redirect=no' );
+ $newUrl = $new->getFullUrl();
+ $oldText = $old->getPrefixedText();
+ $newText = $new->getPrefixedText();
+ $oldLink = "[$oldUrl $oldText]";
+ $newLink = "[$newUrl $newText]";
+
+ $s = wfMsgNoTrans( 'movepage-moved', $oldLink, $newLink, $oldText, $newText );
if ( $talkmoved == 1 ) {
- $wgOut->addWikiText( wfMsg( 'talkpagemoved' ) );
+ $s .= "\n\n" . wfMsgNoTrans( 'talkpagemoved' );
} elseif( 'articleexists' == $talkmoved ) {
- $wgOut->addWikiText( wfMsg( 'talkexists' ) );
+ $s .= "\n\n" . wfMsgNoTrans( '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" . 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() );
}
-
+
}
-?>