MediaWiki REL1_31
|
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) | |
getContentHandler () | |
getDefaultFormat () | |
getDeletionUpdates (WikiPage $page, ParserOutput $parserOutput=null) | |
getModel () | |
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. | |
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. | |
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. | |
getNativeData () | |
Returns native representation of the data. | |
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) | |
fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) | |
Fills the provided ParserOutput with information derived from the content. | |
Protected Attributes | |
$model_id | |
Name of the content model this Content object represents. | |
Base implementation for content objects.
Definition at line 34 of file AbstractContent.php.
AbstractContent::__construct | ( | $modelId = null | ) |
string | $modelId |
Reimplemented in DummyContentForTesting, DummyNonTextContent, GadgetDefinitionContent, WikitextContent, and RevisionTestModifyableContent.
Definition at line 50 of file AbstractContent.php.
AbstractContent::addSectionHeader | ( | $header | ) |
string | $header |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 386 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 136 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 72 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 TextContent.
Definition at line 466 of file AbstractContent.php.
References $result, and getModel().
AbstractContent::equals | ( | Content | $that = null | ) |
Content | $that |
Implements Content.
Definition at line 191 of file AbstractContent.php.
References Content\getNativeData().
Referenced by CssContent\getRedirectTarget(), and JavaScriptContent\getRedirectTarget().
|
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 | Revision ID (for {{REVISIONID}}) |
ParserOptions | $options | |
bool | $generateHtml | Whether or not to generate HTML |
ParserOutput | &$output | The output object to fill (reference). |
MWException |
Reimplemented in GadgetDefinitionContent, JsonContent, TextContent, WikitextContent, DummyContentForTesting, and DummyNonTextContent.
Definition at line 545 of file AbstractContent.php.
Referenced by getParserOutput().
AbstractContent::getContentHandler | ( | ) |
Implements Content.
Definition at line 88 of file AbstractContent.php.
Referenced by GadgetDefinitionContent\getAssocArray(), getDefaultFormat(), getParserOutput(), CssContent\getRedirectTarget(), JavaScriptContent\getRedirectTarget(), getSupportedFormats(), isSupportedFormat(), serialize(), CssContent\updateRedirect(), and JavaScriptContent\updateRedirect().
AbstractContent::getDefaultFormat | ( | ) |
Implements Content.
Definition at line 98 of file AbstractContent.php.
References getContentHandler().
AbstractContent::getDeletionUpdates | ( | WikiPage | $page, |
ParserOutput | $parserOutput = null ) |
WikiPage | $page | |
ParserOutput | null | $parserOutput |
Implements Content.
Reimplemented in GadgetDefinitionContent.
Definition at line 433 of file AbstractContent.php.
AbstractContent::getModel | ( | ) |
Implements Content.
Definition at line 60 of file AbstractContent.php.
References $model_id.
Referenced by checkFormat(), convert(), TextContent\fillParserOutput(), 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.
Title | $title | Context title for parsing |
int | null | $revId | Revision ID (for {{REVISIONID}}) |
ParserOptions | null | $options | |
bool | $generateHtml | Whether or not to generate HTML |
Implements Content.
Reimplemented in MessageContent, DummyContentForTesting, and DummyNonTextContent.
Definition at line 500 of file AbstractContent.php.
References $options, fillParserOutput(), getContentHandler(), and getRedirectTarget().
Referenced by getSecondaryDataUpdates(), and WikitextContent\isCountable().
AbstractContent::getRedirectChain | ( | ) |
Implements Content.
Definition at line 253 of file AbstractContent.php.
References $title, $titles, $wgMaxRedirects, getRedirectTarget(), and Title\isValidRedirectTarget().
Referenced by WikitextContent\fillParserOutput(), and getUltimateRedirectTarget().
AbstractContent::getRedirectTarget | ( | ) |
Subclasses that implement redirects should override this.
Implements Content.
Reimplemented in CssContent, JavaScriptContent, and WikitextContent.
Definition at line 292 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.
Title | $title | |
Content | $old | |
bool | $recursive | |
ParserOutput | $parserOutput |
Implements Content.
Reimplemented in GadgetDefinitionContent.
Definition at line 230 of file AbstractContent.php.
References getParserOutput().
AbstractContent::getSection | ( | $sectionId | ) |
string | int | $sectionId |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 346 of file AbstractContent.php.
AbstractContent::getSupportedFormats | ( | ) |
Implements Content.
Definition at line 108 of file AbstractContent.php.
References getContentHandler().
AbstractContent::getUltimateRedirectTarget | ( | ) |
Implements Content.
Definition at line 305 of file AbstractContent.php.
References $titles, and getRedirectChain().
AbstractContent::isEmpty | ( | ) |
Implements Content.
Definition at line 165 of file AbstractContent.php.
References Content\getSize().
AbstractContent::isRedirect | ( | ) |
Implements Content.
Definition at line 318 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 121 of file AbstractContent.php.
References getContentHandler().
Referenced by checkFormat().
AbstractContent::isValid | ( | ) |
Subclasses may override this to implement (light weight) validation.
Implements Content.
Reimplemented in GadgetDefinitionContent, and JsonContent.
Definition at line 178 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.
MagicWord | $word |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 451 of file AbstractContent.php.
AbstractContent::preloadTransform | ( | Title | $title, |
ParserOptions | $popts, | ||
$params = [] ) |
Title | $title | |
ParserOptions | $popts | |
array | $params |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 400 of file AbstractContent.php.
AbstractContent::preSaveTransform | ( | Title | $title, |
User | $user, | ||
ParserOptions | $popts ) |
Title | $title | |
User | $user | |
ParserOptions | $popts |
Implements Content.
Reimplemented in CssContent, JavaScriptContent, JsonContent, TextContent, and WikitextContent.
Definition at line 374 of file AbstractContent.php.
AbstractContent::replaceSection | ( | $sectionId, | |
Content | $with, | ||
$sectionTitle = '' ) |
string | int | null | bool | $sectionId | |
Content | $with | |
string | $sectionTitle |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 360 of file AbstractContent.php.
AbstractContent::serialize | ( | $format = null | ) |
string | $format |
Implements Content.
Reimplemented in DummyContentForTesting, and DummyNonTextContent.
Definition at line 154 of file AbstractContent.php.
References getContentHandler().
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 334 of file AbstractContent.php.
|
protected |
Name of the content model this Content object represents.
Use with CONTENT_MODEL_XXX constants
Definition at line 43 of file AbstractContent.php.
Referenced by TextContent\__construct(), and getModel().