SpecialChangeContentModel: Use autocomplete for title field
authorKunal Mehta <legoktm@gmail.com>
Wed, 1 Jul 2015 05:31:14 +0000 (22:31 -0700)
committerKunal Mehta <legoktm@gmail.com>
Sat, 25 Jul 2015 01:25:05 +0000 (18:25 -0700)
Change-Id: I766da59e6cbf7ed8f887d1a684ea9e284e9cf67e

includes/specials/SpecialChangeContentModel.php
languages/i18n/en.json
languages/i18n/qqq.json

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]].",