MediaWiki
1.32.5
|
Content object implementation for representing flat text. More...
Public Member Functions | |
__construct ( $text, $model_id=CONTENT_MODEL_TEXT) | |
convert ( $toModel, $lossy='') | |
This implementation provides lossless conversion between content models based on TextContent. More... | |
copy () | |
diff (Content $that, Language $lang=null) | |
Diff this content object with another content object. More... | |
getNativeData () | |
Returns the text represented by this Content object, as a string. More... | |
getSize () | |
Returns the text's size in bytes. More... | |
getTextForSearchIndex () | |
Returns the text represented by this Content object, as a string. More... | |
getTextForSummary ( $maxlength=250) | |
Returns a textual representation of the content suitable for use in edit summaries and log messages. More... | |
getWikitextForTransclusion () | |
Returns attempts to convert this content object to wikitext, and then returns the text string. More... | |
isCountable ( $hasLinks=null) | |
Returns true if this content is not a redirect, and $wgArticleCountMethod is "any". More... | |
preSaveTransform (Title $title, User $user, ParserOptions $popts) | |
Returns a Content object with pre-save transformations applied. More... | |
Public Member Functions inherited from AbstractContent | |
__construct ( $modelId=null) | |
addSectionHeader ( $header) | |
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. 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) | |
getSupportedFormats () | |
getUltimateRedirectTarget () | |
isEmpty () | |
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=[]) | |
prepareSave (WikiPage $page, $flags, $parentRevId, User $user) | |
replaceSection ( $sectionId, Content $with, $sectionTitle='') | |
serialize ( $format=null) | |
updateRedirect (Title $target) | |
This default implementation always returns $this. More... | |
Static Public Member Functions | |
static | normalizeLineEndings ( $text) |
Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace. More... | |
Protected Member Functions | |
fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) | |
Fills the provided ParserOutput object with information derived from the content. More... | |
getHighlightHtml () | |
Generates an HTML version of the content, for display. More... | |
getHtml () | |
Generates an HTML version of the content, for display. More... | |
Protected Member Functions inherited from AbstractContent | |
checkFormat ( $format) | |
checkModelID ( $modelId) | |
Protected Attributes | |
string | $mText |
Protected Attributes inherited from AbstractContent | |
$model_id | |
Name of the content model this Content object represents. More... | |
Content object implementation for representing flat text.
TextContent instances are immutable
Definition at line 37 of file TextContent.php.
TextContent::__construct | ( | $text, | |
$model_id = CONTENT_MODEL_TEXT |
|||
) |
string | $text | |
string | $model_id |
MWException |
Reimplemented in JsonContent, JavaScriptContent, and CssContent.
Definition at line 49 of file TextContent.php.
References AbstractContent\$model_id, and wfWarn().
TextContent::convert | ( | $toModel, | |
$lossy = '' |
|||
) |
This implementation provides lossless conversion between content models based on TextContent.
string | $toModel | The desired content model, use the CONTENT_MODEL_XXX flags. |
string | $lossy | Flag, set to "lossy" to allow lossy conversion. If lossy conversion is not allowed, full round-trip conversion is expected to work without losing information. |
Reimplemented from AbstractContent.
Definition at line 310 of file TextContent.php.
References ContentHandler\getForModelID(), and getNativeData().
Referenced by getWikitextForTransclusion().
TextContent::copy | ( | ) |
Implements Content.
Reimplemented in RevisionTestModifyableContent.
Definition at line 71 of file TextContent.php.
Referenced by WikitextContent\replaceSection().
Diff this content object with another content object.
Content | $that | The other content object to compare this content object to. |
Language | null | $lang | The language object to use for text segmentation. If not given, the content language is used. |
Definition at line 202 of file TextContent.php.
References $lang, AbstractContent\checkModelID(), Content\getModel(), Content\getNativeData(), and getNativeData().
|
protected |
Fills the provided ParserOutput object with information derived from the content.
Unless $generateHtml was false, this includes an HTML representation of the content provided by getHtml().
For content models listed in $wgTextModelsToParse, this method will call the MediaWiki wikitext parser on the text to extract any (wikitext) links, magic words, etc.
Subclasses may override this to provide custom content processing. For custom HTML generation alone, it is sufficient to override getHtml().
Title | $title | Context title for parsing |
int | $revId | Revision ID (for {{REVISIONID}}) |
ParserOptions | $options | |
bool | $generateHtml | Whether or not to generate HTML |
ParserOutput | &$output | The output object to fill (reference). |
Reimplemented from AbstractContent.
Reimplemented in WikitextContent, JsonContent, and GadgetDefinitionContent.
Definition at line 240 of file TextContent.php.
References $html, $options, $output, $wgParser, $wgTextModelsToParse, ParserOutput\clearWrapperDivClass(), getHtml(), AbstractContent\getModel(), and getNativeData().
|
protected |
Generates an HTML version of the content, for display.
This default implementation returns an HTML-escaped version of the raw text content.
Definition at line 293 of file TextContent.php.
References getNativeData().
Referenced by getHtml().
|
protected |
Generates an HTML version of the content, for display.
Used by fillParserOutput() to provide HTML for the ParserOutput object.
Subclasses may override this to provide a custom HTML rendering. If further information is to be derived from the content (such as categories), the fillParserOutput() method can be overridden instead.
For backwards-compatibility, this default implementation just calls getHighlightHtml().
Reimplemented in WikitextContent, CssContent, and JavaScriptContent.
Definition at line 273 of file TextContent.php.
References getHighlightHtml().
Referenced by fillParserOutput().
TextContent::getNativeData | ( | ) |
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 123 of file TextContent.php.
References $mText.
Referenced by WikitextContent\addSectionHeader(), convert(), diff(), fillParserOutput(), JsonContent\getData(), getHighlightHtml(), JavaScriptContent\getHtml(), CssContent\getHtml(), JsonContent\getJsonData(), CssContent\getRedirectTarget(), JavaScriptContent\getRedirectTarget(), WikitextContent\getRedirectTargetAndText(), WikitextContent\getSection(), getSize(), getTextForSearchIndex(), getTextForSummary(), WikitextContent\matchMagicWord(), WikitextContent\preloadTransform(), JavaScriptContent\preSaveTransform(), CssContent\preSaveTransform(), WikitextContent\preSaveTransform(), preSaveTransform(), WikitextContent\replaceSection(), and WikitextContent\updateRedirect().
TextContent::getSize | ( | ) |
Returns the text's size in bytes.
Implements Content.
Definition at line 89 of file TextContent.php.
References getNativeData().
TextContent::getTextForSearchIndex | ( | ) |
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 132 of file TextContent.php.
References getNativeData().
TextContent::getTextForSummary | ( | $maxLength = 250 | ) |
Returns a textual representation of the content suitable for use in edit summaries and log messages.
int | $maxLength | Maximum length of the summary text. |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 75 of file TextContent.php.
References getNativeData().
TextContent::getWikitextForTransclusion | ( | ) |
Returns attempts to convert this content object to wikitext, and then returns the text string.
The conversion may be lossy.
Implements Content.
Definition at line 144 of file TextContent.php.
References CONTENT_MODEL_WIKITEXT, and convert().
TextContent::isCountable | ( | $hasLinks = null | ) |
Returns true if this content is not a redirect, and $wgArticleCountMethod is "any".
bool | null | $hasLinks | If it is known whether this content contains links, provide this information here, to avoid redundant parsing to find out. |
Implements Content.
Definition at line 104 of file TextContent.php.
References $wgArticleCountMethod, and AbstractContent\isRedirect().
|
static |
Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace.
This was formerly part of Parser::preSaveTransform, but for non-wikitext content models they probably still want to normalize line endings without all of the other PST changes.
string | $text |
Definition at line 167 of file TextContent.php.
Referenced by JsonContent\preSaveTransform(), and preSaveTransform().
TextContent::preSaveTransform | ( | Title | $title, |
User | $user, | ||
ParserOptions | $popts | ||
) |
Returns a Content object with pre-save transformations applied.
At a minimum, subclasses should make sure to call TextContent::normalizeLineEndings() either directly or part of Parser::preSaveTransform().
Title | $title | |
User | $user | |
ParserOptions | $popts |
Reimplemented from AbstractContent.
Reimplemented in WikitextContent, JsonContent, CssContent, and JavaScriptContent.
Definition at line 183 of file TextContent.php.
References AbstractContent\getModel(), getNativeData(), and normalizeLineEndings().
|
protected |
Definition at line 42 of file TextContent.php.
Referenced by getNativeData(), and RevisionTestModifyableContent\getText().