Merge "Use WatchedItemStore::countWatchers in SpecialWatchlist"
[lhc/web/wiklou.git] / includes / specials / SpecialChangeContentModel.php
index 1f32e3f..ee9f665 100644 (file)
@@ -41,6 +41,11 @@ class SpecialChangeContentModel extends FormSpecialPage {
                if ( !$this->title ) {
                        $form->setMethod( 'GET' );
                }
+
+               $this->addHelpLink( 'Help:ChangeContentModel' );
+
+               // T120576
+               $form->setSubmitTextMsg( 'changecontentmodel-submit' );
        }
 
        public function validateTitle( $title ) {
@@ -68,40 +73,39 @@ class SpecialChangeContentModel extends FormSpecialPage {
        }
 
        protected function getFormFields() {
-               $that = $this;
-               $fields = array(
-                       'pagetitle' => array(
+               $fields = [
+                       'pagetitle' => [
                                'type' => 'title',
                                'creatable' => true,
                                'name' => 'pagetitle',
                                'default' => $this->par,
                                'label-message' => 'changecontentmodel-title-label',
-                               'validation-callback' => array( $this, 'validateTitle' ),
-                       ),
-               );
+                               'validation-callback' => [ $this, 'validateTitle' ],
+                       ],
+               ];
                if ( $this->title ) {
                        $fields['pagetitle']['readonly'] = true;
-                       $fields += array(
-                               'model' => array(
+                       $fields += [
+                               'model' => [
                                        'type' => 'select',
                                        'name' => 'model',
                                        'options' => $this->getOptionsForTitle( $this->title ),
                                        'label-message' => 'changecontentmodel-model-label'
-                               ),
-                               'reason' => array(
+                               ],
+                               'reason' => [
                                        'type' => 'text',
                                        'name' => 'reason',
-                                       'validation-callback' => function( $reason ) use ( $that ) {
+                                       'validation-callback' => function( $reason ) {
                                                $match = EditPage::matchSummarySpamRegex( $reason );
                                                if ( $match ) {
-                                                       return $that->msg( 'spamprotectionmatch', $match )->parse();
+                                                       return $this->msg( 'spamprotectionmatch', $match )->parse();
                                                }
 
                                                return true;
                                        },
                                        'label-message' => 'changecontentmodel-reason-label',
-                               ),
-                       );
+                               ],
+                       ];
                }
 
                return $fields;
@@ -109,7 +113,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
 
        private function getOptionsForTitle( Title $title = null ) {
                $models = ContentHandler::getContentModels();
-               $options = array();
+               $options = [];
                foreach ( $models as $model ) {
                        $handler = ContentHandler::getForModelID( $model );
                        if ( !$handler->supportsDirectEditing() ) {
@@ -152,7 +156,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
                        $out = $this->getOutput();
                        $wikitext = $out->formatPermissionsErrorMessage( $errors );
                        // Hack to get our wikitext parsed
-                       return Status::newFatal( new RawMessage( '$1', array( $wikitext ) ) );
+                       return Status::newFatal( new RawMessage( '$1', [ $wikitext ] ) );
                }
 
                $page = WikiPage::factory( $this->title );
@@ -184,14 +188,14 @@ class SpecialChangeContentModel extends FormSpecialPage {
                        $flags |= EDIT_FORCE_BOT;
                }
 
-               $log = new ManualLogEntry( 'contentmodel', 'change' );
+               $log = new ManualLogEntry( 'contentmodel', $this->oldRevision ? 'change' : 'new' );
                $log->setPerformer( $user );
                $log->setTarget( $this->title );
                $log->setComment( $data['reason'] );
-               $log->setParameters( array(
+               $log->setParameters( [
                        '4::oldmodel' => $oldModel,
                        '5::newmodel' => $data['model']
-               ) );
+               ] );
 
                $formatter = LogFormatter::newFromEntry( $log );
                $formatter->setContext( RequestContext::newExtraneousContext( $this->title ) );