*/
/**
- * @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( '' );
+ }
}
/**
$wgOut->addWikiMsg( 'movepagetalktext' );
}
- $titleObj = SpecialPage::getTitleFor( 'Movepage' );
$token = htmlspecialchars( $wgUser->editToken() );
if ( !empty($err) ) {
}
$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' ) ) .