MediaWiki master
MediaWiki\Content\WikitextContent Class Reference

Content object for wiki text pages. More...

Inherits MediaWiki\Content\TextContent.

Collaboration diagram for MediaWiki\Content\WikitextContent:

Public Member Functions

 __construct ( $text)
 
 addSectionHeader ( $header)
 Returns a new WikitextContent object with the given section heading prepended.
 
 getContentHandler ()
 
 getPreSaveTransformFlags ()
 Records flags set by preSaveTransform.
 
 getRedirectTarget ()
 Implement redirect extraction for wikitext.
 
 getRedirectTargetAndText ()
 Extract the redirect target and the remaining text on the page.
 
 getSection ( $sectionId)
 
 getTextForSummary ( $maxlength=250)
 
 isCountable ( $hasLinks=null, Title $title=null)
 Returns true if this content is not a redirect, and this content's text is countable according to the criteria defined by $wgArticleCountMethod.
 
 matchMagicWord (MagicWord $word)
 This implementation calls $word->match() on the this TextContent object's text.
 
 replaceSection ( $sectionId, Content $with, $sectionTitle='')
 
 setPreSaveTransformFlags (array $flags)
 Records flags set by preSaveTransform.
 
 updateRedirect (Title $target)
 This implementation replaces the first link on the page with the given new target if this Content object is a redirect.
 
- Public Member Functions inherited from MediaWiki\Content\TextContent
 __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.
 
 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
 equals (Content $that=null)
 Decides whether two Content objects are equal.
 
 getDefaultFormat ()
 
 getModel ()
 
 getSupportedFormats ()
 
 isEmpty ()
 
 isRedirect ()
 
 isSupportedFormat ( $format)
 
 isValid ()
 Subclasses may override this to implement (light weight) validation.
 
 serialize ( $format=null)
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Content\TextContent
static normalizeLineEndings ( $text)
 Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace.
 
- Protected Member Functions inherited from MediaWiki\Content\AbstractContent
 checkFormat ( $format)
 
 checkModelID ( $modelId)
 
 equalsInternal (Content $that)
 Checks whether $that is logically equal to this Content object.
 
 getContentHandlerFactory ()
 
- Protected Attributes inherited from MediaWiki\Content\TextContent
string $mText
 
- Protected Attributes inherited from MediaWiki\Content\AbstractContent
string $model_id
 Name of the content model this Content object represents.
 

Detailed Description

Content object for wiki text pages.

Stability: newable

Definition at line 44 of file WikitextContent.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Content\WikitextContent::__construct ( $text)
Stability: stable
to call
Parameters
string$text

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 56 of file WikitextContent.php.

References CONTENT_MODEL_WIKITEXT.

Member Function Documentation

◆ addSectionHeader()

MediaWiki\Content\WikitextContent::addSectionHeader ( $header)

Returns a new WikitextContent object with the given section heading prepended.

Parameters
string$header
Returns
Content

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 137 of file WikitextContent.php.

References $header, MediaWiki\Content\TextContent\getText(), and wfMessage().

◆ getContentHandler()

MediaWiki\Content\WikitextContent::getContentHandler ( )
Since
1.21
See also
Content::getContentHandler
Returns
ContentHandler

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 295 of file WikitextContent.php.

Referenced by MediaWiki\Content\WikitextContent\getRedirectTarget(), and MediaWiki\Content\WikitextContent\getRedirectTargetAndText().

◆ getPreSaveTransformFlags()

MediaWiki\Content\WikitextContent::getPreSaveTransformFlags ( )

Records flags set by preSaveTransform.

Access: internal
for use by WikitextContentHandler
Returns
string[]

Definition at line 291 of file WikitextContent.php.

◆ getRedirectTarget()

MediaWiki\Content\WikitextContent::getRedirectTarget ( )

Implement redirect extraction for wikitext.

Returns
Title|null
See also
Content::getRedirectTarget

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 169 of file WikitextContent.php.

References MediaWiki\Content\WikitextContent\getContentHandler().

◆ getRedirectTargetAndText()

MediaWiki\Content\WikitextContent::getRedirectTargetAndText ( )

Extract the redirect target and the remaining text on the page.

Since
1.23
Deprecated
since 1.41, use WikitextContentHandler::getRedirectTargetAndText
Returns
array List of two elements: Title|null and string.

Definition at line 153 of file WikitextContent.php.

References MediaWiki\Content\WikitextContent\getContentHandler(), and wfDeprecated().

◆ getSection()

MediaWiki\Content\WikitextContent::getSection ( $sectionId)
Parameters
string | int$sectionId
Returns
Content|false|null
See also
Content::getSection()

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 67 of file WikitextContent.php.

References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Content\TextContent\getText().

◆ getTextForSummary()

MediaWiki\Content\WikitextContent::getTextForSummary ( $maxlength = 250)
Parameters
int$maxlength
Returns
string

Reimplemented from MediaWiki\Content\TextContent.

Definition at line 250 of file WikitextContent.php.

◆ isCountable()

MediaWiki\Content\WikitextContent::isCountable ( $hasLinks = null,
Title $title = null )

Returns true if this content is not a redirect, and this content's text is countable according to the criteria defined by $wgArticleCountMethod.

Parameters
bool | null$hasLinksIf it is known whether this content contains links, provide this information here, to avoid redundant parsing to find out (default: null).
Title | null$titleOptional title, defaults to the title from the current main request.
Returns
bool

Definition at line 217 of file WikitextContent.php.

References MediaWiki\MainConfigNames\ArticleCountMethod, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Content\AbstractContent\isRedirect().

◆ matchMagicWord()

MediaWiki\Content\WikitextContent::matchMagicWord ( MagicWord $word)

This implementation calls $word->match() on the this TextContent object's text.

Parameters
MagicWord$word
Returns
bool
See also
Content::matchMagicWord()

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 270 of file WikitextContent.php.

References MediaWiki\Content\TextContent\getText(), and MediaWiki\Parser\MagicWord\match().

◆ replaceSection()

MediaWiki\Content\WikitextContent::replaceSection ( $sectionId,
Content $with,
$sectionTitle = '' )
Parameters
string | int | null | false$sectionId
Content$withNew section content, must have the same content model as $this.
string$sectionTitle
Returns
Content
See also
Content::replaceSection()

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 88 of file WikitextContent.php.

References MediaWiki\Content\TextContent\copy(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Content\AbstractContent\getModel(), MediaWiki\Content\Content\getModel(), MediaWiki\Content\TextContent\getText(), MediaWiki\Content\Content\replaceSection(), and wfMessage().

◆ setPreSaveTransformFlags()

MediaWiki\Content\WikitextContent::setPreSaveTransformFlags ( array $flags)

Records flags set by preSaveTransform.

Access: internal
for use by WikitextContentHandler
Parameters
string[]$flags

Definition at line 281 of file WikitextContent.php.

◆ updateRedirect()

MediaWiki\Content\WikitextContent::updateRedirect ( Title $target)

This implementation replaces the first link on the page with the given new target if this Content object is a redirect.

Otherwise, this method returns $this.

Since
1.21
Parameters
Title$target
Returns
Content
See also
Content::updateRedirect()

Reimplemented from MediaWiki\Content\AbstractContent.

Definition at line 191 of file WikitextContent.php.

References MediaWiki\Title\Title\getFullText(), and MediaWiki\Content\AbstractContent\isRedirect().


The documentation for this class was generated from the following file: