X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialMovepage.php;h=dbed975ad1caee596b67473aa989480ac97fb1f6;hb=90c703d61c485c633b214f78f48102c2848b82d8;hp=596b62b2d09a51ab51f61a46f8e7c74515428e28;hpb=4a099928f73222b2c92c6bc66384649f3022def1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 596b62b2d0..dbed975ad1 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -1,93 +1,104 @@ readOnlyPage(); - return; + public function __construct() { + parent::__construct( 'Movepage' ); } - $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' ); + public function execute( $par ) { + global $wgUser, $wgOut, $wgRequest; - // Yes, the use of getVal() and getText() is wanted, see bug 20365 - $oldTitleText = $wgRequest->getVal( 'wpOldTitle', $target ); - $newTitleText = $wgRequest->getText( 'wpNewTitle' ); + # Check for database lock + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } - $oldTitle = Title::newFromText( $oldTitleText ); - $newTitle = Title::newFromText( $newTitleText ); + $this->setHeaders(); + $this->outputHeader(); - if( is_null( $oldTitle ) ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); - return; - } - if( !$oldTitle->exists() ) { - $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); - return; - } + $target = !is_null( $par ) ? $par : $wgRequest->getVal( 'target' ); - # Check rights - $permErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser ); - if( !empty( $permErrors ) ) { - $wgOut->showPermissionsErrorPage( $permErrors ); - return; - } + // Yes, the use of getVal() and getText() is wanted, see bug 20365 + $oldTitleText = $wgRequest->getVal( 'wpOldTitle', $target ); + $newTitleText = $wgRequest->getText( 'wpNewTitle' ); - $form = new MovePageForm( $oldTitle, $newTitle ); + $this->oldTitle = Title::newFromText( $oldTitleText ); + $this->newTitle = Title::newFromText( $newTitleText ); - if ( 'submit' == $action && $wgRequest->wasPosted() - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $form->doSubmit(); - } else { - $form->showForm( '' ); - } -} + if( is_null( $this->oldTitle ) ) { + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); + return; + } + if( !$this->oldTitle->exists() ) { + $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); + return; + } -/** - * HTML form for Special:Movepage - * @ingroup SpecialPage - */ -class MovePageForm { - var $oldTitle, $newTitle; # Objects - var $reason; # Text input - var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks + # Check rights + $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $wgUser ); + if( !empty( $permErrors ) ) { + $wgOut->showPermissionsErrorPage( $permErrors ); + return; + } - private $watch = false; + $def = !$wgRequest->wasPosted(); - function __construct( $oldTitle, $newTitle ) { - global $wgRequest; - $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); - $this->oldTitle = $oldTitle; - $this->newTitle = $newTitle; $this->reason = $wgRequest->getText( 'wpReason' ); - if ( $wgRequest->wasPosted() ) { - $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', false ); - $this->fixRedirects = $wgRequest->getBool( 'wpFixRedirects', false ); - $this->leaveRedirect = $wgRequest->getBool( 'wpLeaveRedirect', false ); - } else { - $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', true ); - $this->fixRedirects = $wgRequest->getBool( 'wpFixRedirects', true ); - $this->leaveRedirect = $wgRequest->getBool( 'wpLeaveRedirect', true ); - } + $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', $def ); + $this->fixRedirects = $wgRequest->getBool( 'wpFixRedirects', $def ); + $this->leaveRedirect = $wgRequest->getBool( 'wpLeaveRedirect', $def ); $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false ); $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); $this->moveOverShared = $wgRequest->getBool( 'wpMoveOverSharedFile', false ); $this->watch = $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn(); + + if ( 'submit' == $wgRequest->getVal( 'action' ) && $wgRequest->wasPosted() + && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + $this->doSubmit(); + } else { + $this->showForm( '' ); + } } /** * Show the form - * @param mixed $err Error message. May either be a string message name or - * array message name and parameters, like the second argument to - * OutputPage::wrapWikiMsg(). + * + * @param $err Mixed: error message. May either be a string message name or + * array message name and parameters, like the second argument to + * OutputPage::wrapWikiMsg(). */ function showForm( $err ) { global $wgOut, $wgUser, $wgContLang, $wgFixDoubleRedirects; @@ -97,7 +108,7 @@ class MovePageForm { $oldTitleLink = $skin->link( $this->oldTitle ); $wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) ); - $wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) ); + $skin->setRelevantTitle( $this->oldTitle ); $newTitle = $this->newTitle; @@ -131,7 +142,11 @@ class MovePageForm { "; $err = ''; } else { - $wgOut->addWikiMsg( 'movepagetext' ); + if ($this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) { + $wgOut->wrapWikiMsg( "
$hookErr
\n"; $wgOut->addHTML( $errMsg ); } else { - $wgOut->wrapWikiMsg( '$1
', $err ); + $wgOut->wrapWikiMsg( "\n$1\n
", $err ); } } @@ -192,7 +206,7 @@ class MovePageForm { } $wgOut->addHTML( - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) . + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->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' ) ) . @@ -210,7 +224,7 @@ class MovePageForm { "