X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialMovepage.php;h=7a003bbb2e9da6cb907b9d958058fd6a6a828d58;hb=08aec83eb97be75b0fc9bdff67f3652c33ef1cbc;hp=6701c083d30877e447d47b9b17012bc283501643;hpb=14c53b728fe55f9ad21647b2303c49f1cb491901;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 6701c083d3..7a003bbb2e 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -1,8 +1,7 @@ isAllowed( 'move' ) ) { - $wgOut->showErrorPage( 'movenologin', 'movenologintext' ); + $wgOut->showPermissionsErrorPage( array( $wgUser->isAnon() ? 'movenologintext' : 'movenotallowed' ) ); return; } @@ -42,13 +41,14 @@ function wfSpecialMovepage( $par = null ) { } /** - * - * @package MediaWiki - * @subpackage SpecialPage + * HTML form for Special:Movepage + * @addtogroup SpecialPage */ class MovePageForm { var $oldTitle, $newTitle, $reason; # Text input var $moveTalk, $deleteAndMove; + + private $watch = false; function MovePageForm( $par ) { global $wgRequest; @@ -62,10 +62,14 @@ class MovePageForm { $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); } $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); + $this->watch = $wgRequest->getCheck( 'wpWatch' ); } - function showForm( $err ) { - global $wgOut, $wgUser; + function showForm( $err, $hookErr = '' ) { + global $wgOut, $wgUser, $wgContLang; + + $start = $wgContLang->isRTL() ? 'right' : 'left'; + $end = $wgContLang->isRTL() ? 'left' : 'right'; $wgOut->setPagetitle( wfMsg( 'movepage' ) ); @@ -74,6 +78,8 @@ class MovePageForm { $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); return; } + $sk = $wgUser->getSkin(); + $oldTitleLink = $sk->makeLinkObj( $ot ); $oldTitle = $ot->getPrefixedText(); $encOldTitle = htmlspecialchars( $oldTitle ); @@ -101,14 +107,10 @@ class MovePageForm { 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' ); $submitVar = 'wpDeleteAndMove'; $confirm = " - - - - + " . Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) . " "; $err = ''; } else { @@ -127,7 +129,6 @@ class MovePageForm { $movearticle = wfMsgHtml( 'movearticle' ); $newtitle = wfMsgHtml( 'newtitle' ); - $movetalk = wfMsgHtml( 'movetalk' ); $movereason = wfMsgHtml( 'movereason' ); $titleObj = SpecialPage::getTitleFor( 'Movepage' ); @@ -136,7 +137,13 @@ class MovePageForm { if ( $err != '' ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); - $wgOut->addWikiText( '

' . wfMsg($err) . "

\n" ); + $errMsg = ""; + if( $err == 'hookaborted' ) { + $errMsg = "

$hookErr

\n"; + } else { + $errMsg = '

' . wfMsgWikiHtml( $err ) . "

\n"; + } + $wgOut->addHTML( $errMsg ); } $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : ''; @@ -145,19 +152,19 @@ class MovePageForm {
- - + + - - + - - + " ); @@ -165,17 +172,21 @@ class MovePageForm { if ( $considerTalk ) { $wgOut->addHTML( " - - + " ); } + + $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching(); + $watch = ''; + $watch .= ''; + $watch .= ''; + $wgOut->addHtml( $watch ); + $wgOut->addHTML( " {$confirm} - @@ -183,7 +194,7 @@ class MovePageForm { \n" ); - $this->showLogFragment( $ot, $wgOut ); + $this->showLogFragment( $ot, $wgOut ); } @@ -213,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 ); @@ -242,6 +259,15 @@ class MovePageForm { } else { $talkmoved = 'notalkpage'; } + + # Deal with watches + if( $this->watch ) { + $wgUser->addWatch( $ot ); + $wgUser->addWatch( $nt ); + } else { + $wgUser->removeWatch( $ot ); + $wgUser->removeWatch( $nt ); + } # Give back result to user. $titleObj = SpecialPage::getTitleFor( 'Movepage' ); @@ -254,32 +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 = "[$oldUrl $oldText]"; + $newLink = "[$newUrl $newText]"; - $text = wfMsg( 'pagemovedtext', $oldText, $newText ); - - $allowHTML = $wgRawHtml; - $wgRawHtml = false; - $wgOut->addWikiText( $text ); - $wgRawHtml = $allowHTML; + $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 ) { @@ -290,4 +322,4 @@ class MovePageForm { } } -?> +
{$movearticle}:{$oldTitle}{$movearticle}{$oldTitleLink}
+


+


- - " . Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $moveTalkChecked ) . "
' . Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) . '
  +