MediaWiki
REL1_22
|
Content object implementation for representing flat text. More...
Public Member Functions | |
__construct ($text, $model_id=CONTENT_MODEL_TEXT) | |
convert ($toModel, $lossy= '') | |
copy () | |
Return a copy of this Content object. | |
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. | |
getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true) | |
Returns a generic ParserOutput object, wrapping the HTML returned by getHtml(). | |
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 | |
getHighlightHtml () | |
Generates a syntax-highlighted version of the content, as HTML. | |
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 |
||
) |
Definition at line 37 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 269 of file TextContent.php.
References ContentHandler\getForModelID(), and getNativeData().
Referenced by getWikitextForTransclusion().
Return a copy of this Content object.
The following must be true for the object returned:
if $copy = $original->copy()
If and only if the Content object is immutable, the copy() method can and should return $this. That is, $copy === $original may be true, but only for immutable content objects.
Implements Content.
Reimplemented in RevisionTestModifyableContent.
Definition at line 54 of file TextContent.php.
Referenced by WikitextContent\replaceSection().
TextContent::diff | ( | Content $ | that, |
Language $ | lang = null |
||
) |
Diff this content object with another content object.
$that | Content: The other content object to compare this content object to. |
$lang | Language: The language object to use for text segmentation. If not given, $wgContentLang is used. |
Definition at line 169 of file TextContent.php.
References $wgContLang, AbstractContent\checkModelID(), Content\getModel(), getNativeData(), and global.
TextContent::getHighlightHtml | ( | ) | [protected] |
Generates a syntax-highlighted version of the content, as HTML.
Used by the default implementation of getHtml().
Definition at line 251 of file TextContent.php.
References getNativeData().
Referenced by CssContent\getHtml(), JavaScriptContent\getHtml(), and getHtml().
TextContent::getHtml | ( | ) | [protected] |
Generates an HTML version of the content, for display.
Used by getParserOutput() to construct a ParserOutput object.
This default implementation just calls getHighlightHtml(). Content models that have another mapping to HTML (as is the case for markup languages like wikitext) should override this method to generate the appropriate HTML.
Reimplemented in WikitextContent, JavaScriptContent, and CssContent.
Definition at line 241 of file TextContent.php.
References getHighlightHtml().
Referenced by getParserOutput().
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 108 of file TextContent.php.
Referenced by WikitextContent\addSectionHeader(), convert(), diff(), getHighlightHtml(), getParserOutput(), WikitextContent\getParserOutput(), WikitextContent\getRedirectTarget(), WikitextContent\getSection(), getSize(), getTextForSearchIndex(), getTextForSummary(), WikitextContent\isCountable(), WikitextContent\matchMagicWord(), WikitextContent\preloadTransform(), JavaScriptContent\preSaveTransform(), CssContent\preSaveTransform(), WikitextContent\preSaveTransform(), preSaveTransform(), WikitextContent\replaceSection(), and WikitextContent\updateRedirect().
TextContent::getParserOutput | ( | Title $ | title, |
$ | revId = null , |
||
ParserOptions $ | options = null , |
||
$ | generateHtml = true |
||
) |
Returns a generic ParserOutput object, wrapping the HTML returned by getHtml().
$title | Title Context title for parsing | |
int | null | $revId | Revision ID (for {{REVISIONID}}) |
$options | ParserOptions|null Parser options | |
bool | $generateHtml | Whether or not to generate HTML |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 202 of file TextContent.php.
References $html, $options, $wgParser, AbstractContent\getContentHandler(), getHtml(), AbstractContent\getModel(), getNativeData(), and global.
returns the text's size in bytes.
Implements Content.
Definition at line 75 of file TextContent.php.
References getNativeData().
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 118 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 58 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 130 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 89 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 |
$popts | ParserOptions |
Reimplemented from AbstractContent.
Reimplemented in WikitextContent, CssContent, and JavaScriptContent.
Definition at line 149 of file TextContent.php.
References getNativeData().