MediaWiki  REL1_22
EditPage Class Reference

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

Collaboration diagram for EditPage:

List of all members.

Public Member Functions

 __construct (Article $article)
 attemptSave ()
 Attempt submission.
 blockedPage ()
 Call the stock "user is blocked" page.
 checkUnicodeCompliantBrowser ()
 Check if the browser is on a blacklist of user-agents known to mangle UTF-8 data on form submission.
 edit ()
 This is the function that gets called for "action=edit".
 getArticle ()
 getBaseRevision ()
 getCancelLink ()
 getCheckboxes (&$tabindex, $checked)
 Returns an array of html code of the following checkboxes: minor and watch.
 getContent ($def_text=false)
 Fetch initial editing page content.
 getContextTitle ()
 Get the context title object.
 getEditButtons (&$tabindex)
 Returns an array of html code of the following buttons: save, diff, preview and live.
 getPreviewText ()
 Get the rendered text for previewing.
 getSummaryInput ($summary="", $labelText=null, $inputAttrs=null, $spanLabelAttrs=null)
 Standard summary input and label (wgSummary), abstracted so EditPage subclasses may reorganize the form.
 getTemplates ()
 getTitle ()
 importFormData (&$request)
 This function collects the form data and uses it to populate various member variables.
 initialiseForm ()
 Initialise form fields in the object Called on the first invocation, e.g.
 internalAttemptSave (&$result, $bot=false)
 Attempt submission (no UI)
 livePreview ()
 Output preview text only.
 makesafe ($invalue)
 A number of web browsers are known to corrupt non-ASCII characters in a UTF-8 text editing environment.
 mergeChangesInto (&$editText)
 Attempts to merge text content with base and current revisions.
 noCreatePermission ()
 Show an error page saying to the user that he has insufficient permissions to create a new page.
 noSuchSectionPage ()
 Creates a basic error page which informs the user that they have attempted to edit a nonexistent section.
 readOnlyPage ($source=null, $protected=false, $reasons=array(), $action=null)
 Show a read-only error Parameters are the same as OutputPage:readOnlyPage() Redirect to the article page if redlink=1.
 safeUnicodeInput ($request, $field)
 Filter an input field through a Unicode de-armoring process if it came from an old browser with known broken Unicode editing issues.
 safeUnicodeOutput ($text)
 Filter an output field through a Unicode armoring process if it is going to an old browser with known broken Unicode editing issues.
 safeUnicodeText ($request, $text)
 sectionAnchor ($text)
 Format an anchor fragment as it would appear for a given section name.
 setContextTitle ($title)
 Set the context Title object.
 setHeaders ()
 setPreloadedContent (Content $content)
 Use this method before edit() to preload some content into the edit box.
 setPreloadedText ($text)
 Use this method before edit() to preload some text into the edit box.
 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 $wgOut.
 spamPageWithContent ($match=false)
 Show "your edit contains spam" page with your diff and text.
 submit ()
 tokenOk (&$request)
 Make sure the form isn't faking a user's credentials.
 unmakesafe ($invalue)
 Reverse the previously applied transliteration of non-ASCII characters back to UTF-8.
 userNotLoggedInPage ()
 Produce the stock "please login to edit pages" page.

Static Public Member Functions

static extractSectionTitle ($text)
 Extract the section title from current section text, if any.
static getCopyrightWarning ($title, $format= 'plain')
 Get the copyright warning, by default returns wikitext.
static getEditToolbar ()
 Shows a bulletin board style toolbar for common editing functions.
static getPreviewLimitReport ($output)
 Get the Limit report for page previews.
static matchSpamRegex ($text)
 Check given input text against $wgSpamRegex, and return the text of the first match.
static matchSummarySpamRegex ($text)
 Check given input text against $wgSummarySpamRegex, and return the text of the first match.
static spamPage ($match=false)
 Produce the stock "your edit contains spam" page.

Public Attributes

 $action = 'submit'
 $allowBlankSummary = false
bool $allowNonTextContent = false
 Set to true to allow editing of non-text content types.
 $autoSumm = ''
 $bot = true
 $contentFormat = null
 $contentModel = null
 $deletedSinceEdit
 $didSave = false
 $diff = false
 $editFormPageTop = ''
 $editFormTextAfterContent = ''
 $editFormTextAfterTools = ''
 $editFormTextAfterWarn = ''
 $editFormTextBeforeContent = ''
 $editFormTextBottom = ''
 $editFormTextTop = ''
 $editintro = ''
 $edittime = ''
 $firsttime
 $formtype
Bool $hasPresetSummary = false
 Has a summary been preset using GET parameter &summary= ?
 $hookError = ''
 $incompleteForm = false
 $isConflict = false
 $isCssJsSubpage = false
 $isCssSubpage = false
 $isJsSubpage = false
 $isNew = false
 $isWrongCaseCssJsPage = false
 $kblength = false
 $lastDelete
Article $mArticle
 $mBaseRevision = false
 $minoredit = false
 $missingComment = false
 $missingSummary = false
ParserOutput $mParserOutput
 $mPreloadContent = null
 $mShowSummaryField = true
Title $mTitle
 $mTokenOk = false
 $mTokenOkExceptSuffix = false
 $mTriedSave = false
 $nosummary = false
 $oldid = 0
 $preview = false
 $previewTextAfterContent = ''
 $recreate = false
 $save = false
 $scrolltop = null
 $section = ''
 $sectiontitle = ''
 $starttime = ''
 $summary = ''
 $suppressIntro = false
 $textbox1 = ''
 $textbox2 = ''
 $tooBig = false
 $undidRev = 0
 $watchthis = false
const AS_ARTICLE_WAS_DELETED = 222
 Status: article was deleted while editing and param wpRecreate == false or form was not posted.
const AS_BLANK_ARTICLE = 224
 Status: user tried to create a blank page.
const AS_BLOCKED_PAGE_FOR_USER = 215
 Status: User is blocked from editing this page.
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_CREATE_PERMISSION = 223
 Status: user tried to create this page, but is not allowed to do that ( Title->userCan('create') == false )
const AS_OK = 230
 not used
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_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_USER_CANNOT_EDIT = 217
 Status: User cannot edit? (not used)
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.

Protected Member Functions

 displayPermissionsError (array $permErrors)
 Display a permissions error page, like OutputPage::showPermissionsErrorPage(), but with the following differences:
 displayPreviewArea ($previewOutput, $isOnTop=false)
 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 ()
 getLastDelete ()
 getPreloadedContent ($preload)
 Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given page.
 getPreloadedText ($preload)
 Get the contents to be preloaded into the box, either set by an earlier setPreloadText() or by loading the given 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...
 isSectionEditSupported ()
 Returns whether section editing is supported for the current page.
 isWrongCaseCssJsPage ()
 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?
 runPostMergeFilters (Content $content, Status $status, User $user)
 Run hooks that can filter edits just before they get saved.
 setPostEditCookie ()
 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 ()
 showFormAfterText ()
 showFormBeforeText ()
 showHeader ()
 showHeaderCopyrightWarning ()
 Show the header copyright warning.
 showIntro ()
 Show all applicable editing introductions.
 showPreview ($text)
 Append preview output to $wgOut.
 showStandardInputs (&$tabindex=2)
 showSummaryInput ($isSubjectPreview, $summary="")
 showTextbox ($text, $name, $customAttribs=array())
 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.

Static Protected Member Functions

static matchSpamRegexInternal ($text, $regexes)

Private Member Functions

 getOriginalContent ()
 Get the content of the wanted revision, without section extraction.
 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.

Private Attributes

 $mContextTitle = null

Detailed Description

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

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

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

Definition at line 38 of file EditPage.php.


Constructor & Destructor Documentation

Parameters:
$articleArticle

Definition at line 267 of file EditPage.php.

References $article, ContentHandler\getForModelID(), and Article\getTitle().


Member Function Documentation

Attempt submission.

Exceptions:
UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
Returns:
bool false if output is done, true if the rest of the form should be displayed

Definition at line 1202 of file EditPage.php.

Call the stock "user is blocked" page.

Deprecated:
in 1.19; throw an exception directly instead

Definition at line 3592 of file EditPage.php.

Check if the browser is on a blacklist of user-agents known to mangle UTF-8 data on form submission.

Returns true if Unicode should make it through, false if it's known to be a problem.

Returns:
bool
Access:
private

Definition at line 3708 of file EditPage.php.

EditPage::displayPermissionsError ( array permErrors) [protected]

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

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

Definition at line 478 of file EditPage.php.

EditPage::displayPreviewArea ( previewOutput,
isOnTop = false 
) [protected]

Definition at line 2739 of file EditPage.php.

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

Referenced by importFormData().

static EditPage::extractSectionTitle ( text) [static]

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

Parameters:
string$text
Returns:
Mixed|string or false

Definition at line 2364 of file EditPage.php.

Referenced by EditPageTest\testExtractSectionTitle().

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:
$titleTitle object for which is being edited (where we go to for &action= links)
Returns:
string

Definition at line 3066 of file EditPage.php.

Returns:
Article

Definition at line 280 of file EditPage.php.

Returns:
Revision

Definition at line 1892 of file EditPage.php.

Returns:
string

Definition at line 3043 of file EditPage.php.

EditPage::getCheckboxes ( &$  tabindex,
checked 
)

Returns an array of html code of the following checkboxes: minor and watch.

Parameters:
int$tabindexCurrent tabindex
array$checkedof checkbox => bool, where bool indicates the checked status of the checkbox
Returns:
array

Definition at line 3466 of file EditPage.php.

EditPage::getContent ( def_text = false)

Fetch initial editing page content.

Parameters:
$def_textstring|bool
Returns:
mixed string on success, $def_text for invalid sections
Access:
private
Deprecated:
since 1.21, get WikiPage::getContent() instead.

Definition at line 849 of file EditPage.php.

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

Definition at line 871 of file EditPage.php.

Get the context title object.

If not set, $wgTitle will be returned. This behavior might change in the future to return $this->mTitle instead.

Returns:
Title object

Definition at line 308 of file EditPage.php.

static EditPage::getCopyrightWarning ( title,
format = 'plain' 
) [static]

Get the copyright warning, by default returns wikitext.

Parameters:
Title$title
string$formatoutput format, valid values are any function of a Message object
Returns:
string

Definition at line 2907 of file EditPage.php.

EditPage::getCopywarn ( ) [protected]

Get the copyright warning.

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

Definition at line 2895 of file EditPage.php.

EditPage::getCurrentContent ( ) [protected]

Get the current content of the page.

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

Since:
1.21
Returns:
Content

Definition at line 1024 of file EditPage.php.

EditPage::getEditButtons ( &$  tabindex)

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

Parameters:
int$tabindexCurrent tabindex
Returns:
array

Definition at line 3515 of file EditPage.php.

Returns:
array

Definition at line 444 of file EditPage.php.

static EditPage::getEditToolbar ( ) [static]

Shows a bulletin board style toolbar for common editing functions.

It can be disabled in the user preferences. The necessary JavaScript code can be found in skins/common/edit.js.

Returns:
string

Definition at line 3297 of file EditPage.php.

EditPage::getLastDelete ( ) [protected]

Definition at line 3096 of file EditPage.php.

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::replaceSection()) to the original text of the edit.

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

Since:
1.19
Returns:
Content|null

Definition at line 999 of file EditPage.php.

EditPage::getPreloadedContent ( preload) [protected]

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

Parameters:
string$preloadrepresenting the title to preload from.
Returns:
Content
Since:
1.21

Definition at line 1098 of file EditPage.php.

EditPage::getPreloadedText ( preload) [protected]

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

Parameters:
string$preloadrepresenting the title to preload from.
Returns:
String
Deprecated:
since 1.21, use getPreloadedContent() instead

Definition at line 1079 of file EditPage.php.

static EditPage::getPreviewLimitReport ( output) [static]

Get the Limit report for page previews.

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

Definition at line 2931 of file EditPage.php.

Get the rendered text for previewing.

Exceptions:
MWException
Returns:
string

Definition at line 3139 of file EditPage.php.

EditPage::getSummaryInput ( summary = "",
labelText = null,
inputAttrs = null,
spanLabelAttrs = null 
)

Standard summary input and label (wgSummary), abstracted so EditPage subclasses may reorganize the form.

Note that you do not need to worry about the label's for=, it will be inferred by the id given to the input. You can remove them both by passing array( 'id' => false ) to $userInputAttrs.

Parameters:
string$summaryThe value of the summary input
string$labelTextThe html to place inside the label
array$inputAttrsof attrs to use on the input
array$spanLabelAttrsof attrs to use on the span inside the label
Returns:
array An array in the format array( $label, $input )

Definition at line 2540 of file EditPage.php.

EditPage::getSummaryPreview ( isSubjectPreview,
summary = "" 
) [protected]
Parameters:
$isSubjectPreviewBoolean: true if this is the section subject/title up top, or false if this is the comment summary down below the textarea
string$summarythe text of the summary to display
Returns:
String

Definition at line 2599 of file EditPage.php.

Returns:
Array

Definition at line 3273 of file EditPage.php.

Since:
1.19
Returns:
Title

Definition at line 288 of file EditPage.php.

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:
$requestWebRequest

Definition at line 801 of file EditPage.php.

Referenced by importFormData().

EditPage::importFormData ( &$  request)

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

Parameters:
$requestWebRequest

Definition at line 612 of file EditPage.php.

References $textbox1, $undidRev, $wgContLang, $wgUser, array(), edit(), ContentHandler\getForTitle(), global, importContentFormData(), isSectionEditSupported(), safeUnicodeInput(), save, section, tokenOk(), wfDebug(), wfProfileIn(), wfProfileOut(), wfRunHooks(), and wfTimestampNow().

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

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

Attempt submission (no UI)

Parameters:
array$resultarray to add statuses to, currently with the possible keys: spam - string - Spam string from content if any spam is detected by matchSpamRegex sectionanchor - string - Section anchor for a section save nullEdit - boolean - Set if doEditContent is OK. True if null edit, false otherwise. redirect - boolean - Set if doEditContent is OK. True if resulting revision is a redirect
bool$botTrue if edit is being made under the bot right.
Returns:
Status object, possibly with a message, but always with one of the AS_* constants in $status->value,

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

Returns whether section editing is supported for the current page.

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

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

Definition at line 603 of file EditPage.php.

Referenced by importFormData().

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

Output preview text only.

This can be sucked into the edit page via JavaScript, and saves the server time rendering the skin as well as theoretically being more robust on the client (doesn't disturb the edit box's undo history, won't eat your text on failure, etc).

Todo:
This doesn't include category or interlanguage links. Would need to enhance it a bit, "<s>maybe wrap them in XML or something...</s>" that might also require more skin initialization, so check whether that's a problem.

Definition at line 3569 of file EditPage.php.

EditPage::makesafe ( invalue)

A number of web browsers are known to corrupt non-ASCII characters in a UTF-8 text editing environment.

To protect against this, detected browsers will be served an armored version of the text, with non-ASCII chars converted to numeric HTML character references.

Preexisting such character references will have a 0 added to them to ensure that round-trips do not alter the original data.

Parameters:
$invalueString
Returns:
String
Access:
private

Definition at line 3782 of file EditPage.php.

static EditPage::matchSpamRegex ( text) [static]

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

Parameters:
$textstring
Returns:
string|bool matching string or false

Definition at line 1910 of file EditPage.php.

static EditPage::matchSpamRegexInternal ( text,
regexes 
) [static, protected]
Parameters:
$textstring
$regexesarray
Returns:
bool|string

Definition at line 1935 of file EditPage.php.

static EditPage::matchSummarySpamRegex ( text) [static]

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

Parameters:
$textstring
Returns:
string|bool matching string or false

Definition at line 1924 of file EditPage.php.

Referenced by Title\isValidMoveOperation().

EditPage::mergeChangesInto ( &$  editText)

Attempts to merge text content with base and current revisions.

Parameters:
$editTextstring
Returns:
bool
Deprecated:
since 1.21, use mergeChangesIntoContent() instead

Definition at line 1827 of file EditPage.php.

EditPage::mergeChangesIntoContent ( &$  editContent) [private]

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

Since:
1.21
Parameters:
$editContent
Returns:
bool

Definition at line 1852 of file EditPage.php.

Show an error page saying to the user that he has insufficient permissions to create a new page.

Deprecated:
in 1.19; throw an exception directly instead

Definition at line 3615 of file EditPage.php.

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

Definition at line 3625 of file EditPage.php.

References $res, $wgOut, array(), global, section, wfMessage(), and wfRunHooks().

EditPage::previewOnOpen ( ) [protected]

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

Returns:
bool

Definition at line 551 of file EditPage.php.

EditPage::readOnlyPage ( source = null,
protected = false,
reasons = array(),
action = null 
)

Show a read-only error Parameters are the same as OutputPage:readOnlyPage() Redirect to the article page if redlink=1.

Deprecated:
in 1.19; use displayPermissionsError() instead

Definition at line 532 of file EditPage.php.

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

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

Parameters:
Content$contentthe Content to filter.
Status$statusfor reporting the outcome to the caller
User$userthe user performing the edit
Returns:
bool

Definition at line 1307 of file EditPage.php.

EditPage::safeUnicodeInput ( request,
field 
)

Filter an input field through a Unicode de-armoring process if it came from an old browser with known broken Unicode editing issues.

Parameters:
$requestWebRequest
$fieldString
Returns:
String
Access:
private

Definition at line 3734 of file EditPage.php.

Referenced by importFormData().

Filter an output field through a Unicode armoring process if it is going to an old browser with known broken Unicode editing issues.

Parameters:
$textString
Returns:
String
Access:
private

Definition at line 3761 of file EditPage.php.

EditPage::safeUnicodeText ( request,
text 
)
Parameters:
$requestWebRequest
$textstring
Returns:
string

Definition at line 3746 of file EditPage.php.

Format an anchor fragment as it would appear for a given section name.

Parameters:
$textString
Returns:
String
Access:
private

Definition at line 3696 of file EditPage.php.

Set the context Title object.

Parameters:
$titleTitle object or null

Definition at line 297 of file EditPage.php.

Definition at line 1945 of file EditPage.php.

EditPage::setPostEditCookie ( ) [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.

The cookie is deleted in the mediawiki.action.view.postEdit JS module after the redirect. It must be clearable by JavaScript code, so it must not be marked HttpOnly. The JavaScript code converts the cookie to a wgPostEdit config variable.

We use a path of '/' since wgCookiePath is not exposed to JS

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.

Definition at line 1186 of file EditPage.php.

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

Parameters:
$contentContent
Since:
1.21

Definition at line 1065 of file EditPage.php.

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

Parameters:
$textstring
Deprecated:
since 1.21, use setPreloadedContent() instead.

Definition at line 1050 of file EditPage.php.

EditPage::showConflict ( ) [protected]

Show an edit conflict.

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

Definition at line 3018 of file EditPage.php.

References $wgOut, array(), ContentHandler\getForModelID(), global, showTextbox2(), text, toEditContent(), wfMessage(), and wfRunHooks().

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

EditPage::showCustomIntro ( ) [protected]

Attempt to show a custom editing introduction, if supplied.

Returns:
bool

Definition at line 2089 of file EditPage.php.

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

EditPage::showEditForm ( formCallback = null)

Send the edit form and related headers to $wgOut.

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

Definition at line 2170 of file EditPage.php.

EditPage::showEditTools ( ) [protected]

Definition at line 2883 of file EditPage.php.

EditPage::showFormAfterText ( ) [protected]

Definition at line 2635 of file EditPage.php.

References Html\hidden().

Definition at line 2619 of file EditPage.php.

EditPage::showHeader ( ) [protected]

Definition at line 2374 of file EditPage.php.

Show the header copyright warning.

Definition at line 2855 of file EditPage.php.

EditPage::showIntro ( ) [protected]

Show all applicable editing introductions.

Definition at line 1987 of file EditPage.php.

EditPage::showPreview ( text) [protected]

Append preview output to $wgOut.

Includes category rendering if this is a category page.

Parameters:
string$textthe HTML to be output for the preview.

Definition at line 2776 of file EditPage.php.

EditPage::showStandardInputs ( &$  tabindex = 2) [protected]

Definition at line 2977 of file EditPage.php.

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

Definition at line 2573 of file EditPage.php.

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

Definition at line 2712 of file EditPage.php.

References array().

EditPage::showTextbox1 ( customAttribs = null,
textoverride = null 
) [protected]

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

Parameters:
array$customAttribsof html attributes to use in the textarea
string$textoverrideoptional text to override $this->textarea1 with

Definition at line 2672 of file EditPage.php.

EditPage::showTextbox2 ( ) [protected]

Definition at line 2708 of file EditPage.php.

Referenced by showConflict().

EditPage::showTosSummary ( ) [protected]

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

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

Definition at line 2872 of file EditPage.php.

static EditPage::spamPage ( match = false) [static]

Produce the stock "your edit contains spam" page.

Parameters:
string | bool$matchText which triggered one or more filters
Deprecated:
since 1.17 Use method spamPageWithContent() instead

Definition at line 3643 of file EditPage.php.

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

Parameters:
$matchstring|Array|bool Text (or array of texts) which triggered one or more filters

Definition at line 3665 of file EditPage.php.

Definition at line 317 of file EditPage.php.

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 The content object created from $text. If $text was false or null, false resp. 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 2149 of file EditPage.php.

Referenced by showConflict().

EditPage::toEditText ( content) [protected]

Gets an editable textual representation of $content.

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

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

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

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

Definition at line 2118 of file EditPage.php.

EditPage::tokenOk ( &$  request)

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

Parameters:
$requestWebRequest
Returns:
bool
Access:
private

Definition at line 1162 of file EditPage.php.

Referenced by importFormData().

EditPage::unmakesafe ( invalue)

Reverse the previously applied transliteration of non-ASCII characters back to UTF-8.

Used to protect data from corruption by broken web browsers as listed in $wgBrowserBlackList.

Parameters:
$invalueString
Returns:
String
Access:
private

Definition at line 3824 of file EditPage.php.

EditPage::updateWatchlist ( ) [protected]

Register the change of watch status.

Definition at line 1799 of file EditPage.php.

Produce the stock "please login to edit pages" page.

Deprecated:
in 1.19; throw an exception directly instead

Definition at line 3604 of file EditPage.php.

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


Member Data Documentation

EditPage::$action = 'submit'

Definition at line 196 of file EditPage.php.

EditPage::$allowBlankSummary = false

Definition at line 215 of file EditPage.php.

bool EditPage::$allowNonTextContent = false

Set to true to allow editing of non-text content types.

Definition at line 262 of file EditPage.php.

EditPage::$autoSumm = ''

Definition at line 216 of file EditPage.php.

EditPage::$bot = true

Definition at line 237 of file EditPage.php.

EditPage::$contentFormat = null

Definition at line 238 of file EditPage.php.

EditPage::$contentModel = null

Definition at line 238 of file EditPage.php.

EditPage::$deletedSinceEdit

Definition at line 203 of file EditPage.php.

EditPage::$didSave = false

Definition at line 253 of file EditPage.php.

EditPage::$diff = false

Definition at line 233 of file EditPage.php.

EditPage::$editFormPageTop = ''

Definition at line 242 of file EditPage.php.

EditPage::$editFormTextAfterContent = ''

Definition at line 248 of file EditPage.php.

EditPage::$editFormTextAfterTools = ''

Definition at line 246 of file EditPage.php.

EditPage::$editFormTextAfterWarn = ''

Definition at line 245 of file EditPage.php.

EditPage::$editFormTextBeforeContent = ''

Definition at line 244 of file EditPage.php.

EditPage::$editFormTextBottom = ''

Definition at line 247 of file EditPage.php.

EditPage::$editFormTextTop = ''

Definition at line 243 of file EditPage.php.

EditPage::$editintro = ''

Definition at line 237 of file EditPage.php.

EditPage::$edittime = ''

Definition at line 236 of file EditPage.php.

EditPage::$firsttime

Definition at line 205 of file EditPage.php.

EditPage::$formtype

Definition at line 204 of file EditPage.php.

Bool EditPage::$hasPresetSummary = false

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

Definition at line 227 of file EditPage.php.

EditPage::$hookError = ''

Definition at line 217 of file EditPage.php.

EditPage::$incompleteForm = false

Definition at line 210 of file EditPage.php.

EditPage::$isConflict = false

Definition at line 197 of file EditPage.php.

EditPage::$isCssJsSubpage = false

Definition at line 198 of file EditPage.php.

EditPage::$isCssSubpage = false

Definition at line 199 of file EditPage.php.

EditPage::$isJsSubpage = false

Definition at line 200 of file EditPage.php.

EditPage::$isNew = false

Definition at line 202 of file EditPage.php.

Definition at line 201 of file EditPage.php.

EditPage::$kblength = false

Definition at line 212 of file EditPage.php.

EditPage::$lastDelete

Definition at line 206 of file EditPage.php.

Article EditPage::$mArticle

Definition at line 190 of file EditPage.php.

EditPage::$mBaseRevision = false

Definition at line 229 of file EditPage.php.

EditPage::$mContextTitle = null [private]

Definition at line 195 of file EditPage.php.

EditPage::$minoredit = false

Definition at line 234 of file EditPage.php.

EditPage::$missingComment = false

Definition at line 213 of file EditPage.php.

EditPage::$missingSummary = false

Definition at line 214 of file EditPage.php.

ParserOutput EditPage::$mParserOutput

Definition at line 222 of file EditPage.php.

EditPage::$mPreloadContent = null

Definition at line 250 of file EditPage.php.

EditPage::$mShowSummaryField = true

Definition at line 230 of file EditPage.php.

Title EditPage::$mTitle

Definition at line 194 of file EditPage.php.

EditPage::$mTokenOk = false

Definition at line 207 of file EditPage.php.

EditPage::$mTokenOkExceptSuffix = false

Definition at line 208 of file EditPage.php.

EditPage::$mTriedSave = false

Definition at line 209 of file EditPage.php.

EditPage::$nosummary = false

Definition at line 235 of file EditPage.php.

EditPage::$oldid = 0

Definition at line 237 of file EditPage.php.

EditPage::$preview = false

Definition at line 233 of file EditPage.php.

EditPage::$previewTextAfterContent = ''

Definition at line 249 of file EditPage.php.

EditPage::$recreate = false

Definition at line 234 of file EditPage.php.

EditPage::$save = false

Definition at line 233 of file EditPage.php.

EditPage::$scrolltop = null

Definition at line 237 of file EditPage.php.

EditPage::$section = ''

Definition at line 236 of file EditPage.php.

EditPage::$sectiontitle = ''

Definition at line 236 of file EditPage.php.

EditPage::$starttime = ''

Definition at line 236 of file EditPage.php.

EditPage::$summary = ''

Definition at line 235 of file EditPage.php.

EditPage::$suppressIntro = false

Definition at line 256 of file EditPage.php.

EditPage::$textbox1 = ''

Definition at line 235 of file EditPage.php.

Referenced by importFormData().

EditPage::$textbox2 = ''

Definition at line 235 of file EditPage.php.

EditPage::$tooBig = false

Definition at line 211 of file EditPage.php.

EditPage::$undidRev = 0

Definition at line 254 of file EditPage.php.

Referenced by importFormData().

EditPage::$watchthis = false

Definition at line 234 of file EditPage.php.

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

Definition at line 99 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: user tried to create a blank page.

Definition at line 110 of file EditPage.php.

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

Status: User is blocked from editing this page.

Definition at line 63 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: (non-resolvable) edit conflict.

Definition at line 115 of file EditPage.php.

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

Status: Content too big (> $wgMaxArticleSize)

Definition at line 68 of file EditPage.php.

Referenced by ApiEditPage\execute().

const EditPage::AS_END = 231

Status: WikiPage::doEdit() was unsuccessful.

Definition at line 141 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: Article update aborted by a hook function.

Definition at line 53 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: A hook function returned an error.

Definition at line 58 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 151 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 156 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 131 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 105 of file EditPage.php.

Referenced by ApiEditPage\execute().

const EditPage::AS_OK = 230

not used

Definition at line 136 of file EditPage.php.

Status: can't parse content.

Definition at line 161 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 93 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 88 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 78 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 83 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 146 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: Article successfully created.

Definition at line 48 of file EditPage.php.

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

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

Definition at line 121 of file EditPage.php.

Referenced by ApiEditPage\execute().

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

Definition at line 126 of file EditPage.php.

Referenced by ApiEditPage\execute().

Status: User cannot edit? (not used)

Definition at line 73 of file EditPage.php.

const EditPage::EDITFORM_ID = 'editform'

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

Definition at line 166 of file EditPage.php.

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


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