From: Alexandre Emsenhuber Date: Sun, 8 Aug 2010 18:46:49 +0000 (+0000) Subject: Modified Special:Movepage to subclass UnlistedSpecialPage X-Git-Tag: 1.31.0-rc.0~35596 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=1bb036611705e1eb3f287e8372efb8d0bdcbc30a;p=lhc%2Fweb%2Fwiklou.git Modified Special:Movepage to subclass UnlistedSpecialPage --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 78fb06f1a6..81a9052bd8 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -185,7 +185,7 @@ class SpecialPage { 'Blankpage' => 'SpecialBlankpage', 'Blockme' => 'SpecialBlockme', 'Emailuser' => 'SpecialEmailUser', - 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ), + 'Movepage' => 'MovePageForm', 'Mycontributions' => 'SpecialMycontributions', 'Mypage' => 'SpecialMypage', 'Mytalk' => 'SpecialMytalk', diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 2f78b53c24..00ef62ee85 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -18,87 +18,74 @@ */ /** - * @file + * Implements Special:Movepage * @ingroup SpecialPage */ +class MovePageForm extends UnlistedSpecialPage { + var $oldTitle, $newTitle; # Objects + var $reason; # Text input + var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks -/** - * Constructor - */ -function wfSpecialMovepage( $par = null ) { - global $wgUser, $wgOut, $wgRequest; + private $watch = false; - # Check for database lock - if ( wfReadOnly() ) { - $wgOut->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' ); - - $oldTitle = Title::newFromText( $oldTitleText ); - $newTitle = Title::newFromText( $newTitleText ); + # Check for database lock + if ( wfReadOnly() ) { + $wgOut->readOnlyPage(); + return; + } - if( is_null( $oldTitle ) ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); - return; - } - if( !$oldTitle->exists() ) { - $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); - return; - } + $this->setHeaders(); + $this->outputHeader(); - # Check rights - $permErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser ); - if( !empty( $permErrors ) ) { - $wgOut->showPermissionsErrorPage( $permErrors ); - return; - } + $target = !is_null( $par ) ? $par : $wgRequest->getVal( 'target' ); - $form = new MovePageForm( $oldTitle, $newTitle ); + // Yes, the use of getVal() and getText() is wanted, see bug 20365 + $oldTitleText = $wgRequest->getVal( 'wpOldTitle', $target ); + $newTitleText = $wgRequest->getText( 'wpNewTitle' ); - if ( 'submit' == $wgRequest->getVal( 'action' ) && $wgRequest->wasPosted() - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $form->doSubmit(); - } else { - $form->showForm( '' ); - } -} + $this->oldTitle = Title::newFromText( $oldTitleText ); + $this->newTitle = Title::newFromText( $newTitleText ); -/** - * 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 + if( is_null( $this->oldTitle ) ) { + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); + return; + } + if( !$this->oldTitle->exists() ) { + $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); + return; + } - private $watch = false; + # Check rights + $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $wgUser ); + if( !empty( $permErrors ) ) { + $wgOut->showPermissionsErrorPage( $permErrors ); + return; + } - function __construct( $oldTitle, $newTitle ) { - global $wgRequest, $wgUser; + $def = !$wgRequest->wasPosted(); - $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( '' ); + } } /** @@ -183,7 +170,6 @@ class MovePageForm { $wgOut->addWikiMsg( 'movepagetalktext' ); } - $titleObj = SpecialPage::getTitleFor( 'Movepage' ); $token = htmlspecialchars( $wgUser->editToken() ); if ( !empty($err) ) { @@ -214,7 +200,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' ) ) .