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...

Inheritance diagram for EditPage:
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 ()
 
 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 ()
 
 getEditButtons (&$tabindex)
 Returns an array of html code of the following buttons: save, diff and preview. More...
 
 getExpectedParentRevision ()
 Returns the RevisionRecord corresponding to 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...
 
 getPreviewText ()
 Get the rendered text for previewing. More...
 
 getTemplates ()
 
 getTitle ()
 
 importFormData (&$request)
 This function collects the form data and uses it to populate various member variables. More...
 
 internalAttemptSave (&$result, $markAsBot=false, $markAsMinor=false)
 Attempt submission (no UI) More...
 
 makeTemplatesOnThisPageList (array $templates)
 Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list. More...
 
 maybeActivateTempUserCreate ( $doAcquire)
 Check the configuration and current user and enable automatic temporary user creation if possible. More...
 
 setApiEditOverride ( $enableOverride)
 Allow editing of content that supports API direct editing, but not general direct editing. More...
 
 setContextTitle ( $title)
 
 setEditConflictHelperFactory (callable $factory)
 Set a factory function to create an EditConflictHelper. More...
 
 setHeaders ()
 
 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...
 

Static Public Member Functions

static getCopyrightWarning ( $page, $format='plain', $localizer=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...
 

Public Attributes

string $action = 'submit'
 
null string $contentFormat = null
 
string $contentModel
 
 $didSave = false
 
string $editFormPageTop = ''
 Before even the preview. More...
 
 $editFormTextAfterContent = ''
 
 $editFormTextAfterTools = ''
 
 $editFormTextAfterWarn = ''
 
 $editFormTextBeforeContent = ''
 
 $editFormTextBottom = ''
 
 $editFormTextTop = ''
 
string null $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 $isConflict = false
 Whether an edit conflict needs to be resolved. More...
 
bool $mShowSummaryField = true
 
int $oldid = 0
 Revision ID the edit is based on, or 0 if it's the current revision. More...
 
bool $preview = false
 
 $previewTextAfterContent = ''
 
bool $save = false
 
string $section = ''
 
string null $sectiontitle = null
 
string null $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 = ''
 
 $undidRev = 0
 
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 = UnicodeConstraint::VALID_UNICODE
 Used for Unicode support checks. More...
 
- Public Attributes inherited from MediaWiki\EditPage\IEditObject
const AS_ARTICLE_WAS_DELETED = 222
 Status: article was deleted while editing and 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_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. 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 (ReadOnlyMode::isReadOnly() == 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 and wpIgnoreSelfRedirect is 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...
 

Protected Member Functions

 addNewLineAtEnd ( $wikitext)
 
 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...
 
 getPreviewParserOptions ()
 Get parser options for a preview. More...
 
 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...
 
 previewOnOpen ()
 Should we show a preview when the edit form is first shown? 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...
 
 showFormAfterText ()
 
 showStandardInputs (&$tabindex=2)
 
 showTextbox ( $text, $name, $customAttribs=[])
 
 toEditContent ( $text)
 Turns the given text into a Content object by unserializing it. More...
 

Protected Attributes

bool $blankArticle = false
 
IContextSource $context
 

Private Member Functions

 addContentModelChangeLogEntry (UserIdentity $user, $oldModel, $newModel, $reason)
 
 addEditNotices ()
 
 addExplainConflictHeader ()
 
 addLongPageWarningHeader ()
 
 addPageProtectionWarningHeaders ()
 
 addTalkPageText ()
 
 createTempUser (PageUpdater $pageUpdater)
 If automatic user creation is enabled, create the user and adjust the PageUpdater so that it has the new user/actor ID. More...
 
 displayPermissionsError (array $permErrors)
 Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences: More...
 
 displayPreviewArea (string $previewOutput, bool $isOnTop)
 
 displayViewSourcePage (Content $content, string $errorMessage)
 Display a read-only View Source page. More...
 
 doPostEditRedirect ( $query, $anchor)
 Emit the post-save redirect. More...
 
 getAuthority ()
 Get the authority for permissions purposes. More...
 
 getCancelLink (int $tabindex)
 
 getCheckboxesDefinitionForWatchlist ( $watch)
 Get the watchthis and watchlistExpiry form field definitions. More...
 
 getEditConflictHelper ()
 
 getEditPermissionErrors (string $rigor=PermissionManager::RIGOR_SECURE)
 
 getLastDelete ()
 Get the last log record of this page being deleted, if ever. More...
 
 getOriginalContent (Authority $performer)
 Get the content of the wanted revision, without section extraction. More...
 
 getParentRevId ()
 Get the edit's parent revision ID. More...
 
 getPreloadedContent (string $preload, array $params)
 Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page. More...
 
 getSubmitButtonLabel ()
 Get the message key of the label for the button to save the page. More...
 
 getSummaryInputAttributes (array $inputAttrs)
 Helper function for summary input functions, which returns the necessary attributes for the input. More...
 
 getSummaryInputWidget ( $summary, string $labelText, array $inputAttrs)
 Builds a standard summary input with a label. More...
 
 getSummaryPreview (bool $isSubjectPreview)
 
 getUndoContent (RevisionRecord $undoRev, RevisionRecord $oldRev)
 Returns the result of a three-way merge when undoing changes. More...
 
 getUserForPermissions ()
 Get the user for permissions purposes, with declared type User instead of Authority for compatibility with PermissionManager. More...
 
 getUserForPreview ()
 Get the user for preview or PST purposes. More...
 
 getUserForSave ()
 Get the user suitable for permanent attribution in the database. More...
 
 guessSectionName ( $text)
 Turns section name wikitext into anchors for use in HTTP redirects. More...
 
 handleFailedConstraint (IEditConstraint $failed)
 Apply the specific updates needed for the EditPage fields based on which constraint failed, rather than interspersing this logic throughout internalAttemptSave at each of the points the constraints are checked. More...
 
 handleStatus (Status $status, $resultDetails)
 Handle status, such as after attempt save. More...
 
 incrementConflictStats ()
 
 incrementEditFailureStats (string $failureType)
 
 incrementResolvedConflicts ()
 Log when a page was successfully saved after the edit conflict view. More...
 
 initialiseForm ()
 Initialise form fields in the object Called on the first invocation, e.g. More...
 
 isPageExistingAndViewable (?PageIdentity $page, Authority $performer)
 Verify if a given title exists and the given user is allowed to view it. More...
 
 isSectionEditSupported ()
 Section editing is supported when the page content model allows section edit and we are editing current revision. More...
 
 isSupportedContentModel (string $modelId)
 Returns if the given content model is editable. More...
 
 isUndoClean (Content $content)
 Does checks and compares the automatically generated undo content with the one that was submitted by the user. More...
 
 isWrongCaseUserConfigPage ()
 Checks whether the user entered a skin name in uppercase, e.g. More...
 
 mergeChangesIntoContent (Content $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 ()
 Return the summary to be used for a new section. More...
 
 newTextConflictHelper (string $submitButtonLabel)
 
 noSuchSectionPage ()
 Creates a basic error page which informs the user that they have attempted to edit a nonexistent section. More...
 
 setPostEditCookie (int $statusValue)
 Sets post-edit cookie indicating the user just saved a particular revision. More...
 
 showConflict ()
 Show an edit conflict. More...
 
 showCustomIntro ()
 Attempt to show a custom editing introduction, if supplied. More...
 
 showEditTools ()
 Inserts optional text shown below edit and upload forms. More...
 
 showFormBeforeText ()
 
 showHeader ()
 
 showHeaderCopyrightWarning ()
 
 showIntro ()
 Show all applicable editing introductions. More...
 
 showPreview (string $text)
 Append preview output to OutputPage. More...
 
 showSummaryInput (bool $isSubjectPreview)
 
 showTextbox1 ()
 
 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...
 
 toEditText ( $content)
 Gets an editable textual representation of $content. More...
 
 tokenOk (WebRequest $request)
 Make sure the form isn't faking a user's credentials. 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 Private Member Functions

static extractSectionTitle ( $text)
 Extract the section title from current section text, if any. More...
 

Private Attributes

bool $allowBlankArticle = false
 
bool $allowBlankSummary = false
 
bool $allowSelfRedirect = false
 
string $autoSumm = ''
 
null array $changeTags = null
 
IContentHandlerFactory $contentHandlerFactory
 
bool int $contentLength = false
 
bool $deletedSinceEdit
 
bool $diff = false
 
bool $edit
 
TextConflictHelper null $editConflictHelper
 
callable $editConflictHelperFactory
 Factory function to create an edit conflict helper. More...
 
string $editintro = ''
 
int null $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 $hasPresetSummary = false
 Has a summary been preset using GET parameter &summary= ? More...
 
string $hookError = ''
 
bool $incompleteForm = false
 
bool $isNew = false
 New page or new section. More...
 
bool $isOldRev = false
 Whether an old revision is edited. More...
 
stdClass null $lastDelete
 
LinkBatchFactory $linkBatchFactory
 
LinkRenderer $linkRenderer
 
bool $markAsBot = true
 
Article $mArticle
 
null Title $mContextTitle = null
 
RevisionRecord bool null $mExpectedParentRevision = false
 A RevisionRecord corresponding to $this->editRevId or $this->edittime. More...
 
bool $minoredit = false
 
bool $missingComment = false
 
bool $missingSummary = false
 
ParserOutput $mParserOutput
 
Title $mTitle
 
bool $mTokenOk = false
 
bool $mTriedSave = false
 
bool $nosummary = false
 If true, hide the summary field. More...
 
WikiPage $page
 
int $parentRevId = 0
 Revision ID the edit is based on, adjusted when an edit conflict is resolved. More...
 
PermissionManager $permManager
 
User null $placeholderTempUser
 
bool $recreate = false
 
RedirectLookup $redirectLookup
 
RestrictionStore $restrictionStore
 
RevisionStore $revisionStore
 
User null $savedTempUser
 
int null $scrolltop = null
 
bool $selfRedirect = false
 
bool $tempUserCreateActive = false
 Whether temp user creation will be attempted. More...
 
bool $tempUserCreateDone = false
 Whether temp user creation was successful. More...
 
TempUserCreator $tempUserCreator
 
string null $tempUserName
 If a temp user name was acquired, this is the name. More...
 
bool $tooBig = false
 
 $undoAfter = 0
 
string null $unicodeCheck
 What the user submitted in the 'wpUnicodeCheck' field. More...
 
User null $unsavedTempUser
 
UserFactory $userFactory
 
UserNameUtils $userNameUtils
 
UserOptionsLookup $userOptionsLookup
 
WatchedItemStoreInterface $watchedItemStore
 
string null $watchlistExpiry
 The expiry time of the watch item, or null if it is not watched temporarily. More...
 
bool $watchlistExpiryEnabled
 Corresponds to $wgWatchlistExpiry. More...
 
WatchlistManager $watchlistManager
 
bool $watchthis = false
 
WikiPageFactory $wikiPageFactory
 

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.

Stability: newable
Note
marked as newable in 1.35 for lack of a better alternative, but should be split up into service objects and command objects in the future (T157658).

Definition at line 102 of file EditPage.php.

Constructor & Destructor Documentation

◆ __construct()

EditPage::__construct ( Article  $article)
Stability: stable
to call
Parameters
Article$article

Definition at line 482 of file EditPage.php.

References deprecatePublicProperty(), getContext(), Article\getContext(), Article\getPage(), and Article\getTitle().

Member Function Documentation

◆ addContentModelChangeLogEntry()

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

Definition at line 2750 of file EditPage.php.

◆ addEditNotices()

EditPage::addEditNotices ( )
private

Definition at line 4877 of file EditPage.php.

◆ addExplainConflictHeader()

EditPage::addExplainConflictHeader ( )
private

Definition at line 4981 of file EditPage.php.

◆ addLongPageWarningHeader()

EditPage::addLongPageWarningHeader ( )
private

Definition at line 4900 of file EditPage.php.

◆ addNewLineAtEnd()

EditPage::addNewLineAtEnd (   $wikitext)
protected
Parameters
string$wikitext
Returns
string
Since
1.29
Deprecated:
since 1.38 Use TextboxBuilder::addNewLineAtEnd instead.

Definition at line 4993 of file EditPage.php.

References wfDeprecated().

◆ addPageProtectionWarningHeaders()

EditPage::addPageProtectionWarningHeaders ( )
private

Definition at line 4929 of file EditPage.php.

References LogEventsList\showLogExtract().

◆ addTalkPageText()

EditPage::addTalkPageText ( )
private

Definition at line 4894 of file EditPage.php.

◆ attemptSave()

EditPage::attemptSave ( $resultDetails = false)

Attempt submission.

Parameters
array | bool&$resultDetailsSee docs for $result in internalAttemptSave
Exceptions
UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
Returns
Status

Definition at line 1886 of file EditPage.php.

References getAuthority().

◆ createTempUser()

EditPage::createTempUser ( PageUpdater  $pageUpdater)
private

If automatic user creation is enabled, create the user and adjust the PageUpdater so that it has the new user/actor ID.

This is a helper for internalAttemptSave(). The name should have already been acquired at this point for PST purposes, but if not, it will be acquired here.

If the edit is a null edit, the user will not be created.

Parameters
PageUpdater$pageUpdater
Returns
Status

Definition at line 826 of file EditPage.php.

References MediaWiki\Storage\PageUpdater\isChange(), StatusValue\newGood(), MediaWiki\Storage\PageUpdater\preventChange(), and MediaWiki\Storage\PageUpdater\updateAuthor().

◆ displayPermissionsError()

EditPage::displayPermissionsError ( array  $permErrors)
private

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.
Parameters
array$permErrorsArray of permissions errors
Exceptions
PermissionsError

Definition at line 948 of file EditPage.php.

◆ displayPreviewArea()

EditPage::displayPreviewArea ( string  $previewOutput,
bool  $isOnTop 
)
private

Definition at line 3875 of file EditPage.php.

◆ displayViewSourcePage()

EditPage::displayViewSourcePage ( Content  $content,
string  $errorMessage 
)
private

Display a read-only View Source page.

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

Definition at line 981 of file EditPage.php.

◆ doPostEditRedirect()

EditPage::doPostEditRedirect (   $query,
  $anchor 
)
private

Emit the post-save redirect.

The URL is modifiable with a hook.

Parameters
string$query
string$anchor
Returns
void

Definition at line 2059 of file EditPage.php.

◆ 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 4508 of file EditPage.php.

References $content.

◆ 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 610 of file EditPage.php.

References DeferredUpdates\addCallableUpdate(), WikiPage\hasDifferencesOutsideMainSlot(), and wfDebug().

◆ extractSectionTitle()

static EditPage::extractSectionTitle (   $text)
staticprivate

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

Parameters
string$text
Returns
string|false

Definition at line 3477 of file EditPage.php.

References $matches.

◆ 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 4243 of file EditPage.php.

References $title.

◆ getArticle()

EditPage::getArticle ( )
Returns
Article

Definition at line 537 of file EditPage.php.

References $mArticle.

◆ getAuthority()

EditPage::getAuthority ( )
private

Get the authority for permissions purposes.

On an initial edit page GET request, if automatic temporary user creation is enabled, this may be a placeholder user with a fixed name. Such users are unsuitable for anything that uses or exposes the name, like throttling. The only thing a placeholder user is good for is fooling the permissions system into allowing edits by anons.

Returns
Authority

Definition at line 859 of file EditPage.php.

◆ getCancelLink()

EditPage::getCancelLink ( int  $tabindex)
private
Parameters
int$tabindexCurrent tabindex
Returns
ButtonWidget

Definition at line 4215 of file EditPage.php.

◆ 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
  • 'class' (optional): PHP class name of the OOUI widget to use. Defaults to CheckboxInputWidget.
  • 'options' (optional): options to use for DropdownInputWidget, ComboBoxInputWidget, etc. following the structure as given in the documentation for those classes.
  • 'value-attr' (optional): name of the widget config option for the "current value" of the widget. Defaults to 'selected'; for some widget types it should be 'value'.
    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 4598 of file EditPage.php.

◆ getCheckboxesDefinitionForWatchlist()

EditPage::getCheckboxesDefinitionForWatchlist (   $watch)
private

Get the watchthis and watchlistExpiry form field definitions.

Parameters
bool$watch
Returns
array[]

Definition at line 4633 of file EditPage.php.

References getContext(), WatchAction\getExpiryOptions(), getTitle(), and getUser().

◆ 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
\OOUI\Element[] Associative array of string keys to \OOUI\Widget or \OOUI\Layout instances

Definition at line 4687 of file EditPage.php.

References $title, and Linker\titleAttrib().

◆ getContentObject()

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

Definition at line 1440 of file EditPage.php.

References $content, CONTENT_MODEL_WIKITEXT, getAuthority(), Content\getSection(), ExternalUserNames\getUserLinkTitle(), WikiPage\hasDifferencesOutsideMainSlot(), ExternalUserNames\isExternal(), ParserOptions\newFromUserAndLang(), NS_MEDIAWIKI, and Html\rawElement().

◆ getContext()

EditPage::getContext ( )
Since
1.28
Returns
IContextSource

Definition at line 545 of file EditPage.php.

References $context.

Referenced by __construct().

◆ getContextTitle()

EditPage::getContextTitle ( )
Exceptions
RuntimeExceptionif no context title was set
Returns
Title

Definition at line 568 of file EditPage.php.

References $mContextTitle.

◆ getCopyrightWarning()

static EditPage::getCopyrightWarning (   $page,
  $format = 'plain',
  $localizer = null 
)
static

Get the copyright warning, by default returns wikitext.

Parameters
PageReference$page
string$formatOutput format, valid values are any function of a Message object
MessageLocalizer | Language | string | null$localizerA MessageLocalizer. For backwards-compatibility, a Language object, or a string language code, or omitting the parameter is also allowed, but emits deprecation warnings since 1.38.
Returns
string

Definition at line 4066 of file EditPage.php.

References $title, Title\castFromPageReference(), RequestContext\getMain(), Html\rawElement(), Hooks\runner(), and wfDeprecated().

◆ getCopywarn()

EditPage::getCopywarn ( )
protected

Get the copyright warning.

Deprecated:
since 1.38 Use getCopyrightWarning() instead.
Returns
string

Definition at line 4051 of file EditPage.php.

References getContext(), and wfDeprecated().

◆ getCurrentContent()

EditPage::getCurrentContent ( )
protected

Get the current content of the page.

This is basically similar to WikiPage::getContent( RevisionRecord::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 1725 of file EditPage.php.

References $content.

◆ getEditButtons()

EditPage::getEditButtons ( $tabindex)

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

Parameters
int&$tabindexCurrent tabindex
Returns
string[] Strings or objects with a __toString() implementation. Usually an array of {
See also
ButtonInputWidget}, but EditPageBeforeEditButtons hook handlers might inject something else.

Definition at line 4762 of file EditPage.php.

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

◆ getEditConflictHelper()

EditPage::getEditConflictHelper ( )
private
Returns
TextConflictHelper

Definition at line 5037 of file EditPage.php.

◆ getEditPermissionErrors()

EditPage::getEditPermissionErrors ( string  $rigor = PermissionManager::RIGOR_SECURE)
private
Parameters
string$rigorPermissionManager::RIGOR_ constant
Returns
array

Definition at line 921 of file EditPage.php.

◆ getEditToolbar()

static EditPage::getEditToolbar ( )
static

Allow extensions to provide a toolbar.

Returns
string|null

Definition at line 4562 of file EditPage.php.

References Hooks\runner().

◆ getExpectedParentRevision()

EditPage::getExpectedParentRevision ( )

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

Since
1.35
Returns
RevisionRecord|null Current revision when editing was initiated on the client

Definition at line 2840 of file EditPage.php.

References getTitle().

◆ getLastDelete()

EditPage::getLastDelete ( )
private

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

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

Returns
stdClass|null

Definition at line 4279 of file EditPage.php.

References LogPage\DELETED_COMMENT, and LogPage\DELETED_USER.

◆ getOriginalContent()

EditPage::getOriginalContent ( Authority  $performer)
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.

Parameters
Authority$performerto get the revision for
Returns
Content|null

Definition at line 1685 of file EditPage.php.

◆ getParentRevId()

EditPage::getParentRevId ( )
private

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.

Returns
int Revision ID

Definition at line 1709 of file EditPage.php.

◆ getPreloadedContent()

EditPage::getPreloadedContent ( string  $preload,
array  $params 
)
private

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

Definition at line 1750 of file EditPage.php.

◆ 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 4101 of file EditPage.php.

References Html\closeElement(), Html\openElement(), Html\rawElement(), Hooks\runner(), and wfMessage().

Referenced by ApiParse\execute().

◆ getPreviewParserOptions()

EditPage::getPreviewParserOptions ( )
protected

Get parser options for a preview.

Returns
ParserOptions

Definition at line 4486 of file EditPage.php.

◆ getPreviewText()

EditPage::getPreviewText ( )

Get the rendered text for previewing.

Exceptions
MWException
Returns
string

Definition at line 4326 of file EditPage.php.

References $content, CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, CONTENT_MODEL_JSON, getTitle(), Html\rawElement(), and Html\warningBox().

◆ getSubmitButtonLabel()

EditPage::getSubmitButtonLabel ( )
private

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

Returns
string

Definition at line 4736 of file EditPage.php.

◆ getSummaryInputAttributes()

EditPage::getSummaryInputAttributes ( array  $inputAttrs)
private

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

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

Definition at line 3688 of file EditPage.php.

◆ getSummaryInputWidget()

EditPage::getSummaryInputWidget (   $summary,
string  $labelText,
array  $inputAttrs 
)
private

Builds a standard summary input with a label.

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

Definition at line 3711 of file EditPage.php.

◆ getSummaryPreview()

EditPage::getSummaryPreview ( bool  $isSubjectPreview)
private
Parameters
bool$isSubjectPreviewTrue if this is the section subject/title up top, or false if this is the comment summary down below the textarea
Returns
string

Definition at line 3770 of file EditPage.php.

◆ getTemplates()

EditPage::getTemplates ( )
Returns
Title[]

Definition at line 4540 of file EditPage.php.

References Title\makeTitle().

◆ getTitle()

EditPage::getTitle ( )
Since
1.19
Returns
Title

Definition at line 553 of file EditPage.php.

References $mTitle.

◆ getUndoContent()

EditPage::getUndoContent ( RevisionRecord  $undoRev,
RevisionRecord  $oldRev 
)
private

Returns the result of a three-way merge when undoing changes.

Parameters
RevisionRecord$undoRevNewest revision being undone. Corresponds to undo URL parameter.
RevisionRecord$oldRevRevision that is being restored. Corresponds to undoafter URL parameter.
Returns
Content|false

Definition at line 1648 of file EditPage.php.

References MediaWiki\Revision\RevisionRecord\getContent(), MediaWiki\Revision\RevisionRecord\getId(), and MediaWiki\Revision\RevisionRecord\getSlot().

◆ getUserForPermissions()

EditPage::getUserForPermissions ( )
private

Get the user for permissions purposes, with declared type User instead of Authority for compatibility with PermissionManager.

Returns
User

Definition at line 869 of file EditPage.php.

◆ getUserForPreview()

EditPage::getUserForPreview ( )
private

Get the user for preview or PST purposes.

During the temporary user creation flow this may be an unsaved temporary user.

Returns
User

Definition at line 887 of file EditPage.php.

◆ getUserForSave()

EditPage::getUserForSave ( )
private

Get the user suitable for permanent attribution in the database.

This asserts that an anonymous user won't be used in IP masking mode.

Returns
User

Definition at line 906 of file EditPage.php.

◆ 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 5008 of file EditPage.php.

◆ handleFailedConstraint()

EditPage::handleFailedConstraint ( IEditConstraint  $failed)
private

Apply the specific updates needed for the EditPage fields based on which constraint failed, rather than interspersing this logic throughout internalAttemptSave at each of the points the constraints are checked.

Eventually, this will act on the result from the backend.

Parameters
IEditConstraint$failed

Definition at line 2669 of file EditPage.php.

◆ 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 1922 of file EditPage.php.

◆ 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 1362 of file EditPage.php.

◆ 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 1115 of file EditPage.php.

References ContentHandler\getLocalizedName(), NS_USER, NS_USER_TALK, wfDebug(), wfEscapeWikiText(), and wfTimestampNow().

◆ incrementConflictStats()

EditPage::incrementConflictStats ( )
private

Definition at line 4207 of file EditPage.php.

◆ incrementEditFailureStats()

EditPage::incrementEditFailureStats ( string  $failureType)
private

Definition at line 4477 of file EditPage.php.

◆ incrementResolvedConflicts()

EditPage::incrementResolvedConflicts ( )
private

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

Definition at line 1905 of file EditPage.php.

◆ initialiseForm()

EditPage::initialiseForm ( )
private

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 1371 of file EditPage.php.

◆ internalAttemptSave()

EditPage::internalAttemptSave ( $result,
  $markAsBot = false,
  $markAsMinor = 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 doUserEditContent is OK. True if null edit, false otherwise.
  • redirect (bool): Set if doUserEditContent is OK. True if resulting revision is a redirect.
bool$markAsBotTrue if edit is being made under the bot right and the bot wishes the edit to be marked as such.
bool$markAsMinorTrue if edit should be marked as minor.
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 2140 of file EditPage.php.

References $content, $matches, DB_PRIMARY, EDIT_AUTOSUMMARY, EDIT_FORCE_BOT, EDIT_MINOR, EDIT_NEW, EDIT_UPDATE, getAuthority(), getTitle(), StatusValue\hasMessage(), StatusValue\isOK(), StatusValue\newFatal(), StatusValue\newGood(), CommentStoreComment\newUnsavedComment(), RecentChange\PRC_AUTOPATROLLED, wfDebug(), wfGetDB(), and Status\wrap().

◆ isPageExistingAndViewable()

EditPage::isPageExistingAndViewable ( ?PageIdentity  $page,
Authority  $performer 
)
private

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

See also
EditPage::getPreloadedContent()
Parameters
PageIdentity | null$page
Authority$performer
Returns
bool
Exceptions
Exception

Definition at line 1831 of file EditPage.php.

◆ isSectionEditSupported()

EditPage::isSectionEditSupported ( )
private

Section editing is supported when the page content model allows section edit and we are editing current revision.

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

Definition at line 1096 of file EditPage.php.

◆ isSupportedContentModel()

EditPage::isSupportedContentModel ( string  $modelId)
private

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 583 of file EditPage.php.

◆ isUndoClean()

EditPage::isUndoClean ( Content  $content)
private

Does checks and compares the automatically generated undo content with the one that was submitted by the user.

If they match, the undo is considered "clean". Otherwise there is no guarantee if anything was reverted at all, as the user could even swap out entire content.

Parameters
Content$content
Returns
bool

Definition at line 2704 of file EditPage.php.

◆ isWrongCaseUserConfigPage()

EditPage::isWrongCaseUserConfigPage ( )
private

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 1075 of file EditPage.php.

◆ makeTemplatesOnThisPageList()

EditPage::makeTemplatesOnThisPageList ( array  $templates)

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

Parameters
PageIdentity[]$templates
Returns
string HTML

Definition at line 3450 of file EditPage.php.

References $type, and Html\rawElement().

◆ maybeActivateTempUserCreate()

EditPage::maybeActivateTempUserCreate (   $doAcquire)

Check the configuration and current user and enable automatic temporary user creation if possible.

Parameters
bool$doAcquireWhether to acquire a name for the temporary account
Since
1.39

Definition at line 791 of file EditPage.php.

◆ mergeChangesIntoContent()

EditPage::mergeChangesIntoContent ( Content  $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.

Parameters
Content$editContent
Returns
array|false either false or an array of the new Content and the updated parent revision id

Definition at line 2795 of file EditPage.php.

◆ newSectionSummary()

EditPage::newSectionSummary ( )
private

Return the summary to be used for a new section.

Returns
string[] array with two values, the summary and the anchor text

Definition at line 2080 of file EditPage.php.

◆ newTextConflictHelper()

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

Definition at line 5053 of file EditPage.php.

◆ noSuchSectionPage()

EditPage::noSuchSectionPage ( )
private

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

Definition at line 4829 of file EditPage.php.

◆ previewOnOpen()

EditPage::previewOnOpen ( )
protected

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

Returns
bool

Definition at line 1034 of file EditPage.php.

◆ setApiEditOverride()

EditPage::setApiEditOverride (   $enableOverride)

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

Set to false by default.

Access: internal
Must only be used by ApiEditPage
Parameters
bool$enableOverride

Definition at line 595 of file EditPage.php.

◆ setContextTitle()

EditPage::setContextTitle (   $title)
Parameters
Title | null$title

Definition at line 560 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 5029 of file EditPage.php.

◆ setHeaders()

EditPage::setHeaders ( )

Definition at line 2860 of file EditPage.php.

References NS_MEDIAWIKI, and Html\rawElement().

◆ setPostEditCookie()

EditPage::setPostEditCookie ( int  $statusValue)
private

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 1862 of file EditPage.php.

◆ showConflict()

EditPage::showConflict ( )
private

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 4198 of file EditPage.php.

◆ 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 3829 of file EditPage.php.

◆ showCustomIntro()

EditPage::showCustomIntro ( )
private

Attempt to show a custom editing introduction, if supplied.

Returns
bool

Definition at line 3080 of file EditPage.php.

References $title, and Title\newFromText().

◆ 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 3941 of file EditPage.php.

References ParserOptions\newFromUserAndLang(), NS_MEDIAWIKI, and Html\rawElement().

◆ showEditForm()

EditPage::showEditForm (   $formCallback = null)

Send the edit form and related headers to OutputPage.

Parameters
callable | null$formCallbackThat takes an OutputPage parameter; will be called during form output near the top, for captchas and the like.

The $formCallback parameter is deprecated since MediaWiki 1.25 and hard-deprecated since 1.38. Please use the EditPage::showEditForm:fields hook instead.

Definition at line 3165 of file EditPage.php.

References Xml\checkLabel(), Xml\closeElement(), Xml\element(), Html\errorBox(), Linker\formatHiddenCategories(), CommentStore\getStore(), Html\hidden(), Html\openElement(), Xml\openElement(), Html\rawElement(), Linker\titleAttrib(), and wfDeprecated().

◆ showEditTools()

EditPage::showEditTools ( )
private

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 4037 of file EditPage.php.

◆ showFormAfterText()

EditPage::showFormAfterText ( )
protected

Definition at line 3801 of file EditPage.php.

References Html\hidden().

◆ showFormBeforeText()

EditPage::showFormBeforeText ( )
private

Definition at line 3792 of file EditPage.php.

◆ showHeader()

EditPage::showHeader ( )
private

Definition at line 3486 of file EditPage.php.

◆ showHeaderCopyrightWarning()

EditPage::showHeaderCopyrightWarning ( )
private

Definition at line 4002 of file EditPage.php.

◆ showIntro()

EditPage::showIntro ( )
private

Show all applicable editing introductions.

Definition at line 2931 of file EditPage.php.

◆ showPreview()

EditPage::showPreview ( string  $text)
private

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 3920 of file EditPage.php.

◆ showStandardInputs()

EditPage::showStandardInputs ( $tabindex = 2)
protected

Definition at line 4148 of file EditPage.php.

References Html\linkButton(), and Skin\makeInternalOrExternalUrl().

◆ showSummaryInput()

EditPage::showSummaryInput ( bool  $isSubjectPreview)
private
Parameters
bool$isSubjectPreviewTrue if this is the section subject/title up top, or false if this is the comment summary down below the textarea

Definition at line 3743 of file EditPage.php.

◆ showTextbox()

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

Definition at line 3860 of file EditPage.php.

References Html\textarea().

◆ showTextbox1()

EditPage::showTextbox1 ( )
private

Definition at line 3833 of file EditPage.php.

◆ showTosSummary()

EditPage::showTosSummary ( )
private

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 4020 of file EditPage.php.

References Html\rawElement().

◆ 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 4846 of file EditPage.php.

References Html\rawElement(), and wfEscapeWikiText().

◆ 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 3142 of file EditPage.php.

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

◆ toEditText()

EditPage::toEditText (   $content)
private

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|false|null 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 3114 of file EditPage.php.

References $content.

◆ tokenOk()

EditPage::tokenOk ( WebRequest  $request)
private

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

Parameters
WebRequest$request
Returns
bool

Definition at line 1841 of file EditPage.php.

◆ updateWatchlist()

EditPage::updateWatchlist ( )
private

Register the change of watch status.

Definition at line 2767 of file EditPage.php.

◆ wasDeletedSinceLastEdit()

EditPage::wasDeletedSinceLastEdit ( )
private

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 4254 of file EditPage.php.

Member Data Documentation

◆ $action

string EditPage::$action = 'submit'
Deprecated:
for public usage since 1.38 with no replacement

Definition at line 159 of file EditPage.php.

◆ $allowBlankArticle

bool EditPage::$allowBlankArticle = false
private

Definition at line 210 of file EditPage.php.

◆ $allowBlankSummary

bool EditPage::$allowBlankSummary = false
private

Definition at line 204 of file EditPage.php.

◆ $allowSelfRedirect

bool EditPage::$allowSelfRedirect = false
private

Definition at line 216 of file EditPage.php.

◆ $autoSumm

string EditPage::$autoSumm = ''
private

Definition at line 219 of file EditPage.php.

◆ $blankArticle

bool EditPage::$blankArticle = false
protected

Definition at line 207 of file EditPage.php.

◆ $changeTags

null array EditPage::$changeTags = null
private

Definition at line 349 of file EditPage.php.

◆ $contentFormat

null string EditPage::$contentFormat = null

Definition at line 346 of file EditPage.php.

◆ $contentHandlerFactory

IContentHandlerFactory EditPage::$contentHandlerFactory
private

Definition at line 412 of file EditPage.php.

◆ $contentLength

bool int EditPage::$contentLength = false
private

Definition at line 375 of file EditPage.php.

◆ $contentModel

string EditPage::$contentModel

Definition at line 343 of file EditPage.php.

◆ $context

IContextSource EditPage::$context
protected

Definition at line 385 of file EditPage.php.

Referenced by getContext().

◆ $deletedSinceEdit

bool EditPage::$deletedSinceEdit
private

Definition at line 171 of file EditPage.php.

◆ $didSave

EditPage::$didSave = false

Definition at line 365 of file EditPage.php.

◆ $diff

bool EditPage::$diff = false
private

Definition at line 251 of file EditPage.php.

◆ $edit

bool EditPage::$edit
private

Definition at line 372 of file EditPage.php.

◆ $editConflictHelper

TextConflictHelper null EditPage::$editConflictHelper
private

Definition at line 407 of file EditPage.php.

◆ $editConflictHelperFactory

callable EditPage::$editConflictHelperFactory
private

Factory function to create an edit conflict helper.

Definition at line 402 of file EditPage.php.

◆ $editFormPageTop

string EditPage::$editFormPageTop = ''

Before even the preview.

Definition at line 355 of file EditPage.php.

◆ $editFormTextAfterContent

EditPage::$editFormTextAfterContent = ''

Definition at line 361 of file EditPage.php.

◆ $editFormTextAfterTools

EditPage::$editFormTextAfterTools = ''

Definition at line 359 of file EditPage.php.

◆ $editFormTextAfterWarn

EditPage::$editFormTextAfterWarn = ''

Definition at line 358 of file EditPage.php.

◆ $editFormTextBeforeContent

EditPage::$editFormTextBeforeContent = ''

Definition at line 357 of file EditPage.php.

◆ $editFormTextBottom

EditPage::$editFormTextBottom = ''

Definition at line 360 of file EditPage.php.

◆ $editFormTextTop

EditPage::$editFormTextTop = ''

Definition at line 356 of file EditPage.php.

◆ $editintro

string EditPage::$editintro = ''
private

Definition at line 334 of file EditPage.php.

◆ $editRevId

int null 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
getExpectedParentRevision()

Definition at line 305 of file EditPage.php.

◆ $edittime

string null EditPage::$edittime = ''

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

Definition at line 292 of file EditPage.php.

◆ $enableApiEditOverride

bool EditPage::$enableApiEditOverride = false
private

Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing.

Definition at line 380 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 180 of file EditPage.php.

◆ $formtype

string EditPage::$formtype

Definition at line 174 of file EditPage.php.

◆ $hasPresetSummary

bool EditPage::$hasPresetSummary = false
private

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

Definition at line 230 of file EditPage.php.

◆ $hookError

string EditPage::$hookError = ''
private

Definition at line 222 of file EditPage.php.

◆ $incompleteForm

bool EditPage::$incompleteForm = false
private

Definition at line 192 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 165 of file EditPage.php.

◆ $isNew

bool EditPage::$isNew = false
private

New page or new section.

Definition at line 168 of file EditPage.php.

◆ $isOldRev

bool EditPage::$isOldRev = false
private

Whether an old revision is edited.

Definition at line 390 of file EditPage.php.

◆ $lastDelete

stdClass null EditPage::$lastDelete
private

Definition at line 183 of file EditPage.php.

◆ $linkBatchFactory

LinkBatchFactory EditPage::$linkBatchFactory
private

Definition at line 473 of file EditPage.php.

◆ $linkRenderer

LinkRenderer EditPage::$linkRenderer
private

Definition at line 470 of file EditPage.php.

◆ $markAsBot

bool EditPage::$markAsBot = true
private

Definition at line 340 of file EditPage.php.

◆ $mArticle

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

Definition at line 141 of file EditPage.php.

Referenced by getArticle().

◆ $mContextTitle

null Title EditPage::$mContextTitle = null
private

Definition at line 153 of file EditPage.php.

Referenced by getContextTitle().

◆ $mExpectedParentRevision

RevisionRecord bool null EditPage::$mExpectedParentRevision = false
private

A RevisionRecord corresponding to $this->editRevId or $this->edittime.

Definition at line 237 of file EditPage.php.

◆ $minoredit

bool EditPage::$minoredit = false
private

Definition at line 254 of file EditPage.php.

◆ $missingComment

bool EditPage::$missingComment = false
private

Definition at line 198 of file EditPage.php.

◆ $missingSummary

bool EditPage::$missingSummary = false
private

Definition at line 201 of file EditPage.php.

◆ $mParserOutput

ParserOutput EditPage::$mParserOutput
private

Definition at line 225 of file EditPage.php.

◆ $mShowSummaryField

bool EditPage::$mShowSummaryField = true

Definition at line 240 of file EditPage.php.

◆ $mTitle

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

Definition at line 150 of file EditPage.php.

Referenced by getTitle().

◆ $mTokenOk

bool EditPage::$mTokenOk = false
private

Definition at line 186 of file EditPage.php.

◆ $mTriedSave

bool EditPage::$mTriedSave = false
private

Definition at line 189 of file EditPage.php.

◆ $nosummary

bool EditPage::$nosummary = false
private

If true, hide the summary field.

Definition at line 286 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 323 of file EditPage.php.

◆ $page

WikiPage EditPage::$page
private

Definition at line 144 of file EditPage.php.

◆ $parentRevId

int EditPage::$parentRevId = 0
private

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

See also
$editRevId
$oldid
getparentRevId()

Definition at line 331 of file EditPage.php.

◆ $permManager

PermissionManager EditPage::$permManager
private

Definition at line 417 of file EditPage.php.

◆ $placeholderTempUser

User null EditPage::$placeholderTempUser
private

Definition at line 452 of file EditPage.php.

◆ $preview

bool EditPage::$preview = false

Definition at line 248 of file EditPage.php.

◆ $previewTextAfterContent

EditPage::$previewTextAfterContent = ''

Definition at line 362 of file EditPage.php.

◆ $recreate

bool EditPage::$recreate = false
private

Definition at line 269 of file EditPage.php.

◆ $redirectLookup

RedirectLookup EditPage::$redirectLookup
private

Definition at line 440 of file EditPage.php.

◆ $restrictionStore

RestrictionStore EditPage::$restrictionStore
private

Definition at line 476 of file EditPage.php.

◆ $revisionStore

RevisionStore EditPage::$revisionStore
private

Definition at line 422 of file EditPage.php.

◆ $save

bool EditPage::$save = false

Definition at line 245 of file EditPage.php.

◆ $savedTempUser

User null EditPage::$savedTempUser
private

Definition at line 458 of file EditPage.php.

◆ $scrolltop

int null EditPage::$scrolltop = null
private

Definition at line 337 of file EditPage.php.

◆ $section

string EditPage::$section = ''

Definition at line 308 of file EditPage.php.

◆ $sectiontitle

string null EditPage::$sectiontitle = null

Definition at line 311 of file EditPage.php.

◆ $selfRedirect

bool EditPage::$selfRedirect = false
private

Definition at line 213 of file EditPage.php.

◆ $starttime

string null EditPage::$starttime = ''

Timestamp from the first time the edit form was rendered.

Definition at line 316 of file EditPage.php.

◆ $summary

string EditPage::$summary = ''

Definition at line 280 of file EditPage.php.

◆ $suppressIntro

EditPage::$suppressIntro = false

Definition at line 369 of file EditPage.php.

◆ $tempUserCreateActive

bool EditPage::$tempUserCreateActive = false
private

Whether temp user creation will be attempted.

Definition at line 461 of file EditPage.php.

◆ $tempUserCreateDone

bool EditPage::$tempUserCreateDone = false
private

Whether temp user creation was successful.

Definition at line 467 of file EditPage.php.

◆ $tempUserCreator

TempUserCreator EditPage::$tempUserCreator
private

Definition at line 446 of file EditPage.php.

◆ $tempUserName

string null EditPage::$tempUserName
private

If a temp user name was acquired, this is the name.

Definition at line 464 of file EditPage.php.

◆ $textbox1

string EditPage::$textbox1 = ''

Page content input field.

Definition at line 274 of file EditPage.php.

◆ $textbox2

string EditPage::$textbox2 = ''

Definition at line 277 of file EditPage.php.

◆ $tooBig

bool EditPage::$tooBig = false
private

Definition at line 195 of file EditPage.php.

◆ $undidRev

EditPage::$undidRev = 0

Definition at line 366 of file EditPage.php.

◆ $undoAfter

EditPage::$undoAfter = 0
private

Definition at line 367 of file EditPage.php.

◆ $unicodeCheck

string null EditPage::$unicodeCheck
private

What the user submitted in the 'wpUnicodeCheck' field.

Definition at line 395 of file EditPage.php.

◆ $unsavedTempUser

User null EditPage::$unsavedTempUser
private

Definition at line 455 of file EditPage.php.

◆ $userFactory

UserFactory EditPage::$userFactory
private

Definition at line 449 of file EditPage.php.

◆ $userNameUtils

UserNameUtils EditPage::$userNameUtils
private

Definition at line 437 of file EditPage.php.

◆ $userOptionsLookup

UserOptionsLookup EditPage::$userOptionsLookup
private

Definition at line 443 of file EditPage.php.

◆ $watchedItemStore

WatchedItemStoreInterface EditPage::$watchedItemStore
private

Definition at line 263 of file EditPage.php.

◆ $watchlistExpiry

string null EditPage::$watchlistExpiry
private

The expiry time of the watch item, or null if it is not watched temporarily.

Definition at line 266 of file EditPage.php.

◆ $watchlistExpiryEnabled

bool EditPage::$watchlistExpiryEnabled
private

Corresponds to $wgWatchlistExpiry.

Definition at line 260 of file EditPage.php.

◆ $watchlistManager

WatchlistManager EditPage::$watchlistManager
private

Definition at line 432 of file EditPage.php.

◆ $watchthis

bool EditPage::$watchthis = false
private

Definition at line 257 of file EditPage.php.

◆ $wikiPageFactory

WikiPageFactory EditPage::$wikiPageFactory
private

Definition at line 427 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 114 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 135 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 120 of file EditPage.php.

Referenced by Article\view().

◆ UNICODE_CHECK

const EditPage::UNICODE_CHECK = UnicodeConstraint::VALID_UNICODE

Used for Unicode support checks.

Definition at line 109 of file EditPage.php.

Referenced by ApiEditPage\execute().


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