|
MediaWiki master
|
Provides helper methods used by EditPage and a future editing backend (T157658). More...
Public Member Functions | |
| __construct (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, WikiPage $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, Article $article, string $contentModel, string $section,) | |
| Get the content of the wanted revision, without section extraction. | |
| 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. | |
Provides helper methods used by EditPage and a future editing backend (T157658).
Definition at line 23 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::__construct | ( | private readonly IContentHandlerFactory | $contentHandlerFactory, |
| private readonly ParserFactory | $parserFactory, | ||
| private readonly RevisionStore | $revisionStore ) |
Definition at line 25 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 182 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getExpectedParentRevision | ( | ?int | $editRevId, |
| ?string | $editTime, | ||
| WikiPage | $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 204 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::getOriginalContent | ( | Authority | $performer, |
| Article | $article, | ||
| 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 |
| Article | $article | |
| string | $contentModel | |
| string | $section |
Definition at line 159 of file PageEditingHelper.php.
References MediaWiki\Page\Article\getPage().
| 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 55 of file PageEditingHelper.php.
| MediaWiki\EditPage\PageEditingHelper::guessSectionName | ( | string | $text | ) |
Turns section name wikitext into anchors for use in HTTP redirects.
Definition at line 35 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 135 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 108 of file PageEditingHelper.php.