MediaWiki REL1_39
|
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. | |
getText () | |
Returns the text represented by this Content object, as a string. | |
getTextForSearchIndex () | |
Returns the text represented by this Content object, as a string. | |
getTextForSummary ( $maxlength=250) | |
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". | |
Public Member Functions inherited from AbstractContent | |
__construct ( $modelId=null) | |
addSectionHeader ( $header) | |
equals (Content $that=null) | |
Decides whether two Content objects are equal. | |
getContentHandler () | |
getDefaultFormat () | |
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. | |
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. | |
Static Public Member Functions | |
static | normalizeLineEndings ( $text) |
Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace. | |
Protected Attributes | |
string | $mText |
Protected Attributes inherited from AbstractContent | |
string | $model_id |
Name of the content model this Content object represents. | |
Additional Inherited Members | |
Protected Member Functions inherited from AbstractContent | |
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 () | |
Content object implementation for representing flat text.
TextContent instances are immutable
Definition at line 40 of file TextContent.php.
TextContent::__construct | ( | $text, | |
$model_id = CONTENT_MODEL_TEXT ) |
string | $text | |
string | $model_id |
MWException |
Reimplemented in CssContent, JavaScriptContent, and JsonContent.
Definition at line 53 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. |
MWUnknownContentModelException |
Reimplemented from AbstractContent.
Definition at line 260 of file TextContent.php.
References AbstractContent\getContentHandlerFactory(), and getText().
Referenced by getWikitextForTransclusion().
TextContent::copy | ( | ) |
Implements Content.
Definition at line 75 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 222 of file TextContent.php.
References $lang, AbstractContent\checkModelID(), Content\getModel(), and getText().
TextContent::getNativeData | ( | ) |
Returns the text represented by this Content object, as a string.
Reimplemented from AbstractContent.
Definition at line 141 of file TextContent.php.
References getText().
TextContent::getSize | ( | ) |
Returns the text's size in bytes.
Implements Content.
Definition at line 102 of file TextContent.php.
References getText().
TextContent::getText | ( | ) |
Returns the text represented by this Content object, as a string.
Definition at line 155 of file TextContent.php.
References $mText.
Referenced by WikitextContent\addSectionHeader(), convert(), diff(), JsonContent\getData(), getNativeData(), CssContent\getRedirectTarget(), JavaScriptContent\getRedirectTarget(), WikitextContent\getRedirectTargetAndText(), WikitextContent\getSection(), getSize(), getTextForSearchIndex(), getTextForSummary(), WikitextContent\matchMagicWord(), and WikitextContent\replaceSection().
TextContent::getTextForSearchIndex | ( | ) |
Returns the text represented by this Content object, as a string.
Implements Content.
Definition at line 166 of file TextContent.php.
References getText().
TextContent::getTextForSummary | ( | $maxlength = 250 | ) |
int | $maxlength |
Implements Content.
Reimplemented in WikitextContent.
Definition at line 86 of file TextContent.php.
References getText().
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 180 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 119 of file TextContent.php.
References 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 205 of file TextContent.php.
|
protected |
Definition at line 45 of file TextContent.php.