Go to the documentation of this file.
8 parent::__construct(
'ChangeContentModel',
'editcontentmodel' );
41 $contentModelLogPage =
new LogPage(
'contentmodel' );
42 $text =
Xml::element(
'h2',
null, $contentModelLogPage->getName()->text() );
55 if ( !$this->title ) {
77 if ( $this->oldRevision ) {
78 $oldContent = $this->oldRevision->getContent();
79 if ( !$oldContent->getContentHandler()->supportsDirectEditing() ) {
80 return $this->
msg(
'changecontentmodel-nodirectediting' )
94 'name' =>
'pagetitle',
96 'label-message' =>
'changecontentmodel-title-label',
97 'validation-callback' => [ $this,
'validateTitle' ],
100 if ( $this->title ) {
102 if ( empty( $options ) ) {
104 'changecontentmodel-emptymodels-title',
105 'changecontentmodel-emptymodels-text',
106 [ $this->title->getPrefixedText() ]
109 $fields[
'pagetitle'][
'readonly'] =
true;
113 'name' =>
'currentcontentmodel',
114 'default' => $this->title->getContentModel(),
115 'label-message' =>
'changecontentmodel-current-label',
121 'options' => $options,
122 'label-message' =>
'changecontentmodel-model-label'
127 'validation-callback' =>
function ( $reason ) {
130 return $this->
msg(
'spamprotectionmatch', $match )->parse();
135 'label-message' =>
'changecontentmodel-reason-label',
146 foreach ( $models as $model ) {
148 if ( !$handler->supportsDirectEditing() ) {
155 if ( !$handler->canBeUsedOn(
$title ) ) {
166 if ( $data[
'pagetitle'] ===
'' ) {
174 throw new RuntimeException(
"Form submission was not POSTed" );
184 $this->title->getUserPermissionsErrors(
'editcontentmodel', $user ),
186 $this->title->getUserPermissionsErrors(
'edit', $user ),
188 $titleWithNewContentModel->getUserPermissionsErrors(
'editcontentmodel', $user ),
190 $titleWithNewContentModel->getUserPermissionsErrors(
'edit', $user )
194 $wikitext = $out->formatPermissionsErrorMessage( $errors );
200 if ( $this->oldRevision ===
null ) {
201 $this->oldRevision = $page->getRevision() ?:
false;
203 $oldModel = $this->title->getContentModel();
204 if ( $this->oldRevision ) {
205 $oldContent = $this->oldRevision->getContent();
212 $this->
msg(
'changecontentmodel-cannot-convert' )
214 $this->title->getPrefixedText(),
225 if ( $user->pingLimiter(
'editcontentmodel' ) ) {
231 if ( MediaWikiServices::getInstance()
233 ->userHasRight( $user,
'bot' )
238 $log =
new ManualLogEntry(
'contentmodel', $this->oldRevision ?
'change' :
'new' );
239 $log->setPerformer( $user );
240 $log->setTarget( $this->title );
241 $log->setComment( $data[
'reason'] );
242 $log->setParameters( [
243 '4::oldmodel' => $oldModel,
244 '5::newmodel' => $data[
'model']
249 $reason = $formatter->getPlainActionText();
250 if ( $data[
'reason'] !==
'' ) {
251 $reason .= $this->
msg(
'colon-separator' )->inContentLanguage()->text() . $data[
'reason'];
256 $derivativeContext->setTitle( $this->title );
257 $derivativeContext->setWikiPage( $page );
260 [ $derivativeContext, $newContent,
$status, $reason,
265 $status->fatal(
'hookaborted' );
270 $status = $page->doEditContent(
274 $this->oldRevision ? $this->oldRevision->getId() :
false,
281 $logid = $log->insert();
282 $log->publish( $logid );
289 $out->setPageTitle( $this->
msg(
'changecontentmodel-success-title' ) );
290 $out->addWikiMsg(
'changecontentmodel-success-text', $this->title );
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
wfMergeErrorArrays(... $args)
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getOptionsForTitle(Title $title=null)
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Revision bool null $oldRevision
A Revision object, false if no revision exists, null if not loaded yet.
getOutput()
Get the OutputPage being used for this instance.
postText()
Add post-text to the form.
getPrefixedText()
Get the prefixed title with spaces.
Special page which uses an HTMLForm to handle processing.
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
doesWrites()
Indicates whether this special page may perform database writes.
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.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
An IContextSource implementation which will inherit context from another source but allow individual ...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
getFormFields()
Get an HTMLForm descriptor array.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
static getContentModels()
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Show an error when the user hits a rate limit.
getUser()
Shortcut to get the User executing this instance.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
onSubmit(array $data)
Process the form on POST submission.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
getContext()
Gets the context this SpecialPage is executed in.
string null $par
The sub-page of the special page.
static newFromTextThrow( $text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid,...
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
static matchSummarySpamRegex( $text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match.
getRequest()
Get the WebRequest being used for this instance.
getContentModel( $flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
getDisplayFormat()
Get display format for the form.
setParameter( $par)
Maybe do something interesting with the subpage parameter.
Represents a title within MediaWiki.
Class for creating new log entries and inserting them into the database.
setContentModel( $model)
Set a proposed content model for the page for permissions checking.
Variant of the Message class.
An error page which can definitely be safely rendered using the OutputPage.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.