From db2179b7f6e5adeb5d5114e8a16524ebe19b37ba Mon Sep 17 00:00:00 2001 From: Krinkle Date: Sat, 28 Jan 2012 16:26:12 +0000 Subject: [PATCH] [Special:MovePage] Split new title input, fix bug 29454 (byteLimit), namespaceSelector * Two reasons: -- Limit bug: Limit can't be enforced if the two are together because only page_title is limited, the namespace prefix is not part of the title. Plus even then, there is still ambiguity with the various ways to denote namespaces (aliases) and whitespace freedom between namespace, colon and title. -- Extra feature: Now that the two are separate it' s easier for users to move across namespaces as one doesn't have to type, can't make spelling mistakes. Also, in the future we could exclude certain target namespaces that are not possible or not allowed (now one can perfectly submit a request to move from NS_CATEGORY or NS_FILE, only to get a warning on submission). By showing them disabled in the drop down this becomes clearer). * Keeps backwards compatibility for gadgets and permalinks generated by templates on wikis so that they can still pre-set the "new title" from a url the old way. The new way can also be pre-set from the url, and allows them to be set separately (wpNewTitleNs=10&wpNewTitleMain=Infobox) * Gadgets and templates linking to Special:MovePage with a preset target -- Old way (still works): wpNewTitle=Template:Infobox -- New way: wpNewTitleNs=10 (and/or) wpNewTitleMain=Infobox * Fixes bug 29454; Depends on r109990; -- (bug 29454) Enforce byteLimit for page title input on Special:MovePage --- RELEASE-NOTES-1.19 | 2 ++ includes/specials/SpecialMovepage.php | 32 +++++++++++++++---- .../mediawiki.special.movePage.js | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 72d22ab31a..92ff7df817 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -124,6 +124,7 @@ production. * (bug 30513) Redirect tag is now resolved in XML dump file. * sha1 xml tag added to XML dump file. * (bug 33646) Badtitle error page now emits a 400 HTTP status. +* Special:MovePage now has a dropdown menu for namespaces. === Bug fixes in 1.19 === * $wgUploadNavigationUrl should be used for file redlinks if. @@ -240,6 +241,7 @@ production. * (bug 33902) Decoding %2B with mw.Uri.decode results in ' ' instead of + * (bug 33762) QueryPage-based special pages no longer misses *-summary message. * Other sizes links are no longer generated for wikis without a 404 thumbnail handler. +* (bug 29454) Enforce byteLimit for page title input on Special:MovePage === API changes in 1.19 === * Made action=edit less likely to return "unknownerror", by returning the actual error diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 5920440ee5..ad45ed8c2b 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -51,11 +51,18 @@ class MovePageForm extends UnlistedSpecialPage { $target = !is_null( $par ) ? $par : $request->getVal( 'target' ); // Yes, the use of getVal() and getText() is wanted, see bug 20365 - $oldTitleText = $request->getVal( 'wpOldTitle', $target ); - $newTitleText = $request->getText( 'wpNewTitle' ); + $oldTitleText = $request->getVal( 'wpOldTitle', $target ); $this->oldTitle = Title::newFromText( $oldTitleText ); - $this->newTitle = Title::newFromText( $newTitleText ); + + $newTitleTextMain = $request->getText( 'wpNewTitleMain' ); + $newTitleTextNs = $request->getInt( 'wpNewTitleNs', $this->oldTitle->getNamespace() ); + // Backwards compatibility for forms submitting here from other sources + // which is more common than it should be.. + $newTitleText_bc = $request->getText( 'wpNewTitle' ); + $this->newTitle = strlen( $newTitleText_bc ) > 0 + ? Title::newFromText( $newTitleText_bc ) + : Title::makeTitleSafe( $newTitleTextNs, $newTitleTextMain ); if( is_null( $this->oldTitle ) ) { throw new ErrorPageError( 'notargettitle', 'notargettext' ); @@ -113,7 +120,7 @@ class MovePageForm extends UnlistedSpecialPage { $newTitle = $this->newTitle; - if( !$newTitle ) { + if ( !$newTitle ) { # Show the current title as a default # when the form is first opened. $newTitle = $this->oldTitle; @@ -235,6 +242,9 @@ class MovePageForm extends UnlistedSpecialPage { $out->addHTML( "\n" ); } + // Byte limit (not string length limit) for wpReason and wpNewTitleMain + // is enforced in the mediawiki.special.movePage module + $out->addHTML( Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) . Xml::openElement( 'fieldset' ) . @@ -250,10 +260,18 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::label( wfMsg( 'newtitle' ), 'wpNewTitle' ) . + Xml::label( wfMsg( 'newtitle' ), 'wpNewTitleMain' ) . " " . - Xml::input( 'wpNewTitle', 60, $wgContLang->recodeForEdit( $newTitle->getPrefixedText() ), array( 'type' => 'text', 'id' => 'wpNewTitle' ) ) . + Html::namespaceSelector( + array( 'selected' => $newTitle->getNamespace() ), + array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' ) + ) . + Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getBaseText() ), array( + 'type' => 'text', + 'id' => 'wpNewTitleMain', + 'maxlength' => 255, + ) ) . Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) . " @@ -263,7 +281,7 @@ class MovePageForm extends UnlistedSpecialPage { " " . Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2, - 'maxlength' => 200 ), $this->reason ) . // maxlength byte limit is enforce in mediawiki.special.movePage.js + 'maxlength' => 200 ), $this->reason ) . " " ); diff --git a/resources/mediawiki.special/mediawiki.special.movePage.js b/resources/mediawiki.special/mediawiki.special.movePage.js index 2f94cc06c3..68c2ed078e 100644 --- a/resources/mediawiki.special/mediawiki.special.movePage.js +++ b/resources/mediawiki.special/mediawiki.special.movePage.js @@ -1,5 +1,5 @@ /* JavaScript for Special:MovePage */ jQuery( function( $ ) { - $( '#wpReason' ).byteLimit(); + $( '#wpReason, #wpNewTitleMain' ).byteLimit(); }); -- 2.20.1