MediaWiki REL1_39
|
Base implementation for content objects. More...
Public Member Functions | |
__construct ( $modelId=null) | |
addSectionHeader ( $header) | |
convert ( $toModel, $lossy='') | |
This base implementation calls the hook ConvertContent to enable custom conversions. | |
equals (Content $that=null) | |
Decides whether two Content objects are equal. | |
getContentHandler () | |
getDefaultFormat () | |
getModel () | |
getNativeData () | |
Returns native representation of the data. | |
getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true) | |
Returns a ParserOutput object containing information derived from this content. | |
getRedirectChain () | |
getRedirectTarget () | |
Subclasses that implement redirects should override this. | |
getSection ( $sectionId) | |
getSupportedFormats () | |
getUltimateRedirectTarget () | |
isEmpty () | |
isRedirect () | |
isSupportedFormat ( $format) | |
isValid () | |
Subclasses may override this to implement (light weight) validation. | |
matchMagicWord (MagicWord $word) | |
This default implementation always returns false. | |
preloadTransform (Title $title, ParserOptions $popts, $params=[]) | |
prepareSave (WikiPage $page, $flags, $parentRevId, User $user) | |
preSaveTransform (Title $title, User $user, ParserOptions $popts) | |
replaceSection ( $sectionId, Content $with, $sectionTitle='') | |
serialize ( $format=null) | |
updateRedirect (Title $target) | |
This default implementation always returns $this. | |
Public Member Functions inherited from Content | |
copy () | |
Return a copy of this Content object. | |
getSize () | |
Returns the content's nominal size in "bogo-bytes". | |
getTextForSearchIndex () | |
getTextForSummary ( $maxLength=250) | |
Returns a textual representation of the content suitable for use in edit summaries and log messages. | |
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. | |
Protected Member Functions | |
checkFormat ( $format) | |
checkModelID ( $modelId) | |
equalsInternal (Content $that) | |
Checks whether $that is logically equal to this Content object. | |
fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) | |
Fills the provided ParserOutput with information derived from the content. | |
getContentHandlerFactory () | |
Protected Attributes | |
string | $model_id |
Name of the content model this Content object represents. | |
Base implementation for content objects.
Definition at line 43 of file AbstractContent.php.
AbstractContent::__construct | ( | $modelId = null | ) |
string | null | $modelId |
Reimplemented in WikitextContent.
Definition at line 61 of file AbstractContent.php.
AbstractContent::addSectionHeader | ( | $header | ) |
string | $header |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 430 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 154 of file AbstractContent.php.
|
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 83 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.
string | $toModel | |
string | $lossy |
Implements Content.
Reimplemented in FallbackContent, and TextContent.
Definition at line 523 of file AbstractContent.php.
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 determine 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.
Content | null | $that |
Implements Content.
Definition at line 245 of file AbstractContent.php.
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().
Content | $that |
Reimplemented in FallbackContent.
Definition at line 286 of file AbstractContent.php.
References Content\serialize(), and serialize().
|
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.
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 |
Definition at line 628 of file AbstractContent.php.
References $title, and wfDeprecated().
AbstractContent::getContentHandler | ( | ) |
Implements Content.
Definition at line 99 of file AbstractContent.php.
References getContentHandlerFactory(), and getModel().
Referenced by CssContent\getRedirectTarget(), JavaScriptContent\getRedirectTarget(), CssContent\updateRedirect(), and JavaScriptContent\updateRedirect().
|
protected |
Definition at line 106 of file AbstractContent.php.
Referenced by TextContent\convert(), and getContentHandler().
AbstractContent::getDefaultFormat | ( | ) |
Implements Content.
Definition at line 116 of file AbstractContent.php.
AbstractContent::getModel | ( | ) |
Implements Content.
Definition at line 71 of file AbstractContent.php.
References $model_id.
Referenced by getContentHandler(), and WikitextContent\replaceSection().
AbstractContent::getNativeData | ( | ) |
Returns native representation of the data.
Interpretation depends on the data model used, as given by getDataModel().
LogicException |
Implements Content.
Reimplemented in FallbackContent, MessageContent, and TextContent.
Definition at line 194 of file AbstractContent.php.
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.
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.
Definition at line 558 of file AbstractContent.php.
References $title, and wfDeprecated().
AbstractContent::getRedirectChain | ( | ) |
Definition at line 300 of file AbstractContent.php.
References $title, and wfDeprecated().
AbstractContent::getRedirectTarget | ( | ) |
Subclasses that implement redirects should override this.
Implements Content.
Reimplemented in CssContent, JavaScriptContent, and WikitextContent.
Definition at line 321 of file AbstractContent.php.
AbstractContent::getSection | ( | $sectionId | ) |
string | int | $sectionId |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 380 of file AbstractContent.php.
AbstractContent::getSupportedFormats | ( | ) |
Implements Content.
Definition at line 126 of file AbstractContent.php.
AbstractContent::getUltimateRedirectTarget | ( | ) |
Definition at line 337 of file AbstractContent.php.
References wfDeprecated().
AbstractContent::isEmpty | ( | ) |
Implements Content.
Definition at line 206 of file AbstractContent.php.
AbstractContent::isRedirect | ( | ) |
Implements Content.
Definition at line 350 of file AbstractContent.php.
Referenced by TextContent\isCountable(), WikitextContent\isCountable(), CssContent\updateRedirect(), JavaScriptContent\updateRedirect(), and WikitextContent\updateRedirect().
AbstractContent::isSupportedFormat | ( | $format | ) |
string | $format |
Implements Content.
Definition at line 139 of file AbstractContent.php.
AbstractContent::isValid | ( | ) |
Subclasses may override this to implement (light weight) validation.
Implements Content.
Reimplemented in JsonContent.
Definition at line 220 of file AbstractContent.php.
AbstractContent::matchMagicWord | ( | MagicWord | $word | ) |
This default implementation always returns false.
Subclasses may override this to supply matching logic.
MagicWord | $word |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 506 of file AbstractContent.php.
AbstractContent::preloadTransform | ( | Title | $title, |
ParserOptions | $popts, | ||
$params = [] ) |
Title | $title | |
ParserOptions | $popts | |
array | $params |
Implements Content.
Definition at line 445 of file AbstractContent.php.
References $title, and wfDeprecated().
Implements Content.
Definition at line 467 of file AbstractContent.php.
References wfDeprecated().
AbstractContent::preSaveTransform | ( | Title | $title, |
User | $user, | ||
ParserOptions | $popts ) |
Title | $title | |
User | $user | |
ParserOptions | $popts |
Implements Content.
Definition at line 412 of file AbstractContent.php.
References $title, and wfDeprecated().
AbstractContent::replaceSection | ( | $sectionId, | |
Content | $with, | ||
$sectionTitle = '' ) |
string | int | null | bool | $sectionId | |
Content | $with | |
string | $sectionTitle |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 395 of file AbstractContent.php.
AbstractContent::serialize | ( | $format = null | ) |
string | null | $format |
Implements Content.
Reimplemented in FallbackContent.
Definition at line 173 of file AbstractContent.php.
AbstractContent::updateRedirect | ( | Title | $target | ) |
This default implementation always returns $this.
Subclasses that implement redirects should override this.
Title | $target |
Implements Content.
Reimplemented in CssContent, JavaScriptContent, and WikitextContent.
Definition at line 367 of file AbstractContent.php.
|
protected |
Name of the content model this Content object represents.
Use with CONTENT_MODEL_XXX constants
Definition at line 52 of file AbstractContent.php.
Referenced by FallbackContent\__construct(), TextContent\__construct(), and getModel().