MediaWiki master
|
ParserOutput is a rendering of a Content object or a message. More...
Inherits MediaWiki\Parser\CacheTime, and ContentMetadataCollector.
Public Member Functions | |
__clone () | |
__construct ( $text=null, $languageLinks=[], $categoryLinks=[], $unused=false, $titletext='') | |
__get ( $name) | |
__set ( $name, $value) | |
__sleep () | |
__wakeup () | |
addCacheMessage (string $msg) | |
Adds a comment notice about cache state to the text of the page. | |
addCategory ( $c, $sort='') | |
Add a category. | |
addExternalLink ( $url) | |
addExtraCSPDefaultSrc ( $src) | |
Add an extra value to Content-Security-Policy default-src directive. | |
addExtraCSPScriptSrc ( $src) | |
Add an extra value to Content-Security-Policy script-src directive. | |
addExtraCSPStyleSrc ( $src) | |
Add an extra value to Content-Security-Policy style-src directive. | |
addHeadItem ( $section, $tag=false) | |
Add some text to the "<head>". | |
addImage ( $name, $timestamp=null, $sha1=null) | |
Register a file dependency for this output. | |
addInterwikiLink ( $link) | |
addJsConfigVars ( $keys, $value=null) | |
Add one or more variables to be set in mw.config in JavaScript. | |
addLanguageLink ( $t) | |
Add a language link. | |
addLink (ParsoidLinkTarget $link, $id=null) | |
Record a local or interwiki inline link for saving in future link tables. | |
addModules (array $modules) | |
addModuleStyles (array $modules) | |
addOutputPageMetadata (OutputPage $out) | |
Accommodate very basic transcluding of a temporary OutputPage object into parser output. | |
addTemplate ( $link, $page_id, $rev_id) | |
Register a template dependency for this output. | |
addWarningMsg (string $msg,... $args) | |
Add a warning to the output for this page. | |
addWarningMsgVal (MessageValue $mv) | |
Add a warning to the output for this page. | |
addWrapperDivClass ( $class) | |
Add a CSS class to use for the wrapping div. | |
appendExtensionData (string $key, $value, string $strategy=self::MW_MERGE_STRATEGY_UNION) | |
Appends arbitrary data to this ParserObject. | |
appendJsConfigVar (string $key, string $value, string $strategy=self::MW_MERGE_STRATEGY_UNION) | |
Append a value to a variable to be set in mw.config in JavaScript. | |
appendOutputStrings (string $name, array $value) | |
Provides a uniform interface to various string sets stored in the ParserOutput. | |
clearParseStartTime () | |
Unset the parse start time. | |
clearWrapperDivClass () | |
Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrapperDivClass() is called. | |
collectMetadata (ContentMetadataCollector $metadata) | |
Adds the metadata collected in this ParserOutput to the supplied ContentMetadataCollector. | |
finalizeAdaptiveCacheExpiry () | |
Call this when parsing is done to lower the TTL based on low parse times. | |
getAllFlags () | |
getCacheMessage () | |
getCategoryMap () | |
Return category names and sort keys as a map. | |
getCategoryNames () | |
Return the names of the categories on this page. | |
getCategorySortKey (string $name) | |
Return the sort key for a given category name, or null if the category is not present in this ParserOutput. | |
getContentHolderText () | |
Returns the content holder text of the ParserOutput. | |
getDisplayTitle () | |
Get the title to be used for display. | |
getEnableOOUI () | |
getExtensionData ( $key) | |
Gets extensions data previously attached to this ParserOutput using setExtensionData(). | |
& | getExternalLinks () |
getExtraCSPDefaultSrcs () | |
Get extra Content-Security-Policy 'default-src' directives. | |
getExtraCSPScriptSrcs () | |
Get extra Content-Security-Policy 'script-src' directives. | |
getExtraCSPStyleSrcs () | |
Get extra Content-Security-Policy 'style-src' directives. | |
& | getFileSearchOptions () |
getHeadItems () | |
getHideNewSection () | |
& | getImages () |
getIndexPolicy () | |
getIndicators () | |
getInterwikiLinks () | |
getJsConfigVars (bool $showStrategyKeys=false) | |
getLanguage () | |
Get the primary language code of the output. | |
getLanguageLinks () | |
getLimitReportData () | |
getLimitReportJSData () | |
getLinkList (string $linkType) | |
Get a list of links of the given type. | |
& | getLinks () |
& | getLinksSpecial () |
getModules () | |
getModuleStyles () | |
getNewSection () | |
getNoGallery () | |
getOutputFlag (string $name) | |
Provides a uniform interface to various boolean flags stored in the ParserOutput. | |
getOutputStrings (string $name) | |
Provides a uniform interface to various boolean string sets stored in the ParserOutput. | |
getPageProperties () | |
Return all the page properties set on this ParserOutput. | |
getPageProperty (string $name) | |
Look up a page property. | |
getPreventClickjacking () | |
Get the prevent-clickjacking flag. | |
getRawText () | |
Get the cacheable text with <mw:editsection> markers still in it. | |
getRedirectHeader () | |
Return an HTML prefix to be applied on redirect pages, or null if this is not a redirect. | |
getRenderId () | |
Return the unique rendering id for this ParserOutput. | |
getRevisionTimestamp () | |
getRevisionTimestampUsed () | |
getRevisionUsedSha1Base36 () | |
getSections () | |
getSpeculativePageIdUsed () | |
getSpeculativeRevIdUsed () | |
& | getTemplateIds () |
& | getTemplates () |
getText ( $options=[]) | |
Get the output HTML. | |
getTimeProfile (string $clock) | |
Returns the time that elapsed between the most recent call to resetParseStartTime() and the first call to recordTimeProfile() after that. | |
getTimeSinceStart ( $clock) | |
Returns the time since resetParseStartTime() was last called. | |
getTimestamp () | |
getTitleText () | |
getTOCData () | |
getWarnings () | |
getWrapperDivClass () | |
Returns the class (or classes) to be used with the wrapper div for this output. | |
hasReducedExpiry () | |
Check whether the cache TTL was lowered from the site default. | |
hasText () | |
Returns true if text was passed to the constructor, or set using setText(). | |
mergeHtmlMetaDataFrom (ParserOutput $source) | |
Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source into this ParserOutput. | |
mergeInternalMetaDataFrom (ParserOutput $source) | |
Merges internal metadata such as flags, accessed options, and profiling info from $source into this ParserOutput. | |
mergeTrackingMetaDataFrom (ParserOutput $source) | |
Merges dependency tracking metadata such as backlinks, images used, and extension data from $source into this ParserOutput. | |
recordTimeProfile () | |
Record the time since resetParseStartTime() was last called. | |
resetParseStartTime () | |
Resets the parse start timestamps for future calls to getTimeSinceStart() and recordTimeProfile(). | |
runOutputPipeline (ParserOptions $popts, array $options=[]) | |
setCategories (array $c) | |
Overwrite the category map. | |
setContentHolderText (string $s) | |
Sets the content holder text of the ParserOutput. | |
setDisplayTitle ( $text) | |
Override the title to be used for display. | |
setEnableOOUI (bool $enable=false) | |
Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to. | |
setExtensionData ( $key, $value) | |
Attaches arbitrary data to this ParserObject. | |
setFromParserOptions (ParserOptions $parserOptions) | |
Transfer parser options which affect post-processing from ParserOptions to this ParserOutput. | |
setHideNewSection (bool $value) | |
setIndexPolicy ( $policy) | |
Update the index policy of the robots meta tag. | |
setIndicator ( $id, $content) | |
setJsConfigVar (string $key, $value) | |
Add a variable to be set in mw.config in JavaScript. | |
setLanguage (Bcp47Code $lang) | |
Set the primary language of the output. | |
setLanguageLinks ( $ll) | |
setLimitReportData ( $key, $value) | |
Sets parser limit report data for a key. | |
setNewSection ( $value) | |
setNoGallery ( $value) | |
setNumericPageProperty (string $propName, $numericValue) | |
Set a numeric page property whose value is intended to be sorted and indexed. | |
setOutputFlag (string $name, bool $val=true) | |
Provides a uniform interface to various boolean flags stored in the ParserOutput. | |
setPageProperty (string $name, $value) | |
Set a page property to be stored in the page_props database table. | |
setPreventClickjacking (bool $flag) | |
Set the prevent-clickjacking flag. | |
setRawText (?string $text) | |
Set the raw text of the ParserOutput. | |
setRedirectHeader (string $html) | |
Set an HTML prefix to be applied on redirect pages. | |
setRenderId (string $renderId) | |
Store a unique rendering id for this ParserOutput. | |
setRevisionTimestamp (?string $timestamp) | |
setRevisionTimestampUsed ( $timestamp) | |
setRevisionUsedSha1Base36 ( $hash) | |
setSections (array $sectionArray) | |
setSpeculativePageIdUsed ( $id) | |
setSpeculativeRevIdUsed ( $id) | |
setText ( $text) | |
Set the raw text of the ParserOutput. | |
setTimestamp ( $timestamp) | |
setTitleText ( $t) | |
setTOCData (TOCData $tocData) | |
setUnsortedPageProperty (string $propName, string $value='') | |
Set a page property whose value is not intended to be sorted and indexed. | |
unsetPageProperty (string $name) | |
Remove a page property. | |
updateRuntimeAdaptiveExpiry ( $ttl) | |
Lower the runtime adaptive TTL to at most this value. | |
Public Member Functions inherited from MediaWiki\Parser\CacheTime | |
expired ( $touched) | |
Return true if this cached output object predates the global or per-article cache invalidation timestamps, or if it comes from an incompatible older version. | |
getCacheExpiry () | |
Returns the number of seconds after which this object should expire. | |
getCacheRevisionId () | |
getCacheTime () | |
getUsedOptions () | |
Returns the options from its ParserOptions which have been taken into account to produce the output. | |
hasCacheTime () | |
isCacheable () | |
isDifferentRevision ( $id) | |
Return true if this cached output object is for a different revision of the page. | |
recordOption (string $option) | |
Tags a parser option for use in the cache key for this parser output. | |
recordOptions (array $options) | |
Tags a list of parser option names for use in the cache key for this parser output. | |
setCacheRevisionId ( $id) | |
setCacheTime ( $t) | |
setCacheTime() sets the timestamp expressing when the page has been rendered. | |
updateCacheExpiry ( $seconds) | |
Sets the number of seconds after which this object should expire. | |
Static Public Member Functions | |
static | isLinkInternal ( $internal, $url) |
Checks, if a url is pointing to the own server. | |
static | newFromJsonArray (JsonDeserializer $deserializer, array $json) |
Creates a new instance of the class and initialized it from the $json array. | |
Public Attributes | |
const | MW_MERGE_STRATEGY_KEY = '_mw-strategy' |
const | MW_MERGE_STRATEGY_UNION = 'union' |
Merge strategy to use for ParserOutput accumulators: "union" means that values are strings, stored as a set, and exposed as a PHP associative array mapping from values to true . | |
const | SUPPORTS_STATELESS_TRANSFORMS = 1 |
Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless transforms. | |
const | SUPPORTS_UNWRAP_TRANSFORM = 1 |
Protected Member Functions | |
initFromJson (JsonDeserializer $deserializer, array $jsonData) | |
Initialize member fields from an array returned by jsonSerialize(). | |
toJsonArray () | |
Returns a JSON serializable structure representing this ParserOutput instance. | |
Additional Inherited Members | |
Protected Attributes inherited from MediaWiki\Parser\CacheTime | |
int null | $mCacheExpiry = null |
Seconds after which the object should expire, use 0 for not cacheable. | |
int null | $mCacheRevisionId = null |
Revision ID that was parsed. | |
string int | $mCacheTime = '' |
TS_MW timestamp when this object was generated, or -1 for not cacheable. | |
true[] | $mParseUsedOptions = [] |
ParserOptions which have been taken into account to produce output, option names stored in array keys. | |
ParserOutput is a rendering of a Content object or a message.
Content objects and messages often contain wikitext, but not always.
ParserOutput
object combine the HTML rendering of Content objects or messages, available via ::getRawText()
, with various bits of metadata generated during rendering, which may include categories, links, page properties, and extension data, among others.
ParserOutput
objects corresponding to the content of page revisions are created by the ParserOutputAccess
service, which automatically caches them via ParserCache
where appropriate and produces new output via ContentHandler
as needed.
In addition, wikitext from system messages as well as odd bits of wikitext rendered to create special pages and other UX elements are rendered to ParserOutput
objects. In these cases the metadata from the ParserOutput
is generally discarded and the ParserOutput
is not cached. These bits of wikitext are generally rendered with ParserOptions::setInterfaceMessage(true)
when content is intended to be in the user interface language, but sometimes rendered to the content language and displayed in the content area instead.
A ParserOutput
object corresponding to a given revision may be a combination of the renderings of multiple "slots": the Multi-Content Revisions (MCR) work allows articles to be composed from multiple Content
objects. Each Content
renders to a ParserOutput
, and those ParserOutput
s are merged by RevisionRenderer::combineSlotOutput()
to create the final article output.
Similarly, OutputPage
maintains metadata overlapping with the metadata kept by ParserOutput
(T301020) and may merge several ParserOutput
s using OutputPage::addParserOutput()
to create the final output page. Parsoid parses certain transclusions in independent top-level contexts using Parser::parseExtensionTagAsTopLevelDoc()
and these also result in ParserOutput
s which are merged via ParserOutput::collectMetadata()
.
Future plans for incremental parsing and asynchronous rendering may result in several of these component ParserOutput
objects being cached independently and then recombined asynchronously, so operations on ParserOutput
objects should be compatible with that model (T300979).
Definition at line 93 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::__construct | ( | $text = null, | |
$languageLinks = [], | |||
$categoryLinks = [], | |||
$unused = false, | |||
$titletext = '' ) |
string | null | $text | HTML. Use null to indicate that this ParserOutput contains only meta-data, and the HTML output is undetermined, as opposed to empty. Passing null here causes hasText() to return false. In 1.39 the default value changed from '' to null. |
array | $languageLinks | |
array | $categoryLinks | |
bool | $unused | |
string | $titletext |
Definition at line 377 of file ParserOutput.php.
References MediaWiki\Parser\ParserOutput\addLanguageLink(), MediaWiki\Parser\ParserOutput\resetParseStartTime(), and wfDeprecated().
MediaWiki\Parser\ParserOutput::__clone | ( | ) |
Definition at line 3276 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::__get | ( | $name | ) |
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 3316 of file ParserOutput.php.
References wfDeprecatedMsg().
MediaWiki\Parser\ParserOutput::__set | ( | $name, | |
$value ) |
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 3331 of file ParserOutput.php.
References wfDeprecatedMsg().
MediaWiki\Parser\ParserOutput::__sleep | ( | ) |
Definition at line 2480 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::__wakeup | ( | ) |
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 3180 of file ParserOutput.php.
References $mText.
MediaWiki\Parser\ParserOutput::addCacheMessage | ( | string | $msg | ) |
Adds a comment notice about cache state to the text of the page.
string | $msg |
Definition at line 558 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and MediaWiki\Parser\ParserCache\save().
MediaWiki\Parser\ParserOutput::addCategory | ( | $c, | |
$sort = '' ) |
Add a category.
Although ParserOutput::getCategorySortKey() will return exactly the sort key you specify here, before storing in the database all sort keys will be language converted, HTML entities will be decoded, newlines stripped, and then they will be truncated to 255 bytes. Thus the "effective" sort key in the DB may be different from what is passed to $sort
here and returned by ::getCategorySortKey().
string | ParsoidLinkTarget | $c | The category name |
string | $sort | The sort key; an empty string indicates that the default sort key for the page should be used. |
Definition at line 1138 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addExternalLink | ( | $url | ) |
Definition at line 1282 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addExtraCSPDefaultSrc | ( | $src | ) |
Add an extra value to Content-Security-Policy default-src directive.
Call this if you are including a resource (e.g. image) from a third party domain. This is used for all source types except style and script.
string | $src | CSP source e.g. example.com |
Definition at line 2396 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addExtraCSPScriptSrc | ( | $src | ) |
Add an extra value to Content-Security-Policy script-src directive.
Call this if you are loading third-party Javascript
string | $src | CSP source e.g. example.com |
Definition at line 2418 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addExtraCSPStyleSrc | ( | $src | ) |
Add an extra value to Content-Security-Policy style-src directive.
string | $src | CSP source e.g. example.com |
Definition at line 2406 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addHeadItem | ( | $section, | |
$tag = false ) |
Add some text to the "<head>".
If $tag is set, the section with that tag will only be included once in a given page.
string | $section | |
string | false | $tag |
Definition at line 1389 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addImage | ( | $name, | |
$timestamp = null, | |||
$sha1 = null ) |
Register a file dependency for this output.
string | ParsoidLinkTarget | $name | Title dbKey |
string | false | null | $timestamp | MW timestamp of file creation (or false if non-existing) |
string | false | null | $sha1 | Base 36 SHA-1 of file (or false if non-existing) |
Definition at line 1340 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addInterwikiLink | ( | $link | ) |
ParsoidLinkTarget | $link | must be an interwiki link (used to require Title until 1.38). |
Definition at line 1374 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addJsConfigVars | ( | $keys, | |
$value = null ) |
Add one or more variables to be set in mw.config in JavaScript.
string | array | $keys | Key or array of key/value pairs. |
mixed | null | $value | [optional] Value of the configuration variable. |
Definition at line 1425 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addLanguageLink | ( | $t | ) |
Add a language link.
ParsoidLinkTarget | string | $t |
Definition at line 1179 of file ParserOutput.php.
Referenced by MediaWiki\Parser\ParserOutput\__construct().
MediaWiki\Parser\ParserOutput::addLink | ( | ParsoidLinkTarget | $link, |
$id = null ) |
Record a local or interwiki inline link for saving in future link tables.
ParsoidLinkTarget | $link | (used to require Title until 1.38) |
int | null | $id | Optional known page_id so we can skip the lookup |
Definition at line 1306 of file ParserOutput.php.
Referenced by MediaWiki\Content\WikitextContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::addModules | ( | array | $modules | ) |
string[] | $modules |
Definition at line 1401 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addModuleStyles | ( | array | $modules | ) |
string[] | $modules |
Definition at line 1410 of file ParserOutput.php.
Referenced by MediaWiki\Content\JsonContentHandler\fillParserOutput(), and MediaWiki\Content\WikitextContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::addOutputPageMetadata | ( | OutputPage | $out | ) |
Accommodate very basic transcluding of a temporary OutputPage object into parser output.
This is a fragile method that cannot be relied upon in any meaningful way. It exists solely to support the wikitext feature of transcluding a SpecialPage, and only has to work for that use case to ensure relevant styles are loaded, and that essential config vars needed between SpecialPage and a JS feature are added.
This relies on there being no overlap between modules or config vars added by the SpecialPage and those added by parser extensions. If there is overlap, then arise and break one or both sides. This is expected and unsupported.
OutputPage | $out |
Definition at line 1516 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::addTemplate | ( | $link, | |
$page_id, | |||
$rev_id ) |
Register a template dependency for this output.
ParsoidLinkTarget | $link | (used to require Title until 1.38) |
int | $page_id | |
int | $rev_id |
Definition at line 1357 of file ParserOutput.php.
References wfDeprecated().
MediaWiki\Parser\ParserOutput::addWarningMsg | ( | string | $msg, |
$args ) |
Add a warning to the output for this page.
string | $msg | The localization message key for the warning |
mixed|JsonDeserializable | ...$args Optional arguments for the message. These arguments must be serializable/deserializable with JsonCodec; see the |
Definition at line 1218 of file ParserOutput.php.
References wfDeprecatedMsg().
MediaWiki\Parser\ParserOutput::addWarningMsgVal | ( | MessageValue | $mv | ) |
Add a warning to the output for this page.
MessageValue | $mv |
Definition at line 1205 of file ParserOutput.php.
References Wikimedia\Message\MessageValue\getKey().
MediaWiki\Parser\ParserOutput::addWrapperDivClass | ( | $class | ) |
Add a CSS class to use for the wrapping div.
If no class is given, no wrapper is added.
string | $class |
Definition at line 567 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::appendExtensionData | ( | string | $key, |
$value, | |||
string | $strategy = self::MW_MERGE_STRATEGY_UNION ) |
Appends arbitrary data to this ParserObject.
This can be used to store some information in the ParserOutput object for later use during page output. The data will be cached along with the ParserOutput object, but unlike data set using setPageProperty(), it is not recorded in the database.
See setExtensionData() for more details on rationale and use.
In order to provide for out-of-order/asynchronous/incremental parsing, this method appends values to a set. See setExtensionData() for the flag-like version of this method.
string | $key | The key for accessing the data. Extensions should take care to avoid conflicts in naming keys. It is suggested to use the extension's name as a prefix. |
int | string | $value | The value to append to the list. |
string | $strategy | Merge strategy: only MW_MERGE_STRATEGY_UNION is currently supported and external callers should treat this parameter as |
Definition at line 2133 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::appendJsConfigVar | ( | string | $key, |
string | $value, | ||
string | $strategy = self::MW_MERGE_STRATEGY_UNION ) |
Append a value to a variable to be set in mw.config in JavaScript.
In order to ensure the result is independent of the parse order, the value of this key will be an associative array, mapping all of the values set under that key to true. (The array is implicitly ordered in PHP, but you should treat it as unordered.) If you want a non-array type for the key, and can ensure that only a single value will be set, you should use ::setJsConfigVar() instead.
string | $key | Key to use under mw.config |
string | $value | Value to append to the configuration variable. |
string | $strategy | Merge strategy: only MW_MERGE_STRATEGY_UNION is currently supported and external callers should treat this parameter as |
Definition at line 1480 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::appendOutputStrings | ( | string | $name, |
array | $value ) |
Provides a uniform interface to various string sets stored in the ParserOutput.
String sets internal to MediaWiki core should have names which are constants in ParserOutputStringSets. Extensions should use ::appendExtensionData() rather than creating new string sets with ::appendOutputStrings() in order to prevent namespace conflicts.
string | $name | A string set name |
string[] | $value |
Definition at line 1987 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::clearParseStartTime | ( | ) |
Unset the parse start time.
This is intended for testing purposes only, in order to avoid spurious differences between testing outputs created at different times.
Definition at line 2207 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::clearWrapperDivClass | ( | ) |
Clears the CSS class to use for the wrapping div, effectively disabling the wrapper div until addWrapperDivClass() is called.
Definition at line 575 of file ParserOutput.php.
Referenced by MediaWiki\Content\CssContentHandler\fillParserOutput(), MediaWiki\Content\JavaScriptContentHandler\fillParserOutput(), and MediaWiki\Content\TextContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::collectMetadata | ( | ContentMetadataCollector | $metadata | ) |
Adds the metadata collected in this ParserOutput to the supplied ContentMetadataCollector.
This is similar to ::mergeHtmlMetaDataFrom() but in the opposite direction, since ParserOutput is read/write while ContentMetadataCollector is write-only.
ContentMetadataCollector | $metadata |
Definition at line 2692 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::finalizeAdaptiveCacheExpiry | ( | ) |
Call this when parsing is done to lower the TTL based on low parse times.
Definition at line 2427 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getAllFlags | ( | ) |
Definition at line 1684 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getCacheMessage | ( | ) |
MediaWiki\Parser\ParserOutput::getCategoryMap | ( | ) |
Return category names and sort keys as a map.
BEWARE that numeric category names get converted to 'int' when stored as array keys. Because of this, use of this method is not recommended in new code; using ::getCategoryNames() and ::getCategorySortKey() will be less error-prone.
Definition at line 709 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getCategoryNames | ( | ) |
Return the names of the categories on this page.
Unlike ::getCategories(), sort keys are not included in the return value.
Definition at line 691 of file ParserOutput.php.
Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories(), and MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getCategorySortKey | ( | string | $name | ) |
Return the sort key for a given category name, or null
if the category is not present in this ParserOutput.
Returns the empty string if the category is to use the default sort key.
string | $name | The category name |
null
if the category is not present in this ParserOutput Definition at line 726 of file ParserOutput.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getContentHolderText | ( | ) |
Returns the content holder text of the ParserOutput.
This will eventually be replaced by something like getContentHolder()->getText() when we have a ContentHolder/HtmlHolder class.
Definition at line 3301 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getDisplayTitle | ( | ) |
Get the title to be used for display.
As per the contract of setDisplayTitle(), this is safe HTML, ready to be served to the client.
Definition at line 1566 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getEnableOOUI | ( | ) |
Definition at line 988 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getExtensionData | ( | $key | ) |
Gets extensions data previously attached to this ParserOutput using setExtensionData().
Typically, such data would be set while parsing the page, e.g. by a parser function.
string | $key | The key to look up. |
Definition at line 2165 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter\hasPageBundle().
& MediaWiki\Parser\ParserOutput::getExternalLinks | ( | ) |
Definition at line 909 of file ParserOutput.php.
Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getExternalLinks(), and MediaWiki\Deferred\LinksUpdate\ExternalLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getExtraCSPDefaultSrcs | ( | ) |
Get extra Content-Security-Policy 'default-src' directives.
Definition at line 997 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getExtraCSPScriptSrcs | ( | ) |
Get extra Content-Security-Policy 'script-src' directives.
Definition at line 1006 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getExtraCSPStyleSrcs | ( | ) |
Get extra Content-Security-Policy 'style-src' directives.
Definition at line 1015 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
& MediaWiki\Parser\ParserOutput::getFileSearchOptions | ( | ) |
Definition at line 899 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getHeadItems | ( | ) |
Definition at line 921 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getHideNewSection | ( | ) |
Definition at line 1255 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
& MediaWiki\Parser\ParserOutput::getImages | ( | ) |
Definition at line 894 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata(), and MediaWiki\Deferred\LinksUpdate\ImageLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getIndexPolicy | ( | ) |
Definition at line 955 of file ParserOutput.php.
Referenced by Article\getRobotPolicy().
MediaWiki\Parser\ParserOutput::getIndicators | ( | ) |
Definition at line 737 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getInterwikiLinks | ( | ) |
Definition at line 680 of file ParserOutput.php.
Referenced by MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getJsConfigVars | ( | bool | $showStrategyKeys = false | ) |
bool | $showStrategyKeys | Defaults to false; if set to true will expose the internal MW_MERGE_STRATEGY_KEY in the result. This should only be used internally to allow safe merge of config vars. |
Definition at line 940 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputContent(), and MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getLanguage | ( | ) |
Get the primary language code of the output.
This returns the primary language of the output, including any LanguageConverter variant applied.
NOTE: This may differ from the wiki's default content language ($wgLanguageCode, MediaWikiServices::getContentLanguage), because each page may have its own "page language" set (PageStoreRecord, Title::getDbPageLanguageCode, ContentHandler::getPageLanguage).
NOTE: This may differ from the "page language" when parsing user interface messages, in which case this reflects the user language (including any variant preference).
NOTE: This may differ from the Parser's "target language" that was set while the Parser was parsing the page, because the final output is converted to the current user's preferred LanguageConverter variant (assuming this is a variant of the target language). See Parser::getTargetLanguageConverter()->getPreferredVariant(); use LanguageFactory::getParentLanguage() on the language code to obtain the base language code. LanguageConverter::getPreferredVariant() depends on the global RequestContext for the URL and the User language preference.
Finally, note that a single ParserOutput object may contain HTML content in multiple different languages and directions (T114640). Authors of wikitext and of parser extensions are expected to mark such subtrees with a lang
attribute (set to a BCP-47 value, see Language::toBcp47Code()) and a corresponding dir
attribute (see Language::getDir()). This method returns the language code for wrapper of the HTML content.
null
if a language was not set. Definition at line 1612 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getLanguageLinks | ( | ) |
Definition at line 670 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata(), and MediaWiki\Deferred\LinksUpdate\LangLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getLimitReportData | ( | ) |
Definition at line 980 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getLimitReportJSData | ( | ) |
Definition at line 984 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getLinkList | ( | string | $linkType | ) |
Get a list of links of the given type.
Provides a uniform interface to various lists of links stored in the metadata.
Each element of the returned array has a LinkTarget as the 'link' property. Local and template links also have 'pageid' set. Template links have 'revid' set. Category links have 'sort' set. Media links optionally have 'time' and 'sha1' set.
string | $linkType | A link type, which should be a constant from ParserOutputLinkTypes. |
Definition at line 788 of file ParserOutput.php.
References NS_CATEGORY, NS_FILE, NS_MAIN, and NS_SPECIAL.
& MediaWiki\Parser\ParserOutput::getLinks | ( | ) |
Definition at line 870 of file ParserOutput.php.
Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getOutgoingLinks(), and MediaWiki\Deferred\LinksUpdate\PageLinksTable\setParserOutput().
& MediaWiki\Parser\ParserOutput::getLinksSpecial | ( | ) |
Definition at line 879 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getModules | ( | ) |
Definition at line 925 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputContent(), and MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getModuleStyles | ( | ) |
Definition at line 929 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputContent(), and MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getNewSection | ( | ) |
Definition at line 1259 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getNoGallery | ( | ) |
Definition at line 917 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getOutputFlag | ( | string | $name | ) |
Provides a uniform interface to various boolean flags stored in the ParserOutput.
Flags internal to MediaWiki core should have names which are constants in ParserOutputFlags. Extensions should only use ::getOutputFlag() to query flags defined in ParserOutputFlags in core; they should use getExtensionData() to define their own flags.
string | $name | A flag name |
Definition at line 1947 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata(), and MediaWiki\OutputTransform\Stages\HandleParsoidSectionLinks\transformDOM().
MediaWiki\Parser\ParserOutput::getOutputStrings | ( | string | $name | ) |
Provides a uniform interface to various boolean string sets stored in the ParserOutput.
String sets internal to MediaWiki core should have names which are constants in ParserOutputStringSets. Extensions should only use ::getOutputStrings() to query string sets defined in ParserOutputStringSets in core; they should use ::appendExtensionData() to define their own string sets.
string | $name | A string set name |
Definition at line 2027 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getPageProperties | ( | ) |
Return all the page properties set on this ParserOutput.
Definition at line 1868 of file ParserOutput.php.
Referenced by MediaWiki\Deferred\LinksUpdate\PagePropsTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getPageProperty | ( | string | $name | ) |
Look up a page property.
string | $name | The page property name to look up. |
Definition at line 1850 of file ParserOutput.php.
Referenced by MediaWiki\Deferred\LinksUpdate\CategoryLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getPreventClickjacking | ( | ) |
Get the prevent-clickjacking flag.
Definition at line 2372 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getRawText | ( | ) |
Get the cacheable text with <mw:editsection> markers still in it.
The return value is suitable for writing back via setText() but is not valid for display to the user.
Definition at line 417 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getRedirectHeader | ( | ) |
Return an HTML prefix to be applied on redirect pages, or null if this is not a redirect.
Definition at line 1639 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getRenderId | ( | ) |
Return the unique rendering id for this ParserOutput.
This is used whenever a client needs to record a dependency on a specific parse.
Definition at line 1670 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and MediaWiki\Parser\ParserCache\save().
MediaWiki\Parser\ParserOutput::getRevisionTimestamp | ( | ) |
Definition at line 968 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save().
MediaWiki\Parser\ParserOutput::getRevisionTimestampUsed | ( | ) |
Definition at line 634 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getRevisionUsedSha1Base36 | ( | ) |
Definition at line 661 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getSections | ( | ) |
MediaWiki\Parser\ParserOutput::getSpeculativePageIdUsed | ( | ) |
MediaWiki\Parser\ParserOutput::getSpeculativeRevIdUsed | ( | ) |
& MediaWiki\Parser\ParserOutput::getTemplateIds | ( | ) |
Definition at line 889 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
& MediaWiki\Parser\ParserOutput::getTemplates | ( | ) |
Definition at line 884 of file ParserOutput.php.
Referenced by MediaWiki\Search\ParserOutputSearchDataExtractor\getTemplates(), and MediaWiki\Deferred\LinksUpdate\TemplateLinksTable\setParserOutput().
MediaWiki\Parser\ParserOutput::getText | ( | $options = [] | ) |
Get the output HTML.
T293512: in the future, ParserOutput::getText() will be deprecated in favor of invoking the OutputTransformPipeline directly on a ParserOutput.
array | $options | (since 1.31) Transformations to apply to the HTML
|
__NOTOC__
wasn't used. Default is true, but might be statefully overridden.<style>
tags with the data-mw-deduplicate
attribute set are deduplicated by value of the attribute: all but the first will be replaced by <link rel="mw-deduplicated-inline-style" href="mw-data:..."/>
tags, where the scheme-specific-part of the href is the (percent-encoded) value of the data-mw-deduplicate
attribute.Definition at line 469 of file ParserOutput.php.
Referenced by MediaWiki\Status\StatusFormatter\getHTML(), and MediaWiki\Message\Message\parseText().
MediaWiki\Parser\ParserOutput::getTimeProfile | ( | string | $clock | ) |
Returns the time that elapsed between the most recent call to resetParseStartTime() and the first call to recordTimeProfile() after that.
Clocks available are:
If recordTimeProfile() has noit been called since the most recent call to resetParseStartTime(), or if resetParseStartTime() was never called, then this method will return null.
string | $clock |
Definition at line 2256 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\ParsoidParser\makeLimitReport().
MediaWiki\Parser\ParserOutput::getTimeSinceStart | ( | $clock | ) |
Returns the time since resetParseStartTime() was last called.
Clocks available are:
string | $clock |
Definition at line 2272 of file ParserOutput.php.
References wfDeprecated().
MediaWiki\Parser\ParserOutput::getTimestamp | ( | ) |
Definition at line 976 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getTitleText | ( | ) |
Definition at line 741 of file ParserOutput.php.
Referenced by Article\adjustDisplayTitle().
MediaWiki\Parser\ParserOutput::getTOCData | ( | ) |
Definition at line 749 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::getWarnings | ( | ) |
Definition at line 951 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::getWrapperDivClass | ( | ) |
Returns the class (or classes) to be used with the wrapper div for this output.
If there is no wrapper class given, no wrapper div should be added. The wrapper div is added automatically by getText().
Definition at line 586 of file ParserOutput.php.
Referenced by MediaWiki\Output\OutputPage\addParserOutputMetadata().
MediaWiki\Parser\ParserOutput::hasReducedExpiry | ( | ) |
Check whether the cache TTL was lowered from the site default.
When content is determined by more than hard state (e.g. page edits), such as template/file transclusions based on the current timestamp or extension tags that generate lists based on queries, this return true.
This method mainly exists to facilitate the logic in WikiPage::triggerOpportunisticLinksUpdate. As such, beware that reducing the TTL for reasons that do not relate to "dynamic content", may have the side-effect of incurring more RefreshLinksJob executions.
Definition at line 2342 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\ParsoidParser\makeLimitReport(), and WikiPage\triggerOpportunisticLinksUpdate().
MediaWiki\Parser\ParserOutput::hasText | ( | ) |
Returns true if text was passed to the constructor, or set using setText().
Returns false if null was passed to the $text parameter of the constructor to indicate that this ParserOutput only contains meta-data, and the HTML output is undetermined.
Definition at line 405 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and MediaWiki\Parser\ParserCache\save().
|
protected |
Initialize member fields from an array returned by jsonSerialize().
JsonDeserializer | $deserializer | |
array | $jsonData |
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 3066 of file ParserOutput.php.
|
static |
Checks, if a url is pointing to the own server.
string | $internal | The server to check against |
string | $url | The url to check |
Definition at line 1271 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::mergeHtmlMetaDataFrom | ( | ParserOutput | $source | ) |
Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source into this ParserOutput.
This should be used whenever the HTML in $source has been somehow merged into the HTML of this ParserOutput.
ParserOutput | $source |
Definition at line 2574 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter\parserOutputFromPageBundle().
MediaWiki\Parser\ParserOutput::mergeInternalMetaDataFrom | ( | ParserOutput | $source | ) |
Merges internal metadata such as flags, accessed options, and profiling info from $source into this ParserOutput.
This should be used whenever the state of $source has any impact on the state of this ParserOutput.
ParserOutput | $source |
Definition at line 2500 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::mergeTrackingMetaDataFrom | ( | ParserOutput | $source | ) |
Merges dependency tracking metadata such as backlinks, images used, and extension data from $source into this ParserOutput.
This allows dependency tracking to be done for the combined output of multiple content slots.
ParserOutput | $source |
Definition at line 2652 of file ParserOutput.php.
|
static |
Creates a new instance of the class and initialized it from the $json array.
JsonDeserializer | $deserializer | an instance of JsonDeserializer to use for nested properties if they need special care. |
array | $json |
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 3055 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::recordTimeProfile | ( | ) |
Record the time since resetParseStartTime() was last called.
The recorded time can be accessed using getTimeProfile().
After resetParseStartTime() was called, the first call to recordTimeProfile() will record the time profile. Subsequent calls to recordTimeProfile() will have no effect until resetParseStartTime() is called again.
Definition at line 2221 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::resetParseStartTime | ( | ) |
Resets the parse start timestamps for future calls to getTimeSinceStart() and recordTimeProfile().
Definition at line 2193 of file ParserOutput.php.
Referenced by MediaWiki\Parser\ParserOutput\__construct().
MediaWiki\Parser\ParserOutput::runOutputPipeline | ( | ParserOptions | $popts, |
array | $options = [] ) |
ParserOptions | $popts | |
array | $options | (since 1.31) Transformations to apply to the HTML
|
__NOTOC__
wasn't used. Default is true, but might be statefully overridden.<style>
tags with the data-mw-deduplicate
attribute set are deduplicated by value of the attribute: all but the first will be replaced by <link rel="mw-deduplicated-inline-style" href="mw-data:..."/>
tags, where the scheme-specific-part of the href is the (percent-encoded) value of the data-mw-deduplicate
attribute.Definition at line 526 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setCategories | ( | array | $c | ) |
Overwrite the category map.
array<string,string> | $c Map of category names to sort keys |
Definition at line 1150 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setContentHolderText | ( | string | $s | ) |
Sets the content holder text of the ParserOutput.
This will eventually be replaced by something like getContentHolder()->setText() when we have a ContentHolder/HtmlHolder class.
Definition at line 3312 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setDisplayTitle | ( | $text | ) |
Override the title to be used for display.
string | $text | Desired title text |
Definition at line 1553 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setEnableOOUI | ( | bool | $enable = false | ) |
Enables OOUI, if true, in any OutputPage instance this ParserOutput object is added to.
bool | $enable | If OOUI should be enabled or not |
Definition at line 1171 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setExtensionData | ( | $key, | |
$value ) |
Attaches arbitrary data to this ParserObject.
This can be used to store some information in the ParserOutput object for later use during page output. The data will be cached along with the ParserOutput object, but unlike data set using setPageProperty(), it is not recorded in the database.
This method is provided to overcome the unsafe practice of attaching extra information to a ParserObject by directly assigning member variables.
To use setExtensionData() to pass extension information from a hook inside the parser to a hook in the page output, use this in the parser hook:
And then later, in OutputPageParserOutput or similar:
In MediaWiki 1.20 and older, you have to use a custom member variable within the ParserOutput object:
string | $key | The key for accessing the data. Extensions should take care to avoid conflicts in naming keys. It is suggested to use the extension's name as a prefix. |
mixed | JsonDeserializable | $value | The value to set. Setting a value to null is equivalent to removing the value. |
Definition at line 2093 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setFromParserOptions | ( | ParserOptions | $parserOptions | ) |
Transfer parser options which affect post-processing from ParserOptions to this ParserOutput.
ParserOptions | $parserOptions |
Definition at line 2452 of file ParserOutput.php.
References MediaWiki\Parser\ParserOptions\getCollapsibleSections(), MediaWiki\Parser\ParserOptions\getInterfaceMessage(), MediaWiki\Parser\ParserOptions\getIsPreview(), MediaWiki\Parser\ParserOptions\getSuppressSectionEditLinks(), and MediaWiki\Parser\ParserOptions\getWrapOutputClass().
MediaWiki\Parser\ParserOutput::setHideNewSection | ( | bool | $value | ) |
bool | $value | Hide the new section link? |
Definition at line 1251 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setIndexPolicy | ( | $policy | ) |
Update the index policy of the robots meta tag.
Note that calling this method does not guarantee that self::getIndexPolicy()
will return the given policy – if different calls set the index policy to 'index' and 'noindex', then 'noindex' always wins (T16899), even if the 'index' call happened later. If this is not what you want, you can reset ParserOutputFlags::NO_INDEX_POLICY
with self::setOutputFlag()
.
string | $policy | 'index' or 'noindex'. |
Definition at line 1096 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setIndicator | ( | $id, | |
$content ) |
MediaWiki\Parser\ParserOutput::setJsConfigVar | ( | string | $key, |
$value ) |
Add a variable to be set in mw.config in JavaScript.
In order to ensure the result is independent of the parse order, the values set here must be unique – that is, you can pass the same $key multiple times but ONLY if the $value is identical each time. If you want to collect multiple pieces of data under a single key, use ::appendJsConfigVar().
string | $key | Key to use under mw.config |
mixed | null | $value | Value of the configuration variable. |
Definition at line 1450 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setLanguage | ( | Bcp47Code | $lang | ) |
Set the primary language of the output.
See the discussion and caveats in ::getLanguage().
Bcp47Code | $lang | The primary language for this output, including any variant specification. |
Definition at line 1629 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter\applyPageBundleDataToParserOutput().
MediaWiki\Parser\ParserOutput::setLanguageLinks | ( | $ll | ) |
Definition at line 1050 of file ParserOutput.php.
References wfDeprecated().
MediaWiki\Parser\ParserOutput::setLimitReportData | ( | $key, | |
$value ) |
Sets parser limit report data for a key.
The key is used as the prefix for various messages used for formatting:
Note that all values are interpreted as wikitext, and so should be encoded with htmlspecialchars() as necessary, but should avoid complex HTML for display in the "NewPP limit report" comment.
string | $key | Message key |
mixed | $value | Appropriate for Message::params() |
Definition at line 2302 of file ParserOutput.php.
Referenced by MediaWiki\Parser\Parsoid\ParsoidParser\makeLimitReport().
MediaWiki\Parser\ParserOutput::setNewSection | ( | $value | ) |
Definition at line 1244 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setNoGallery | ( | $value | ) |
Definition at line 913 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setNumericPageProperty | ( | string | $propName, |
$numericValue ) |
Set a numeric page property whose value is intended to be sorted and indexed.
The sort key used for the property will be the value, coerced to a number.
See ::setPageProperty()
for details.
In the future, we may allow the value to be specified independent of sort key (T357783).
string | $propName | The name of the page property |
int | float | string | $numericValue | the numeric value |
Definition at line 1808 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setOutputFlag | ( | string | $name, |
bool | $val = true ) |
Provides a uniform interface to various boolean flags stored in the ParserOutput.
Flags internal to MediaWiki core should have names which are constants in ParserOutputFlags. Extensions should use setExtensionData() rather than creating new flags with ::setOutputFlag() in order to prevent namespace conflicts.
Flags are always combined with OR. That is, the flag is set in the resulting ParserOutput if the flag is set in any of the fragments composing the ParserOutput.
string | $name | A flag name |
bool | $val |
Definition at line 1895 of file ParserOutput.php.
Referenced by MediaWiki\Content\CssContentHandler\fillParserOutput(), MediaWiki\Content\JavaScriptContentHandler\fillParserOutput(), and MediaWiki\Content\WikitextContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::setPageProperty | ( | string | $name, |
$value ) |
Set a page property to be stored in the page_props database table.
page_props is a key-value store indexed by the page ID. This allows the parser to set a property on a page which can then be quickly retrieved given the page ID or via a DB join when given the page title.
Since 1.23, page_props are also indexed by numeric value, to allow for efficient "top k" queries of pages wrt a given property. This only works if the value is passed as a int, float, or bool. Since 1.42 you should use ::setNumericPageProperty() if you want your page property value to be indexed, which will ensure that the value is of the proper type.
setPageProperty() is thus used to propagate properties from the parsed page to request contexts other than a page view of the currently parsed article.
Some applications examples:
string|int|float|bool
) has been deprecated in 1.42. Although any JSON-serializable value can be stored/fetched in ParserOutput, when the values are stored to the database (in deferred/LinksUpdate/PagePropsTable.php
) they will be converted: booleans will be converted to '0' and '1', null will become '', and everything else will be cast to string (not JSON-serialized). Page properties obtained from the PageProps service will thus always be strings.int|float|bool
. If you do not want your property value indexed and sorted (for example, the value is a title string which can be numeric but only incidentally, like when it gets retrieved from an array key) be sure to cast to string or use ::setUnsortedPageProperty()
. If you do want your property value indexed and sorted, you should use ::setNumericPageProperty()
instead as this will ensure the value type is correct. Note that either way it is possible to efficiently look up all the pages with a certain property; we are only talking about sorting the values assigned to the property, for example for a "top N values of the property" query.::getPageProperty()
/::setPageProperty()
do not do any conversions themselves; you should therefore be careful to distinguish values returned from the PageProp service (always strings) from values retrieved from a ParserOutput.And then later, in OutputPageParserOutput or similar:
null
as a value is deprecated since 1.42; use the empty string instead if you need a placeholder value, or ::unsetPageProperty() if you mean to remove a page property.string | $name | |
?scalar | $value |
Definition at line 1780 of file ParserOutput.php.
References wfDeprecated().
MediaWiki\Parser\ParserOutput::setPreventClickjacking | ( | bool | $flag | ) |
Set the prevent-clickjacking flag.
If set this will cause an X-Frame-Options
header appropriate for edit pages to be sent. The header value is controlled by $wgEditPageFrameOptions
.
This is the default for special pages. If you display a CSRF-protected form on an ordinary view page, then you need to call this function with $flag = true
.
bool | $flag | New flag value |
Definition at line 2361 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setRawText | ( | ?string | $text | ) |
Set the raw text of the ParserOutput.
If you did not generate html, pass null to mark it as such.
string | null | $text | HTML content of ParserOutput or null if not generated |
Definition at line 1028 of file ParserOutput.php.
Referenced by MediaWiki\Content\CssContentHandler\fillParserOutput(), MediaWiki\Content\FallbackContentHandler\fillParserOutput(), MediaWiki\Content\JavaScriptContentHandler\fillParserOutput(), MediaWiki\Content\TextContentHandler\fillParserOutput(), MediaWiki\Content\JsonContentHandler\fillParserOutput(), MediaWiki\Content\WikitextContentHandler\fillParserOutput(), MediaWiki\Pager\TablePager\getBodyOutput(), and MediaWiki\Pager\TablePager\getFullOutput().
MediaWiki\Parser\ParserOutput::setRedirectHeader | ( | string | $html | ) |
Set an HTML prefix to be applied on redirect pages.
string | $html | HTML to prepend to redirect pages |
Definition at line 1647 of file ParserOutput.php.
Referenced by MediaWiki\Content\WikitextContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::setRenderId | ( | string | $renderId | ) |
Store a unique rendering id for this ParserOutput.
This is used whenever a client needs to record a dependency on a specific parse. It is typically set only when a parser output is cached.
string | $renderId | a UUID identifying a specific parse |
Definition at line 1659 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save(), and MediaWiki\Parser\ParserCache\save().
MediaWiki\Parser\ParserOutput::setRevisionTimestamp | ( | ?string | $timestamp | ) |
?string | $timestamp | TS_MW timestamp of the revision content |
Definition at line 1109 of file ParserOutput.php.
Referenced by MediaWiki\Parser\RevisionOutputCache\save().
MediaWiki\Parser\ParserOutput::setRevisionTimestampUsed | ( | $timestamp | ) |
string | $timestamp | TS_MW timestamp |
Definition at line 626 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setRevisionUsedSha1Base36 | ( | $hash | ) |
string | $hash | Lowercase SHA-1 base 36 hash |
Definition at line 642 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::setSections | ( | array | $sectionArray | ) |
array | $sectionArray |
Definition at line 1077 of file ParserOutput.php.
Referenced by MediaWiki\Content\CssContentHandler\fillParserOutput(), and MediaWiki\Content\JavaScriptContentHandler\fillParserOutput().
MediaWiki\Parser\ParserOutput::setSpeculativePageIdUsed | ( | $id | ) |
MediaWiki\Parser\ParserOutput::setSpeculativeRevIdUsed | ( | $id | ) |
MediaWiki\Parser\ParserOutput::setText | ( | $text | ) |
Set the raw text of the ParserOutput.
If you did not generate html, pass null to mark it as such.
string | null | $text | HTML content of ParserOutput or null if not generated |
Definition at line 1043 of file ParserOutput.php.
References wfSetVar().
MediaWiki\Parser\ParserOutput::setTimestamp | ( | $timestamp | ) |
?string | $timestamp | TS_MW timestamp of the revision content |
Definition at line 1119 of file ParserOutput.php.
References wfSetVar().
MediaWiki\Parser\ParserOutput::setTitleText | ( | $t | ) |
Definition at line 1062 of file ParserOutput.php.
References wfSetVar().
MediaWiki\Parser\ParserOutput::setTOCData | ( | TOCData | $tocData | ) |
TOCData | $tocData | Table of contents data for the page |
Definition at line 1069 of file ParserOutput.php.
Referenced by MediaWiki\Specials\SpecialVersion\execute(), MediaWiki\Specials\SpecialEditWatchlist\executeViewEditWatchlist(), and MediaWiki\Api\ApiHelp\getHelp().
MediaWiki\Parser\ParserOutput::setUnsortedPageProperty | ( | string | $propName, |
string | $value = '' ) |
Set a page property whose value is not intended to be sorted and indexed.
See ::setPageProperty()
for details. It is recommended to use the empty string if you need a placeholder value (ie, if it is the presence of the property which is important, not the value the property is set to).
It is still possible to efficiently look up all the pages with a certain property (the "presence" of it is indexed; see Special:PagesWithProp, list=pageswithprop).
string | $propName | The name of the page property |
string | $value | Optional value; defaults to the empty string. |
Definition at line 1833 of file ParserOutput.php.
|
protected |
Returns a JSON serializable structure representing this ParserOutput instance.
Reimplemented from MediaWiki\Parser\CacheTime.
Definition at line 2978 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::unsetPageProperty | ( | string | $name | ) |
Remove a page property.
string | $name | The page property name. |
Definition at line 1859 of file ParserOutput.php.
MediaWiki\Parser\ParserOutput::updateRuntimeAdaptiveExpiry | ( | $ttl | ) |
Lower the runtime adaptive TTL to at most this value.
int | $ttl |
Definition at line 2382 of file ParserOutput.php.
const MediaWiki\Parser\ParserOutput::MW_MERGE_STRATEGY_KEY = '_mw-strategy' |
const MediaWiki\Parser\ParserOutput::MW_MERGE_STRATEGY_UNION = 'union' |
Merge strategy to use for ParserOutput accumulators: "union" means that values are strings, stored as a set, and exposed as a PHP associative array mapping from values to true
.
This constant should be treated as
Definition at line 130 of file ParserOutput.php.
const MediaWiki\Parser\ParserOutput::SUPPORTS_STATELESS_TRANSFORMS = 1 |
Feature flags to indicate to extensions that MediaWiki core supports and uses getText() stateless transforms.
Definition at line 107 of file ParserOutput.php.
const MediaWiki\Parser\ParserOutput::SUPPORTS_UNWRAP_TRANSFORM = 1 |
Definition at line 112 of file ParserOutput.php.