|
MediaWiki master
|
Provides helper methods used by EditPage and a future editing backend (T157658). More...
Public Member Functions | |
| __construct (private readonly ServiceOptions $options, private readonly IContentHandlerFactory $contentHandlerFactory, private readonly ParserFactory $parserFactory, private readonly RevisionStore $revisionStore,) | |
| getCurrentContent (string $contentModel, WikiPage $page,) | |
| Get the current content of the page. | |
| getExpectedParentRevision (?int $editRevId, ?string $editTime, PageReference $page,) | |
| 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. | |
| getOriginalContent (Authority $performer, $page, ?RevisionRecord $revisionRecord, string $contentModel, string $section,) | |
| Get the content of the wanted revision, without section extraction. | |
| getSubmitButtonLabel (PageIdentity $page) | |
| Get the message key of the label for the button to save the page. | |
| getUndoContent (WikiPage $page, RevisionRecord $undoRev, RevisionRecord $oldRev, ?string &$error) | |
| Returns the result of a three-way merge when undoing changes. | |
| guessSectionName (string $text) | |
| Turns section name wikitext into anchors for use in HTTP redirects. | |
| isSupportedContentModel (string $modelId, bool $enableApiEditOverride,) | |
| Returns if the given content model is editable. | |
| toEditText (Content|null|false|string $content, ?string $contentFormat, bool $enableApiEditOverride,) | |
| Gets an editable textual representation of $content. | |
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
Provides helper methods used by EditPage and a future editing backend (T157658).
Definition at line 26 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::__construct | ( | private readonly ServiceOptions | $options, |
| private readonly IContentHandlerFactory | $contentHandlerFactory, | ||
| private readonly ParserFactory | $parserFactory, | ||
| private readonly RevisionStore | $revisionStore ) |
Definition at line 32 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getCurrentContent | ( | string | $contentModel, |
| WikiPage | $page ) |
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 197 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getExpectedParentRevision | ( | ?int | $editRevId, |
| ?string | $editTime, | ||
| PageReference | $page ) |
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 219 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getOriginalContent | ( | Authority | $performer, |
| $page, | |||
| ?RevisionRecord | $revisionRecord, | ||
| string | $contentModel, | ||
| string | $section ) |
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 |
| WikiPage | $page | |
| RevisionRecord | null | $revisionRecord | |
| string | $contentModel | |
| string | $section |
Definition at line 174 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getSubmitButtonLabel | ( | PageIdentity | $page | ) |
Get the message key of the label for the button to save the page.
| PageIdentity | $page | The page that's being edited. |
Definition at line 244 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getUndoContent | ( | WikiPage | $page, |
| RevisionRecord | $undoRev, | ||
| RevisionRecord | $oldRev, | ||
| ?string & | $error ) |
Returns the result of a three-way merge when undoing changes.
| WikiPage | $page | |
| RevisionRecord | $undoRev | Newest revision being undone. Corresponds to undo URL parameter. |
| RevisionRecord | $oldRev | Revision that is being restored. Corresponds to undoafter URL parameter. |
| ?string | &$error | If false is returned, this will be set to "norev" if the revision failed to load, or "failure" if the content handler failed to merge the required changes. |
Definition at line 69 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::guessSectionName | ( | string | $text | ) |
Turns section name wikitext into anchors for use in HTTP redirects.
Definition at line 46 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::isSupportedContentModel | ( | string | $modelId, |
| bool | $enableApiEditOverride ) |
Returns if the given content model is editable.
| string | $modelId | The ID of the content model to test. Use CONTENT_MODEL_XXX constants. |
| bool | $enableApiEditOverride |
| UnknownContentModelException | If $modelId has no known handler |
Definition at line 149 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::toEditText | ( | Content|null|false|string | $content, |
| ?string | $contentFormat, | ||
| bool | $enableApiEditOverride ) |
Gets an editable textual representation of $content.
The textual representation can be turned by into a Content object by the EditPage::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 $enableApiEditOverride to true to allow editing of non-textual content.
| UnsupportedContentFormatException |
Definition at line 122 of file PageEditingHelper.php.
| const MediaWiki\EditPage\PageEditingHelper::CONSTRUCTOR_OPTIONS |
Definition at line 28 of file PageEditingHelper.php.