18 parent::__construct(
'ChangeContentModel',
'editcontentmodel' );
21 wfDeprecated( __METHOD__ .
' without $contentHandlerFactory parameter',
'1.35' );
57 $contentModelLogPage =
new LogPage(
'contentmodel' );
58 $text = Xml::element(
'h2',
null, $contentModelLogPage->getName()->text() );
60 LogEventsList::showLogExtract( $out,
'contentmodel', $this->title );
83 $this->
getOutput()->addBacklinkSubtitle( $this->title );
90 $titleObj = Title::newFromTextThrow(
$title );
92 $this->oldRevision = MediaWikiServices::getInstance()
94 ->getRevisionByTitle( $titleObj ) ?:
false;
96 if ( $this->oldRevision ) {
97 $oldContent = $this->oldRevision->getContent( SlotRecord::MAIN );
98 if ( !$oldContent->getContentHandler()->supportsDirectEditing() ) {
99 return $this->
msg(
'changecontentmodel-nodirectediting' )
100 ->params( ContentHandler::getLocalizedName( $oldContent->getModel() ) )
113 'name' =>
'pagetitle',
115 'label-message' =>
'changecontentmodel-title-label',
116 'validation-callback' => [ $this,
'validateTitle' ],
119 if ( $this->title ) {
120 $spamChecker = MediaWikiServices::getInstance()->getSpamChecker();
123 if ( empty( $options ) ) {
125 'changecontentmodel-emptymodels-title',
126 'changecontentmodel-emptymodels-text',
127 [ $this->title->getPrefixedText() ]
130 $fields[
'pagetitle'][
'readonly'] =
true;
134 'name' =>
'currentcontentmodel',
135 'default' => $this->title->getContentModel(),
136 'label-message' =>
'changecontentmodel-current-label',
142 'options' => $options,
143 'label-message' =>
'changecontentmodel-model-label'
147 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
149 'validation-callback' =>
function ( $reason ) use ( $spamChecker ) {
150 if ( $reason ===
null || $reason ===
'' ) {
155 $match = $spamChecker->checkSummary( $reason );
158 return $this->
msg(
'spamprotectionmatch', $match )->parse();
163 'label-message' =>
'changecontentmodel-reason-label',
172 $models = $this->contentHandlerFactory->getContentModels();
174 foreach ( $models as $model ) {
175 $handler = $this->contentHandlerFactory->getContentHandler( $model );
176 if ( !$handler->supportsDirectEditing() ) {
183 if ( !$handler->canBeUsedOn(
$title ) ) {
187 $options[ContentHandler::getLocalizedName( $model )] = $model;
195 $this->title = Title::newFromText( $data[
'pagetitle'] );
196 $page = WikiPage::factory( $this->title );
198 $changer = MediaWikiServices::getInstance()
199 ->getContentModelChangeFactory()
200 ->newContentModelChange(
206 $errors = $changer->checkPermissions();
209 $wikitext = $out->formatPermissionsErrorMessage( $errors );
211 return Status::newFatal(
new RawMessage(
'$1', [ $wikitext ] ) );
215 $status = $changer->doContentModelChange(
226 $out->setPageTitle( $this->
msg(
'changecontentmodel-success-title' ) );
227 $out->addWikiMsg(
'changecontentmodel-success-text', $this->title );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string null $par
The sub-page of the special page.
Class to simplify the use of log pages.
Variant of the Message class.
setParameter( $par)
Maybe do something interesting with the subpage parameter.
getOptionsForTitle(Title $title=null)
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
RevisionRecord bool null $oldRevision
A RevisionRecord object, false if no revision exists, null if not loaded yet.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
IContentHandlerFactory $contentHandlerFactory
getFormFields()
Get an HTMLForm descriptor array.
postText()
Add post-text to the form.
getDisplayFormat()
Get display format for the form.
doesWrites()
Indicates whether this special page may perform database writes.
onSubmit(array $data)
Process the form on POST submission.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
__construct(?IContentHandlerFactory $contentHandlerFactory=null)
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
Represents a title within MediaWiki.
getContentModel( $flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
getPrefixedText()
Get the prefixed title with spaces.