MediaWiki  1.23.2
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...
 
 getParserOutput (Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
 Returns a ParserOutput object resulting from parsing the content's text using $wgParser. More...
 
 getRedirectTarget ()
 Implement redirect extraction for wikitext. More...
 
 getSection ( $section)
 
 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...
 
 preloadTransform (Title $title, ParserOptions $popts, $params=array())
 Returns a Content object with preload transformations applied (or this object if no transformations apply). More...
 
 preSaveTransform (Title $title, User $user, ParserOptions $popts)
 Returns a Content object with pre-save transformations applied using Parser::preSaveTransform(). More...
 
 replaceSection ( $section, 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. 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...
 
 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)
 
 getContentHandler ()
 
 getDefaultFormat ()
 
 getDeletionUpdates (WikiPage $page, ParserOutput $parserOutput=null)
 
 getModel ()
 
 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. More...
 
 getSupportedFormats ()
 
 getUltimateRedirectTarget ()
 
 isEmpty ()
 
 isRedirect ()
 
 isSupportedFormat ( $format)
 
 isValid ()
 Subclasses may override this to implement (light weight) validation. More...
 
 prepareSave (WikiPage $page, $flags, $baseRevId, User $user)
 
 serialize ( $format=null)
 

Protected Member Functions

 getHtml ()
 
- Protected Member Functions inherited from TextContent
 getHighlightHtml ()
 Generates a syntax-highlighted version of the content, as HTML. More...
 
- Protected Member Functions inherited from AbstractContent
 checkFormat ( $format)
 
 checkModelID ( $modelId)
 

Additional Inherited Members

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

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

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

◆ getHtml()

WikitextContent::getHtml ( )
protected
Exceptions
MWException

Reimplemented from TextContent.

Definition at line 330 of file WikitextContent.php.

◆ getParserOutput()

WikitextContent::getParserOutput ( Title  $title,
  $revId = null,
ParserOptions  $options = null,
  $generateHtml = true 
)

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

Since
1.21
Parameters
Title$title*
int$revIdRevision to pass to the parser (default: null)
ParserOptions$options(default: null)
bool$generateHtml(default: false)

Reimplemented from TextContent.

Definition at line 313 of file WikitextContent.php.

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

Referenced by isCountable().

◆ getRedirectTarget()

WikitextContent::getRedirectTarget ( )

Implement redirect extraction for wikitext.

Returns
null|Title
Note
: migrated here from Title::newFromRedirectInternal()
See also
Content::getRedirectTarget
AbstractContent::getRedirectTarget

Reimplemented from AbstractContent.

Definition at line 180 of file WikitextContent.php.

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

◆ getSection()

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

Reimplemented from AbstractContent.

Definition at line 46 of file WikitextContent.php.

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

◆ getTextForSummary()

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

Reimplemented from TextContent.

Definition at line 289 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$hasLinksIf it is known whether this content contains links, provide this information here, to avoid redundant parsing to find out (default: null).
Title$titleOptional title, defaults to the title from the current main request.

Definition at line 253 of file WikitextContent.php.

References $title, RequestContext\getMain(), TextContent\getNativeData(), 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 346 of file WikitextContent.php.

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

◆ preloadTransform()

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

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

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

◆ replaceSection()

WikitextContent::replaceSection (   $section,
Content  $with,
  $sectionTitle = '' 
)

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

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


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