47 parent::__construct(
'ChangeContentModel',
'editcontentmodel' );
87 $contentModelLogPage =
new LogPage(
'contentmodel' );
88 $text = Xml::element(
'h2',
null, $contentModelLogPage->getName()->text() );
90 LogEventsList::showLogExtract( $out,
'contentmodel', $this->title );
103 if ( $this->title ) {
112 if ( $this->title ) {
113 $this->
getOutput()->addBacklinkSubtitle( $this->title );
120 $titleObj = Title::newFromTextThrow(
$title );
122 $this->oldRevision = $this->revisionLookup->getRevisionByTitle( $titleObj ) ?:
false;
124 if ( $this->oldRevision ) {
125 $oldContent = $this->oldRevision->getContent( SlotRecord::MAIN );
126 if ( !$oldContent->getContentHandler()->supportsDirectEditing() ) {
127 return $this->
msg(
'changecontentmodel-nodirectediting' )
128 ->params( ContentHandler::getLocalizedName( $oldContent->getModel() ) )
141 'name' =>
'pagetitle',
143 'label-message' =>
'changecontentmodel-title-label',
144 'validation-callback' => [ $this,
'validateTitle' ],
147 if ( $this->title ) {
149 if ( empty( $options ) ) {
151 'changecontentmodel-emptymodels-title',
152 'changecontentmodel-emptymodels-text',
153 [ $this->title->getPrefixedText() ]
156 $fields[
'pagetitle'][
'readonly'] =
true;
160 'name' =>
'currentcontentmodel',
161 'default' => $this->title->getContentModel(),
162 'label-message' =>
'changecontentmodel-current-label',
168 'options' => $options,
169 'label-message' =>
'changecontentmodel-model-label'
173 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
175 'validation-callback' =>
function ( $reason ) {
176 if ( $reason ===
null || $reason ===
'' ) {
181 $match = $this->spamChecker->checkSummary( $reason );
184 return $this->
msg(
'spamprotectionmatch', $match )->parse();
189 'label-message' =>
'changecontentmodel-reason-label',
198 $models = $this->contentHandlerFactory->getContentModels();
200 foreach ( $models as $model ) {
201 $handler = $this->contentHandlerFactory->getContentHandler( $model );
202 if ( !$handler->supportsDirectEditing() ) {
209 if ( !$handler->canBeUsedOn(
$title ) ) {
213 $options[ContentHandler::getLocalizedName( $model )] = $model;
220 $this->title = Title::newFromText( $data[
'pagetitle'] );
221 $page = $this->wikiPageFactory->newFromTitle( $this->title );
223 $changer = $this->contentModelChangeFactory->newContentModelChange(
229 $permissionStatus = $changer->authorizeChange();
230 if ( !$permissionStatus->isGood() ) {
232 $wikitext = $out->formatPermissionStatus( $permissionStatus );
234 return Status::newFatal(
new RawMessage(
'$1', [ $wikitext ] ) );
238 $status = $changer->doContentModelChange(
249 $out->setPageTitle( $this->
msg(
'changecontentmodel-success-title' ) );
250 $out->addWikiMsg(
'changecontentmodel-success-text', $this->title );
262 return $this->
prefixSearchString( $search, $limit, $offset, $this->searchEngineFactory );
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.
Service to check if text (either content or a summary) qualifies as spam.
Variant of the Message class.
Factory class for SearchEngine.
setParameter( $par)
Maybe do something interesting with the subpage parameter.
getOptionsForTitle(Title $title=null)
RevisionLookup $revisionLookup
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
SearchEngineFactory $searchEngineFactory
getFormFields()
Get an HTMLForm descriptor array.
postText()
Add post-text to the form.
ContentModelChangeFactory $contentModelChangeFactory
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.
__construct(IContentHandlerFactory $contentHandlerFactory, ContentModelChangeFactory $contentModelChangeFactory, SpamChecker $spamChecker, RevisionLookup $revisionLookup, WikiPageFactory $wikiPageFactory, SearchEngineFactory $searchEngineFactory)
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
WikiPageFactory $wikiPageFactory
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
prefixSearchString( $search, $limit, $offset, SearchEngineFactory $searchEngineFactory=null)
Perform a regular substring search for prefixSearchSubpages.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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.