MediaWiki  master
EditPage Class Reference

The edit page/HTML interface (split from Article) The actual database and text munging is still in Article, but it should get easier to call those from alternate interfaces. More...

Collaboration diagram for EditPage:

Public Member Functions

 __construct (Article $article)
 
 attemptSave (&$resultDetails=false)
 Attempt submission. More...
 
 edit ()
 This is the function that gets called for "action=edit". More...
 
 getArticle ()
 
 getBaseRevision ()
 Returns the revision that was current at the time editing was initiated on the client, even if the edit was based on an old revision. More...
 
 getCancelLink ()
 
 getCheckboxesDefinition ( $checked)
 Return an array of checkbox definitions. More...
 
 getCheckboxesWidget (&$tabindex, $checked)
 Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and any other added by extensions. More...
 
 getContext ()
 
 getContextTitle ()
 Get the context title object. More...
 
 getEditButtons (&$tabindex)
 Returns an array of html code of the following buttons: save, diff and preview. More...
 
 getParentRevId ()
 Get the edit's parent revision ID. More...
 
 getPreviewText ()
 Get the rendered text for previewing. More...
 
 getSummaryInputWidget ( $summary="", $labelText=null, $inputAttrs=null)
 Builds a standard summary input with a label. More...
 
 getTemplates ()
 
 getTitle ()
 
 importFormData (&$request)
 This function collects the form data and uses it to populate various member variables. More...
 
 initialiseForm ()
 Initialise form fields in the object Called on the first invocation, e.g. More...
 
 internalAttemptSave (&$result, $bot=false)
 Attempt submission (no UI) More...
 
 isSupportedContentModel ( $modelId)
 Returns if the given content model is editable. More...
 
 makeTemplatesOnThisPageList (array $templates)
 Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list. More...
 
 noSuchSectionPage ()
 Creates a basic error page which informs the user that they have attempted to edit a nonexistent section. More...
 
 setApiEditOverride ( $enableOverride)
 Allow editing of content that supports API direct editing, but not general direct editing. More...
 
 setContextTitle ( $title)
 Set the context Title object. More...
 
 setEditConflictHelperFactory (callable $factory)
 Set a factory function to create an EditConflictHelper. More...
 
 setHeaders ()
 
 setPreloadedContent (Content $content)
 Use this method before edit() to preload some content into the edit box. More...
 
 showDiff ()
 Get a diff between the current contents of the edit box and the version of the page we're editing from. More...
 
 showEditForm ( $formCallback=null)
 Send the edit form and related headers to OutputPage. More...
 
 spamPageWithContent ( $match=false)
 Show "your edit contains spam" page with your diff and text. More...
 
 tokenOk (&$request)
 Make sure the form isn't faking a user's credentials. More...
 

Static Public Member Functions

static extractSectionTitle ( $text)
 Extract the section title from current section text, if any. More...
 
static getCopyrightWarning ( $title, $format='plain', $langcode=null)
 Get the copyright warning, by default returns wikitext. More...
 
static getEditToolbar ()
 Allow extensions to provide a toolbar. More...
 
static getPreviewLimitReport (ParserOutput $output=null)
 Get the Limit report for page previews. More...
 
static matchSpamRegex ( $text)
 Check given input text against $wgSpamRegex, and return the text of the first match. More...
 
static matchSummarySpamRegex ( $text)
 Check given input text against $wgSummarySpamRegex, and return the text of the first match. More...
 

Public Attributes

string $action = 'submit'
 
bool $allowBlankSummary = false
 
string $autoSumm = ''
 
bool $bot = true
 
null string $contentFormat = null
 
string $contentModel
 
bool $deletedSinceEdit
 
 $didSave = false
 
bool $diff = false
 
string $editFormPageTop = ''
 Before even the preview. More...
 
 $editFormTextAfterContent = ''
 
 $editFormTextAfterTools = ''
 
 $editFormTextAfterWarn = ''
 
 $editFormTextBeforeContent = ''
 
 $editFormTextBottom = ''
 
 $editFormTextTop = ''
 
string $editintro = ''
 
string $edittime = ''
 Timestamp of the latest revision of the page when editing was initiated on the client. More...
 
bool $firsttime
 True the first time the edit form is rendered, false after re-rendering with diff, save prompts, etc. More...
 
string $formtype
 
bool $hasPresetSummary = false
 Has a summary been preset using GET parameter &summary= ? More...
 
string $hookError = ''
 
bool $incompleteForm = false
 
bool $isConflict = false
 Whether an edit conflict needs to be resolved. More...
 
bool $isNew = false
 New page or new section. More...
 
bool stdClass $lastDelete
 
Article $mArticle
 
Revision bool null $mBaseRevision = false
 A revision object corresponding to $this->editRevId. More...
 
bool $minoredit = false
 
bool $missingComment = false
 
bool $missingSummary = false
 
ParserOutput $mParserOutput
 
 $mPreloadContent = null
 
bool $mShowSummaryField = true
 
Title $mTitle
 
bool $mTokenOk = false
 
bool $mTokenOkExceptSuffix = false
 
bool $mTriedSave = false
 
bool $nosummary = false
 If true, hide the summary field. More...
 
int $oldid = 0
 Revision ID the edit is based on, or 0 if it's the current revision. More...
 
int $parentRevId = 0
 Revision ID the edit is based on, adjusted when an edit conflict is resolved. More...
 
bool $preview = false
 
 $previewTextAfterContent = ''
 
bool $recreate = false
 
bool $save = false
 
null $scrolltop = null
 
string $section = ''
 
string $sectiontitle = ''
 
string $starttime = ''
 Timestamp from the first time the edit form was rendered. More...
 
string $summary = ''
 
 $suppressIntro = false
 
string $textbox1 = ''
 Page content input field. More...
 
string $textbox2 = ''
 
bool $tooBig = false
 
 $undidRev = 0
 
bool $watchthis = false
 
const AS_ARTICLE_WAS_DELETED = 222
 Status: article was deleted while editing and param wpRecreate == false or form was not posted. More...
 
const AS_BLANK_ARTICLE = 224
 Status: user tried to create a blank page and wpIgnoreBlankArticle == false. More...
 
const AS_BLOCKED_PAGE_FOR_USER = 215
 Status: User is blocked from editing this page. More...
 
const AS_CANNOT_USE_CUSTOM_MODEL = 241
 Status: when changing the content model is disallowed due to $wgContentHandlerUseDB being false. More...
 
const AS_CHANGE_TAG_ERROR = 237
 Status: an error relating to change tagging. More...
 
const AS_CONFLICT_DETECTED = 225
 Status: (non-resolvable) edit conflict. More...
 
const AS_CONTENT_TOO_BIG = 216
 Status: Content too big (> $wgMaxArticleSize) More...
 
const AS_END = 231
 Status: WikiPage::doEdit() was unsuccessful. More...
 
const AS_HOOK_ERROR = 210
 Status: Article update aborted by a hook function. More...
 
const AS_HOOK_ERROR_EXPECTED = 212
 Status: A hook function returned an error. More...
 
const AS_IMAGE_REDIRECT_ANON = 233
 Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false) More...
 
const AS_IMAGE_REDIRECT_LOGGED = 234
 Status: logged in user is not allowed to upload (User::isAllowed('upload') == false) More...
 
const AS_MAX_ARTICLE_SIZE_EXCEEDED = 229
 Status: article is too big (> $wgMaxArticleSize), after merging in the new section. More...
 
const AS_NO_CHANGE_CONTENT_MODEL = 235
 Status: user tried to modify the content model, but is not allowed to do that ( User::isAllowed('editcontentmodel') == false ) More...
 
const AS_NO_CREATE_PERMISSION = 223
 Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == false ) More...
 
const AS_PARSE_ERROR = 240
 Status: can't parse content. More...
 
const AS_RATE_LIMITED = 221
 Status: rate limiter for action 'edit' was tripped. More...
 
const AS_READ_ONLY_PAGE = 220
 Status: wiki is in readonly mode (wfReadOnly() == true) More...
 
const AS_READ_ONLY_PAGE_ANON = 218
 Status: this anonymous user is not allowed to edit this page. More...
 
const AS_READ_ONLY_PAGE_LOGGED = 219
 Status: this logged in user is not allowed to edit this page. More...
 
const AS_SELF_REDIRECT = 236
 Status: user tried to create self-redirect (redirect to the same article) and wpIgnoreSelfRedirect == false. More...
 
const AS_SPAM_ERROR = 232
 Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex. More...
 
const AS_SUCCESS_NEW_ARTICLE = 201
 Status: Article successfully created. More...
 
const AS_SUCCESS_UPDATE = 200
 Status: Article successfully updated. More...
 
const AS_SUMMARY_NEEDED = 226
 Status: no edit summary given and the user has forceeditsummary set and the user is not editing in his own userspace or talkspace and wpIgnoreBlankSummary == false. More...
 
const AS_TEXTBOX_EMPTY = 228
 Status: user tried to create a new section without content. More...
 
const AS_UNICODE_NOT_SUPPORTED = 242
 Status: edit rejected because browser doesn't support Unicode. More...
 
const EDITFORM_ID = 'editform'
 HTML id and name for the beginning of the edit form. More...
 
const POST_EDIT_COOKIE_DURATION = 1200
 Duration of PostEdit cookie, in seconds. More...
 
const POST_EDIT_COOKIE_KEY_PREFIX = 'PostEditRevision'
 Prefix of key for cookie used to pass post-edit state. More...
 
const UNICODE_CHECK = 'ℳ𝒲β™₯π“Šπ“ƒπ’Ύπ’Έβ„΄π’Ήβ„―'
 Used for Unicode support checks. More...
 

Protected Member Functions

 addContentModelChangeLogEntry (User $user, $oldModel, $newModel, $reason)
 
 addEditNotices ()
 
 addExplainConflictHeader (OutputPage $out)
 
 addLongPageWarningHeader ()
 
 addNewLineAtEnd ( $wikitext)
 
 addPageProtectionWarningHeaders ()
 
 addTalkPageText ()
 
 buildTextboxAttribs ( $name, array $customAttribs, User $user)
 
 displayPermissionsError (array $permErrors)
 Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences: More...
 
 displayPreviewArea ( $previewOutput, $isOnTop=false)
 
 displayViewSourcePage (Content $content, $errorMessage='')
 Display a read-only View Source page. More...
 
 doPreviewParse (Content $content)
 Parse the page for a preview. More...
 
 getActionURL (Title $title)
 Returns the URL to use in the form's action attribute. More...
 
 getContentObject ( $def_content=null)
 
 getCopywarn ()
 Get the copyright warning. More...
 
 getCurrentContent ()
 Get the current content of the page. More...
 
 getEditPermissionErrors ( $rigor='secure')
 
 getLastDelete ()
 Get the last log record of this page being deleted, if ever. More...
 
 getPreloadedContent ( $preload, $params=[])
 Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page. More...
 
 getPreviewParserOptions ()
 Get parser options for a preview. More...
 
 getSubmitButtonLabel ()
 Get the message key of the label for the button to save the page. More...
 
 getSummaryPreview ( $isSubjectPreview, $summary="")
 
 importContentFormData (&$request)
 Subpage overridable method for extracting the page content data from the posted form to be placed in $this->textbox1, if using customized input this method should be overridden and return the page text that will be used for saving, preview parsing and so on... More...
 
 incrementConflictStats ()
 
 isSectionEditSupported ()
 Returns whether section editing is supported for the current page. More...
 
 isWrongCaseUserConfigPage ()
 Checks whether the user entered a skin name in uppercase, e.g. More...
 
 previewOnOpen ()
 Should we show a preview when the edit form is first shown? More...
 
 runPostMergeFilters (Content $content, Status $status, User $user)
 Run hooks that can filter edits just before they get saved. More...
 
 setPostEditCookie ( $statusValue)
 Sets post-edit cookie indicating the user just saved a particular revision. More...
 
 showConflict ()
 Show an edit conflict. More...
 
 showContentForm ()
 Subpage overridable method for printing the form for page content editing By default this simply outputs wpTextbox1 Subclasses can override this to provide a custom UI for editing; be it a form, or simply wpTextbox1 with a modified content that will be reverse modified when extracted from the post data. More...
 
 showCustomIntro ()
 Attempt to show a custom editing introduction, if supplied. More...
 
 showEditTools ()
 Inserts optional text shown below edit and upload forms. More...
 
 showFormAfterText ()
 
 showFormBeforeText ()
 
 showHeader ()
 
 showHeaderCopyrightWarning ()
 Show the header copyright warning. More...
 
 showIntro ()
 Show all applicable editing introductions. More...
 
 showPreview ( $text)
 Append preview output to OutputPage. More...
 
 showStandardInputs (&$tabindex=2)
 
 showSummaryInput ( $isSubjectPreview, $summary="")
 
 showTextbox ( $text, $name, $customAttribs=[])
 
 showTextbox1 ( $customAttribs=null, $textoverride=null)
 Method to output wpTextbox1 The $textoverride method can be used by subclasses overriding showContentForm to pass back to this method. More...
 
 showTextbox2 ()
 
 showTosSummary ()
 Give a chance for site and per-namespace customizations of terms of service summary link that might exist separately from the copyright notice. More...
 
 toEditContent ( $text)
 Turns the given text into a Content object by unserializing it. More...
 
 toEditText ( $content)
 Gets an editable textual representation of $content. More...
 
 updateWatchlist ()
 Register the change of watch status. More...
 
 wasDeletedSinceLastEdit ()
 Check if a page was deleted while the user was editing it, before submit. More...
 

Static Protected Member Functions

static matchSpamRegexInternal ( $text, $regexes)
 

Protected Attributes

bool $allowBlankArticle = false
 
bool $allowSelfRedirect = false
 
bool $blankArticle = false
 
bool int $contentLength = false
 
IContextSource $context
 
bool $edit
 
bool $selfRedirect = false
 

Private Member Functions

 formatStatusErrors (Status $status)
 Wrap status errors in an errorbox for increased visibility. More...
 
 getEditConflictHelper ()
 
 getOriginalContent (User $user)
 Get the content of the wanted revision, without section extraction. More...
 
 getSummaryInputAttributes (array $inputAttrs=null)
 Helper function for summary input functions, which returns the necessary attributes for the input. More...
 
 guessSectionName ( $text)
 Turns section name wikitext into anchors for use in HTTP redirects. More...
 
 handleStatus (Status $status, $resultDetails)
 Handle status, such as after attempt save. More...
 
 incrementEditFailureStats ( $failureType)
 
 incrementResolvedConflicts ()
 Log when a page was successfully saved after the edit conflict view. More...
 
 isPageExistingAndViewable ( $title, User $user)
 Verify if a given title exists and the given user is allowed to view it. More...
 
 mergeChangesIntoContent (&$editContent)
 Attempts to do 3-way merge of edit content with a base revision and current content, in case of edit conflict, in whichever way appropriate for the content type. More...
 
 newSectionSummary (&$sectionanchor=null)
 Return the summary to be used for a new section. More...
 
 newTextConflictHelper ( $submitButtonLabel)
 

Private Attributes

null array $changeTags = null
 
TextConflictHelper null $editConflictHelper
 
callable $editConflictHelperFactory
 Factory function to create an edit conflict helper. More...
 
int $editRevId = null
 Revision ID of the latest revision of the page when editing was initiated on the client. More...
 
bool $enableApiEditOverride = false
 Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing. More...
 
bool $isOldRev = false
 Whether an old revision is edited. More...
 
null Title $mContextTitle = null
 
WikiPage $page
 
string null $unicodeCheck
 What the user submitted in the 'wpUnicodeCheck' field. More...
 

Detailed Description

The edit page/HTML interface (split from Article) The actual database and text munging is still in Article, but it should get easier to call those from alternate interfaces.

EditPage cares about two distinct titles: $this->mContextTitle is the page that forms submit to, links point to, redirects go to, etc. $this->mTitle (as well as $mArticle) is the page in the database that is actually being edited. These are usually the same, but they are now allowed to be different.

Surgeon General's Warning: prolonged exposure to this class is known to cause headaches, which may be fatal.

Definition at line 45 of file EditPage.php.

Constructor & Destructor Documentation

◆ __construct()

EditPage::__construct ( Article  $article)

Member Function Documentation

◆ addContentModelChangeLogEntry()

EditPage::addContentModelChangeLogEntry ( User  $user,
  $oldModel,
  $newModel,
  $reason 
)
protected
Parameters
User$user
string | false$oldModelfalse if the page is being newly created
string$newModel
string$reason

Definition at line 2361 of file EditPage.php.

Referenced by internalAttemptSave().

◆ addEditNotices()

EditPage::addEditNotices ( )
protected
Since
1.29

Definition at line 4386 of file EditPage.php.

References $out.

Referenced by showEditForm().

◆ addExplainConflictHeader()

EditPage::addExplainConflictHeader ( OutputPage  $out)
protected
Parameters
OutputPage$out
Since
1.29

Definition at line 4490 of file EditPage.php.

References OutputPage\addHTML(), and getEditConflictHelper().

Referenced by showHeader().

◆ addLongPageWarningHeader()

EditPage::addLongPageWarningHeader ( )
protected
Since
1.29

Definition at line 4415 of file EditPage.php.

References $lang, and $out.

Referenced by showHeader().

◆ addNewLineAtEnd()

EditPage::addNewLineAtEnd (   $wikitext)
protected
Parameters
string$wikitext
Returns
string
Since
1.29

Definition at line 4514 of file EditPage.php.

◆ addPageProtectionWarningHeaders()

EditPage::addPageProtectionWarningHeaders ( )
protected
Since
1.29

Definition at line 4445 of file EditPage.php.

References $out, as, list, and LogEventsList\showLogExtract().

Referenced by showHeader().

◆ addTalkPageText()

EditPage::addTalkPageText ( )
protected
Since
1.29

Definition at line 4406 of file EditPage.php.

Referenced by showEditForm().

◆ attemptSave()

EditPage::attemptSave ( $resultDetails = false)

Attempt submission.

Parameters
array | bool&$resultDetailsSee docs for $result in internalAttemptSave
Exceptions
UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
Returns
Status The resulting status object.

Definition at line 1589 of file EditPage.php.

References $bot, internalAttemptSave(), and Hooks\run().

Referenced by edit().

◆ buildTextboxAttribs()

EditPage::buildTextboxAttribs (   $name,
array  $customAttribs,
User  $user 
)
protected
Parameters
string$name
mixed[]$customAttribs
User$user
Returns
mixed[]
Since
1.29

Definition at line 4503 of file EditPage.php.

References $name.

◆ displayPermissionsError()

EditPage::displayPermissionsError ( array  $permErrors)
protected

Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences:

  • If redlink=1, the user will be redirected to the page
  • If there is content to display or the error occurs while either saving, previewing or showing the difference, it will be a "View source for ..." page displaying the source code after the error message.
Since
1.19
Parameters
array$permErrorsArray of permissions errors, as returned by Title::getUserPermissionsErrors().
Exceptions
PermissionsError

Definition at line 757 of file EditPage.php.

References $content, $out, displayViewSourcePage(), and getContentObject().

Referenced by edit().

◆ displayPreviewArea()

EditPage::displayPreviewArea (   $previewOutput,
  $isOnTop = false 
)
protected

Definition at line 3456 of file EditPage.php.

References $attribs, $out, Xml\openElement(), Html\rawElement(), showDiff(), and showPreview().

Referenced by showEditForm().

◆ displayViewSourcePage()

EditPage::displayViewSourcePage ( Content  $content,
  $errorMessage = '' 
)
protected

Display a read-only View Source page.

Parameters
Content$content
string$errorMessageadditional wikitext error message to display

Definition at line 787 of file EditPage.php.

References $e, $out, $textbox1, getContextTitle(), getTemplates(), makeTemplatesOnThisPageList(), null, Hooks\run(), Content\serialize(), showTextbox(), and toEditText().

Referenced by displayPermissionsError(), and edit().

◆ doPreviewParse()

EditPage::doPreviewParse ( Content  $content)
protected

Parse the page for a preview.

Subclasses may override this class, in order to parse with different options, or to otherwise modify the preview HTML.

Parameters
Content$contentThe page content
Returns
array with keys:
  • parserOutput: The ParserOutput object
  • html: The HTML to be displayed

Definition at line 4081 of file EditPage.php.

References $user, getPreviewParserOptions(), null, and Content\preSaveTransform().

Referenced by getPreviewText().

◆ edit()

EditPage::edit ( )

This is the function that gets called for "action=edit".

It sets up various member variables, then passes execution to another function, usually showEditForm()

The edit form is self-submitting, so that when things like preview and edit conflicts occur, we get the same form back with the extra stuff added. Only when the final submission is made and all is well do we actually save and redirect to the newly-edited page.

Definition at line 580 of file EditPage.php.

References $contentModel, $out, $request, DeferredUpdates\addCallableUpdate(), attemptSave(), diff, displayPermissionsError(), displayViewSourcePage(), First, getContentObject(), getEditPermissionErrors(), handleStatus(), importFormData(), initialiseForm(), Revision\newFromId(), noSuchSectionPage(), null, plain, previewOnOpen(), Hooks\run(), save, showEditForm(), showIntro(), wfDebug(), and wfReadOnly().

Referenced by importFormData().

◆ extractSectionTitle()

static EditPage::extractSectionTitle (   $text)
static

Extract the section title from current section text, if any.

Parameters
string$text
Returns
string|bool String or false

Definition at line 3073 of file EditPage.php.

References $matches.

Referenced by EditPageTest\testExtractSectionTitle().

◆ formatStatusErrors()

EditPage::formatStatusErrors ( Status  $status)
private

Wrap status errors in an errorbox for increased visibility.

Parameters
Status$status
Returns
string Wikitext

Definition at line 1801 of file EditPage.php.

References div, and Status\getWikiText().

Referenced by runPostMergeFilters().

◆ getActionURL()

EditPage::getActionURL ( Title  $title)
protected

Returns the URL to use in the form's action attribute.

This is used by EditPage subclasses when simply customizing the action variable in the constructor is not enough. This can be used when the EditPage lives inside of a Special page rather than a custom page action.

Parameters
Title$titleTitle object for which is being edited (where we go to for &action= links)
Returns
string

Definition at line 3811 of file EditPage.php.

References Title\getLocalURL().

Referenced by showEditForm().

◆ getArticle()

EditPage::getArticle ( )
Returns
Article

Definition at line 500 of file EditPage.php.

References $mArticle.

◆ getBaseRevision()

EditPage::getBaseRevision ( )

Returns the revision that was current at the time editing was initiated on the client, even if the edit was based on an old revision.

Warning
this method is very poorly named. If the user opened the form with ?oldid=X, one might think of X as the "base revision", which is NOT what this returns, see oldid for that. One might further assume that this corresponds to the $baseRevId parameter of WikiPage::doEditContent, which is not the case either. getExpectedParentRevision() would perhaps be a better name.
Returns
Revision|null Current version when editing was initiated on the client

Definition at line 2452 of file EditPage.php.

References $mBaseRevision, DB_MASTER, Revision\loadFromTimestamp(), Revision\newFromId(), and wfGetDB().

Referenced by mergeChangesIntoContent().

◆ getCancelLink()

EditPage::getCancelLink ( )
Returns
string

Definition at line 3784 of file EditPage.php.

References $oldid, and getContextTitle().

Referenced by showStandardInputs().

◆ getCheckboxesDefinition()

EditPage::getCheckboxesDefinition (   $checked)

Return an array of checkbox definitions.

Array keys correspond to the <input> 'name' attribute to use for each checkbox.

Array values are associative arrays with the following keys:

  • 'label-message' (required): message for label text
  • 'id' (required): 'id' attribute for the <input>
  • 'default' (required): default checkedness (true or false)
  • 'title-message' (optional): used to generate 'title' attribute for the <label>
  • 'tooltip' (optional): used to generate 'title' and 'accesskey' attributes from messages like 'tooltip-foo', 'accesskey-foo'
  • 'label-id' (optional): 'id' attribute for the <label>
  • 'legacy-name' (optional): short name for backwards-compatibility
    Parameters
    array$checkedArray of checkbox name (matching the 'legacy-name') => bool, where bool indicates the checked status of the checkbox
    Returns
    array

Definition at line 4156 of file EditPage.php.

References $user, and Hooks\run().

Referenced by getCheckboxesWidget().

◆ getCheckboxesWidget()

EditPage::getCheckboxesWidget ( $tabindex,
  $checked 
)

Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and any other added by extensions.

Parameters
int&$tabindexCurrent tabindex
array$checkedArray of checkbox => bool, where bool indicates the checked status of the checkbox
Returns
array Associative array of string keys to OOUI\FieldLayout instances

Definition at line 4201 of file EditPage.php.

References $name, $options, $tabindex, $title, as, getCheckboxesDefinition(), null, and Linker\titleAttrib().

Referenced by showStandardInputs().

◆ getContentObject()

EditPage::getContentObject (   $def_content = null)
protected
Parameters
Content | null$def_contentThe default value to return
Returns
Content|null Content on success, $def_content for invalid sections
Since
1.21

Definition at line 1180 of file EditPage.php.

References $content, $out, $params, $request, $summary, $user, Revision\DELETED_TEXT, getOriginalContent(), getPreloadedContent(), WikiPage\hasDifferencesOutsideMainSlot(), isSupportedContentModel(), Revision\newFromId(), ParserOptions\newFromUserAndLang(), NS_MEDIAWIKI, null, page, Revision\RAW, Html\rawElement(), and toEditContent().

Referenced by displayPermissionsError(), edit(), and initialiseForm().

◆ getContext()

EditPage::getContext ( )
Since
1.28
Returns
IContextSource

Definition at line 508 of file EditPage.php.

References $context.

Referenced by newTextConflictHelper().

◆ getContextTitle()

EditPage::getContextTitle ( )

Get the context title object.

If not set, $wgTitle will be returned, but this is deprecated. This will throw an exception.

Returns
Title

Definition at line 537 of file EditPage.php.

References $mContextTitle, $wgTitle, and wfDeprecated().

Referenced by displayViewSourcePage(), getCancelLink(), setHeaders(), showEditForm(), and spamPageWithContent().

◆ getCopyrightWarning()

static EditPage::getCopyrightWarning (   $title,
  $format = 'plain',
  $langcode = null 
)
static

Get the copyright warning, by default returns wikitext.

Parameters
Title$title
string$formatOutput format, valid values are any function of a Message object
Language | string | null$langcodeLanguage code or Language object.
Returns
string

Definition at line 3642 of file EditPage.php.

References $title, $wgRightsText, Hooks\run(), and wfMessage().

◆ getCopywarn()

EditPage::getCopywarn ( )
protected

Get the copyright warning.

Renamed to getCopyrightWarning(), old name kept around for backwards compatibility

Returns
string

Definition at line 3630 of file EditPage.php.

Referenced by showStandardInputs().

◆ getCurrentContent()

EditPage::getCurrentContent ( )
protected

Get the current content of the page.

This is basically similar to WikiPage::getContent( Revision::RAW ) except that when the page doesn't exist an empty content object is returned instead of null.

Since
1.21
Returns
Content

Definition at line 1406 of file EditPage.php.

References $content, $handler, $rev, ContentHandler\getForModelID(), getTitle(), null, page, and Revision\RAW.

Referenced by getOriginalContent(), internalAttemptSave(), showDiff(), and showEditForm().

◆ getEditButtons()

EditPage::getEditButtons ( $tabindex)

Returns an array of html code of the following buttons: save, diff and preview.

Parameters
int&$tabindexCurrent tabindex
Returns
array

Definition at line 4270 of file EditPage.php.

References $tabindex, Linker\accesskey(), getSubmitButtonLabel(), Hooks\run(), and Linker\titleAttrib().

Referenced by showStandardInputs().

◆ getEditConflictHelper()

EditPage::getEditConflictHelper ( )
private

◆ getEditPermissionErrors()

EditPage::getEditPermissionErrors (   $rigor = 'secure')
protected
Parameters
string$rigorSame format as Title::getUserPermissionErrors()
Returns
array

Definition at line 713 of file EditPage.php.

References $user, as, diff, and wfArrayDiff2().

Referenced by edit().

◆ getEditToolbar()

static EditPage::getEditToolbar ( )
static

Allow extensions to provide a toolbar.

Returns
string|null

Definition at line 4127 of file EditPage.php.

References null, and Hooks\run().

◆ getLastDelete()

EditPage::getLastDelete ( )
protected

Get the last log record of this page being deleted, if ever.

This is used to detect whether a delete occurred during editing.

Returns
bool|stdClass

Definition at line 3847 of file EditPage.php.

References $dbr, DB_REPLICA, LogPage\DELETED_COMMENT, LogPage\DELETED_USER, CommentStore\getStore(), ActorMigration\newMigration(), null, and wfGetDB().

Referenced by wasDeletedSinceLastEdit().

◆ getOriginalContent()

EditPage::getOriginalContent ( User  $user)
private

Get the content of the wanted revision, without section extraction.

The result of this function can be used to compare user's input with section replaced in its context (using WikiPage::replaceSectionAtRev()) to the original text of the edit.

This differs from Article::getContent() that when a missing revision is encountered the result will be null and not the 'missing-revision' message.

Since
1.19
Parameters
User$userThe user to get the revision for
Returns
Content|null

Definition at line 1365 of file EditPage.php.

References $content, $handler, Revision\FOR_THIS_USER, getCurrentContent(), ContentHandler\getForModelID(), and null.

Referenced by getContentObject().

◆ getParentRevId()

EditPage::getParentRevId ( )

Get the edit's parent revision ID.

The "parent" revision is the ancestor that should be recorded in this page's revision history. It is either the revision ID of the in-memory article content, or in the case of a 3-way merge in order to rebase across a recoverable edit conflict, the ID of the newer revision to which we have rebased this page.

Since
1.27
Returns
int Revision ID

Definition at line 1390 of file EditPage.php.

References $parentRevId.

Referenced by showEditForm().

◆ getPreloadedContent()

EditPage::getPreloadedContent (   $preload,
  $params = [] 
)
protected

Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page.

Parameters
string$preloadRepresenting the title to preload from.
array$paramsParameters to use (interface-message style) in the preloaded text
Returns
Content
Since
1.21

Definition at line 1467 of file EditPage.php.

References $content, $handler, $mPreloadContent, $params, $title, $user, WikiPage\factory(), WikiPage\getContent(), ContentHandler\getForModelID(), WikiPage\getRedirectTarget(), isPageExistingAndViewable(), WikiPage\isRedirect(), Title\newFromText(), ParserOptions\newFromUser(), Revision\RAW, and wfDebug().

Referenced by getContentObject().

◆ getPreviewLimitReport()

static EditPage::getPreviewLimitReport ( ParserOutput  $output = null)
static

Get the Limit report for page previews.

Since
1.22
Parameters
ParserOutput | null$outputParserOutput object from the parse
Returns
string HTML

Definition at line 3670 of file EditPage.php.

References $output, $value, $wgLang, as, Html\closeElement(), null, Html\openElement(), Html\rawElement(), Hooks\run(), and wfMessage().

Referenced by ApiParse\execute().

◆ getPreviewParserOptions()

EditPage::getPreviewParserOptions ( )
protected

Get parser options for a preview.

Returns
ParserOptions

Definition at line 4058 of file EditPage.php.

References page.

Referenced by doPreviewParse().

◆ getPreviewText()

EditPage::getPreviewText ( )

◆ getSubmitButtonLabel()

EditPage::getSubmitButtonLabel ( )
protected

Get the message key of the label for the button to save the page.

Since
1.30
Returns
string

Definition at line 4246 of file EditPage.php.

Referenced by getEditButtons(), getEditConflictHelper(), and showHeader().

◆ getSummaryInputAttributes()

EditPage::getSummaryInputAttributes ( array  $inputAttrs = null)
private

Helper function for summary input functions, which returns the necessary attributes for the input.

Parameters
array | null$inputAttrsArray of attrs to use on the input
Returns
array

Definition at line 3258 of file EditPage.php.

References CommentStore\COMMENT_CHARACTER_LIMIT.

Referenced by getSummaryInputWidget().

◆ getSummaryInputWidget()

EditPage::getSummaryInputWidget (   $summary = "",
  $labelText = null,
  $inputAttrs = null 
)

Builds a standard summary input with a label.

Parameters
string$summaryThe value of the summary input
string | null$labelTextThe html to place inside the label
array | null$inputAttrsArray of attrs to use on the input
Returns
OOUI\FieldLayout OOUI FieldLayout with Label and Input

Definition at line 3281 of file EditPage.php.

References Linker\accesskey(), getSummaryInputAttributes(), and Linker\titleAttrib().

Referenced by showSummaryInput().

◆ getSummaryPreview()

EditPage::getSummaryPreview (   $isSubjectPreview,
  $summary = "" 
)
protected
Parameters
bool$isSubjectPreviewTrue if this is the section subject/title up top, or false if this is the comment summary down below the textarea
string$summaryThe text of the summary to display
Returns
string

Definition at line 3340 of file EditPage.php.

References Linker\commentBlock(), diff, and Xml\tags().

Referenced by showEditForm(), and showStandardInputs().

◆ getTemplates()

EditPage::getTemplates ( )
Returns
array

Definition at line 4105 of file EditPage.php.

References $template, as, and Title\makeTitle().

Referenced by displayViewSourcePage(), and showEditForm().

◆ getTitle()

EditPage::getTitle ( )

◆ guessSectionName()

EditPage::guessSectionName (   $text)
private

Turns section name wikitext into anchors for use in HTTP redirects.

Various versions of Microsoft browsers misinterpret fragment encoding of Location: headers resulting in mojibake in address bar. Redirect them to legacy section IDs, if possible. All the other browsers get HTML5 if the wiki is configured for it, to spread the new style links more efficiently.

Parameters
string$text
Returns
string

Definition at line 4528 of file EditPage.php.

References $name, and $parser.

Referenced by internalAttemptSave(), and newSectionSummary().

◆ handleStatus()

EditPage::handleStatus ( Status  $status,
  $resultDetails 
)
private

Handle status, such as after attempt save.

Parameters
Status$status
array | bool$resultDetails
Exceptions
ErrorPageError
Returns
bool False, if output is done, true if rest of the form should be displayed

Definition at line 1623 of file EditPage.php.

References $out, $query, $request, Status\getWikiText(), incrementResolvedConflicts(), Hooks\run(), setPostEditCookie(), and spamPageWithContent().

Referenced by edit().

◆ importContentFormData()

EditPage::importContentFormData ( $request)
protected

Subpage overridable method for extracting the page content data from the posted form to be placed in $this->textbox1, if using customized input this method should be overridden and return the page text that will be used for saving, preview parsing and so on...

Parameters
WebRequest&$request
Returns
string|null

Definition at line 1132 of file EditPage.php.

Referenced by importFormData().

◆ importFormData()

EditPage::importFormData ( $request)

This function collects the form data and uses it to populate various member variables.

Parameters
WebRequest&$request
Exceptions
ErrorPageError

Definition at line 912 of file EditPage.php.

References $diff, $e, $handler, $preview, $request, $textbox1, $undidRev, $user, diff, edit(), ContentHandler\getForModelID(), ContentHandler\getLocalizedName(), importContentFormData(), isSectionEditSupported(), NS_USER, NS_USER_TALK, null, Hooks\run(), save, tokenOk(), true, wfDebug(), wfEscapeWikiText(), and wfTimestampNow().

Referenced by edit().

◆ incrementConflictStats()

EditPage::incrementConflictStats ( )
protected

Definition at line 3777 of file EditPage.php.

References getEditConflictHelper().

Referenced by showConflict().

◆ incrementEditFailureStats()

EditPage::incrementEditFailureStats (   $failureType)
private

Definition at line 4049 of file EditPage.php.

Referenced by getPreviewText().

◆ incrementResolvedConflicts()

EditPage::incrementResolvedConflicts ( )
private

Log when a page was successfully saved after the edit conflict view.

Definition at line 1606 of file EditPage.php.

References getEditConflictHelper().

Referenced by handleStatus().

◆ initialiseForm()

EditPage::initialiseForm ( )

Initialise form fields in the object Called on the first invocation, e.g.

when a user clicks an edit link

Returns
bool If the requested section is valid

Definition at line 1141 of file EditPage.php.

References $content, $isNew, $user, content, getContentObject(), page, and toEditText().

Referenced by edit().

◆ internalAttemptSave()

EditPage::internalAttemptSave ( $result,
  $bot = false 
)

Attempt submission (no UI)

Parameters
array&$resultArray to add statuses to, currently with the possible keys:
  • spam (string): Spam string from content if any spam is detected by matchSpamRegex.
  • sectionanchor (string): Section anchor for a section save.
  • nullEdit (bool): Set if doEditContent is OK. True if null edit, false otherwise.
  • redirect (bool): Set if doEditContent is OK. True if resulting revision is a redirect.
bool$botTrue if edit is being made under the bot right.
Returns
Status Status object, possibly with a message, but always with one of the AS_* constants in $status->value,
Todo:
FIXME: This interface is TERRIBLE, but hard to get rid of due to various error display idiosyncrasies. There are also lots of cases where error metadata is set in the object and retrieved later instead of being returned, e.g. AS_CONTENT_TOO_BIG and AS_BLOCKED_PAGE_FOR_USER. All that stuff needs to be cleaned up some time.

Definition at line 1869 of file EditPage.php.

References $autoSumm, $changeTags, $code, $content, $edittime, $matches, $mTitle, $request, $sectiontitle, $summary, $undidRev, $user, addContentModelChangeLogEntry(), ChangeTags\canAddTagsAccompanyingChange(), DB_MASTER, EDIT_AUTOSUMMARY, EDIT_FORCE_BOT, EDIT_MINOR, EDIT_NEW, EDIT_UPDATE, etc, false, ContentHandler\getContentText(), getCurrentContent(), getTitle(), guessSectionName(), mergeChangesIntoContent(), StatusValue\newGood(), newSectionSummary(), NS_FILE, NS_MEDIAWIKI, null, of, page, Hooks\run(), runPostMergeFilters(), Title\setContentModel(), toEditContent(), toEditText(), updateWatchlist(), Revision\userWasLastToEdit(), wasDeletedSinceLastEdit(), wfDebug(), wfDebugLog(), and wfReadOnly().

Referenced by attemptSave().

◆ isPageExistingAndViewable()

EditPage::isPageExistingAndViewable (   $title,
User  $user 
)
private

Verify if a given title exists and the given user is allowed to view it.

See also
EditPage::getPreloadedContent()
Parameters
Title | null$title
User$user
Returns
bool
Exceptions
Exception

Definition at line 1533 of file EditPage.php.

References $title.

Referenced by getPreloadedContent(), and showCustomIntro().

◆ isSectionEditSupported()

EditPage::isSectionEditSupported ( )
protected

Returns whether section editing is supported for the current page.

Subclasses may override this to replace the default behavior, which is to check ContentHandler::supportsSections.

Returns
bool True if this edit page supports sections, false otherwise.

Definition at line 902 of file EditPage.php.

References ContentHandler\getForTitle().

Referenced by importFormData(), and showEditForm().

◆ isSupportedContentModel()

EditPage::isSupportedContentModel (   $modelId)

Returns if the given content model is editable.

Parameters
string$modelIdThe ID of the content model to test. Use CONTENT_MODEL_XXX constants.
Returns
bool
Exceptions
MWExceptionIf $modelId has no known handler

Definition at line 554 of file EditPage.php.

References ContentHandler\getForModelID().

Referenced by getContentObject(), toEditContent(), and toEditText().

◆ isWrongCaseUserConfigPage()

EditPage::isWrongCaseUserConfigPage ( )
protected

Checks whether the user entered a skin name in uppercase, e.g.

"User:Example/Monobook.css" instead of "monobook.css"

Returns
bool

Definition at line 881 of file EditPage.php.

References $name, and Skin\getSkinNames().

Referenced by showHeader().

◆ makeTemplatesOnThisPageList()

EditPage::makeTemplatesOnThisPageList ( array  $templates)

Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list.

Parameters
Title[]$templates
Returns
string HTML

Definition at line 3049 of file EditPage.php.

References $type, and Html\rawElement().

Referenced by displayViewSourcePage(), and showEditForm().

◆ matchSpamRegex()

static EditPage::matchSpamRegex (   $text)
static

Check given input text against $wgSpamRegex, and return the text of the first match.

Parameters
string$text
Returns
string|bool Matching string or false

Definition at line 2469 of file EditPage.php.

References $wgSpamRegex.

◆ matchSpamRegexInternal()

static EditPage::matchSpamRegexInternal (   $text,
  $regexes 
)
staticprotected
Parameters
string$text
array$regexes
Returns
bool|string

Definition at line 2494 of file EditPage.php.

References $matches, and as.

◆ matchSummarySpamRegex()

static EditPage::matchSummarySpamRegex (   $text)
static

Check given input text against $wgSummarySpamRegex, and return the text of the first match.

Parameters
string$text
Returns
string|bool Matching string or false

Definition at line 2483 of file EditPage.php.

References $wgSummarySpamRegex.

Referenced by MovePage\checkPermissions(), MergeHistory\checkPermissions(), and SpecialChangeContentModel\getFormFields().

◆ mergeChangesIntoContent()

EditPage::mergeChangesIntoContent ( $editContent)
private

Attempts to do 3-way merge of edit content with a base revision and current content, in case of edit conflict, in whichever way appropriate for the content type.

Since
1.21
Parameters
Content$editContent
Returns
bool

Definition at line 2406 of file EditPage.php.

References $handler, DB_MASTER, getBaseRevision(), ContentHandler\getForModelID(), Revision\loadFromTitle(), null, and wfGetDB().

Referenced by internalAttemptSave().

◆ newSectionSummary()

EditPage::newSectionSummary ( $sectionanchor = null)
private

Return the summary to be used for a new section.

Parameters
string$sectionanchorSet to the section anchor text
Returns
string

Definition at line 1821 of file EditPage.php.

References $summary, and guessSectionName().

Referenced by internalAttemptSave().

◆ newTextConflictHelper()

EditPage::newTextConflictHelper (   $submitButtonLabel)
private
Parameters
string$submitButtonLabel
Returns
TextConflictHelper

Definition at line 4572 of file EditPage.php.

References getContext(), and getTitle().

◆ noSuchSectionPage()

EditPage::noSuchSectionPage ( )

Creates a basic error page which informs the user that they have attempted to edit a nonexistent section.

Definition at line 4339 of file EditPage.php.

References $out, $res, and Hooks\run().

Referenced by edit().

◆ previewOnOpen()

EditPage::previewOnOpen ( )
protected

Should we show a preview when the edit form is first shown?

Returns
bool

Definition at line 840 of file EditPage.php.

References $request.

Referenced by edit().

◆ runPostMergeFilters()

EditPage::runPostMergeFilters ( Content  $content,
Status  $status,
User  $user 
)
protected

Run hooks that can filter edits just before they get saved.

Parameters
Content$contentThe Content to filter.
Status$statusFor reporting the outcome to the caller
User$userThe user performing the edit
Returns
bool

Definition at line 1754 of file EditPage.php.

References StatusValue\fatal(), formatStatusErrors(), StatusValue\isGood(), StatusValue\isOK(), and Hooks\run().

Referenced by internalAttemptSave().

◆ setApiEditOverride()

EditPage::setApiEditOverride (   $enableOverride)

Allow editing of content that supports API direct editing, but not general direct editing.

Set to false by default.

Parameters
bool$enableOverride

Definition at line 565 of file EditPage.php.

◆ setContextTitle()

EditPage::setContextTitle (   $title)

Set the context Title object.

Parameters
Title | null$titleTitle object or null

Definition at line 525 of file EditPage.php.

References $title.

◆ setEditConflictHelperFactory()

EditPage::setEditConflictHelperFactory ( callable  $factory)

Set a factory function to create an EditConflictHelper.

Parameters
callable$factoryFactory function
Since
1.31

Definition at line 4549 of file EditPage.php.

References null.

◆ setHeaders()

EditPage::setHeaders ( )

Definition at line 2504 of file EditPage.php.

References $out, $user, false, getContextTitle(), and NS_MEDIAWIKI.

Referenced by showEditForm().

◆ setPostEditCookie()

EditPage::setPostEditCookie (   $statusValue)
protected

Sets post-edit cookie indicating the user just saved a particular revision.

This uses a temporary cookie for each revision ID so separate saves will never interfere with each other.

Article::view deletes the cookie on server-side after the redirect and converts the value to the global JavaScript variable wgPostEdit.

If the variable were set on the server, it would be cached, which is unwanted since the post-edit state should only apply to the load right after the save.

Parameters
int$statusValueThe status value (to check for new article status)

Definition at line 1568 of file EditPage.php.

References $response, and page.

Referenced by handleStatus().

◆ setPreloadedContent()

EditPage::setPreloadedContent ( Content  $content)

Use this method before edit() to preload some content into the edit box.

Parameters
Content$content
Since
1.21

Definition at line 1452 of file EditPage.php.

References $content.

◆ showConflict()

EditPage::showConflict ( )
protected

Show an edit conflict.

textbox1 is already shown in showEditForm(). If you want to use another entry point to this function, be careful.

Definition at line 3766 of file EditPage.php.

References $out, getEditConflictHelper(), incrementConflictStats(), and Hooks\run().

Referenced by showEditForm().

◆ showContentForm()

EditPage::showContentForm ( )
protected

Subpage overridable method for printing the form for page content editing By default this simply outputs wpTextbox1 Subclasses can override this to provide a custom UI for editing; be it a form, or simply wpTextbox1 with a modified content that will be reverse modified when extracted from the post data.

Note that this is basically the inverse for importContentFormData

Definition at line 3398 of file EditPage.php.

References showTextbox1().

Referenced by showEditForm().

◆ showCustomIntro()

EditPage::showCustomIntro ( )
protected

Attempt to show a custom editing introduction, if supplied.

Returns
bool

Definition at line 2693 of file EditPage.php.

References $mTitle, $title, isPageExistingAndViewable(), and Title\newFromText().

Referenced by showIntro().

◆ showDiff()

EditPage::showDiff ( )

Get a diff between the current contents of the edit box and the version of the page we're editing from.

If this is a section edit, we'll replace the section as for final save and then make a comparison.

Definition at line 3525 of file EditPage.php.

References $user, getCurrentContent(), ParserOptions\newFromUserAndLang(), NS_MEDIAWIKI, null, page, Hooks\run(), and toEditContent().

Referenced by displayPreviewArea(), and spamPageWithContent().

◆ showEditForm()

◆ showEditTools()

EditPage::showEditTools ( )
protected

Inserts optional text shown below edit and upload forms.

Can be used to offer special characters not present on most keyboards for copying/pasting.

Definition at line 3618 of file EditPage.php.

Referenced by showEditForm().

◆ showFormAfterText()

EditPage::showFormAfterText ( )
protected

Definition at line 3370 of file EditPage.php.

References Html\hidden().

Referenced by showEditForm().

◆ showFormBeforeText()

EditPage::showFormBeforeText ( )
protected

Definition at line 3361 of file EditPage.php.

References $out, and Html\hidden().

Referenced by showEditForm().

◆ showHeader()

◆ showHeaderCopyrightWarning()

EditPage::showHeaderCopyrightWarning ( )
protected

Show the header copyright warning.

Definition at line 3587 of file EditPage.php.

Referenced by showHeader().

◆ showIntro()

◆ showPreview()

EditPage::showPreview (   $text)
protected

Append preview output to OutputPage.

Includes category rendering if this is a category page.

Parameters
string$textThe HTML to be output for the preview.

Definition at line 3504 of file EditPage.php.

References $out, and Hooks\run().

Referenced by displayPreviewArea().

◆ showStandardInputs()

EditPage::showStandardInputs ( $tabindex = 2)
protected

◆ showSummaryInput()

EditPage::showSummaryInput (   $isSubjectPreview,
  $summary = "" 
)
protected
Parameters
bool$isSubjectPreviewTrue if this is the section subject/title up top, or false if this is the comment summary down below the textarea
string$summaryThe text of the summary to display

Definition at line 3314 of file EditPage.php.

References getSummaryInputWidget().

Referenced by showEditForm(), and showStandardInputs().

◆ showTextbox()

EditPage::showTextbox (   $text,
  $name,
  $customAttribs = [] 
)
protected

Definition at line 3442 of file EditPage.php.

References $attribs, $customAttribs, $mTitle, $name, and Html\textarea().

Referenced by displayViewSourcePage(), showTextbox1(), and showTextbox2().

◆ showTextbox1()

EditPage::showTextbox1 (   $customAttribs = null,
  $textoverride = null 
)
protected

Method to output wpTextbox1 The $textoverride method can be used by subclasses overriding showContentForm to pass back to this method.

Parameters
array | null$customAttribsArray of html attributes to use in the textarea
string | null$textoverrideOptional text to override $this->textarea1 with

Definition at line 3410 of file EditPage.php.

References $attribs, $customAttribs, getTitle(), showTextbox(), and wasDeletedSinceLastEdit().

Referenced by showContentForm().

◆ showTextbox2()

EditPage::showTextbox2 ( )
protected

Definition at line 3438 of file EditPage.php.

References showTextbox().

Referenced by spamPageWithContent().

◆ showTosSummary()

EditPage::showTosSummary ( )
protected

Give a chance for site and per-namespace customizations of terms of service summary link that might exist separately from the copyright notice.

This will display between the save button and the edit tools, so should remain short!

Definition at line 3603 of file EditPage.php.

References $out, and Hooks\run().

Referenced by showEditForm().

◆ spamPageWithContent()

EditPage::spamPageWithContent (   $match = false)

Show "your edit contains spam" page with your diff and text.

Parameters
string | array | bool$matchText (or array of texts) which triggered one or more filters

Definition at line 4358 of file EditPage.php.

References $out, $textbox1, getContextTitle(), showDiff(), showTextbox2(), and wfEscapeWikiText().

Referenced by handleStatus().

◆ toEditContent()

EditPage::toEditContent (   $text)
protected

Turns the given text into a Content object by unserializing it.

If the resulting Content object is not of a type that can be edited using the text base EditPage, an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual content.

Parameters
string | null | bool$textText to unserialize
Returns
Content|bool|null The content object created from $text. If $text was false or null, then false or null will be returned instead.
Exceptions
MWExceptionIf unserializing the text results in a Content object that is not an instance of TextContent and $this->allowNonTextContent is not true.

Definition at line 2755 of file EditPage.php.

References $content, getTitle(), isSupportedContentModel(), ContentHandler\makeContent(), and null.

Referenced by getContentObject(), getPreviewText(), internalAttemptSave(), and showDiff().

◆ toEditText()

EditPage::toEditText (   $content)
protected

Gets an editable textual representation of $content.

The textual representation can be turned by into a Content object by the toEditContent() method.

If $content is null or false or a string, $content is returned unchanged.

If the given Content object is not of a type that can be edited using the text base EditPage, an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual content.

Parameters
Content | null | bool | string$content
Returns
string The editable text form of the content.
Exceptions
MWExceptionIf $content is not an instance of TextContent and $this->allowNonTextContent is not true.

Definition at line 2727 of file EditPage.php.

References $content, isSupportedContentModel(), and null.

Referenced by displayViewSourcePage(), initialiseForm(), internalAttemptSave(), and showEditForm().

◆ tokenOk()

EditPage::tokenOk ( $request)

Make sure the form isn't faking a user's credentials.

Parameters
WebRequest&$request
Returns
bool
Access:
private

Definition at line 1546 of file EditPage.php.

References $mTokenOk, $request, and $user.

Referenced by importFormData().

◆ updateWatchlist()

EditPage::updateWatchlist ( )
protected

Register the change of watch status.

Definition at line 2378 of file EditPage.php.

References $mTitle, $title, $user, $watchthis, DeferredUpdates\addCallableUpdate(), WatchAction\doWatchOrUnwatch(), User\IGNORE_USER_RIGHTS, and use.

Referenced by internalAttemptSave().

◆ wasDeletedSinceLastEdit()

EditPage::wasDeletedSinceLastEdit ( )
protected

Check if a page was deleted while the user was editing it, before submit.

Note that we rely on the logging table, which hasn't been always there, but that doesn't matter, because this only applies to brand new deletes.

Returns
bool

Definition at line 3822 of file EditPage.php.

References $deletedSinceEdit, getLastDelete(), null, and wfTimestamp().

Referenced by internalAttemptSave(), showEditForm(), and showTextbox1().

Member Data Documentation

◆ $action

string EditPage::$action = 'submit'

Definition at line 237 of file EditPage.php.

◆ $allowBlankArticle

bool EditPage::$allowBlankArticle = false
protected

Definition at line 291 of file EditPage.php.

◆ $allowBlankSummary

bool EditPage::$allowBlankSummary = false

Definition at line 285 of file EditPage.php.

◆ $allowSelfRedirect

bool EditPage::$allowSelfRedirect = false
protected

Definition at line 297 of file EditPage.php.

◆ $autoSumm

string EditPage::$autoSumm = ''

Definition at line 300 of file EditPage.php.

Referenced by internalAttemptSave().

◆ $blankArticle

bool EditPage::$blankArticle = false
protected

Definition at line 288 of file EditPage.php.

◆ $bot

bool EditPage::$bot = true

Definition at line 404 of file EditPage.php.

Referenced by attemptSave().

◆ $changeTags

null array EditPage::$changeTags = null
private

Definition at line 413 of file EditPage.php.

Referenced by internalAttemptSave().

◆ $contentFormat

null string EditPage::$contentFormat = null

Definition at line 410 of file EditPage.php.

◆ $contentLength

bool int EditPage::$contentLength = false
protected

Definition at line 439 of file EditPage.php.

◆ $contentModel

string EditPage::$contentModel

Definition at line 407 of file EditPage.php.

Referenced by edit().

◆ $context

IContextSource EditPage::$context
protected

Definition at line 449 of file EditPage.php.

Referenced by getContext().

◆ $deletedSinceEdit

bool EditPage::$deletedSinceEdit

Definition at line 249 of file EditPage.php.

Referenced by wasDeletedSinceLastEdit().

◆ $didSave

EditPage::$didSave = false

Definition at line 430 of file EditPage.php.

◆ $diff

bool EditPage::$diff = false

Definition at line 326 of file EditPage.php.

Referenced by importFormData().

◆ $edit

bool EditPage::$edit
protected

Definition at line 436 of file EditPage.php.

◆ $editConflictHelper

TextConflictHelper null EditPage::$editConflictHelper
private

Definition at line 471 of file EditPage.php.

Referenced by getEditConflictHelper().

◆ $editConflictHelperFactory

callable EditPage::$editConflictHelperFactory
private

Factory function to create an edit conflict helper.

Definition at line 466 of file EditPage.php.

◆ $editFormPageTop

string EditPage::$editFormPageTop = ''

Before even the preview.

Definition at line 419 of file EditPage.php.

◆ $editFormTextAfterContent

EditPage::$editFormTextAfterContent = ''

Definition at line 425 of file EditPage.php.

◆ $editFormTextAfterTools

EditPage::$editFormTextAfterTools = ''

Definition at line 423 of file EditPage.php.

◆ $editFormTextAfterWarn

EditPage::$editFormTextAfterWarn = ''

Definition at line 422 of file EditPage.php.

◆ $editFormTextBeforeContent

EditPage::$editFormTextBeforeContent = ''

Definition at line 421 of file EditPage.php.

◆ $editFormTextBottom

EditPage::$editFormTextBottom = ''

Definition at line 424 of file EditPage.php.

◆ $editFormTextTop

EditPage::$editFormTextTop = ''

Definition at line 420 of file EditPage.php.

◆ $editintro

string EditPage::$editintro = ''

Definition at line 398 of file EditPage.php.

◆ $editRevId

int EditPage::$editRevId = null
private

Revision ID of the latest revision of the page when editing was initiated on the client.

This is used to detect and resolve edit conflicts.

Note
0 if the page did not exist at that time.
When starting an edit from an old revision, this still records the current revision at the time, not the one the edit is based on.
See also
$oldid
getBaseRevision()

Definition at line 370 of file EditPage.php.

◆ $edittime

string EditPage::$edittime = ''

Timestamp of the latest revision of the page when editing was initiated on the client.

Definition at line 357 of file EditPage.php.

Referenced by internalAttemptSave().

◆ $enableApiEditOverride

bool EditPage::$enableApiEditOverride = false
private

Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing.

Definition at line 444 of file EditPage.php.

◆ $firsttime

bool EditPage::$firsttime

True the first time the edit form is rendered, false after re-rendering with diff, save prompts, etc.

Definition at line 258 of file EditPage.php.

◆ $formtype

string EditPage::$formtype

Definition at line 252 of file EditPage.php.

◆ $hasPresetSummary

bool EditPage::$hasPresetSummary = false

Has a summary been preset using GET parameter &summary= ?

Definition at line 309 of file EditPage.php.

◆ $hookError

string EditPage::$hookError = ''

Definition at line 303 of file EditPage.php.

◆ $incompleteForm

bool EditPage::$incompleteForm = false

Definition at line 273 of file EditPage.php.

◆ $isConflict

bool EditPage::$isConflict = false

Whether an edit conflict needs to be resolved.

Detected based on whether $editRevId is different than the latest revision. When a conflict has successfully been resolved by a 3-way-merge, this field is set to false.

Definition at line 243 of file EditPage.php.

◆ $isNew

bool EditPage::$isNew = false

New page or new section.

Definition at line 246 of file EditPage.php.

Referenced by initialiseForm().

◆ $isOldRev

bool EditPage::$isOldRev = false
private

Whether an old revision is edited.

Definition at line 454 of file EditPage.php.

◆ $lastDelete

bool stdClass EditPage::$lastDelete

Definition at line 261 of file EditPage.php.

◆ $mArticle

Article EditPage::$mArticle
Deprecated:
for public usage since 1.30 use EditPage::getArticle()

Definition at line 223 of file EditPage.php.

Referenced by getArticle().

◆ $mBaseRevision

Revision bool null EditPage::$mBaseRevision = false

A revision object corresponding to $this->editRevId.

Definition at line 312 of file EditPage.php.

Referenced by getBaseRevision().

◆ $mContextTitle

null Title EditPage::$mContextTitle = null
private

Definition at line 234 of file EditPage.php.

Referenced by getContextTitle().

◆ $minoredit

bool EditPage::$minoredit = false

Definition at line 329 of file EditPage.php.

◆ $missingComment

bool EditPage::$missingComment = false

Definition at line 279 of file EditPage.php.

◆ $missingSummary

bool EditPage::$missingSummary = false

Definition at line 282 of file EditPage.php.

◆ $mParserOutput

ParserOutput EditPage::$mParserOutput

Definition at line 306 of file EditPage.php.

◆ $mPreloadContent

EditPage::$mPreloadContent = null

Definition at line 427 of file EditPage.php.

Referenced by getPreloadedContent().

◆ $mShowSummaryField

bool EditPage::$mShowSummaryField = true

Definition at line 315 of file EditPage.php.

◆ $mTitle

Title EditPage::$mTitle
Deprecated:
for public usage since 1.30 use EditPage::getTitle()

Definition at line 231 of file EditPage.php.

Referenced by getTitle(), internalAttemptSave(), showCustomIntro(), showTextbox(), and updateWatchlist().

◆ $mTokenOk

bool EditPage::$mTokenOk = false

Definition at line 264 of file EditPage.php.

Referenced by getPreviewText(), and tokenOk().

◆ $mTokenOkExceptSuffix

bool EditPage::$mTokenOkExceptSuffix = false

Definition at line 267 of file EditPage.php.

◆ $mTriedSave

bool EditPage::$mTriedSave = false

Definition at line 270 of file EditPage.php.

◆ $nosummary

bool EditPage::$nosummary = false

If true, hide the summary field.

Definition at line 351 of file EditPage.php.

◆ $oldid

int EditPage::$oldid = 0

Revision ID the edit is based on, or 0 if it's the current revision.

FIXME: This isn't used in conflict resolution–provide a better justification or merge with parentRevId.

See also
$editRevId

Definition at line 388 of file EditPage.php.

Referenced by getCancelLink().

◆ $page

WikiPage EditPage::$page
private

Definition at line 225 of file EditPage.php.

◆ $parentRevId

int EditPage::$parentRevId = 0

Revision ID the edit is based on, adjusted when an edit conflict is resolved.

See also
$editRevId
$oldid
getparentRevId()

Definition at line 395 of file EditPage.php.

Referenced by getParentRevId().

◆ $preview

bool EditPage::$preview = false

Definition at line 323 of file EditPage.php.

Referenced by importFormData().

◆ $previewTextAfterContent

EditPage::$previewTextAfterContent = ''

Definition at line 426 of file EditPage.php.

Referenced by getPreviewText().

◆ $recreate

bool EditPage::$recreate = false

Definition at line 335 of file EditPage.php.

◆ $save

bool EditPage::$save = false

Definition at line 320 of file EditPage.php.

◆ $scrolltop

null EditPage::$scrolltop = null

Definition at line 401 of file EditPage.php.

◆ $section

string EditPage::$section = ''

Definition at line 373 of file EditPage.php.

◆ $sectiontitle

string EditPage::$sectiontitle = ''

Definition at line 376 of file EditPage.php.

Referenced by internalAttemptSave().

◆ $selfRedirect

bool EditPage::$selfRedirect = false
protected

Definition at line 294 of file EditPage.php.

◆ $starttime

string EditPage::$starttime = ''

Timestamp from the first time the edit form was rendered.

Definition at line 381 of file EditPage.php.

◆ $summary

string EditPage::$summary = ''

Definition at line 346 of file EditPage.php.

Referenced by getContentObject(), internalAttemptSave(), and newSectionSummary().

◆ $suppressIntro

EditPage::$suppressIntro = false

Definition at line 433 of file EditPage.php.

◆ $textbox1

string EditPage::$textbox1 = ''

Page content input field.

Definition at line 340 of file EditPage.php.

Referenced by displayViewSourcePage(), importFormData(), showEditForm(), and spamPageWithContent().

◆ $textbox2

string EditPage::$textbox2 = ''

Definition at line 343 of file EditPage.php.

◆ $tooBig

bool EditPage::$tooBig = false

Definition at line 276 of file EditPage.php.

◆ $undidRev

EditPage::$undidRev = 0

Definition at line 431 of file EditPage.php.

Referenced by importFormData(), and internalAttemptSave().

◆ $unicodeCheck

string null EditPage::$unicodeCheck
private

What the user submitted in the 'wpUnicodeCheck' field.

Definition at line 459 of file EditPage.php.

◆ $watchthis

bool EditPage::$watchthis = false

Definition at line 332 of file EditPage.php.

Referenced by updateWatchlist().

◆ AS_ARTICLE_WAS_DELETED

const EditPage::AS_ARTICLE_WAS_DELETED = 222

Status: article was deleted while editing and param wpRecreate == false or form was not posted.

Definition at line 105 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_BLANK_ARTICLE

const EditPage::AS_BLANK_ARTICLE = 224

Status: user tried to create a blank page and wpIgnoreBlankArticle == false.

Definition at line 116 of file EditPage.php.

Referenced by ApiEditPage\execute(), EditPageTest\provideCreatePages(), EditPageTest\testCreatePage(), and EditPageTest\testCreatePageTrx().

◆ AS_BLOCKED_PAGE_FOR_USER

const EditPage::AS_BLOCKED_PAGE_FOR_USER = 215

Status: User is blocked from editing this page.

Definition at line 74 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_CANNOT_USE_CUSTOM_MODEL

const EditPage::AS_CANNOT_USE_CUSTOM_MODEL = 241

Status: when changing the content model is disallowed due to $wgContentHandlerUseDB being false.

Definition at line 186 of file EditPage.php.

◆ AS_CHANGE_TAG_ERROR

const EditPage::AS_CHANGE_TAG_ERROR = 237

Status: an error relating to change tagging.

Look at the message key for more details

Definition at line 175 of file EditPage.php.

◆ AS_CONFLICT_DETECTED

const EditPage::AS_CONFLICT_DETECTED = 225

Status: (non-resolvable) edit conflict.

Definition at line 121 of file EditPage.php.

Referenced by ApiEditPage\execute(), and EditPageTest\provideAutoMerge().

◆ AS_CONTENT_TOO_BIG

const EditPage::AS_CONTENT_TOO_BIG = 216

Status: Content too big (> $wgMaxArticleSize)

Definition at line 79 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_END

const EditPage::AS_END = 231

Status: WikiPage::doEdit() was unsuccessful.

Definition at line 142 of file EditPage.php.

◆ AS_HOOK_ERROR

const EditPage::AS_HOOK_ERROR = 210

Status: Article update aborted by a hook function.

Definition at line 64 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_HOOK_ERROR_EXPECTED

const EditPage::AS_HOOK_ERROR_EXPECTED = 212

Status: A hook function returned an error.

Definition at line 69 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_IMAGE_REDIRECT_ANON

const EditPage::AS_IMAGE_REDIRECT_ANON = 233

Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false)

Definition at line 152 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_IMAGE_REDIRECT_LOGGED

const EditPage::AS_IMAGE_REDIRECT_LOGGED = 234

Status: logged in user is not allowed to upload (User::isAllowed('upload') == false)

Definition at line 157 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_MAX_ARTICLE_SIZE_EXCEEDED

const EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED = 229

Status: article is too big (> $wgMaxArticleSize), after merging in the new section.

Definition at line 137 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_NO_CHANGE_CONTENT_MODEL

const EditPage::AS_NO_CHANGE_CONTENT_MODEL = 235

Status: user tried to modify the content model, but is not allowed to do that ( User::isAllowed('editcontentmodel') == false )

Definition at line 163 of file EditPage.php.

Referenced by ApiEditPage\execute(), EditPageTest\testShouldPreventChangingContentModelWhenUserCannotChangeModelForTitle(), and EditPageTest\testShouldPreventChangingContentModelWhenUserCannotEditTargetTitle().

◆ AS_NO_CREATE_PERMISSION

const EditPage::AS_NO_CREATE_PERMISSION = 223

Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == false )

Definition at line 111 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_PARSE_ERROR

const EditPage::AS_PARSE_ERROR = 240

Status: can't parse content.

Definition at line 180 of file EditPage.php.

◆ AS_RATE_LIMITED

const EditPage::AS_RATE_LIMITED = 221

Status: rate limiter for action 'edit' was tripped.

Definition at line 99 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_READ_ONLY_PAGE

const EditPage::AS_READ_ONLY_PAGE = 220

Status: wiki is in readonly mode (wfReadOnly() == true)

Definition at line 94 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_READ_ONLY_PAGE_ANON

const EditPage::AS_READ_ONLY_PAGE_ANON = 218

Status: this anonymous user is not allowed to edit this page.

Definition at line 84 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_READ_ONLY_PAGE_LOGGED

const EditPage::AS_READ_ONLY_PAGE_LOGGED = 219

Status: this logged in user is not allowed to edit this page.

Definition at line 89 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_SELF_REDIRECT

const EditPage::AS_SELF_REDIRECT = 236

Status: user tried to create self-redirect (redirect to the same article) and wpIgnoreSelfRedirect == false.

Definition at line 169 of file EditPage.php.

◆ AS_SPAM_ERROR

const EditPage::AS_SPAM_ERROR = 232

Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex.

Definition at line 147 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_SUCCESS_NEW_ARTICLE

const EditPage::AS_SUCCESS_NEW_ARTICLE = 201

Status: Article successfully created.

Definition at line 59 of file EditPage.php.

Referenced by ApiEditPage\execute(), and EditPageTest\provideCreatePages().

◆ AS_SUCCESS_UPDATE

◆ AS_SUMMARY_NEEDED

const EditPage::AS_SUMMARY_NEEDED = 226

Status: no edit summary given and the user has forceeditsummary set and the user is not editing in his own userspace or talkspace and wpIgnoreBlankSummary == false.

Definition at line 127 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_TEXTBOX_EMPTY

const EditPage::AS_TEXTBOX_EMPTY = 228

Status: user tried to create a new section without content.

Definition at line 132 of file EditPage.php.

Referenced by ApiEditPage\execute().

◆ AS_UNICODE_NOT_SUPPORTED

const EditPage::AS_UNICODE_NOT_SUPPORTED = 242

Status: edit rejected because browser doesn't support Unicode.

Definition at line 191 of file EditPage.php.

◆ EDITFORM_ID

const EditPage::EDITFORM_ID = 'editform'

HTML id and name for the beginning of the edit form.

Definition at line 196 of file EditPage.php.

◆ POST_EDIT_COOKIE_DURATION

const EditPage::POST_EDIT_COOKIE_DURATION = 1200

Duration of PostEdit cookie, in seconds.

The cookie will be removed instantly if the JavaScript runs.

Otherwise, though, we don't want the cookies to accumulate. RFC 2109 ( https://www.ietf.org/rfc/rfc2109.txt ) specifies a possible limit of only 20 cookies per domain. This still applies at least to some versions of IE without full updates: https://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx

A value of 20 minutes should be enough to take into account slow loads and minor clock skew while still avoiding cookie accumulation when JavaScript is turned off.

Definition at line 217 of file EditPage.php.

◆ POST_EDIT_COOKIE_KEY_PREFIX

const EditPage::POST_EDIT_COOKIE_KEY_PREFIX = 'PostEditRevision'

Prefix of key for cookie used to pass post-edit state.

The revision id edited is added after this

Definition at line 202 of file EditPage.php.

Referenced by Article\view().

◆ UNICODE_CHECK

const EditPage::UNICODE_CHECK = 'ℳ𝒲β™₯π“Šπ“ƒπ’Ύπ’Έβ„΄π’Ήβ„―'

The documentation for this class was generated from the following file: