MediaWiki master
MediaWiki\Diff\TextDiffer\TextDiffer Interface Reference

An interface for parts of a diff page view which represent changes to text. More...

Inherited by MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

Public Member Functions

 addModules (OutputPage $out, string $format)
 Modify the OutputPage, adding any headers required by the specified format.
 
 addRowWrapper (string $format, string $diffText)
 Make the context consistent by adding a colspan=4 wrapper around plain HTML output.
 
 getCacheKeys (array $formats)
 Get additional cache keys required by the specified formats.
 
 getFormatContext (string $format)
 Get the context for a given format.
 
 getFormats ()
 Get the supported format names.
 
 getName ()
 Get a stable unique name to identify this differ in a cache key.
 
 getPreferredFormatBatch (string $format)
 Given a format, get a list of formats which can be generated at the same time with minimal additional CPU cost.
 
 getTablePrefixes (string $format)
 Get table prefixes for the specified format.
 
 hasFormat (string $format)
 Determine whether we support the specified format.
 
 localize (string $format, string $diff, array $options=[])
 Expand messages in the diff text using the current MessageLocalizer.
 
 render (string $oldText, string $newText, string $format)
 Generate a diff comparing $oldText with $newText.
 
 renderBatch (string $oldText, string $newText, array $formats)
 Render a diff in multiple formats.
 

Public Attributes

const CONTEXT_PLAIN = 'plain'
 The HTML returned is an ordinary block.
 
const CONTEXT_PRE = 'pre'
 The return value is plain text and should be wrapped in a.
 
const CONTEXT_ROW = 'row'
 The HTML returned is zero or more table rows.
 

Detailed Description

An interface for parts of a diff page view which represent changes to text.

Since
1.41

Definition at line 12 of file TextDiffer.php.

Member Function Documentation

◆ addModules()

MediaWiki\Diff\TextDiffer\TextDiffer::addModules ( OutputPage $out,
string $format )

Modify the OutputPage, adding any headers required by the specified format.

Parameters
OutputPage$out
string$format
Returns
void

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

◆ addRowWrapper()

MediaWiki\Diff\TextDiffer\TextDiffer::addRowWrapper ( string $format,
string $diffText )

Make the context consistent by adding a colspan=4 wrapper around plain HTML output.

Parameters
string$format
string$diffText
Returns
string

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

◆ getCacheKeys()

MediaWiki\Diff\TextDiffer\TextDiffer::getCacheKeys ( array $formats)

Get additional cache keys required by the specified formats.

The result should have unique string keys, so that cache keys can be deduplicated.

Parameters
string[]$formats
Returns
array<string,string>

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, MediaWiki\Diff\TextDiffer\ManifoldTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.

◆ getFormatContext()

MediaWiki\Diff\TextDiffer\TextDiffer::getFormatContext ( string $format)

Get the context for a given format.

Returns one of the CONTEXT_* constants.

Parameters
string$format
Returns
string

Implemented in MediaWiki\Diff\TextDiffer\ExternalTextDiffer, MediaWiki\Diff\TextDiffer\ManifoldTextDiffer, MediaWiki\Diff\TextDiffer\PhpTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.

◆ getFormats()

MediaWiki\Diff\TextDiffer\TextDiffer::getFormats ( )

◆ getName()

MediaWiki\Diff\TextDiffer\TextDiffer::getName ( )

◆ getPreferredFormatBatch()

MediaWiki\Diff\TextDiffer\TextDiffer::getPreferredFormatBatch ( string $format)

Given a format, get a list of formats which can be generated at the same time with minimal additional CPU cost.

Parameters
string$format
Returns
string[]

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, MediaWiki\Diff\TextDiffer\ManifoldTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.

◆ getTablePrefixes()

MediaWiki\Diff\TextDiffer\TextDiffer::getTablePrefixes ( string $format)

Get table prefixes for the specified format.

These are HTML fragments placed above all slot diffs. The key should be a string, used for sorting and deduplication.

Parameters
string$format
Returns
array

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, MediaWiki\Diff\TextDiffer\ManifoldTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.

◆ hasFormat()

MediaWiki\Diff\TextDiffer\TextDiffer::hasFormat ( string $format)

Determine whether we support the specified format.

Parameters
string$format
Returns
bool

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

◆ localize()

MediaWiki\Diff\TextDiffer\TextDiffer::localize ( string $format,
string $diff,
array $options = [] )

Expand messages in the diff text using the current MessageLocalizer.

Perform any other necessary post-cache transformations.

Parameters
string$format
string$diff
array$optionsAn associative array of options, may contain:
  • reducedLineNumbers: If true, remove "line 1" but allow other line numbers
Returns
string

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, MediaWiki\Diff\TextDiffer\ManifoldTextDiffer, MediaWiki\Diff\TextDiffer\PhpTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.

◆ render()

MediaWiki\Diff\TextDiffer\TextDiffer::render ( string $oldText,
string $newText,
string $format )

Generate a diff comparing $oldText with $newText.

The result must be passed through localize() before being sent to the user.

Parameters
string$oldText
string$newText
string$format
Returns
string

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

◆ renderBatch()

MediaWiki\Diff\TextDiffer\TextDiffer::renderBatch ( string $oldText,
string $newText,
array $formats )

Render a diff in multiple formats.

The results must be passed through localize() before being sent to the user.

Parameters
string$oldText
string$newText
string[]$formats
Returns
array An array with the format in the key and the diff in the value.

Implemented in MediaWiki\Diff\TextDiffer\BaseTextDiffer, and MediaWiki\Diff\TextDiffer\ManifoldTextDiffer.

Member Data Documentation

◆ CONTEXT_PLAIN

const MediaWiki\Diff\TextDiffer\TextDiffer::CONTEXT_PLAIN = 'plain'

The HTML returned is an ordinary block.

Definition at line 16 of file TextDiffer.php.

◆ CONTEXT_PRE

const MediaWiki\Diff\TextDiffer\TextDiffer::CONTEXT_PRE = 'pre'

The return value is plain text and should be wrapped in a.


Definition at line 26 of file TextDiffer.php.

◆ CONTEXT_ROW

const MediaWiki\Diff\TextDiffer\TextDiffer::CONTEXT_ROW = 'row'

The HTML returned is zero or more table rows.

Definition at line 21 of file TextDiffer.php.


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