MediaWiki REL1_27
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.
 
 getRedirectTarget ()
 Implement redirect extraction for wikitext.
 
 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.
 
 preloadTransform (Title $title, ParserOptions $popts, $params=[])
 Returns a Content object with preload transformations applied (or this object if no transformations apply).
 
 preSaveTransform (Title $title, User $user, ParserOptions $popts)
 Returns a Content object with pre-save transformations applied using Parser::preSaveTransform().
 
 replaceSection ( $sectionId, Content $with, $sectionTitle='')
 
 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 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.
 
 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 AbstractContent
 equals (Content $that=null)
 
 getContentHandler ()
 
 getDefaultFormat ()
 
 getDeletionUpdates (WikiPage $page, ParserOutput $parserOutput=null)
 
 getModel ()
 
 getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
 Returns a ParserOutput object containing information derived from this content.
 
 getRedirectChain ()
 
 getSecondaryDataUpdates (Title $title, Content $old=null, $recursive=true, ParserOutput $parserOutput=null)
 Returns a list of DataUpdate objects for recording information about this Content in some secondary data store.
 
 getSupportedFormats ()
 
 getUltimateRedirectTarget ()
 
 isEmpty ()
 
 isRedirect ()
 
 isSupportedFormat ( $format)
 
 isValid ()
 Subclasses may override this to implement (light weight) validation.
 
 prepareSave (WikiPage $page, $flags, $parentRevId, User $user)
 
 serialize ( $format=null)
 

Protected Member Functions

 fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 Returns a ParserOutput object resulting from parsing the content's text using $wgParser.
 
 getHtml ()
 
 getRedirectTargetAndText ()
 Extract the redirect target and the remaining text on the page.
 
- Protected Member Functions inherited from TextContent
 getHighlightHtml ()
 Generates an HTML version of the content, for display.
 
- Protected Member Functions inherited from AbstractContent
 checkFormat ( $format)
 
 checkModelID ( $modelId)
 

Private Attributes

 $redirectTargetAndText = null
 

Additional Inherited Members

- Protected Attributes inherited from AbstractContent
 $model_id
 Name of the content model this Content object represents.
 

Detailed Description

Content object for wiki text pages.

Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 33 of file WikitextContent.php.

Constructor & Destructor Documentation

◆ __construct()

WikitextContent::__construct (   $modelId)
Parameters
string$modelId
Since
1.21

Reimplemented from AbstractContent.

Definition at line 36 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 117 of file WikitextContent.php.

References TextContent\getNativeData(), and wfMessage().

◆ fillParserOutput()

WikitextContent::fillParserOutput ( Title  $title,
  $revId,
ParserOptions  $options,
  $generateHtml,
ParserOutput $output 
)
protected

Returns a ParserOutput object resulting from parsing the content's text using $wgParser.

Parameters
Title$title
int$revIdRevision to pass to the parser (default: null)
ParserOptions$options(default: null)
bool$generateHtml(default: true)
ParserOutput&$outputParserOutput representing the HTML form of the text, may be manipulated or replaced.

Reimplemented from TextContent.

Definition at line 325 of file WikitextContent.php.

References $generateHtml, $options, $output, $revId, $title, $wgParser, ParserOutput\addLink(), ParserOutput\addModuleStyles(), ParserOutput\getRawText(), AbstractContent\getRedirectChain(), Article\getRedirectHeaderHtml(), getRedirectTargetAndText(), global, list, and ParserOutput\setText().

◆ getHtml()

WikitextContent::getHtml ( )
protected
Exceptions
MWException

Reimplemented from TextContent.

Definition at line 351 of file WikitextContent.php.

◆ getRedirectTarget()

WikitextContent::getRedirectTarget ( )

Implement redirect extraction for wikitext.

Returns
Title|null
See also
Content::getRedirectTarget

Reimplemented from AbstractContent.

Definition at line 224 of file WikitextContent.php.

References $title, getRedirectTargetAndText(), and list.

◆ getRedirectTargetAndText()

WikitextContent::getRedirectTargetAndText ( )
protected

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

References $redirectTargetAndText, $title, $wgMaxRedirects, MagicWord\get(), TextContent\getNativeData(), global, and Title\newFromText().

Referenced by fillParserOutput(), and getRedirectTarget().

◆ getSection()

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

Reimplemented from AbstractContent.

Definition at line 47 of file WikitextContent.php.

References $wgParser, TextContent\getNativeData(), and global.

◆ getTextForSummary()

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

Reimplemented from TextContent.

Definition at line 303 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 268 of file WikitextContent.php.

References $context, $title, $wgArticleCountMethod, RequestContext\getMain(), TextContent\getNativeData(), AbstractContent\getParserOutput(), global, 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 367 of file WikitextContent.php.

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

◆ preloadTransform()

WikitextContent::preloadTransform ( Title  $title,
ParserOptions  $popts,
  $params = [] 
)

Returns a Content object with preload transformations applied (or this object if no transformations apply).

Parameters
Title$title
ParserOptions$popts
array$params
Returns
Content

Reimplemented from AbstractContent.

Definition at line 156 of file WikitextContent.php.

References $params, $title, $wgParser, TextContent\getNativeData(), and global.

◆ preSaveTransform()

WikitextContent::preSaveTransform ( Title  $title,
User  $user,
ParserOptions  $popts 
)

Returns a Content object with pre-save transformations applied using Parser::preSaveTransform().

Parameters
Title$title
User$user
ParserOptions$popts
Returns
Content

Reimplemented from TextContent.

Definition at line 136 of file WikitextContent.php.

References $title, $user, $wgParser, TextContent\getNativeData(), and global.

◆ replaceSection()

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

Reimplemented from AbstractContent.

Definition at line 70 of file WikitextContent.php.

References $wgParser, TextContent\copy(), AbstractContent\getModel(), Content\getModel(), Content\getNativeData(), TextContent\getNativeData(), global, and wfMessage().

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

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

Member Data Documentation

◆ $redirectTargetAndText

WikitextContent::$redirectTargetAndText = null
private

Definition at line 34 of file WikitextContent.php.

Referenced by getRedirectTargetAndText().


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