|
MediaWiki master
|
Helper for getting output of a given wikitext page rendered by parsoid. More...
Inherits MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.

Public Member Functions | |||||||
| __construct (ParsoidOutputStash $parsoidOutputStash, StatsFactory $statsFactory, ParserOutputAccess $parserOutputAccess, PageLookup $pageLookup, RevisionLookup $revisionLookup, RevisionRenderer $revisionRenderer, ParsoidSiteConfig $parsoidSiteConfig, HtmlTransformFactory $htmlTransformFactory, IContentHandlerFactory $contentHandlerFactory, LanguageFactory $languageFactory, ?PageIdentity $page=null, array $parameters=[], ?Authority $authority=null, $revision=null, bool $lenientRevHandling=false, ?ParserOptions $parserOptions=null) | |||||||
| getETag (string $suffix='') | |||||||
Returns an ETag uniquely identifying the HTML output.
| |||||||
| getFlavor () | |||||||
| Returns the flavor of HTML that will be generated. | |||||||
| getHtml () | |||||||
Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.
| |||||||
| getHtmlOutputContentLanguage () | |||||||
| The content language of the HTML output after parsing. | |||||||
| getLastModified () | |||||||
Returns the time at which the HTML was rendered.
| |||||||
| getPageBundle () | |||||||
| Returns the rendered HTML as a HtmlPageBundle object. | |||||||
| getRevisionId () | |||||||
| Returns the ID of the revision that is being rendered. | |||||||
| init (PageIdentity $page, array $parameters, Authority $authority, $revision=null) | |||||||
| Initializes the helper with the given parameters like the page we're dealing with, parameters gotten from the request inputs, and the revision if any is available. | |||||||
| isParsoidContent () | |||||||
| putHeaders (ResponseInterface $response, bool $forHtml=true) | |||||||
Set the HTTP headers based on the response generated.
| |||||||
| setContent (Content $content) | |||||||
| Set the content to render. | |||||||
| setContentSource (string $source, string $model) | |||||||
| Set the content to render. | |||||||
| setFlavor (string $flavor) | |||||||
| Sets the given flavor to use for Wikitext -> HTML transformations. | |||||||
| setOutputProfileVersion ( $version) | |||||||
| Set the desired Parsoid profile version for the output. | |||||||
| setPageLanguage ( $pageLanguage) | |||||||
| This is equivalent to 'pageLanguageOverride' in PageConfigFactory For example, when clients call the REST API with the 'content-language' header to affect language variant conversion. | |||||||
| setRevision ( $revisionOrId) | |||||||
| Set the revision to render. | |||||||
| setStashingEnabled (bool $stash) | |||||||
| Determine whether stashing should be applied. | |||||||
| setVariantConversionLanguage ( $targetLanguage, $sourceLanguage=null) | |||||||
Set the language to be used for variant conversion.If $targetLanguage is a string, it may be a list of language ranges as specified by RFC 9110 for use in the Accept-Language header. Implementations must be able to process this format, and may use the information provided to choose a supported target language that is desirable to the client.
| |||||||
Static Public Member Functions | |
| static | getAcceptedTargetLanguage (string $targetLanguage) |
| Get a target language from an accept header. | |
| static | getParamSettings () |
Gets the request parameters of this request.
| |
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
Helper for getting output of a given wikitext page rendered by parsoid.
Definition at line 66 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::__construct | ( | ParsoidOutputStash | $parsoidOutputStash, |
| StatsFactory | $statsFactory, | ||
| ParserOutputAccess | $parserOutputAccess, | ||
| PageLookup | $pageLookup, | ||
| RevisionLookup | $revisionLookup, | ||
| RevisionRenderer | $revisionRenderer, | ||
| ParsoidSiteConfig | $parsoidSiteConfig, | ||
| HtmlTransformFactory | $htmlTransformFactory, | ||
| IContentHandlerFactory | $contentHandlerFactory, | ||
| LanguageFactory | $languageFactory, | ||
| ?PageIdentity | $page = null, | ||
| array | $parameters = [], | ||
| ?Authority | $authority = null, | ||
| $revision = null, | |||
| bool | $lenientRevHandling = false, | ||
| ?ParserOptions | $parserOptions = null ) |
| ParsoidOutputStash | $parsoidOutputStash | |
| StatsFactory | $statsFactory | |
| ParserOutputAccess | $parserOutputAccess | |
| PageLookup | $pageLookup | |
| RevisionLookup | $revisionLookup | |
| RevisionRenderer | $revisionRenderer | |
| ParsoidSiteConfig | $parsoidSiteConfig | |
| HtmlTransformFactory | $htmlTransformFactory | |
| IContentHandlerFactory | $contentHandlerFactory | |
| LanguageFactory | $languageFactory | |
| PageIdentity | null | $page | |
| array | $parameters | |
| Authority | null | $authority | |
| RevisionRecord | int | null | $revision | |
| bool | $lenientRevHandling | Should we ignore mismatches between $page and the page that $revision belongs to? Usually happens because of page moves. This should be set to true only for internal API calls. |
| ParserOptions | null | $parserOptions |
Definition at line 165 of file HtmlOutputRendererHelper.php.
References wfDeprecated().
|
static |
Get a target language from an accept header.
Definition at line 452 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getETag | ( | string | $suffix = '' | ) |
Returns an ETag uniquely identifying the HTML output.
| string | $suffix | A suffix to attach to the etag. Must consist of characters that are legal in ETags. |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 537 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getFlavor | ( | ) |
Returns the flavor of HTML that will be generated.
Definition at line 236 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getHtml | ( | ) |
Fetch the HTML for rendering of a given page.If the rendering is available in parsoid parser cache, return that. Otherwise, perform a parse and return the result while caching it in the parser cache.NOTE: Caching can be explicitly disabled or a force parse action can be issued. Stashing and rate limiting on stashing also applies here if specified.
| LocalizedHttpException | |
| ClientError |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 468 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getHtmlOutputContentLanguage | ( | ) |
The content language of the HTML output after parsing.
Definition at line 686 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getLastModified | ( | ) |
Returns the time at which the HTML was rendered.
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 578 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getPageBundle | ( | ) |
Returns the rendered HTML as a HtmlPageBundle object.
Definition at line 744 of file HtmlOutputRendererHelper.php.
|
static |
Gets the request parameters of this request.
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 599 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getRevisionId | ( | ) |
Returns the ID of the revision that is being rendered.
This will return 0 if no revision has been specified, so the current revision will be rendered.
This wil return null if RevisionRecord has been set but that RevisionRecord does not have a revision ID, e.g. when rendering a preview.
Definition at line 772 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::init | ( | PageIdentity | $page, |
| array | $parameters, | ||
| Authority | $authority, | ||
| $revision = null ) |
Initializes the helper with the given parameters like the page we're dealing with, parameters gotten from the request inputs, and the revision if any is available.
| PageIdentity | $page | |
| array | $parameters | |
| Authority | $authority | |
| RevisionRecord | int | null | $revision |
Definition at line 389 of file HtmlOutputRendererHelper.php.
References wfDeprecated().
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::isParsoidContent | ( | ) |
Definition at line 993 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::putHeaders | ( | ResponseInterface | $response, |
| bool | $forHtml = true ) |
Set the HTTP headers based on the response generated.
| ResponseInterface | $response | |
| bool | $forHtml | Whether the response will be HTML (rather than JSON) |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 715 of file HtmlOutputRendererHelper.php.
References MediaWiki\Rest\ResponseInterface\setHeader().
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setContent | ( | Content | $content | ) |
Set the content to render.
Useful when rendering for previews or when switching the editor from source mode to visual mode.
This will create a fake revision for rendering, the revision ID will be 0.
| Content | $content |
Definition at line 333 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setContentSource | ( | string | $source, |
| string | $model ) |
Set the content to render.
Useful when rendering for previews or when switching the editor from source mode to visual mode.
This will create a fake revision for rendering. The revision ID will be 0.
| string | $source | The source data, e.g. wikitext |
| string | $model | The content model indicating how to interpret $source, e.g. CONTENT_MODEL_WIKITEXT |
Definition at line 353 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setFlavor | ( | string | $flavor | ) |
Sets the given flavor to use for Wikitext -> HTML transformations.
Flavors may influence parser options, parsoid options, and DOM transformations. They will be reflected by the ETag returned by getETag().
| string | $flavor |
Definition at line 218 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setOutputProfileVersion | ( | $version | ) |
Set the desired Parsoid profile version for the output.
The actual output version is selected to be compatible with the one given here, per the rules of semantic versioning.
| string | $version |
| HttpException | If the given version is not supported (status 406) |
Definition at line 251 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setPageLanguage | ( | $pageLanguage | ) |
This is equivalent to 'pageLanguageOverride' in PageConfigFactory For example, when clients call the REST API with the 'content-language' header to affect language variant conversion.
| Bcp47Code | string | $pageLanguage | the page language, as a Bcp47Code or a BCP-47 string. |
Definition at line 371 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setRevision | ( | $revisionOrId | ) |
Set the revision to render.
This can take a fake RevisionRecord when rendering for previews or when switching the editor from source mode to visual mode.
In that case, $revisionOrId->getId() must return 0 to indicate that the ParserCache should be bypassed. Stashing may still apply.
| RevisionRecord | int | $revisionOrId |
Definition at line 304 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setStashingEnabled | ( | bool | $stash | ) |
Determine whether stashing should be applied.
| bool | $stash |
Definition at line 283 of file HtmlOutputRendererHelper.php.
| MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setVariantConversionLanguage | ( | $targetLanguage, | |
| $sourceLanguage = null ) |
Set the language to be used for variant conversion.If $targetLanguage is a string, it may be a list of language ranges as specified by RFC 9110 for use in the Accept-Language header. Implementations must be able to process this format, and may use the information provided to choose a supported target language that is desirable to the client.
| Bcp47Code | string | $targetLanguage | |
| Bcp47Code | string | null | $sourceLanguage |
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 430 of file HtmlOutputRendererHelper.php.
| const MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::CONSTRUCTOR_OPTIONS |
Definition at line 73 of file HtmlOutputRendererHelper.php.