MediaWiki  1.28.0
AbstractContent Class Reference

Base implementation for content objects. More...

Inheritance diagram for AbstractContent:
Collaboration diagram for AbstractContent:

Public Member Functions

 __construct ($modelId=null)
 
 addSectionHeader ($header)
 
 convert ($toModel, $lossy= '')
 This base implementation calls the hook ConvertContent to enable custom conversions. More...
 
 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. More...
 
 getRedirectChain ()
 
 getRedirectTarget ()
 Subclasses that implement redirects should override this. More...
 
 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...
 
 getSection ($sectionId)
 
 getSupportedFormats ()
 
 getUltimateRedirectTarget ()
 
 isEmpty ()
 
 isRedirect ()
 
 isSupportedFormat ($format)
 
 isValid ()
 Subclasses may override this to implement (light weight) validation. More...
 
 matchMagicWord (MagicWord $word)
 This default implementation always returns false. More...
 
 preloadTransform (Title $title, ParserOptions $popts, $params=[])
 
 prepareSave (WikiPage $page, $flags, $parentRevId, User $user)
 
 preSaveTransform (Title $title, User $user, ParserOptions $popts)
 
 replaceSection ($sectionId, Content $with, $sectionTitle= '')
 
 serialize ($format=null)
 
 updateRedirect (Title $target)
 This default implementation always returns $this. More...
 
- Public Member Functions inherited from Content
 copy ()
 Return a copy of this Content object. More...
 
 getNativeData ()
 Returns native representation of the data. More...
 
 getSize ()
 Returns the content's nominal size in "bogo-bytes". More...
 
 getTextForSearchIndex ()
 
 getTextForSummary ($maxLength=250)
 Returns a textual representation of the content suitable for use in edit summaries and log messages. More...
 
 getWikitextForTransclusion ()
 
 isCountable ($hasLinks=null)
 Returns true if this content is countable as a "real" wiki page, provided that it's also in a countable location (e.g. More...
 

Protected Member Functions

 checkFormat ($format)
 
 checkModelID ($modelId)
 
 fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 Fills the provided ParserOutput with information derived from the content. More...
 

Protected Attributes

 $model_id
 Name of the content model this Content object represents. More...
 

Detailed Description

Base implementation for content objects.

Definition at line 34 of file AbstractContent.php.

Constructor & Destructor Documentation

AbstractContent::__construct (   $modelId = null)
Parameters
string$modelId
Since
1.21

Definition at line 50 of file AbstractContent.php.

Member Function Documentation

AbstractContent::addSectionHeader (   $header)
Since
1.21
Returns
Content $this
See also
Content::addSectionHeader

Implements Content.

Definition at line 374 of file AbstractContent.php.

AbstractContent::checkFormat (   $format)
protected
Since
1.21
Parameters
string$formatThe serialization format to check.
Exceptions
MWExceptionIf the format is not supported by this content handler.

Definition at line 132 of file AbstractContent.php.

References getModel(), and isSupportedFormat().

AbstractContent::checkModelID (   $modelId)
protected
Since
1.21
Parameters
string$modelIdThe model to check
Exceptions
MWExceptionIf the provided ID is not the ID of the content model supported by this Content object.

Definition at line 71 of file AbstractContent.php.

Referenced by TextContent\diff().

AbstractContent::convert (   $toModel,
  $lossy = '' 
)

This base implementation calls the hook ConvertContent to enable custom conversions.

Subclasses may override this to implement conversion for "their" content model.

Parameters
string$toModel
string$lossy
Returns
Content|bool
See also
Content::convert()

Implements Content.

Definition at line 447 of file AbstractContent.php.

References getModel(), and Hooks\run().

AbstractContent::equals ( Content  $that = null)
Since
1.21
Parameters
Content$that
Returns
bool
See also
Content::equals

Implements Content.

Definition at line 187 of file AbstractContent.php.

References getModel(), and Content\getNativeData().

Referenced by CssContent\getRedirectTarget(), and JavaScriptContent\getRedirectTarget().

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

Fills the provided ParserOutput with information derived from the content.

Unless $generateHtml was false, this includes an HTML representation of the content.

This is called by getParserOutput() after consulting the ContentGetParserOutput hook. Subclasses are expected to override this method (or getParserOutput(), if need be). Subclasses of TextContent should generally override getHtml() instead.

This placeholder implementation always throws an exception.

Since
1.24
Parameters
Title$titleContext title for parsing
int | null$revIdRevision ID (for {{REVISIONID}})
ParserOptions$optionsParser options
bool$generateHtmlWhether or not to generate HTML
ParserOutput&$outputThe output object to fill (reference).
Exceptions
MWException

Definition at line 526 of file AbstractContent.php.

Referenced by getParserOutput().

AbstractContent::getDefaultFormat ( )
Since
1.21
See also
Content::getDefaultFormat

Implements Content.

Definition at line 95 of file AbstractContent.php.

References getContentHandler().

AbstractContent::getDeletionUpdates ( WikiPage  $page,
ParserOutput  $parserOutput = null 
)
Since
1.21
Parameters
WikiPage$page
ParserOutput$parserOutput
Returns
LinksDeletionUpdate[]
See also
Content::getDeletionUpdates

Implements Content.

Definition at line 414 of file AbstractContent.php.

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

Returns a ParserOutput object containing information derived from this content.

Most importantly, unless $generateHtml was false, the return value contains an HTML representation of the content.

Subclasses that want to control the parser output may override this, but it is preferred to override fillParserOutput() instead.

Subclasses that override getParserOutput() itself should take care to call the ContentGetParserOutput hook.

Since
1.24
Parameters
Title$titleContext title for parsing
int | null$revIdRevision ID (for {{REVISIONID}})
ParserOptions | null$optionsParser options
bool$generateHtmlWhether or not to generate HTML
Returns
ParserOutput Containing information derived from this content.

Implements Content.

Definition at line 481 of file AbstractContent.php.

References $generateHtml, $options, $revId, fillParserOutput(), getContentHandler(), getRedirectTarget(), and Hooks\run().

Referenced by getSecondaryDataUpdates(), and WikitextContent\isCountable().

AbstractContent::getRedirectChain ( )
Since
1.21
Returns
Title[]|null
See also
Content::getRedirectChain

Implements Content.

Definition at line 249 of file AbstractContent.php.

References $page, $title, $titles, WikiPage\factory(), getRedirectTarget(), and global.

Referenced by WikitextContent\fillParserOutput(), and getUltimateRedirectTarget().

AbstractContent::getRedirectTarget ( )

Subclasses that implement redirects should override this.

Since
1.21
Returns
Title|null
See also
Content::getRedirectTarget

Implements Content.

Definition at line 288 of file AbstractContent.php.

Referenced by getParserOutput(), getRedirectChain(), and isRedirect().

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

This default implementation returns a LinksUpdate object and calls the SecondaryDataUpdates hook.

Subclasses may override this to determine the secondary data updates more efficiently, preferably without the need to generate a parser output object. They should however make sure to call SecondaryDataUpdates to give extensions a chance to inject additional updates.

Since
1.21
Parameters
Title$title
Content$old
bool$recursive
ParserOutput$parserOutput
Returns
DataUpdate[]
See also
Content::getSecondaryDataUpdates()

Implements Content.

Definition at line 226 of file AbstractContent.php.

References $parserOutput, getParserOutput(), and Hooks\run().

AbstractContent::getSection (   $sectionId)
Since
1.21
Returns
null
See also
Content::getSection

Implements Content.

Definition at line 341 of file AbstractContent.php.

AbstractContent::getSupportedFormats ( )
Since
1.21
See also
Content::getSupportedFormats

Implements Content.

Definition at line 104 of file AbstractContent.php.

References getContentHandler().

AbstractContent::getUltimateRedirectTarget ( )
Note
Migrated here from Title::newFromRedirectRecurse.
Since
1.21
Returns
Title|null
See also
Content::getUltimateRedirectTarget

Implements Content.

Definition at line 301 of file AbstractContent.php.

References $titles, and getRedirectChain().

AbstractContent::isEmpty ( )
Since
1.21
Returns
bool
See also
Content::isEmpty

Implements Content.

Definition at line 161 of file AbstractContent.php.

References Content\getSize().

AbstractContent::isRedirect ( )
AbstractContent::isSupportedFormat (   $format)
Since
1.21
Parameters
string$format
Returns
bool
See also
Content::isSupportedFormat

Implements Content.

Definition at line 117 of file AbstractContent.php.

References getContentHandler().

Referenced by checkFormat().

AbstractContent::isValid ( )

Subclasses may override this to implement (light weight) validation.

Since
1.21
Returns
bool Always true.
See also
Content::isValid

Implements Content.

Definition at line 174 of file AbstractContent.php.

Referenced by prepareSave().

AbstractContent::matchMagicWord ( MagicWord  $word)

This default implementation always returns false.

Subclasses may override this to supply matching logic.

Since
1.21
Parameters
MagicWord$word
Returns
bool Always false.
See also
Content::matchMagicWord

Implements Content.

Definition at line 432 of file AbstractContent.php.

AbstractContent::preloadTransform ( Title  $title,
ParserOptions  $popts,
  $params = [] 
)
Since
1.21
Returns
Content $this
See also
Content::preloadTransform

Implements Content.

Definition at line 385 of file AbstractContent.php.

AbstractContent::prepareSave ( WikiPage  $page,
  $flags,
  $parentRevId,
User  $user 
)
Since
1.21
Returns
Status
See also
Content::prepareSave

Implements Content.

Definition at line 396 of file AbstractContent.php.

References isValid(), StatusValue\newFatal(), and StatusValue\newGood().

AbstractContent::preSaveTransform ( Title  $title,
User  $user,
ParserOptions  $popts 
)
Since
1.21
Returns
Content $this
See also
Content::preSaveTransform

Implements Content.

Definition at line 363 of file AbstractContent.php.

AbstractContent::replaceSection (   $sectionId,
Content  $with,
  $sectionTitle = '' 
)
Since
1.21
Returns
null
See also
Content::replaceSection

Implements Content.

Definition at line 352 of file AbstractContent.php.

AbstractContent::serialize (   $format = null)
Since
1.21
Parameters
string$format
Returns
string
See also
Content::serialize

Implements Content.

Definition at line 150 of file AbstractContent.php.

References getContentHandler().

AbstractContent::updateRedirect ( Title  $target)

This default implementation always returns $this.

Subclasses that implement redirects should override this.

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

Implements Content.

Definition at line 330 of file AbstractContent.php.

Member Data Documentation

string AbstractContent::$model_id
protected

Name of the content model this Content object represents.

Use with CONTENT_MODEL_XXX constants

Since
1.21

Definition at line 43 of file AbstractContent.php.

Referenced by TextContent\__construct(), and getModel().


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