MediaWiki  master
WikitextContent Class Reference

Content object for wiki text pages. More...

Inheritance diagram for WikitextContent:
Collaboration diagram for WikitextContent:

Public Member Functions

 __construct ( $text)
 
 addSectionHeader ( $header)
 Returns a new WikitextContent object with the given section heading prepended. More...
 
 getPreSaveTransformFlags ()
 Records flags set by preSaveTransform. More...
 
 getRedirectTarget ()
 Implement redirect extraction for wikitext. More...
 
 getRedirectTargetAndText ()
 Extract the redirect target and the remaining text on the page. More...
 
 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. More...
 
 matchMagicWord (MagicWord $word)
 This implementation calls $word->match() on the this TextContent object's text. More...
 
 replaceSection ( $sectionId, Content $with, $sectionTitle='')
 
 setPreSaveTransformFlags (array $flags)
 Records flags set by preSaveTransform. More...
 
 updateRedirect (Title $target)
 This implementation replaces the first link on the page with the given new target if this Content object is a redirect. More...
 
- Public Member Functions inherited from TextContent
 __construct ( $text, $model_id=CONTENT_MODEL_TEXT)
 
 convert ( $toModel, $lossy='')
 This implementation provides lossless conversion between content models based on TextContent. More...
 
 copy ()
 
 diff (Content $that, Language $lang=null)
 Diff this content object with another content object. More...
 
 getNativeData ()
 Returns the text represented by this Content object, as a string. More...
 
 getSize ()
 Returns the text's size in bytes. More...
 
 getText ()
 Returns the text represented by this Content object, as a string. More...
 
 getTextForSearchIndex ()
 Returns the text represented by this Content object, as a string. More...
 
 getWikitextForTransclusion ()
 Returns attempts to convert this content object to wikitext, and then returns the text string. More...
 
 isCountable ( $hasLinks=null)
 Returns true if this content is not a redirect, and $wgArticleCountMethod is "any". More...
 
- Public Member Functions inherited from AbstractContent
 equals (Content $that=null)
 Decides whether two Content objects are equal. More...
 
 getContentHandler ()
 
 getDefaultFormat ()
 
 getModel ()
 
 getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
 Returns a ParserOutput object containing information derived from this content. More...
 
 getRedirectChain ()
 
 getSupportedFormats ()
 
 getUltimateRedirectTarget ()
 
 isEmpty ()
 
 isRedirect ()
 
 isSupportedFormat ( $format)
 
 isValid ()
 Subclasses may override this to implement (light weight) validation. More...
 
 preloadTransform (Title $title, ParserOptions $popts, $params=[])
 
 prepareSave (WikiPage $page, $flags, $parentRevId, User $user)
 
 preSaveTransform (Title $title, User $user, ParserOptions $popts)
 
 serialize ( $format=null)
 

Private Attributes

string[] $preSaveTransformFlags = []
 flags set by PST More...
 
 $redirectTargetAndText = null
 

Additional Inherited Members

- Static Public Member Functions inherited from TextContent
static normalizeLineEndings ( $text)
 Do a "\\r\\n" -> "\\n" and "\\r" -> "\\n" transformation as well as trim trailing whitespace. More...
 
- Protected Member Functions inherited from AbstractContent
 checkFormat ( $format)
 
 checkModelID ( $modelId)
 
 equalsInternal (Content $that)
 Checks whether $that is logically equal to this Content object. More...
 
 fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 Fills the provided ParserOutput with information derived from the content. More...
 
 getContentHandlerFactory ()
 
- Protected Attributes inherited from TextContent
string $mText
 
- Protected Attributes inherited from AbstractContent
string $model_id
 Name of the content model this Content object represents. More...
 

Detailed Description

Content object for wiki text pages.

@newable

Definition at line 36 of file WikitextContent.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from AbstractContent.

Definition at line 49 of file WikitextContent.php.

References CONTENT_MODEL_WIKITEXT.

Member Function Documentation

◆ addSectionHeader()

WikitextContent::addSectionHeader (   $header)

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

Parameters
string$header
Returns
Content

Reimplemented from AbstractContent.

Definition at line 129 of file WikitextContent.php.

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

◆ getPreSaveTransformFlags()

WikitextContent::getPreSaveTransformFlags ( )

Records flags set by preSaveTransform.

Access: internal
for use by WikitextContentHandler
Returns
string[]

Definition at line 309 of file WikitextContent.php.

References $preSaveTransformFlags.

◆ getRedirectTarget()

WikitextContent::getRedirectTarget ( )

Implement redirect extraction for wikitext.

Returns
Title|null
See also
Content::getRedirectTarget

Reimplemented from AbstractContent.

Definition at line 197 of file WikitextContent.php.

References $title, and getRedirectTargetAndText().

◆ getRedirectTargetAndText()

WikitextContent::getRedirectTargetAndText ( )

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

Note
migrated here from Title::newFromRedirectInternal()
Since
1.23
Returns
array List of two elements: Title|null and string.

Definition at line 147 of file WikitextContent.php.

References $redirectTargetAndText, $title, $wgMaxRedirects, TextContent\getText(), and Title\newFromText().

Referenced by getRedirectTarget().

◆ getSection()

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

Reimplemented from AbstractContent.

Definition at line 60 of file WikitextContent.php.

References TextContent\getText().

◆ getTextForSummary()

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

Reimplemented from TextContent.

Definition at line 271 of file WikitextContent.php.

◆ isCountable()

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 241 of file WikitextContent.php.

References $title, $wgArticleCountMethod, RequestContext\getMain(), AbstractContent\getParserOutput(), and AbstractContent\isRedirect().

◆ matchMagicWord()

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 AbstractContent.

Definition at line 291 of file WikitextContent.php.

References TextContent\getText(), and MagicWord\match().

◆ replaceSection()

WikitextContent::replaceSection (   $sectionId,
Content  $with,
  $sectionTitle = '' 
)
Parameters
string | int | null | bool$sectionId
Content$with
string$sectionTitle
Exceptions
MWException
Returns
Content
See also
Content::replaceSection()

Reimplemented from AbstractContent.

Definition at line 82 of file WikitextContent.php.

References TextContent\copy(), AbstractContent\getModel(), Content\getModel(), TextContent\getText(), Hooks\runner(), and wfMessage().

◆ setPreSaveTransformFlags()

WikitextContent::setPreSaveTransformFlags ( array  $flags)

Records flags set by preSaveTransform.

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

Definition at line 300 of file WikitextContent.php.

◆ updateRedirect()

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 AbstractContent.

Definition at line 215 of file WikitextContent.php.

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

Member Data Documentation

◆ $preSaveTransformFlags

string [] WikitextContent::$preSaveTransformFlags = []
private

flags set by PST

Definition at line 42 of file WikitextContent.php.

Referenced by getPreSaveTransformFlags().

◆ $redirectTargetAndText

WikitextContent::$redirectTargetAndText = null
private

Definition at line 37 of file WikitextContent.php.

Referenced by getRedirectTargetAndText().


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