SpecialMovepage: Don't change button text when moving over existing page
[lhc/web/wiklou.git] / includes / specials / SpecialMovepage.php
index ab28fa4..e9fb75b 100644 (file)
@@ -77,11 +77,9 @@ class MovePageForm extends UnlistedSpecialPage {
                // Yes, the use of getVal() and getText() is wanted, see bug 20365
 
                $oldTitleText = $request->getVal( 'wpOldTitle', $target );
-               if ( is_string( $oldTitleText ) ) {
-                       $this->oldTitle = Title::newFromText( $oldTitleText );
-               }
+               $this->oldTitle = Title::newFromText( $oldTitleText );
 
-               if ( $this->oldTitle === null ) {
+               if ( !$this->oldTitle ) {
                        // Either oldTitle wasn't passed, or newFromText returned null
                        throw new ErrorPageError( 'notargettitle', 'notargettext' );
                }
@@ -142,14 +140,31 @@ class MovePageForm extends UnlistedSpecialPage {
 
                $this->getSkin()->setRelevantTitle( $this->oldTitle );
 
-               $oldTitleLink = Linker::link( $this->oldTitle );
-
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) );
                $out->addModules( 'mediawiki.special.movePage' );
                $out->addModuleStyles( 'mediawiki.special.movePage.styles' );
                $this->addHelpLink( 'Help:Moving a page' );
 
+               if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
+                       $out->wrapWikiMsg(
+                               "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>",
+                               'moveuserpage-warning'
+                       );
+               } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
+                       $out->wrapWikiMsg(
+                               "<div class=\"error mw-movecategorypage-warning\">\n$1\n</div>",
+                               'movecategorypage-warning'
+                       );
+               }
+
+               $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
+                       'movepagetext' :
+                       'movepagetext-noredirectfixer'
+               );
+               $submitVar = 'wpMove';
+               $confirm = false;
+
                $newTitle = $this->newTitle;
 
                if ( !$newTitle ) {
@@ -172,30 +187,9 @@ class MovePageForm extends UnlistedSpecialPage {
                        && $newTitle->quickUserCan( 'delete', $user )
                ) {
                        $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
-                       $movepagebtn = $this->msg( 'delete_and_move' )->text();
                        $submitVar = 'wpDeleteAndMove';
                        $confirm = true;
                        $err = array();
-               } else {
-                       if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) {
-                               $out->wrapWikiMsg(
-                                       "<div class=\"error mw-moveuserpage-warning\">\n$1\n</div>",
-                                       'moveuserpage-warning'
-                               );
-                       } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) {
-                               $out->wrapWikiMsg(
-                                       "<div class=\"error mw-movecategorypage-warning\">\n$1\n</div>",
-                                       'movecategorypage-warning'
-                               );
-                       }
-
-                       $out->addWikiMsg( $this->getConfig()->get( 'FixDoubleRedirects' ) ?
-                               'movepagetext' :
-                               'movepagetext-noredirectfixer'
-                       );
-                       $movepagebtn = $this->msg( 'movepagebtn' )->text();
-                       $submitVar = 'wpMove';
-                       $confirm = false;
                }
 
                if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'file-exists-sharedrepo'
@@ -230,10 +224,6 @@ class MovePageForm extends UnlistedSpecialPage {
                        $hasRedirects = false;
                }
 
-               if ( $considerTalk ) {
-                       $out->addWikiMsg( 'movepagetalktext' );
-               }
-
                if ( count( $err ) ) {
                        $out->addHTML( "<div class='error'>\n" );
                        $action_desc = $this->msg( 'action-move' )->plain();
@@ -302,16 +292,6 @@ class MovePageForm extends UnlistedSpecialPage {
                $out->enableOOUI();
                $fields = array();
 
-               $fields[] = new OOUI\FieldLayout(
-                       new OOUI\LabelWidget( array(
-                               'label' => new OOUI\HtmlSnippet( "<strong>$oldTitleLink</strong>" )
-                       ) ),
-                       array(
-                               'label' => $this->msg( 'movearticle' )->text(),
-                               'align' => 'top',
-                       )
-               );
-
                $fields[] = new OOUI\FieldLayout(
                        new MediaWiki\Widget\ComplexTitleInputWidget( array(
                                'id' => 'wpNewTitle',
@@ -360,7 +340,9 @@ class MovePageForm extends UnlistedSpecialPage {
                                ) ),
                                array(
                                        'label' => $this->msg( 'movetalk' )->text(),
+                                       'help' => new OOUI\HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
                                        'align' => 'inline',
+                                       'infusable' => true,
                                )
                        );
                }
@@ -462,8 +444,8 @@ class MovePageForm extends UnlistedSpecialPage {
                $fields[] = new OOUI\FieldLayout(
                        new OOUI\ButtonInputWidget( array(
                                'name' => $submitVar,
-                               'value' => $movepagebtn,
-                               'label' => $movepagebtn,
+                               'value' => $this->msg( 'movepagebtn' )->text(),
+                               'label' => $this->msg( 'movepagebtn' )->text(),
                                'flags' => array( 'constructive', 'primary' ),
                                'type' => 'submit',
                        ) ),
@@ -616,7 +598,7 @@ class MovePageForm extends UnlistedSpecialPage {
                $newText = $nt->getPrefixedText();
 
                if ( $ot->exists() ) {
-                       //NOTE: we assume that if the old title exists, it's because it was re-created as
+                       // NOTE: we assume that if the old title exists, it's because it was re-created as
                        // a redirect to the new title. This is not safe, but what we did before was
                        // even worse: we just determined whether a redirect should have been created,
                        // and reported that it was created if it should have, without any checks.
@@ -643,17 +625,16 @@ class MovePageForm extends UnlistedSpecialPage {
                        $this->moveSubpages = false;
                }
 
-               # Next make a list of id's.  This might be marginally less efficient
-               # than a more direct method, but this is not a highly performance-cri-
-               # tical code path and readable code is more important here.
-               #
-               # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
-               # 4 might get confused.  If so, consider rewriting as a UNION.
-               #
-               # If the target namespace doesn't allow subpages, moving with subpages
-               # would mean that you couldn't move them back in one operation, which
-               # is bad.
-               # @todo FIXME: A specific error message should be given in this case.
+               /**
+                * Next make a list of id's.  This might be marginally less efficient
+                * than a more direct method, but this is not a highly performance-cri-
+                * tical code path and readable code is more important here.
+                *
+                * If the target namespace doesn't allow subpages, moving with subpages
+                * would mean that you couldn't move them back in one operation, which
+                * is bad.
+                * @todo FIXME: A specific error message should be given in this case.
+                */
 
                // @todo FIXME: Use Title::moveSubpages() here
                $dbr = wfGetDB( DB_MASTER );