X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialMovepage.php;h=cfc434ae5f6d6fb19fc69ac4bb964e92108efc3e;hb=04bfab85fbaa9b26d95b92aea9d0c321e3bae8f4;hp=b5fa9e13a9c61b9292488363b7a9506ca9baea78;hpb=7ffbd3933367b0e99c6da1469f686f69f2071e5c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index b5fa9e13a9..cfc434ae5f 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -1,19 +1,18 @@ isAllowed( 'move' ) || ( $wgOnlySysopMayMove && $wgUser->isNewbie() ) ) { - $wgOut->showErrorPage( 'movenologin', 'movenologintext' ); + if ( !$wgUser->isAllowed( 'move' ) ) { + $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; @@ -56,12 +56,20 @@ class MovePageForm { $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $target ); $this->newTitle = $wgRequest->getText( 'wpNewTitle' ); $this->reason = $wgRequest->getText( 'wpReason' ); - $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); + if ( $wgRequest->wasPosted() ) { + $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', false ); + } else { + $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; + global $wgOut, $wgUser, $wgContLang; + + $start = $wgContLang->isRTL() ? 'right' : 'left'; + $end = $wgContLang->isRTL() ? 'left' : 'right'; $wgOut->setPagetitle( wfMsg( 'movepage' ) ); @@ -97,14 +105,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 { @@ -123,10 +127,9 @@ class MovePageForm { $movearticle = wfMsgHtml( 'movearticle' ); $newtitle = wfMsgHtml( 'newtitle' ); - $movetalk = wfMsgHtml( 'movetalk' ); $movereason = wfMsgHtml( 'movereason' ); - $titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' ); + $titleObj = SpecialPage::getTitleFor( 'Movepage' ); $action = $titleObj->escapeLocalURL( 'action=submit' ); $token = htmlspecialchars( $wgUser->editToken() ); @@ -141,19 +144,19 @@ class MovePageForm {
- - + + - - + - - + " ); @@ -161,17 +164,21 @@ class MovePageForm { if ( $considerTalk ) { $wgOut->addHTML( " - - + " ); } + + $watchChecked = $this->watch || $wgUser->getBoolOption( 'watchmoves' ) || $ot->userIsWatching(); + $watch = ''; + $watch .= ''; + $watch .= ''; + $wgOut->addHtml( $watch ); + $wgOut->addHTML( " {$confirm} - @@ -185,7 +192,6 @@ class MovePageForm { function doSubmit() { global $wgOut, $wgUser, $wgRequest; - $fname = "MovePageForm::doSubmit"; if ( $wgUser->pingLimiter( 'move' ) ) { $wgOut->rateLimited(); @@ -221,7 +227,7 @@ class MovePageForm { # 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() ) { + if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) { $ntt = $nt->getTalkPage(); # Attempt the move @@ -239,9 +245,18 @@ 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 = Title::makeTitle( NS_SPECIAL, 'Movepage' ); + $titleObj = SpecialPage::getTitleFor( 'Movepage' ); $success = $titleObj->getFullURL( 'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) . '&newtitle=' . wfUrlencode( $nt->getPrefixedText() ) . @@ -251,32 +266,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 = $old->getPrefixedText(); + $newText = $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 ) { @@ -287,4 +308,4 @@ class MovePageForm { } } -?> +
{$movearticle}:{$oldTitle}{$movearticle}{$oldTitle}
+


+


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