|
MediaWiki master
|
Inherits JsonCodecable.

Public Member Functions | |
| __clone () | |
| addFragment (string $name=self::BODY_FRAGMENT, ?string $html=null) | |
| appendDom (DocumentFragment $df, string $fragmentName=self::BODY_FRAGMENT) | |
| Helper method to append the given DocumentFragment to the named content fragment. | |
| appendHtmlString (string $html, string $fragmentName=self::BODY_FRAGMENT) | |
| Helper method to append the given HTML string to the named content fragment. | |
| createFragment (?string $html=null) | |
| getAsDom (string $fragmentName=self::BODY_FRAGMENT) | |
| Returns the designated fragment as a DOM DocumentFragment, or null if it is not present. | |
| getAsHtmlString (string $fragmentName=self::BODY_FRAGMENT) | |
| Returns the designated fragment as an HTML string version, or null if it is not present. | |
| getBasePageBundle () | |
| Return the BasePageBundle of the ContentHolder. | |
| getFragmentNames (bool $bodyFirst=false) | |
| Return all the fragment names. | |
| has (string $fragmentName) | |
| Returns false if the designated fragment is not present in the ContentHolder. | |
| hasContent () | |
| isParsoidContent () | |
| Returns true if this ContentHolder contains Parsoid-generated content. | |
| preferDom () | |
| Given a ContentHolderTransformStage that has two valid transform options, returns true if the state of the ContentHolder calls for a DOM transform, false if it calls for a text transform. | |
| prependDom (DocumentFragment $df, string $fragmentName=self::BODY_FRAGMENT) | |
| Helper method to prepend the given DocumentFragment to the named content fragment. | |
| prependHtmlString (string $html, string $fragmentName=self::BODY_FRAGMENT) | |
| Helper method to prepend the given HTML string to the named content fragment. | |
| setAsDom (string $fragmentName=self::BODY_FRAGMENT, ?DocumentFragment $fragment=null) | |
| Sets or removes a fragment, provided as a DOM DocumentFragment. | |
| setAsHtmlString (string $fragmentName=self::BODY_FRAGMENT, ?string $html=null) | |
| Sets or removes a fragment, provided as an HTML string. | |
| toJsonArray () | |
Static Public Member Functions | |
| static | createEmpty () |
| Creates an empty ContentHolder that can be used as a placeholder. | |
| static | createFromLegacyString (string $html) |
| Create a ContentHolder from a legacy body HTML string, typically returned by the legacy parser. | |
| static | createFromParsoidPageBundle (HtmlPageBundle $pb, ?SiteConfig $siteConfig=null) |
| Create a ContentHolder from a Parsoid HtmlPageBundle. | |
| static | jsonClassHintFor (string $keyName) |
| static | newFromJsonArray (array $json) |
Public Attributes | |
| const | BODY_FRAGMENT = "body" |
A ContentHolder holds a map of fragments that can be HTML string or DOM fragments. It should, as much as possible, be used in a consistent format and/or limit format switches, as conversions of all the fragments happen on all accessors, which has a performance impact.
The canonical body fragment is body-only: getAsHtmlString( BODY_FRAGMENT ) returns just the <body> contents, and the full document (with <head>) is generated when needed with PageBundleParserOutputConverter::htmlPageBundleFromParserOutput(). Pre-MW-1.47 ParserCache entries may still contain a full HTML document in the BODY_FRAGMENT, and that wrapper is stripped in ::getAsHtmlString().
Definition at line 43 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::__clone | ( | ) |
Definition at line 482 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::addFragment | ( | string | $name = self::BODY_FRAGMENT, |
| ?string | $html = null ) |
Definition at line 361 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::appendDom | ( | DocumentFragment | $df, |
| string | $fragmentName = self::BODY_FRAGMENT ) |
Helper method to append the given DocumentFragment to the named content fragment.
Definition at line 285 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::appendHtmlString | ( | string | $html, |
| string | $fragmentName = self::BODY_FRAGMENT ) |
Helper method to append the given HTML string to the named content fragment.
Definition at line 271 of file ContentHolder.php.
|
static |
Creates an empty ContentHolder that can be used as a placeholder.
This does not contain any body content.
Definition at line 129 of file ContentHolder.php.
Referenced by MediaWiki\Parser\ParserOutput\__construct().
| MediaWiki\Parser\ContentHolder::createFragment | ( | ?string | $html = null | ) |
Definition at line 348 of file ContentHolder.php.
|
static |
Create a ContentHolder from a legacy body HTML string, typically returned by the legacy parser.
Definition at line 89 of file ContentHolder.php.
Referenced by MediaWiki\Parser\ParserOutput\__construct().
|
static |
Create a ContentHolder from a Parsoid HtmlPageBundle.
Definition at line 101 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::getAsDom | ( | string | $fragmentName = self::BODY_FRAGMENT | ) |
Returns the designated fragment as a DOM DocumentFragment, or null if it is not present.
Definition at line 188 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::getAsHtmlString | ( | string | $fragmentName = self::BODY_FRAGMENT | ) |
Returns the designated fragment as an HTML string version, or null if it is not present.
bodyOnly: false to obtain a full document. Definition at line 168 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::getBasePageBundle | ( | ) |
Return the BasePageBundle of the ContentHolder.
Definition at line 397 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::getFragmentNames | ( | bool | $bodyFirst = false | ) |
Return all the fragment names.
You can pass bodyFirst: true in cases where the order of fragments matters, which will ensure that the first element is self::BODY_FRAGMENT (if it exists in this ContentHolder).
| bool | $bodyFirst | Pass true to get a repeatable sorted list of fragments with the body fragment first. |
Definition at line 376 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::has | ( | string | $fragmentName | ) |
Returns false if the designated fragment is not present in the ContentHolder.
Definition at line 153 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::hasContent | ( | ) |
Definition at line 502 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::isParsoidContent | ( | ) |
Returns true if this ContentHolder contains Parsoid-generated content.
Definition at line 140 of file ContentHolder.php.
|
static |
Definition at line 543 of file ContentHolder.php.
|
static |
Definition at line 524 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::preferDom | ( | ) |
Given a ContentHolderTransformStage that has two valid transform options, returns true if the state of the ContentHolder calls for a DOM transform, false if it calls for a text transform.
Right now, this is strictly directed by whether the ContentHolder is in DOM format or in HTML format; this might change in the future if we maintain both formats in some cases.
Definition at line 498 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::prependDom | ( | DocumentFragment | $df, |
| string | $fragmentName = self::BODY_FRAGMENT ) |
Helper method to prepend the given DocumentFragment to the named content fragment.
Definition at line 250 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::prependHtmlString | ( | string | $html, |
| string | $fragmentName = self::BODY_FRAGMENT ) |
Helper method to prepend the given HTML string to the named content fragment.
Definition at line 236 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::setAsDom | ( | string | $fragmentName = self::BODY_FRAGMENT, |
| ?DocumentFragment | $fragment = null ) |
Sets or removes a fragment, provided as a DOM DocumentFragment.
| string | $fragmentName | name of the fragment to set |
| DocumentFragment | null | $fragment | the fragment to set, or null to remove a fragment. |
Definition at line 314 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::setAsHtmlString | ( | string | $fragmentName = self::BODY_FRAGMENT, |
| ?string | $html = null ) |
Sets or removes a fragment, provided as an HTML string.
| string | $fragmentName | name of the fragment to set |
| string | null | $html | string of the fragment to set, or null to remove a fragment. |
Definition at line 207 of file ContentHolder.php.
| MediaWiki\Parser\ContentHolder::toJsonArray | ( | ) |
Definition at line 509 of file ContentHolder.php.
| const MediaWiki\Parser\ContentHolder::BODY_FRAGMENT = "body" |
Definition at line 46 of file ContentHolder.php.