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) | |||||||
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 PageBundle 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. | |||||||
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. | |||||||
setUseParserCache (bool $read, bool $write) | |||||||
Controls how the parser cache is used. | |||||||
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 | 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 79 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 ) |
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. |
Definition at line 183 of file HtmlOutputRendererHelper.php.
References wfDeprecated().
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 560 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getFlavor | ( | ) |
Returns the flavor of HTML that will be generated.
Definition at line 252 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 489 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getHtmlOutputContentLanguage | ( | ) |
The content language of the HTML output after parsing.
Definition at line 677 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 581 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::getPageBundle | ( | ) |
Returns the rendered HTML as a PageBundle object.
Definition at line 735 of file HtmlOutputRendererHelper.php.
|
static |
Gets the request parameters of this request.
Implements MediaWiki\Rest\Handler\Helper\HtmlOutputHelper.
Definition at line 588 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 765 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 417 of file HtmlOutputRendererHelper.php.
References wfDeprecated().
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 704 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 361 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 381 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 234 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 267 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 399 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 332 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setStashingEnabled | ( | bool | $stash | ) |
Determine whether stashing should be applied.
bool | $stash |
Definition at line 311 of file HtmlOutputRendererHelper.php.
MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::setUseParserCache | ( | bool | $read, |
bool | $write ) |
Controls how the parser cache is used.
bool | $read | Whether we should look for cached output before parsing |
bool | $write | Whether we should cache output after parsing |
Definition at line 298 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 451 of file HtmlOutputRendererHelper.php.
const MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper::CONSTRUCTOR_OPTIONS |
Definition at line 86 of file HtmlOutputRendererHelper.php.