MediaWiki
master
|
Base implementation for content objects. More...
Public Member Functions | |
__construct ( $modelId=null) | |
Stable to call. More... | |
addSectionHeader ( $header) | |
Stable to override. More... | |
convert ( $toModel, $lossy='') | |
This base implementation calls the hook ConvertContent to enable custom conversions. More... | |
equals (Content $that=null) | |
Decides whether two Content objects are equal. More... | |
getContentHandler () | |
getDefaultFormat () | |
getDeletionUpdates (WikiPage $page, ParserOutput $parserOutput=null) | |
Stable to override. More... | |
getModel () | |
getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true) | |
Returns a ParserOutput object containing information derived from this content. More... | |
getRedirectChain () | |
getRedirectTarget () | |
Subclasses that implement redirects should override this. More... | |
getSecondaryDataUpdates (Title $title, Content $old=null, $recursive=true, ParserOutput $parserOutput=null) | |
Returns a list of DataUpdate objects for recording information about this Content in some secondary data store. More... | |
getSection ( $sectionId) | |
Stable to override. More... | |
getSupportedFormats () | |
getUltimateRedirectTarget () | |
isEmpty () | |
Stable to override. More... | |
isRedirect () | |
isSupportedFormat ( $format) | |
isValid () | |
Subclasses may override this to implement (light weight) validation. More... | |
matchMagicWord (MagicWord $word) | |
This default implementation always returns false. More... | |
preloadTransform (Title $title, ParserOptions $popts, $params=[]) | |
Stable to override. More... | |
prepareSave (WikiPage $page, $flags, $parentRevId, User $user) | |
Stable to override. More... | |
preSaveTransform (Title $title, User $user, ParserOptions $popts) | |
Stable to override. More... | |
replaceSection ( $sectionId, Content $with, $sectionTitle='') | |
Stable to override. More... | |
serialize ( $format=null) | |
Stable to override. More... | |
updateRedirect (Title $target) | |
This default implementation always returns $this. More... | |
![]() | |
copy () | |
Return a copy of this Content object. More... | |
getNativeData () | |
Returns native representation of the data. More... | |
getSize () | |
Returns the content's nominal size in "bogo-bytes". More... | |
getTextForSearchIndex () | |
getTextForSummary ( $maxLength=250) | |
Returns a textual representation of the content suitable for use in edit summaries and log messages. More... | |
getWikitextForTransclusion () | |
isCountable ( $hasLinks=null) | |
Returns true if this content is countable as a "real" wiki page, provided that it's also in a countable location (e.g. More... | |
Protected Member Functions | |
checkFormat ( $format) | |
checkModelID ( $modelId) | |
equalsInternal (Content $that) | |
Checks whether $that is logically equal to this Content object. More... | |
fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) | |
Fills the provided ParserOutput with information derived from the content. More... | |
getContentHandlerFactory () | |
Protected Attributes | |
string | $model_id |
Name of the content model this Content object represents. More... | |
Base implementation for content objects.
Stable to extend
Definition at line 39 of file AbstractContent.php.
AbstractContent::__construct | ( | $modelId = null | ) |
Stable to call.
string | null | $modelId |
Reimplemented in WikitextContent.
Definition at line 57 of file AbstractContent.php.
AbstractContent::addSectionHeader | ( | $header | ) |
Stable to override.
string | $header |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 452 of file AbstractContent.php.
|
protected |
string | $format | The serialization format to check. |
MWException | If the format is not supported by this content handler. |
Definition at line 150 of file AbstractContent.php.
References getModel(), and isSupportedFormat().
|
protected |
string | $modelId | The model to check |
MWException | If the provided ID is not the ID of the content model supported by this Content object. |
Definition at line 79 of file AbstractContent.php.
Referenced by TextContent\diff().
AbstractContent::convert | ( | $toModel, | |
$lossy = '' |
|||
) |
This base implementation calls the hook ConvertContent to enable custom conversions.
Subclasses may override this to implement conversion for "their" content model.
Stable to override
string | $toModel | |
string | $lossy |
Implements Content.
Reimplemented in TextContent, and FallbackContent.
Definition at line 538 of file AbstractContent.php.
References getModel(), and Hooks\runner().
AbstractContent::equals | ( | Content | $that = null | ) |
Decides whether two Content objects are equal.
Two Content objects MUST not be considered equal if they do not share the same content model. Two Content objects that are equal SHOULD have the same serialization.
This default implementation relies on equalsInternal() to determin whether the Content objects are logically equivalent. Subclasses that need to implement a custom equality check should consider overriding equalsInternal(). Subclasses that override equals() itself MUST make sure that the implementation returns false for $that === null, and true for $that === this. It MUST also return false if $that does not have the same content model.
Stable to override
Content | null | $that |
Implements Content.
Definition at line 220 of file AbstractContent.php.
References equalsInternal().
Referenced by CssContent\getRedirectTarget(), and JavaScriptContent\getRedirectTarget().
|
protected |
Checks whether $that is logically equal to this Content object.
This method can be overwritten by subclasses that need to implement custom equality checks.
This default implementation checks whether the serializations of $this and $that are the same: $this->serialize() === $that->serialize()
Implementors can assume that $that is an instance of the same class as the present Content object, as long as equalsInternal() is only called by the standard implementation of equals().
Stable to override
Content | $that |
Reimplemented in FallbackContent.
Definition at line 261 of file AbstractContent.php.
References serialize(), and Content\serialize().
Referenced by equals().
|
protected |
Fills the provided ParserOutput with information derived from the content.
Unless $generateHtml was false, this includes an HTML representation of the content.
This is called by getParserOutput() after consulting the ContentGetParserOutput hook. Subclasses are expected to override this method (or getParserOutput(), if need be). Subclasses of TextContent should generally override getHtml() instead.
This placeholder implementation always throws an exception.
Stable to override
Title | $title | Context title for parsing |
int | null | $revId | ID of the revision being rendered. See Parser::parse() for the ramifications. |
ParserOptions | $options | |
bool | $generateHtml | Whether or not to generate HTML |
ParserOutput | &$output | The output object to fill (reference). |
MWException |
Reimplemented in WikitextContent, TextContent, JsonContent, and FallbackContent.
Definition at line 624 of file AbstractContent.php.
Referenced by getParserOutput().
AbstractContent::getContentHandler | ( | ) |
Implements Content.
Definition at line 95 of file AbstractContent.php.
References getContentHandlerFactory(), and getModel().
Referenced by getDefaultFormat(), CssContent\getRedirectTarget(), JavaScriptContent\getRedirectTarget(), getSupportedFormats(), isSupportedFormat(), serialize(), CssContent\updateRedirect(), and JavaScriptContent\updateRedirect().
|
protected |
Definition at line 102 of file AbstractContent.php.
Referenced by TextContent\convert(), and getContentHandler().
AbstractContent::getDefaultFormat | ( | ) |
Implements Content.
Definition at line 112 of file AbstractContent.php.
References getContentHandler().
AbstractContent::getDeletionUpdates | ( | WikiPage | $page, |
ParserOutput | $parserOutput = null |
||
) |
Stable to override.
WikiPage | $page | |
ParserOutput | null | $parserOutput |
Implements Content.
Definition at line 502 of file AbstractContent.php.
AbstractContent::getModel | ( | ) |
Implements Content.
Definition at line 67 of file AbstractContent.php.
References $model_id.
Referenced by checkFormat(), convert(), FallbackContent\fillParserOutput(), TextContent\fillParserOutput(), getContentHandler(), TextContent\preSaveTransform(), and WikitextContent\replaceSection().
AbstractContent::getParserOutput | ( | Title | $title, |
$revId = null , |
|||
ParserOptions | $options = null , |
||
$generateHtml = true |
|||
) |
Returns a ParserOutput object containing information derived from this content.
Most importantly, unless $generateHtml was false, the return value contains an HTML representation of the content.
Subclasses that want to control the parser output may override this, but it is preferred to override fillParserOutput() instead.
Subclasses that override getParserOutput() itself should take care to call the ContentGetParserOutput hook.
Stable to override
Title | $title | Context title for parsing |
int | null | $revId | Revision ID being rendered |
ParserOptions | null | $options | |
bool | $generateHtml | Whether or not to generate HTML |
Implements Content.
Reimplemented in MessageContent.
Definition at line 574 of file AbstractContent.php.
References $title, fillParserOutput(), getRedirectTarget(), ParserOptions\newCanonical(), and Hooks\runner().
Referenced by getSecondaryDataUpdates(), and WikitextContent\isCountable().
AbstractContent::getRedirectChain | ( | ) |
Implements Content.
Definition at line 312 of file AbstractContent.php.
References $title, $wgMaxRedirects, getRedirectTarget(), and Title\isValidRedirectTarget().
Referenced by WikitextContent\fillParserOutput(), and getUltimateRedirectTarget().
AbstractContent::getRedirectTarget | ( | ) |
Subclasses that implement redirects should override this.
Stable to override
Implements Content.
Reimplemented in WikitextContent, JavaScriptContent, and CssContent.
Definition at line 353 of file AbstractContent.php.
Referenced by getParserOutput(), getRedirectChain(), and isRedirect().
AbstractContent::getSecondaryDataUpdates | ( | Title | $title, |
Content | $old = null , |
||
$recursive = true , |
|||
ParserOutput | $parserOutput = null |
||
) |
Returns a list of DataUpdate objects for recording information about this Content in some secondary data store.
This default implementation returns a LinksUpdate object and calls the SecondaryDataUpdates hook.
Subclasses may override this to determine the secondary data updates more efficiently, preferably without the need to generate a parser output object. They should however make sure to call SecondaryDataUpdates to give extensions a chance to inject additional updates.
Stable to override
Title | $title | |
Content | null | $old | |
bool | $recursive | |
ParserOutput | null | $parserOutput |
Implements Content.
Definition at line 289 of file AbstractContent.php.
References $title, getParserOutput(), and Hooks\runner().
AbstractContent::getSection | ( | $sectionId | ) |
Stable to override.
string | int | $sectionId |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 409 of file AbstractContent.php.
AbstractContent::getSupportedFormats | ( | ) |
Implements Content.
Definition at line 122 of file AbstractContent.php.
References getContentHandler().
AbstractContent::getUltimateRedirectTarget | ( | ) |
Implements Content.
Definition at line 366 of file AbstractContent.php.
References getRedirectChain().
AbstractContent::isEmpty | ( | ) |
Stable to override.
Implements Content.
Definition at line 181 of file AbstractContent.php.
References Content\getSize().
AbstractContent::isRedirect | ( | ) |
Implements Content.
Definition at line 379 of file AbstractContent.php.
References getRedirectTarget().
Referenced by TextContent\isCountable(), WikitextContent\isCountable(), CssContent\updateRedirect(), JavaScriptContent\updateRedirect(), and WikitextContent\updateRedirect().
AbstractContent::isSupportedFormat | ( | $format | ) |
string | $format |
Implements Content.
Definition at line 135 of file AbstractContent.php.
References getContentHandler().
Referenced by checkFormat().
AbstractContent::isValid | ( | ) |
Subclasses may override this to implement (light weight) validation.
Stable to override
Implements Content.
Reimplemented in JsonContent.
Definition at line 195 of file AbstractContent.php.
Referenced by prepareSave().
AbstractContent::matchMagicWord | ( | MagicWord | $word | ) |
This default implementation always returns false.
Subclasses may override this to supply matching logic.
Stable to override
MagicWord | $word |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 521 of file AbstractContent.php.
AbstractContent::preloadTransform | ( | Title | $title, |
ParserOptions | $popts, | ||
$params = [] |
|||
) |
Stable to override.
Title | $title | |
ParserOptions | $popts | |
array | $params |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 467 of file AbstractContent.php.
Stable to override.
Implements Content.
Definition at line 483 of file AbstractContent.php.
References isValid(), StatusValue\newFatal(), and StatusValue\newGood().
AbstractContent::preSaveTransform | ( | Title | $title, |
User | $user, | ||
ParserOptions | $popts | ||
) |
Stable to override.
Title | $title | |
User | $user | |
ParserOptions | $popts |
Implements Content.
Reimplemented in WikitextContent, TextContent, JsonContent, JavaScriptContent, and CssContent.
Definition at line 439 of file AbstractContent.php.
AbstractContent::replaceSection | ( | $sectionId, | |
Content | $with, | ||
$sectionTitle = '' |
|||
) |
Stable to override.
string | int | null | bool | $sectionId | |
Content | $with | |
string | $sectionTitle |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 424 of file AbstractContent.php.
AbstractContent::serialize | ( | $format = null | ) |
Stable to override.
string | null | $format |
Implements Content.
Reimplemented in FallbackContent.
Definition at line 169 of file AbstractContent.php.
References getContentHandler().
Referenced by equalsInternal().
AbstractContent::updateRedirect | ( | Title | $target | ) |
This default implementation always returns $this.
Subclasses that implement redirects should override this.
Stable to override
Title | $target |
Implements Content.
Reimplemented in WikitextContent, JavaScriptContent, and CssContent.
Definition at line 396 of file AbstractContent.php.
|
protected |
Name of the content model this Content object represents.
Use with CONTENT_MODEL_XXX constants
Definition at line 48 of file AbstractContent.php.
Referenced by FallbackContent\__construct(), TextContent\__construct(), and getModel().