6 parent::__construct(
'ChangeContentModel',
'editcontentmodel' );
41 if ( !$this->
title ) {
59 $titleObj = Title::newFromTextThrow(
$title );
63 if ( $this->oldRevision ) {
64 $oldContent = $this->oldRevision->getContent();
65 if ( !$oldContent->getContentHandler()->supportsDirectEditing() ) {
66 return $this->
msg(
'changecontentmodel-nodirectediting' )
80 'name' =>
'pagetitle',
82 'label-message' =>
'changecontentmodel-title-label',
83 'validation-callback' => [ $this,
'validateTitle' ],
90 'changecontentmodel-emptymodels-title',
91 'changecontentmodel-emptymodels-text',
92 $this->
title->getPrefixedText()
95 $fields[
'pagetitle'][
'readonly'] =
true;
101 'label-message' =>
'changecontentmodel-model-label'
106 'validation-callback' =>
function( $reason ) {
109 return $this->
msg(
'spamprotectionmatch', $match )->parse();
114 'label-message' =>
'changecontentmodel-reason-label',
125 foreach ( $models
as $model ) {
127 if ( !
$handler->supportsDirectEditing() ) {
147 if ( $data[
'pagetitle'] ===
'' ) {
155 throw new RuntimeException(
"Form submission was not POSTed" );
158 $this->
title = Title::newFromText( $data[
'pagetitle'] );
165 $this->title->getUserPermissionsErrors(
'editcontentmodel',
$user ),
167 $this->title->getUserPermissionsErrors(
'edit',
$user ),
169 $titleWithNewContentModel->getUserPermissionsErrors(
'editcontentmodel',
$user ),
171 $titleWithNewContentModel->getUserPermissionsErrors(
'edit',
$user )
175 $wikitext =
$out->formatPermissionsErrorMessage( $errors );
177 return Status::newFatal(
new RawMessage(
'$1', [ $wikitext ] ) );
181 if ( $this->oldRevision ===
null ) {
182 $this->oldRevision =
$page->getRevision() ?:
false;
184 $oldModel = $this->title->getContentModel();
185 if ( $this->oldRevision ) {
186 $oldContent = $this->oldRevision->getContent();
189 $oldContent->getNativeData(), $this->title, $data[
'model']
192 return Status::newFatal(
193 $this->
msg(
'changecontentmodel-cannot-convert' )
195 $this->title->getPrefixedText(),
206 if (
$user->pingLimiter(
'editcontentmodel' ) ) {
212 if (
$user->isAllowed(
'bot' ) ) {
216 $log =
new ManualLogEntry(
'contentmodel', $this->oldRevision ?
'change' :
'new' );
218 $log->setTarget( $this->title );
219 $log->setComment( $data[
'reason'] );
220 $log->setParameters( [
221 '4::oldmodel' => $oldModel,
222 '5::newmodel' => $data[
'model']
227 $reason = $formatter->getPlainActionText();
228 if ( $data[
'reason'] !==
'' ) {
229 $reason .= $this->
msg(
'colon-separator' )->inContentLanguage()->text() . $data[
'reason'];
231 # Truncate for whole multibyte characters.
236 $derivativeContext->setTitle( $this->title );
237 $derivativeContext->setWikiPage(
$page );
239 if ( !Hooks::run(
'EditFilterMergedContent',
240 [ $derivativeContext, $newContent,
$status, $reason,
245 $status->fatal(
'hookaborted' );
254 $this->oldRevision ? $this->oldRevision->getId() :
false,
261 $logid = $log->insert();
262 $log->publish( $logid );
269 $out->setPageTitle( $this->
msg(
'changecontentmodel-success-title' ) );
270 $out->addWikiMsg(
'changecontentmodel-success-text', $this->
title );
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getContentModels()
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
An IContextSource implementation which will inherit context from another source but allow individual ...
static matchSummarySpamRegex( $text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match.
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string $par
The sub-page of the special page.
Class for creating log entries manually, to inject them into the database.
setPerformer(User $performer)
Set the user that performed the action being logged.
Variant of the Message class.
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target.
Revision bool null $oldRevision
A Revision object, false if no revision exists, null if not loaded yet.
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.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getFormFields()
Get an HTMLForm descriptor array.
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...
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.
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.
msg()
Wrapper around wfMessage that sets the current context.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Show an error when the user hits a rate limit.
Represents a title within MediaWiki.
getContentModel( $flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
setContentModel( $model)
Set a proposed content model for the page for permissions checking.
getPrefixedText()
Get the prefixed title with spaces.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
when a variable name is used in a it is silently declared as a new local masking the global
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
the array() calling protocol came about after MediaWiki 1.4rc1.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
it s the revision text itself In either if gzip is the revision text is gzipped $flags
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
returning false will NOT prevent logging $e
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php