MediaWiki REL1_37
|
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...
Public Member Functions | |
__construct (Article $article) | |
attemptSave (&$resultDetails=false) | |
Attempt submission. | |
edit () | |
This is the function that gets called for "action=edit". | |
getArticle () | |
getCancelLink ( $tabindex=0) | |
getCheckboxesDefinition ( $checked) | |
Return an array of checkbox definitions. | |
getCheckboxesWidget (&$tabindex, $checked) | |
Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and any other added by extensions. | |
getContext () | |
getContextTitle () | |
getEditButtons (&$tabindex) | |
Returns an array of html code of the following buttons: save, diff and preview. | |
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. | |
getParentRevId () | |
Get the edit's parent revision ID. | |
getPreviewText () | |
Get the rendered text for previewing. | |
getTemplates () | |
getTitle () | |
importFormData (&$request) | |
This function collects the form data and uses it to populate various member variables. | |
internalAttemptSave (&$result, $markAsBot=false) | |
Attempt submission (no UI) | |
isSupportedContentModel ( $modelId) | |
Returns if the given content model is editable. | |
makeTemplatesOnThisPageList (array $templates) | |
Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list. | |
setApiEditOverride ( $enableOverride) | |
Allow editing of content that supports API direct editing, but not general direct editing. | |
setContextTitle ( $title) | |
setEditConflictHelperFactory (callable $factory) | |
Set a factory function to create an EditConflictHelper. | |
setHeaders () | |
showDiff () | |
Get a diff between the current contents of the edit box and the version of the page we're editing from. | |
showEditForm ( $formCallback=null) | |
Send the edit form and related headers to OutputPage. | |
spamPageWithContent ( $match=false) | |
Show "your edit contains spam" page with your diff and text. | |
tokenOk (&$request) | |
Make sure the form isn't faking a user's credentials. | |
Static Public Member Functions | |
static | getCopyrightWarning ( $title, $format='plain', $langcode=null) |
Get the copyright warning, by default returns wikitext. | |
static | getEditToolbar () |
Allow extensions to provide a toolbar. | |
static | getPreviewLimitReport (ParserOutput $output=null) |
Get the Limit report for page previews. | |
Public Attributes | |
string | $action = 'submit' |
null string | $contentFormat = null |
string | $contentModel |
$didSave = false | |
bool | $diff = false |
string | $editFormPageTop = '' |
Before even the preview. | |
$editFormTextAfterContent = '' | |
$editFormTextAfterTools = '' | |
$editFormTextAfterWarn = '' | |
$editFormTextBeforeContent = '' | |
$editFormTextBottom = '' | |
$editFormTextTop = '' | |
string null | $edittime = '' |
Timestamp of the latest revision of the page when editing was initiated on the client. | |
bool | $firsttime |
True the first time the edit form is rendered, false after re-rendering with diff, save prompts, etc. | |
string | $formtype |
bool | $isConflict = false |
Whether an edit conflict needs to be resolved. | |
bool | $isNew = false |
New page or new section. | |
Article | $mArticle |
$mPreloadContent = null | |
bool | $mShowSummaryField = true |
Title | $mTitle |
int | $oldid = 0 |
Revision ID the edit is based on, or 0 if it's the current revision. | |
bool | $preview = false |
$previewTextAfterContent = '' | |
bool | $save = false |
string | $section = '' |
string | $sectiontitle = '' |
string | $starttime = '' |
Timestamp from the first time the edit form was rendered. | |
string | $summary = '' |
$suppressIntro = false | |
string | $textbox1 = '' |
Page content input field. | |
string | $textbox2 = '' |
$undidRev = 0 | |
$undoAfter = 0 | |
const | EDITFORM_ID = 'editform' |
HTML id and name for the beginning of the edit form. | |
const | POST_EDIT_COOKIE_DURATION = 1200 |
Duration of PostEdit cookie, in seconds. | |
const | POST_EDIT_COOKIE_KEY_PREFIX = 'PostEditRevision' |
Prefix of key for cookie used to pass post-edit state. | |
const | UNICODE_CHECK = UnicodeConstraint::VALID_UNICODE |
Used for Unicode support checks. | |
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. | |
const | AS_BLANK_ARTICLE = 224 |
Status: user tried to create a blank page and wpIgnoreBlankArticle == false. | |
const | AS_BLOCKED_PAGE_FOR_USER = 215 |
Status: User is blocked from editing this page. | |
const | AS_CANNOT_USE_CUSTOM_MODEL = 241 |
Status: when changing the content model is disallowed due to $wgContentHandlerUseDB being false. | |
const | AS_CHANGE_TAG_ERROR = 237 |
Status: an error relating to change tagging. | |
const | AS_CONFLICT_DETECTED = 225 |
Status: (non-resolvable) edit conflict. | |
const | AS_CONTENT_TOO_BIG = 216 |
Status: Content too big (> $wgMaxArticleSize) | |
const | AS_END = 231 |
Status: WikiPage::doEdit() was unsuccessful. | |
const | AS_HOOK_ERROR = 210 |
Status: Article update aborted by a hook function. | |
const | AS_HOOK_ERROR_EXPECTED = 212 |
Status: A hook function returned an error. | |
const | AS_IMAGE_REDIRECT_ANON = 233 |
Status: anonymous user is not allowed to upload (User::isAllowed('upload') == false) | |
const | AS_IMAGE_REDIRECT_LOGGED = 234 |
Status: logged in user is not allowed to upload (User::isAllowed('upload') == false) | |
const | AS_MAX_ARTICLE_SIZE_EXCEEDED = 229 |
Status: article is too big (> $wgMaxArticleSize), after merging in the new section. | |
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 ) | |
const | AS_NO_CREATE_PERMISSION = 223 |
Status: user tried to create this page, but is not allowed to do that. | |
const | AS_PARSE_ERROR = 240 |
Status: can't parse content. | |
const | AS_RATE_LIMITED = 221 |
Status: rate limiter for action 'edit' was tripped. | |
const | AS_READ_ONLY_PAGE = 220 |
Status: wiki is in readonly mode (wfReadOnly() == true) | |
const | AS_READ_ONLY_PAGE_ANON = 218 |
Status: this anonymous user is not allowed to edit this page. | |
const | AS_READ_ONLY_PAGE_LOGGED = 219 |
Status: this logged in user is not allowed to edit this page. | |
const | AS_SELF_REDIRECT = 236 |
Status: user tried to create self-redirect and wpIgnoreSelfRedirect is false. | |
const | AS_SPAM_ERROR = 232 |
Status: summary contained spam according to one of the regexes in $wgSummarySpamRegex. | |
const | AS_SUCCESS_NEW_ARTICLE = 201 |
Status: Article successfully created. | |
const | AS_SUCCESS_UPDATE = 200 |
Status: Article successfully updated. | |
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. | |
const | AS_TEXTBOX_EMPTY = 228 |
Status: user tried to create a new section without content. | |
const | AS_UNICODE_NOT_SUPPORTED = 242 |
Status: edit rejected because browser doesn't support Unicode. | |
Protected Member Functions | |
addContentModelChangeLogEntry (UserIdentity $user, $oldModel, $newModel, $reason) | |
addEditNotices () | |
addExplainConflictHeader (OutputPage $out) | |
addLongPageWarningHeader () | |
addNewLineAtEnd ( $wikitext) | |
addPageProtectionWarningHeaders () | |
addTalkPageText () | |
displayPermissionsError (array $permErrors) | |
Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences: | |
displayPreviewArea ( $previewOutput, $isOnTop=false) | |
displayViewSourcePage (Content $content, $errorMessage='') | |
Display a read-only View Source page. | |
doPreviewParse (Content $content) | |
Parse the page for a preview. | |
getActionURL (Title $title) | |
Returns the URL to use in the form's action attribute. | |
getContentObject ( $def_content=null) | |
getCopywarn () | |
Get the copyright warning. | |
getCurrentContent () | |
Get the current content of the page. | |
getEditPermissionErrors ( $rigor=PermissionManager::RIGOR_SECURE) | |
getLastDelete () | |
Get the last log record of this page being deleted, if ever. | |
getPreloadedContent ( $preload, $params=[]) | |
Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page. | |
getPreviewParserOptions () | |
Get parser options for a preview. | |
getSubmitButtonLabel () | |
Get the message key of the label for the button to save the page. | |
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... | |
incrementConflictStats () | |
isSectionEditSupported () | |
Section editing is supported when the page content model allows section edit and we are editing current revision. | |
isWrongCaseUserConfigPage () | |
Checks whether the user entered a skin name in uppercase, e.g. | |
previewOnOpen () | |
Should we show a preview when the edit form is first shown? | |
setPostEditCookie ( $statusValue) | |
Sets post-edit cookie indicating the user just saved a particular revision. | |
showConflict () | |
Show an edit conflict. | |
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. | |
showCustomIntro () | |
Attempt to show a custom editing introduction, if supplied. | |
showEditTools () | |
Inserts optional text shown below edit and upload forms. | |
showFormAfterText () | |
showFormBeforeText () | |
showHeader () | |
showHeaderCopyrightWarning () | |
showIntro () | |
Show all applicable editing introductions. | |
showPreview ( $text) | |
Append preview output to OutputPage. | |
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. | |
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. | |
toEditContent ( $text) | |
Turns the given text into a Content object by unserializing it. | |
toEditText ( $content) | |
Gets an editable textual representation of $content. | |
updateWatchlist () | |
Register the change of watch status. | |
wasDeletedSinceLastEdit () | |
Check if a page was deleted while the user was editing it, before submit. | |
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 | |
getCheckboxesDefinitionForWatchlist ( $watch) | |
Get the watchthis and watchlistExpiry form field definitions. | |
getEditConflictHelper () | |
getOriginalContent (Authority $performer) | |
Get the content of the wanted revision, without section extraction. | |
getSummaryInputAttributes (array $inputAttrs=null) | |
Helper function for summary input functions, which returns the necessary attributes for the input. | |
getSummaryInputWidget ( $summary="", $labelText=null, $inputAttrs=null) | |
Builds a standard summary input with a label. | |
getUndoContent (RevisionRecord $undoRev, RevisionRecord $oldRev) | |
Returns the result of a three-way merge when undoing changes. | |
guessSectionName ( $text) | |
Turns section name wikitext into anchors for use in HTTP redirects. | |
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. | |
handleStatus (Status $status, $resultDetails) | |
Handle status, such as after attempt save. | |
incrementEditFailureStats ( $failureType) | |
incrementResolvedConflicts () | |
Log when a page was successfully saved after the edit conflict view. | |
initialiseForm () | |
Initialise form fields in the object Called on the first invocation, e.g. | |
isPageExistingAndViewable (?PageIdentity $page, Authority $performer) | |
Verify if a given title exists and the given user is allowed to view it. | |
isUndoClean (Content $content) | |
Does sanity checks and compares the automatically generated undo content with the one that was submitted by the user. | |
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. | |
newSectionSummary () | |
Return the summary to be used for a new section. | |
newTextConflictHelper ( $submitButtonLabel) | |
noSuchSectionPage () | |
Creates a basic error page which informs the user that they have attempted to edit a nonexistent section. | |
Static Private Member Functions | |
static | extractSectionTitle ( $text) |
Extract the section title from current section text, if any. | |
Private Attributes | |
bool | $allowBlankSummary = false |
string | $autoSumm = '' |
null array | $changeTags = null |
IContentHandlerFactory | $contentHandlerFactory |
bool | $deletedSinceEdit |
TextConflictHelper null | $editConflictHelper |
callable | $editConflictHelperFactory |
Factory function to create an edit conflict helper. | |
string | $editintro = '' |
int | $editRevId = null |
Revision ID of the latest revision of the page when editing was initiated on the client. | |
bool | $enableApiEditOverride = false |
Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing. | |
bool | $hasPresetSummary = false |
Has a summary been preset using GET parameter &summary= ? | |
string | $hookError = '' |
bool | $incompleteForm = false |
bool | $isOldRev = false |
Whether an old revision is edited. | |
bool stdClass | $lastDelete |
bool | $markAsBot = true |
null Title | $mContextTitle = null |
RevisionRecord bool null | $mExpectedParentRevision = false |
A RevisionRecord corresponding to $this->editRevId or $this->edittime. | |
bool | $minoredit = false |
bool | $missingComment = false |
bool | $missingSummary = false |
ParserOutput | $mParserOutput |
bool | $mTokenOk = false |
bool | $mTriedSave = false |
bool | $nosummary = false |
If true, hide the summary field. | |
WikiPage | $page |
int | $parentRevId = 0 |
Revision ID the edit is based on, adjusted when an edit conflict is resolved. | |
PermissionManager | $permManager |
bool | $recreate = false |
RevisionStore | $revisionStore |
int null | $scrolltop = null |
bool | $tooBig = false |
string null | $unicodeCheck |
What the user submitted in the 'wpUnicodeCheck' field. | |
UserNameUtils | $userNameUtils |
WatchedItemStoreInterface | $watchedItemStore |
string null | $watchlistExpiry |
The expiry time of the watch item, or null if it is not watched temporarily. | |
bool | $watchlistExpiryEnabled |
Corresponds to $wgWatchlistExpiry. | |
WatchlistManager | $watchlistManager |
bool | $watchthis = false |
WikiPageFactory | $wikiPageFactory |
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.
@newable
Definition at line 88 of file EditPage.php.
EditPage::__construct | ( | Article | $article | ) |
Article | $article |
Definition at line 427 of file EditPage.php.
References deprecatePublicProperty(), Config\get(), getContext(), Article\getContext(), Article\getPage(), and Article\getTitle().
|
protected |
UserIdentity | $user | |
string | false | $oldModel | false if the page is being newly created |
string | $newModel | |
string | $reason |
Definition at line 2486 of file EditPage.php.
References ManualLogEntry\setPerformer().
|
protected |
Definition at line 4564 of file EditPage.php.
|
protected |
OutputPage | $out |
Definition at line 4669 of file EditPage.php.
References OutputPage\addHTML().
|
protected |
|
protected |
|
protected |
Definition at line 4624 of file EditPage.php.
|
protected |
Definition at line 4584 of file EditPage.php.
EditPage::attemptSave | ( | & | $resultDetails = false | ) |
Attempt submission.
array | bool | &$resultDetails | See docs for $result in internalAttemptSave |
UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError |
Definition at line 1678 of file EditPage.php.
References $markAsBot, and internalAttemptSave().
Referenced by edit().
|
protected |
Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences:
array | $permErrors | Array of permissions errors |
PermissionsError |
Definition at line 767 of file EditPage.php.
References $action, $content, displayViewSourcePage(), and getContentObject().
Referenced by edit().
|
protected |
Definition at line 3583 of file EditPage.php.
|
protected |
Display a read-only View Source page.
Content | $content | |
string | $errorMessage | additional wikitext error message to display |
Definition at line 800 of file EditPage.php.
References $content, $textbox1, getContextTitle(), getTemplates(), makeTemplatesOnThisPageList(), showTextbox(), and toEditText().
Referenced by displayPermissionsError(), and edit().
|
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.
Content | $content | The page content |
Definition at line 4201 of file EditPage.php.
References $content.
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 554 of file EditPage.php.
References attemptSave(), displayPermissionsError(), displayViewSourcePage(), getContentObject(), getEditPermissionErrors(), handleStatus(), importFormData(), initialiseForm(), previewOnOpen(), showEditForm(), showIntro(), wfDebug(), and wfReadOnly().
Referenced by importFormData().
|
staticprivate |
Extract the section title from current section text, if any.
string | $text |
Definition at line 3189 of file EditPage.php.
References $matches.
|
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.
Definition at line 3937 of file EditPage.php.
References $title.
EditPage::getArticle | ( | ) |
EditPage::getCancelLink | ( | $tabindex = 0 | ) |
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:
<input>
<label>
<label>
array | $checked | Array of checkbox name (matching the 'legacy-name') => bool, where bool indicates the checked status of the checkbox |
Definition at line 4285 of file EditPage.php.
|
private |
Get the watchthis and watchlistExpiry form field definitions.
bool | $watch |
Definition at line 4321 of file EditPage.php.
References getContext(), and getTitle().
EditPage::getCheckboxesWidget | ( | & | $tabindex, |
$checked | |||
) |
Returns an array of checkboxes for the edit form, including 'minor' and 'watch' checkboxes and any other added by extensions.
int | &$tabindex | Current tabindex |
array | $checked | Array of checkbox => bool, where bool indicates the checked status of the checkbox |
Definition at line 4375 of file EditPage.php.
References $title, and Linker\titleAttrib().
|
protected |
Content | null | $def_content | The default value to return |
Definition at line 1252 of file EditPage.php.
References $content, $summary, $wgDisableAnonTalk, getOriginalContent(), getPreloadedContent(), getUndoContent(), isSupportedContentModel(), NS_MEDIAWIKI, and toEditContent().
Referenced by displayPermissionsError(), edit(), and initialiseForm().
EditPage::getContext | ( | ) |
Definition at line 490 of file EditPage.php.
References $context.
Referenced by __construct(), getPreloadedContent(), importFormData(), and initialiseForm().
EditPage::getContextTitle | ( | ) |
RuntimeException | if no context title was set |
Definition at line 513 of file EditPage.php.
References $mContextTitle.
Referenced by displayViewSourcePage().
|
static |
Get the copyright warning, by default returns wikitext.
Title | $title | |
string | $format | Output format, valid values are any function of a Message object |
Language | string | null | $langcode | Language code or Language object. |
Definition at line 3765 of file EditPage.php.
References $title, $wgRightsText, and wfMessage().
|
protected |
Get the copyright warning.
Renamed to getCopyrightWarning(), old name kept around for backwards compatibility
Definition at line 3753 of file EditPage.php.
|
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.
Definition at line 1526 of file EditPage.php.
References $content.
Referenced by getOriginalContent().
EditPage::getEditButtons | ( | & | $tabindex | ) |
Returns an array of html code of the following buttons: save, diff and preview.
int | &$tabindex | Current tabindex |
Definition at line 4451 of file EditPage.php.
References Linker\accesskey(), and Linker\titleAttrib().
|
private |
Definition at line 4723 of file EditPage.php.
Referenced by incrementResolvedConflicts().
|
protected |
string | $rigor | PermissionManager::RIGOR_ constant |
Definition at line 729 of file EditPage.php.
References wfArrayDiff2().
Referenced by edit().
|
static |
Allow extensions to provide a toolbar.
Definition at line 4249 of file EditPage.php.
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.
Definition at line 2578 of file EditPage.php.
References getTitle().
|
protected |
Get the last log record of this page being deleted, if ever.
This is used to detect whether a delete occurred during editing.
Definition at line 3973 of file EditPage.php.
References $dbr, DB_REPLICA, LogPage\DELETED_COMMENT, LogPage\DELETED_USER, and wfGetDB().
|
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.
Authority | $performer | to get the revision for |
Definition at line 1485 of file EditPage.php.
References getCurrentContent().
Referenced by getContentObject().
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.
Definition at line 1510 of file EditPage.php.
References $parentRevId.
|
protected |
Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page.
string | $preload | Representing the title to preload from. |
array | $params | Parameters to use (interface-message style) in the preloaded text |
Definition at line 1553 of file EditPage.php.
References $content, $mPreloadContent, $page, $title, getAuthority(), WikiPage\getContent(), getContext(), WikiPage\getRedirectTarget(), isPageExistingAndViewable(), WikiPage\isRedirect(), and wfDebug().
Referenced by getContentObject().
|
static |
Get the Limit report for page previews.
ParserOutput | null | $output | ParserOutput object from the parse |
Definition at line 3793 of file EditPage.php.
References wfMessage().
Referenced by ApiParse\execute().
|
protected |
Get parser options for a preview.
Definition at line 4178 of file EditPage.php.
EditPage::getPreviewText | ( | ) |
Get the rendered text for previewing.
MWException |
Definition at line 4020 of file EditPage.php.
References $content, CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, CONTENT_MODEL_JSON, and getTitle().
|
protected |
Get the message key of the label for the button to save the page.
Definition at line 4425 of file EditPage.php.
|
private |
Helper function for summary input functions, which returns the necessary attributes for the input.
array | null | $inputAttrs | Array of attrs to use on the input |
Definition at line 3382 of file EditPage.php.
|
private |
Builds a standard summary input with a label.
string | $summary | The value of the summary input |
string | null | $labelText | The html to place inside the label |
array | null | $inputAttrs | Array of attrs to use on the input |
Definition at line 3405 of file EditPage.php.
References Linker\accesskey(), and Linker\titleAttrib().
|
protected |
bool | $isSubjectPreview | True if this is the section subject/title up top, or false if this is the comment summary down below the textarea |
string | $summary | The text of the summary to display |
Definition at line 3464 of file EditPage.php.
References Linker\commentBlock().
EditPage::getTemplates | ( | ) |
EditPage::getTitle | ( | ) |
Definition at line 498 of file EditPage.php.
References $mTitle.
Referenced by initialiseForm().
|
private |
Returns the result of a three-way merge when undoing changes.
RevisionRecord | $undoRev | Newest revision being undone. Corresponds to undo URL parameter. |
RevisionRecord | $oldRev | Revision that is being restored. Corresponds to undoafter URL parameter. |
Definition at line 1450 of file EditPage.php.
References MediaWiki\Revision\RevisionRecord\getContent(), MediaWiki\Revision\RevisionRecord\getId(), and MediaWiki\Revision\RevisionRecord\getSlot().
Referenced by getContentObject().
|
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.
string | $text |
Definition at line 4694 of file EditPage.php.
|
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.
IEditConstraint | $failed |
Definition at line 2404 of file EditPage.php.
References wfReadOnly().
|
private |
Handle status, such as after attempt save.
Status | $status | |
array | bool | $resultDetails |
ErrorPageError |
Definition at line 1714 of file EditPage.php.
References MediaWiki\EditPage\IEditObject\AS_ARTICLE_WAS_DELETED, MediaWiki\EditPage\IEditObject\AS_BLANK_ARTICLE, MediaWiki\EditPage\IEditObject\AS_BLOCKED_PAGE_FOR_USER, MediaWiki\EditPage\IEditObject\AS_CANNOT_USE_CUSTOM_MODEL, MediaWiki\EditPage\IEditObject\AS_CONFLICT_DETECTED, MediaWiki\EditPage\IEditObject\AS_CONTENT_TOO_BIG, MediaWiki\EditPage\IEditObject\AS_END, MediaWiki\EditPage\IEditObject\AS_HOOK_ERROR, MediaWiki\EditPage\IEditObject\AS_HOOK_ERROR_EXPECTED, MediaWiki\EditPage\IEditObject\AS_IMAGE_REDIRECT_ANON, MediaWiki\EditPage\IEditObject\AS_IMAGE_REDIRECT_LOGGED, MediaWiki\EditPage\IEditObject\AS_MAX_ARTICLE_SIZE_EXCEEDED, MediaWiki\EditPage\IEditObject\AS_NO_CHANGE_CONTENT_MODEL, MediaWiki\EditPage\IEditObject\AS_NO_CREATE_PERMISSION, MediaWiki\EditPage\IEditObject\AS_PARSE_ERROR, MediaWiki\EditPage\IEditObject\AS_RATE_LIMITED, MediaWiki\EditPage\IEditObject\AS_READ_ONLY_PAGE, MediaWiki\EditPage\IEditObject\AS_READ_ONLY_PAGE_ANON, MediaWiki\EditPage\IEditObject\AS_READ_ONLY_PAGE_LOGGED, MediaWiki\EditPage\IEditObject\AS_SELF_REDIRECT, MediaWiki\EditPage\IEditObject\AS_SPAM_ERROR, MediaWiki\EditPage\IEditObject\AS_SUCCESS_NEW_ARTICLE, MediaWiki\EditPage\IEditObject\AS_SUCCESS_UPDATE, MediaWiki\EditPage\IEditObject\AS_SUMMARY_NEEDED, MediaWiki\EditPage\IEditObject\AS_TEXTBOX_EMPTY, MediaWiki\EditPage\IEditObject\AS_UNICODE_NOT_SUPPORTED, Status\getWikiText(), incrementResolvedConflicts(), setPostEditCookie(), spamPageWithContent(), and wfDeprecated().
Referenced by edit().
|
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...
WebRequest | &$request |
Definition at line 1173 of file EditPage.php.
Referenced by importFormData().
EditPage::importFormData | ( | & | $request | ) |
This function collects the form data and uses it to populate various member variables.
WebRequest | &$request |
ErrorPageError |
Definition at line 934 of file EditPage.php.
References $changeTags, $diff, $preview, $textbox1, $undidRev, $undoAfter, edit(), getContext(), importContentFormData(), isSectionEditSupported(), NS_USER, NS_USER_TALK, tokenOk(), wfDebug(), wfEscapeWikiText(), and wfTimestampNow().
Referenced by edit().
|
protected |
Definition at line 3901 of file EditPage.php.
|
private |
Definition at line 4169 of file EditPage.php.
|
private |
Log when a page was successfully saved after the edit conflict view.
Definition at line 1697 of file EditPage.php.
References getEditConflictHelper().
Referenced by handleStatus().
|
private |
Initialise form fields in the object Called on the first invocation, e.g.
when a user clicks an edit link
Definition at line 1182 of file EditPage.php.
References $content, getContentObject(), getContext(), getTitle(), isSupportedContentModel(), noSuchSectionPage(), Message\plaintextParam(), and toEditText().
Referenced by edit().
EditPage::internalAttemptSave | ( | & | $result, |
$markAsBot = false |
|||
) |
Attempt submission (no UI)
array | &$result | Array to add statuses to, currently with the possible keys:
|
bool | $markAsBot | True if edit is being made under the bot right and the bot wishes the edit to be marked as such. |
Definition at line 1909 of file EditPage.php.
References $content, $matches, DB_PRIMARY, EDIT_AUTOSUMMARY, EDIT_FORCE_BOT, EDIT_MINOR, EDIT_NEW, EDIT_UPDATE, getTitle(), wfDebug(), and wfGetDB().
Referenced by attemptSave().
|
private |
Verify if a given title exists and the given user is allowed to view it.
PageIdentity | null | $page | |
Authority | $performer |
Exception |
Definition at line 1625 of file EditPage.php.
References $page, MediaWiki\Permissions\Authority\authorizeRead(), and WikiPage\exists().
Referenced by getPreloadedContent().
|
protected |
Section editing is supported when the page content model allows section edit and we are editing current revision.
Definition at line 915 of file EditPage.php.
Referenced by importFormData().
EditPage::isSupportedContentModel | ( | $modelId | ) |
Returns if the given content model is editable.
string | $modelId | The ID of the content model to test. Use CONTENT_MODEL_XXX constants. |
MWException | If $modelId has no known handler |
Definition at line 528 of file EditPage.php.
Referenced by getContentObject(), and initialiseForm().
|
private |
Does sanity 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.
Content | $content |
Definition at line 2439 of file EditPage.php.
|
protected |
Checks whether the user entered a skin name in uppercase, e.g.
"User:Example/Monobook.css" instead of "monobook.css"
Definition at line 894 of file EditPage.php.
EditPage::makeTemplatesOnThisPageList | ( | array | $templates | ) |
Wrapper around TemplatesOnThisPageFormatter to make a "templates on this page" list.
Title[] | $templates |
Definition at line 3165 of file EditPage.php.
References $type.
Referenced by displayViewSourcePage().
|
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.
Content | $editContent |
false
or an array of the new Content and the updated parent revision id Definition at line 2533 of file EditPage.php.
|
private |
Return the summary to be used for a new section.
Definition at line 1854 of file EditPage.php.
|
private |
string | $submitButtonLabel |
MWUnknownContentModelException |
Definition at line 4739 of file EditPage.php.
References getContext(), and getTitle().
|
private |
Creates a basic error page which informs the user that they have attempted to edit a nonexistent section.
Definition at line 4518 of file EditPage.php.
References $res.
Referenced by initialiseForm().
|
protected |
Should we show a preview when the edit form is first shown?
Definition at line 853 of file EditPage.php.
Referenced by edit().
EditPage::setApiEditOverride | ( | $enableOverride | ) |
Allow editing of content that supports API direct editing, but not general direct editing.
Set to false by default.
bool | $enableOverride |
Definition at line 539 of file EditPage.php.
EditPage::setContextTitle | ( | $title | ) |
EditPage::setEditConflictHelperFactory | ( | callable | $factory | ) |
Set a factory function to create an EditConflictHelper.
callable | $factory | Factory function |
Definition at line 4715 of file EditPage.php.
EditPage::setHeaders | ( | ) |
Definition at line 2598 of file EditPage.php.
References NS_MEDIAWIKI.
|
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.
int | $statusValue | The status value (to check for new article status) |
Definition at line 1657 of file EditPage.php.
Referenced by handleStatus().
|
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 3890 of file EditPage.php.
|
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 3522 of file EditPage.php.
|
protected |
Attempt to show a custom editing introduction, if supplied.
Definition at line 2803 of file EditPage.php.
References $title.
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 3649 of file EditPage.php.
References NS_MEDIAWIKI.
EditPage::showEditForm | ( | $formCallback = null | ) |
Send the edit form and related headers to OutputPage.
callable | null | $formCallback | That 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. Please use the EditPage::showEditForm:fields hook instead.
Definition at line 2888 of file EditPage.php.
References $content, Linker\formatHiddenCategories(), Linker\titleAttrib(), and wfWarn().
Referenced by edit().
|
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 3741 of file EditPage.php.
|
protected |
Definition at line 3494 of file EditPage.php.
|
protected |
Definition at line 3485 of file EditPage.php.
|
protected |
Definition at line 3198 of file EditPage.php.
References getTitle(), SpecialPage\getTitleFor(), wfArrayToCgi(), wfReadOnly(), and wfReadOnlyReason().
|
protected |
Definition at line 3710 of file EditPage.php.
|
protected |
Show all applicable editing introductions.
Definition at line 2663 of file EditPage.php.
References $dbr, $file, CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, CONTENT_MODEL_JSON, DB_REPLICA, User\newFromName(), NS_FILE, NS_MEDIAWIKI, NS_USER, NS_USER_TALK, wfEscapeWikiText(), wfExpandUrl(), and wfGetDB().
Referenced by edit().
|
protected |
Append preview output to OutputPage.
Includes category rendering if this is a category page.
string | $text | The HTML to be output for the preview. |
Definition at line 3628 of file EditPage.php.
|
protected |
Definition at line 3840 of file EditPage.php.
|
protected |
bool | $isSubjectPreview | True if this is the section subject/title up top, or false if this is the comment summary down below the textarea |
string | $summary | The text of the summary to display |
Definition at line 3438 of file EditPage.php.
|
protected |
Definition at line 3569 of file EditPage.php.
Referenced by displayViewSourcePage().
|
protected |
Method to output wpTextbox1 The $textoverride method can be used by subclasses overriding showContentForm to pass back to this method.
array | null | $customAttribs | Array of html attributes to use in the textarea |
string | null | $textoverride | Optional text to override $this->textarea1 with |
Definition at line 3534 of file EditPage.php.
References getTitle().
|
protected |
Definition at line 3565 of file EditPage.php.
|
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 3726 of file EditPage.php.
EditPage::spamPageWithContent | ( | $match = false | ) |
Show "your edit contains spam" page with your diff and text.
string | array | bool | $match | Text (or array of texts) which triggered one or more filters |
Definition at line 4535 of file EditPage.php.
References wfEscapeWikiText().
Referenced by handleStatus().
|
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.
string | null | bool | $text | Text to unserialize |
MWException | If unserializing the text results in a Content object that is not an instance of TextContent and $this->allowNonTextContent is not true. |
Definition at line 2865 of file EditPage.php.
References $content, and getTitle().
Referenced by getContentObject().
|
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.
Content | null | bool | string | $content |
MWException | If $content is not an instance of TextContent and $this->allowNonTextContent is not true. |
Definition at line 2837 of file EditPage.php.
References $content.
Referenced by displayViewSourcePage(), and initialiseForm().
EditPage::tokenOk | ( | & | $request | ) |
Make sure the form isn't faking a user's credentials.
WebRequest | &$request |
Definition at line 1636 of file EditPage.php.
References $mTokenOk.
Referenced by importFormData().
|
protected |
Register the change of watch status.
Definition at line 2503 of file EditPage.php.
|
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.
Definition at line 3948 of file EditPage.php.
References wfTimestamp().
string EditPage::$action = 'submit' |
Definition at line 142 of file EditPage.php.
Referenced by displayPermissionsError().
|
protected |
Definition at line 193 of file EditPage.php.
|
private |
Definition at line 187 of file EditPage.php.
|
protected |
Definition at line 199 of file EditPage.php.
|
private |
Definition at line 202 of file EditPage.php.
|
protected |
Definition at line 190 of file EditPage.php.
|
private |
Definition at line 332 of file EditPage.php.
Referenced by importFormData().
null string EditPage::$contentFormat = null |
Definition at line 329 of file EditPage.php.
|
private |
Definition at line 396 of file EditPage.php.
|
protected |
Definition at line 359 of file EditPage.php.
string EditPage::$contentModel |
Definition at line 326 of file EditPage.php.
|
protected |
Definition at line 369 of file EditPage.php.
Referenced by getContext().
|
private |
Definition at line 154 of file EditPage.php.
EditPage::$didSave = false |
Definition at line 349 of file EditPage.php.
bool EditPage::$diff = false |
Definition at line 234 of file EditPage.php.
Referenced by importFormData().
|
protected |
Definition at line 356 of file EditPage.php.
|
private |
Definition at line 391 of file EditPage.php.
|
private |
Factory function to create an edit conflict helper.
Definition at line 386 of file EditPage.php.
string EditPage::$editFormPageTop = '' |
Before even the preview.
Definition at line 338 of file EditPage.php.
EditPage::$editFormTextAfterContent = '' |
Definition at line 344 of file EditPage.php.
EditPage::$editFormTextAfterTools = '' |
Definition at line 342 of file EditPage.php.
EditPage::$editFormTextAfterWarn = '' |
Definition at line 341 of file EditPage.php.
EditPage::$editFormTextBeforeContent = '' |
Definition at line 340 of file EditPage.php.
EditPage::$editFormTextBottom = '' |
Definition at line 343 of file EditPage.php.
EditPage::$editFormTextTop = '' |
Definition at line 339 of file EditPage.php.
|
private |
Definition at line 317 of file EditPage.php.
|
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.
Definition at line 288 of file EditPage.php.
string null EditPage::$edittime = '' |
Timestamp of the latest revision of the page when editing was initiated on the client.
Definition at line 275 of file EditPage.php.
|
private |
Set in ApiEditPage, based on ContentHandler::allowsDirectApiEditing.
Definition at line 364 of file EditPage.php.
bool EditPage::$firsttime |
True the first time the edit form is rendered, false after re-rendering with diff, save prompts, etc.
Definition at line 163 of file EditPage.php.
string EditPage::$formtype |
Definition at line 157 of file EditPage.php.
|
private |
Has a summary been preset using GET parameter &summary= ?
Definition at line 213 of file EditPage.php.
|
private |
Definition at line 205 of file EditPage.php.
|
private |
Definition at line 175 of file EditPage.php.
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 148 of file EditPage.php.
bool EditPage::$isNew = false |
New page or new section.
Definition at line 151 of file EditPage.php.
|
private |
Whether an old revision is edited.
Definition at line 374 of file EditPage.php.
|
private |
Definition at line 166 of file EditPage.php.
|
private |
Definition at line 323 of file EditPage.php.
Referenced by attemptSave().
Article EditPage::$mArticle |
Definition at line 127 of file EditPage.php.
Referenced by getArticle().
|
private |
Definition at line 139 of file EditPage.php.
Referenced by getContextTitle().
|
private |
A RevisionRecord corresponding to $this->editRevId or $this->edittime.
Definition at line 220 of file EditPage.php.
|
private |
Definition at line 237 of file EditPage.php.
|
private |
Definition at line 181 of file EditPage.php.
|
private |
Definition at line 184 of file EditPage.php.
|
private |
Definition at line 208 of file EditPage.php.
EditPage::$mPreloadContent = null |
Definition at line 346 of file EditPage.php.
Referenced by getPreloadedContent().
bool EditPage::$mShowSummaryField = true |
Definition at line 223 of file EditPage.php.
Title EditPage::$mTitle |
Definition at line 136 of file EditPage.php.
Referenced by getTitle().
|
private |
Definition at line 169 of file EditPage.php.
Referenced by tokenOk().
|
private |
Definition at line 172 of file EditPage.php.
|
private |
If true, hide the summary field.
Definition at line 269 of file EditPage.php.
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.
Definition at line 306 of file EditPage.php.
|
private |
Definition at line 130 of file EditPage.php.
Referenced by getPreloadedContent(), and isPageExistingAndViewable().
|
private |
Revision ID the edit is based on, adjusted when an edit conflict is resolved.
Definition at line 314 of file EditPage.php.
Referenced by getParentRevId().
|
private |
Definition at line 401 of file EditPage.php.
bool EditPage::$preview = false |
Definition at line 231 of file EditPage.php.
Referenced by importFormData().
EditPage::$previewTextAfterContent = '' |
Definition at line 345 of file EditPage.php.
|
private |
Definition at line 252 of file EditPage.php.
|
private |
Definition at line 406 of file EditPage.php.
bool EditPage::$save = false |
Definition at line 228 of file EditPage.php.
|
private |
Definition at line 320 of file EditPage.php.
string EditPage::$section = '' |
Definition at line 291 of file EditPage.php.
string EditPage::$sectiontitle = '' |
Definition at line 294 of file EditPage.php.
|
protected |
Definition at line 196 of file EditPage.php.
string EditPage::$starttime = '' |
Timestamp from the first time the edit form was rendered.
Definition at line 299 of file EditPage.php.
string EditPage::$summary = '' |
Definition at line 263 of file EditPage.php.
Referenced by getContentObject().
EditPage::$suppressIntro = false |
Definition at line 353 of file EditPage.php.
string EditPage::$textbox1 = '' |
Page content input field.
Definition at line 257 of file EditPage.php.
Referenced by displayViewSourcePage(), and importFormData().
string EditPage::$textbox2 = '' |
Definition at line 260 of file EditPage.php.
|
private |
Definition at line 178 of file EditPage.php.
EditPage::$undidRev = 0 |
Definition at line 350 of file EditPage.php.
Referenced by importFormData().
EditPage::$undoAfter = 0 |
Definition at line 351 of file EditPage.php.
Referenced by importFormData().
|
private |
What the user submitted in the 'wpUnicodeCheck' field.
Definition at line 379 of file EditPage.php.
|
private |
Definition at line 421 of file EditPage.php.
|
private |
Definition at line 246 of file EditPage.php.
|
private |
The expiry time of the watch item, or null if it is not watched temporarily.
Definition at line 249 of file EditPage.php.
|
private |
Corresponds to $wgWatchlistExpiry.
Definition at line 243 of file EditPage.php.
|
private |
Definition at line 416 of file EditPage.php.
|
private |
Definition at line 240 of file EditPage.php.
|
private |
Definition at line 411 of file EditPage.php.
const EditPage::EDITFORM_ID = 'editform' |
HTML id and name for the beginning of the edit form.
Definition at line 100 of file EditPage.php.
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 121 of file EditPage.php.
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 106 of file EditPage.php.
Referenced by Article\view().
const EditPage::UNICODE_CHECK = UnicodeConstraint::VALID_UNICODE |
Used for Unicode support checks.
Definition at line 95 of file EditPage.php.
Referenced by ApiEditPage\execute().