MediaWiki
REL1_24
|
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. | |
copy () | |
diff (Content $that, Language $lang=null) | |
Diff this content object with another content object. | |
getNativeData () | |
Returns the text represented by this Content object, as a string. | |
getSize () | |
Returns the text's size in bytes. | |
getTextForSearchIndex () | |
Returns the text represented by this Content object, as a string. | |
getTextForSummary ($maxlength=250) | |
Returns a textual representation of the content suitable for use in edit summaries and log messages. | |
getWikitextForTransclusion () | |
Returns attempts to convert this content object to wikitext, and then returns the text string. | |
isCountable ($hasLinks=null) | |
Returns true if this content is not a redirect, and $wgArticleCountMethod is "any". | |
preSaveTransform (Title $title, User $user, ParserOptions $popts) | |
Returns a Content object with pre-save transformations applied. | |
Protected Member Functions | |
fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) | |
Fills the provided ParserOutput object with information derived from the content. | |
getHighlightHtml () | |
Generates an HTML version of the content, for display. | |
getHtml () | |
Generates an HTML version of the content, for display. |
Content object implementation for representing flat text.
TextContent instances are immutable
Definition at line 35 of file TextContent.php.
TextContent::__construct | ( | $ | text, |
$ | model_id = CONTENT_MODEL_TEXT |
||
) |
string | $text | |
string | $model_id |
Reimplemented in CssContent, JavaScriptContent, and JsonContent.
Definition at line 41 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 287 of file TextContent.php.
References ContentHandler\getForModelID(), and getNativeData().
Referenced by getWikitextForTransclusion().
Implements Content.
Reimplemented in RevisionTestModifyableContent.
Definition at line 63 of file TextContent.php.
Referenced by WikitextContent\replaceSection().
TextContent::diff | ( | Content $ | that, |
Language $ | lang = null |
||
) |
Diff this content object with another content object.
Content | $that | The other content object to compare this content object to. |
Language | $lang | The language object to use for text segmentation. If not given, $wgContentLang is used. |
Definition at line 178 of file TextContent.php.
References $wgContLang, AbstractContent\checkModelID(), Content\getModel(), Content\getNativeData(), getNativeData(), and global.
TextContent::fillParserOutput | ( | Title $ | title, |
$ | revId, | ||
ParserOptions $ | options, | ||
$ | generateHtml, | ||
ParserOutput &$ | output | ||
) | [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 | Parser options |
bool | $generateHtml | Whether or not to generate HTML |
ParserOutput | $output | The output object to fill (reference). |
Reimplemented from AbstractContent.
Reimplemented in WikitextContent, and JsonContent.
Definition at line 218 of file TextContent.php.
References $generateHtml, $html, $revId, $wgParser, getHtml(), AbstractContent\getModel(), getNativeData(), global, and ParserOutput\setText().
TextContent::getHighlightHtml | ( | ) | [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 270 of file TextContent.php.
References getNativeData().
Referenced by getHtml().
TextContent::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 250 of file TextContent.php.
References getHighlightHtml().
Referenced by fillParserOutput().
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 118 of file TextContent.php.
Referenced by WikitextContent\addSectionHeader(), JsonContent\beautifyJSON(), convert(), diff(), fillParserOutput(), getHighlightHtml(), JavaScriptContent\getHtml(), CssContent\getHtml(), JsonContent\getJsonData(), WikitextContent\getRedirectTargetAndText(), WikitextContent\getSection(), getSize(), getTextForSearchIndex(), getTextForSummary(), WikitextContent\isCountable(), WikitextContent\matchMagicWord(), WikitextContent\preloadTransform(), JavaScriptContent\preSaveTransform(), CssContent\preSaveTransform(), WikitextContent\preSaveTransform(), preSaveTransform(), WikitextContent\replaceSection(), and WikitextContent\updateRedirect().
Returns the text's size in bytes.
Implements Content.
Definition at line 84 of file TextContent.php.
References getNativeData().
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 127 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 67 of file TextContent.php.
References $wgContLang, getNativeData(), and global.
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 139 of file TextContent.php.
References convert().
TextContent::isCountable | ( | $ | hasLinks = null | ) |
Returns true if this content is not a redirect, and $wgArticleCountMethod is "any".
bool | $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 99 of file TextContent.php.
References global, and AbstractContent\isRedirect().
TextContent::preSaveTransform | ( | Title $ | title, |
User $ | user, | ||
ParserOptions $ | popts | ||
) |
Returns a Content object with pre-save transformations applied.
This implementation just trims trailing whitespace.
Title | $title | |
User | $user | |
ParserOptions | $popts |
Reimplemented from AbstractContent.
Reimplemented in WikitextContent, JsonContent, CssContent, and JavaScriptContent.
Definition at line 159 of file TextContent.php.
References AbstractContent\getModel(), and getNativeData().