Go to the documentation of this file.
53 $out->setRobotPolicy(
'noindex,nofollow' );
54 if ( $this->
getContext()->getConfig()->
get(
'UseMediaWikiUIEverywhere' ) ) {
55 $out->addModuleStyles( [
57 'mediawiki.ui.checkbox',
65 "<div id=\"mw-read-only-warning\">\n$1\n</div>",
68 } elseif ( $this->context->getUser()->isAnon() ) {
69 if ( !$this->
getRequest()->getCheck(
'wpPreview' ) ) {
71 "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
75 'returnto' => $this->
getTitle()->getPrefixedDBkey()
79 'returnto' => $this->
getTitle()->getPrefixedDBkey()
84 $out->wrapWikiMsg(
"<div id=\"mw-anon-preview-warning\" class=\"warningbox\">\n$1</div>",
94 $this->undoafter = $this->
getRequest()->getInt(
'undoafter' );
97 if ( $this->
undo == 0 || $this->undoafter == 0 ) {
98 throw new ErrorPageError(
'mcrundofailed',
'mcrundo-missingparam' );
105 $this->curRev =
$curRev->getRevisionRecord();
106 $this->cur = $this->
getRequest()->getInt(
'cur', $this->curRev->getId() );
110 parent::checkCanExecute(
$user );
114 $revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
116 $undoRev = $revisionLookup->getRevisionById( $this->
undo );
117 $oldRev = $revisionLookup->getRevisionById( $this->undoafter );
119 if ( $undoRev ===
null || $oldRev ===
null ||
120 $undoRev->isDeleted( RevisionRecord::DELETED_TEXT ) ||
121 $oldRev->isDeleted( RevisionRecord::DELETED_TEXT )
133 $revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
135 $undoRev = $revisionLookup->getRevisionById( $this->
undo );
136 $oldRev = $revisionLookup->getRevisionById( $this->undoafter );
141 if ( $undoRev ===
null || $oldRev ===
null ||
142 $undoRev->isDeleted( RevisionRecord::DELETED_TEXT ) ||
143 $oldRev->isDeleted( RevisionRecord::DELETED_TEXT )
150 return MutableRevisionRecord::newFromParentRevision( $oldRev );
153 $newRev = MutableRevisionRecord::newFromParentRevision(
$curRev );
157 $rolesToMerge = array_unique( array_merge(
158 $oldRev->getSlotRoles(),
159 $undoRev->getSlotRoles(),
165 $rolesToMerge = array_intersect(
166 $rolesToMerge, $oldRev->getSlots()->getRolesWithDifferentContent( $undoRev->getSlots() )
168 if ( !$rolesToMerge ) {
174 $rolesToMerge = array_intersect(
175 $rolesToMerge, $oldRev->getSlots()->getRolesWithDifferentContent(
$curRev->
getSlots() )
177 if ( !$rolesToMerge ) {
183 $diffRoles = array_intersect(
184 $rolesToMerge, $undoRev->getSlots()->getRolesWithDifferentContent(
$curRev->
getSlots() )
186 foreach ( array_diff( $rolesToMerge, $diffRoles )
as $role ) {
187 if ( $oldRev->hasSlot( $role ) ) {
188 $newRev->inheritSlot( $oldRev->getSlot( $role, RevisionRecord::RAW ) );
193 $rolesToMerge = $diffRoles;
204 foreach ( $rolesToMerge
as $role ) {
205 if ( !$oldRev->hasSlot( $role ) || !$undoRev->hasSlot( $role ) || !
$curRev->
hasSlot( $role ) ) {
211 foreach ( $rolesToMerge
as $role ) {
212 $oldContent = $oldRev->getSlot( $role, RevisionRecord::RAW )->getContent();
213 $undoContent = $undoRev->getSlot( $role, RevisionRecord::RAW )->getContent();
214 $curContent =
$curRev->
getSlot( $role, RevisionRecord::RAW )->getContent();
215 $newContent = $undoContent->getContentHandler()
216 ->getUndoContent( $curContent, $undoContent, $oldContent, $isLatest );
217 if ( !$newContent ) {
220 $newRev->setSlot( SlotRecord::newUnsaved( $role, $newContent ) );
228 if (
$newRev->hasSameContent( $this->curRev ) ) {
233 $diffEngine->setRevisions( $this->curRev,
$newRev );
235 $oldtitle = $this->context->msg(
'currentrev' )->parse();
236 $newtitle = $this->context->msg(
'yourtext' )->parse();
238 if ( $this->
getRequest()->getCheck(
'wpPreview' ) ) {
242 $diffText = $diffEngine->getDiff( $oldtitle, $newtitle );
243 $diffEngine->showDiffStyle();
244 return '<div id="wikiDiff">' . $diffText .
'</div>';
255 # provide a anchor link to the form
256 $continueEditing =
'<span class="mw-continue-editing">' .
257 '[[#mw-mcrundo-form|' .
258 $this->context->getLanguage()->getArrow() .
' ' .
259 $this->context->msg(
'continue-editing' )->text() .
']]</span>';
261 $note = $this->context->msg(
'previewnote' )->plain() .
' ' . $continueEditing;
263 $parserOptions = $this->
page->makeParserOptions( $this->context );
264 $parserOptions->setIsPreview(
true );
265 $parserOptions->setIsSectionPreview(
false );
266 $parserOptions->enableLimitReport();
268 $parserOutput = MediaWikiServices::getInstance()->getRevisionRenderer()
269 ->getRenderedRevision(
$rev, $parserOptions, $this->context->getUser() )
270 ->getRevisionParserOutput();
271 $previewHTML = $parserOutput->getText( [
'enableSectionEditLinks' =>
false ] );
273 $out->addParserOutputMetadata( $parserOutput );
274 if (
count( $parserOutput->getWarnings() ) ) {
275 $note .=
"\n\n" . implode(
"\n\n", $parserOutput->getWarnings() );
278 $m = $this->context->msg(
279 'content-failed-to-parse',
282 $note .=
"\n\n" . $m->parse();
286 $previewhead = Html::rawElement(
287 'div', [
'class' =>
'previewnote' ],
289 'h2', [
'id' =>
'mw-previewheader' ],
290 $this->context->msg(
'preview' )->text()
292 $out->parseAsInterface( $note ) .
296 $pageViewLang = $this->
getTitle()->getPageViewLanguage();
297 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
298 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
299 $previewHTML = Html::rawElement(
'div',
$attribs, $previewHTML );
301 $out->addHTML( $previewhead . $previewHTML );
307 if ( !$this->
getRequest()->getCheck(
'wpSave' ) ) {
312 $updater = $this->
page->getPage()->newPageUpdater( $this->context->getUser() );
327 foreach (
$newRev->getSlots()->getSlots()
as $slot ) {
331 if ( !
$newRev->hasSlot( $role ) ) {
336 $updater->setOriginalRevisionId(
false );
340 if ( $wgUseRCPatrol && $this->
getTitle()->userCan(
'autopatrol', $this->
getUser() ) ) {
364 'vertical-label' =>
true,
366 'default' =>
function () {
373 'name' =>
'wpSummary',
374 'cssclass' =>
'mw-summary',
375 'label-message' =>
'summary',
377 'value' =>
$request->getVal(
'wpSummary',
'' ),
379 'spellcheck' =>
'true',
381 'summarypreview' => [
383 'label-message' =>
'summary-preview',
388 if (
$request->getCheck(
'wpSummary' ) ) {
389 $ret[
'summarypreview'][
'default'] =
Xml::tags(
'div', [
'class' =>
'mw-summary-preview' ],
393 unset(
$ret[
'summarypreview'] );
402 $labelAsPublish = $this->context->getConfig()->get(
'EditSubmitButtonLabelPublish' );
404 $form->
setId(
'mw-mcrundo-form' );
407 $form->
setSubmitTextMsg( $labelAsPublish ?
'publishchanges' :
'savechanges' );
411 'name' =>
'wpPreview',
413 'label-message' =>
'showpreview',
419 'label-message' =>
'showdiff',
437 return '<div style="clear:both"></div>';
return true to allow those checks to and false if checking is done & $user
processing should stop and the error should be shown to the user * false
getRequest()
Get the WebRequest being used for this instance.
preText()
Add pre- or post-text to the form.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
show()
The basic pattern for actions is to display some sort of HTMLForm UI, maybe with some stuff underneat...
static newFatal( $message)
Factory function for fatal errors.
wfReadOnly()
Check whether the wiki is in read-only mode.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getFormFields()
Get an HTMLForm descriptor array.
Temporary action for MCR undos.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
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
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
getContext()
Get the IContextSource in use here.
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
getDescription()
Returns the description that goes below the <h1> tag.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e undo
addStatePropagationFields(HTMLForm $form)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Exception representing a failure to serialize or unserialize a content object.
usesOOUI()
Whether the form should use OOUI.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
RevisionRecord null $curRev
getName()
Return the name of the action this object responds to.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
getUser()
Shortcut to get the User being used for this instance.
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static newGood( $value=null)
Factory function for good results.
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
getTitle()
Shortcut to get the Title object from the page.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
onSubmit( $data)
Process the form on POST submission.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
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
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
showPreview(RevisionRecord $rev)
$page->newPageUpdater($user) $updater
getOutput()
Get the OutputPage being used for this instance.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
onSuccess()
Do something exciting on successful processing of the form.
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 MediaWikiServices
An error page which can definitely be safely rendered using the OutputPage.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...