<?php
+use MediaWiki\MediaWikiServices;
+
class SpecialChangeContentModel extends FormSpecialPage {
public function __construct() {
throw new ErrorPageError(
'changecontentmodel-emptymodels-title',
'changecontentmodel-emptymodels-text',
- $this->title->getPrefixedText()
+ [ $this->title->getPrefixedText() ]
);
}
$fields['pagetitle']['readonly'] = true;
$fields += [
+ 'currentmodel' => [
+ 'type' => 'text',
+ 'name' => 'currentcontentmodel',
+ 'default' => $this->title->getContentModel(),
+ 'label-message' => 'changecontentmodel-current-label',
+ 'readonly' => true
+ ],
'model' => [
'type' => 'select',
'name' => 'model',
'reason' => [
'type' => 'text',
'name' => 'reason',
- 'validation-callback' => function( $reason ) {
+ 'validation-callback' => function ( $reason ) {
$match = EditPage::matchSummarySpamRegex( $reason );
if ( $match ) {
return $this->msg( 'spamprotectionmatch', $match )->parse();
}
public function onSubmit( array $data ) {
- global $wgContLang;
-
if ( $data['pagetitle'] === '' ) {
// Initial form view of special page, pass
return false;
$oldContent = $this->oldRevision->getContent();
try {
$newContent = ContentHandler::makeContent(
- $oldContent->getNativeData(), $this->title, $data['model']
+ $oldContent->serialize(), $this->title, $data['model']
);
} catch ( MWException $e ) {
return Status::newFatal(
$flags = $this->oldRevision ? EDIT_UPDATE : EDIT_NEW;
$flags |= EDIT_INTERNAL;
- if ( $user->isAllowed( 'bot' ) ) {
+ if ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasRight( $user, 'bot' )
+ ) {
$flags |= EDIT_FORCE_BOT;
}
if ( $data['reason'] !== '' ) {
$reason .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $data['reason'];
}
- # Truncate for whole multibyte characters.
- $reason = $wgContLang->truncate( $reason, 255 );
// Run edit filters
$derivativeContext = new DerivativeContext( $this->getContext() );