Merge "HTMLTitleTextField: Support 'relative' config option"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 27 Jul 2015 02:12:47 +0000 (02:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 27 Jul 2015 02:12:47 +0000 (02:12 +0000)
includes/htmlform/HTMLForm.php
includes/htmlform/HTMLSelectAndOtherField.php
includes/htmlform/HTMLSelectOrOtherField.php
includes/htmlform/HTMLTitleTextField.php
includes/specials/SpecialChangeContentModel.php
languages/i18n/en.json
languages/i18n/qqq.json

index 48cc828..a56b398 100644 (file)
@@ -1302,11 +1302,14 @@ class HTMLForm extends ContextSource {
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
        public function setMethod( $method = 'post' ) {
-               $this->mMethod = $method;
+               $this->mMethod = strtolower( $method );
 
                return $this;
        }
 
+       /**
+        * @return string Always lowercase
+        */
        public function getMethod() {
                return $this->mMethod;
        }
index 23ca3bf..0e4f4f3 100644 (file)
@@ -64,6 +64,10 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
                return "$select<br />\n$textbox";
        }
 
+       function getInputOOUI( $value ) {
+               return false;
+       }
+
        /**
         * @param WebRequest $request
         *
index cbf7d12..3e7acdf 100644 (file)
@@ -62,6 +62,10 @@ class HTMLSelectOrOtherField extends HTMLTextField {
                return "$select<br />\n$textbox";
        }
 
+       function getInputOOUI( $value ) {
+               return false;
+       }
+
        /**
         * @param WebRequest $request
         *
index 6e5242c..a225c67 100644 (file)
@@ -7,7 +7,8 @@ use MediaWiki\Widget\TitleInputWidget;
  * Automatically does validation that the title is valid,
  * as well as autocompletion if using the OOUI display format.
  *
- * FIXME: Does not work for forms that support GET requests.
+ * Note: Forms using GET requests will need to make sure the title value is not
+ * an empty string.
  *
  * Optional parameters:
  * 'namespace' - Namespace the page must be in
@@ -30,6 +31,11 @@ class HTMLTitleTextField extends HTMLTextField {
        }
 
        public function validate( $value, $alldata ) {
+               if ( $this->mParent->getMethod() === 'get' && $value === '' ) {
+                       // If the form is a GET form and has no value, assume it hasn't been
+                       // submitted yet, and skip validation
+                       return parent::validate( $value, $alldata );
+               }
                try {
                        if ( !$this->mParams['relative'] ) {
                                $title = Title::newFromTextThrow( $value );
index 7647999..cce5da5 100644 (file)
@@ -44,22 +44,10 @@ class SpecialChangeContentModel extends FormSpecialPage {
                        // No form input yet
                        return true;
                }
-               try {
-                       $titleObj = Title::newFromTextThrow( $title );
-               } catch ( MalformedTitleException $e ) {
-                       $msg = $this->msg( $e->getErrorMessage() );
-                       $params = $e->getErrorMessageParameters();
-                       if ( $params ) {
-                               $msg->params( $params );
-                       }
-                       return $msg->parse();
-               }
-               if ( !$titleObj->canExist() ) {
-                       return $this->msg(
-                               'changecontentmodel-title-cantexist',
-                               $titleObj->getPrefixedText()
-                       )->escaped();
-               }
+
+               // Already validated by HTMLForm, but if not, throw
+               // and exception instead of a fatal
+               $titleObj = Title::newFromTextThrow( $title );
 
                $this->oldRevision = Revision::newFromTitle( $titleObj ) ?: false;
 
@@ -79,7 +67,8 @@ class SpecialChangeContentModel extends FormSpecialPage {
                $that = $this;
                $fields = array(
                        'pagetitle' => array(
-                               'type' => 'text',
+                               'type' => 'title',
+                               'creatable' => true,
                                'name' => 'pagetitle',
                                'default' => $this->par,
                                'label-message' => 'changecontentmodel-title-label',
index 1fdd75d..97f1310 100644 (file)
        "changecontentmodel-success-title": "The content model was changed",
        "changecontentmodel-success-text": "The content type of [[:$1]] has been changed.",
        "changecontentmodel-cannot-convert": "The content on [[:$1]] cannot be converted to a type of $2.",
-       "changecontentmodel-title-cantexist": "It is not possible to have a page at $1.",
        "changecontentmodel-nodirectediting": "The $1 content model does not support direct editing",
        "log-name-contentmodel": "Content model change log",
        "log-description-contentmodel": "Events related to the content models of a page",
index 872a89f..4137931 100644 (file)
        "changecontentmodel-success-title": "Title of the success page of the change content model special page",
        "changecontentmodel-success-text": "Message telling user that their change has been successfully done.\n* $1 - Target page title",
        "changecontentmodel-cannot-convert": "Error message shown if the content model cannot be changed to the specified type. $1 is the page title, $2 is the localized content model name.",
-       "changecontentmodel-title-cantexist": "Error message shown if the page the user provided is a special page.\n\nParameters:\n* $1 - the page title which cannot exist",
        "changecontentmodel-nodirectediting": "Error message shown if the content model does not allow for direct editing. $1 is the localized name of the content model.",
        "log-name-contentmodel": "{{doc-logpage}}\n\nTitle of [[Special:Log/contentmodel]].",
        "log-description-contentmodel": "Text in [[Special:Log/contentmodel]].",