if ( !$this->title ) {
$form->setMethod( 'GET' );
}
+
+ $this->addHelpLink( 'Help:ChangeContentModel' );
+
+ // T120576
+ $form->setSubmitTextMsg( 'changecontentmodel-submit' );
}
public function validateTitle( $title ) {
}
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;
private function getOptionsForTitle( Title $title = null ) {
$models = ContentHandler::getContentModels();
- $options = array();
+ $options = [];
foreach ( $models as $model ) {
$handler = ContentHandler::getForModelID( $model );
if ( !$handler->supportsDirectEditing() ) {
$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 );
$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 ) );