|
MediaWiki master
|
Content object implementation for representing flat text. More...
Inherits MediaWiki\Content\AbstractContent.
Inherited by MediaWiki\Content\CssContent, MediaWiki\Content\JavaScriptContent, MediaWiki\Content\JsonContent, MediaWiki\Content\VueContent, and MediaWiki\Content\WikitextContent.

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 MediaWiki\Content\AbstractContent | |
| __construct ( $modelId=null) | |
| addSectionHeader ( $header) | |
| equals (?Content $that=null) | |
| getContentHandler () | |
| getDefaultFormat () | |
| getModel () | |
| getRedirectTarget () | |
| Subclasses that implement redirects should override this. | |
| getSection ( $sectionId) | |
| getSupportedFormats () | |
| isEmpty () | |
| isRedirect () | |
| isSupportedFormat ( $format) | |
| isValid () | |
| matchMagicWord (MagicWord $word) | |
| This default implementation always returns false. | |
| 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. | |
Static Public Member Functions inherited from MediaWiki\Content\AbstractContent | |
| static | jsonClassCodec (JsonCodecInterface $codec, ContainerInterface $serviceContainer) |
Protected Attributes | |
| string | $mText |
Protected Attributes inherited from MediaWiki\Content\AbstractContent | |
| string | $model_id |
Additional Inherited Members | |
Protected Member Functions inherited from MediaWiki\Content\AbstractContent | |
| checkFormat ( $format) | |
| Helper for subclasses. | |
| checkModelID ( $modelId) | |
| Helper for subclasses. | |
| equalsInternal (Content $that) | |
| Helper for AbstractContent::equals. | |
| getContentHandlerFactory () | |
Content object implementation for representing flat text.
TextContent instances are immutable
Definition at line 27 of file TextContent.php.
| MediaWiki\Content\TextContent::__construct | ( | $text, | |
| $model_id = CONTENT_MODEL_TEXT ) |
| string | $text | |
| string | $model_id |
Reimplemented in MediaWiki\Content\CssContent, MediaWiki\Content\JavaScriptContent, MediaWiki\Content\JsonContent, and MediaWiki\Content\VueContent.
Definition at line 39 of file TextContent.php.
References MediaWiki\Content\AbstractContent\$model_id, and wfWarn().
| MediaWiki\Content\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 MediaWiki\Content\AbstractContent.
Definition at line 246 of file TextContent.php.
References MediaWiki\Content\AbstractContent\getContentHandlerFactory(), and MediaWiki\Content\TextContent\getText().
Referenced by MediaWiki\Content\TextContent\getWikitextForTransclusion().
| MediaWiki\Content\TextContent::copy | ( | ) |
Implements MediaWiki\Content\Content.
Definition at line 61 of file TextContent.php.
Referenced by MediaWiki\Content\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 208 of file TextContent.php.
References MediaWiki\Content\AbstractContent\checkModelID(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Content\Content\getModel(), and MediaWiki\Content\TextContent\getText().
| MediaWiki\Content\TextContent::getNativeData | ( | ) |
Returns the text represented by this Content object, as a string.
Reimplemented from MediaWiki\Content\AbstractContent.
Definition at line 127 of file TextContent.php.
References MediaWiki\Content\TextContent\getText().
| MediaWiki\Content\TextContent::getSize | ( | ) |
Returns the text's size in bytes.
Implements MediaWiki\Content\Content.
Definition at line 88 of file TextContent.php.
References MediaWiki\Content\TextContent\getText().
| MediaWiki\Content\TextContent::getText | ( | ) |
Returns the text represented by this Content object, as a string.
Definition at line 141 of file TextContent.php.
References MediaWiki\Content\TextContent\$mText.
Referenced by MediaWiki\Content\WikitextContent\addSectionHeader(), MediaWiki\Content\TextContent\convert(), MediaWiki\Content\TextContent\diff(), MediaWiki\Content\JsonContent\getData(), MediaWiki\Content\TextContent\getNativeData(), MediaWiki\Content\CssContent\getRedirectTarget(), MediaWiki\Content\JavaScriptContent\getRedirectTarget(), MediaWiki\Content\WikitextContent\getSection(), MediaWiki\Content\TextContent\getSize(), MediaWiki\Content\TextContent\getTextForSearchIndex(), MediaWiki\Content\TextContent\getTextForSummary(), MediaWiki\Content\WikitextContent\matchMagicWord(), and MediaWiki\Content\WikitextContent\replaceSection().
| MediaWiki\Content\TextContent::getTextForSearchIndex | ( | ) |
Returns the text represented by this Content object, as a string.
Implements MediaWiki\Content\Content.
Definition at line 152 of file TextContent.php.
References MediaWiki\Content\TextContent\getText().
| MediaWiki\Content\TextContent::getTextForSummary | ( | $maxlength = 250 | ) |
| int | $maxlength |
Implements MediaWiki\Content\Content.
Reimplemented in MediaWiki\Content\WikitextContent.
Definition at line 72 of file TextContent.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Content\TextContent\getText().
| MediaWiki\Content\TextContent::getWikitextForTransclusion | ( | ) |
Returns attempts to convert this content object to wikitext, and then returns the text string.
The conversion may be lossy.
Implements MediaWiki\Content\Content.
Definition at line 166 of file TextContent.php.
References CONTENT_MODEL_WIKITEXT, and MediaWiki\Content\TextContent\convert().
| MediaWiki\Content\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 MediaWiki\Content\Content.
Definition at line 105 of file TextContent.php.
References MediaWiki\MainConfigNames\ArticleCountMethod, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Content\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 191 of file TextContent.php.
|
protected |
Definition at line 32 of file TextContent.php.
Referenced by MediaWiki\Content\TextContent\getText().