MediaWiki master
MediaWiki\Diff\TextDiffer\ManifoldTextDiffer Class Reference

A TextDiffer which acts as a container for other TextDiffers, and dispatches requests to them. More...

Inherits MediaWiki\Diff\TextDiffer\TextDiffer.

Collaboration diagram for MediaWiki\Diff\TextDiffer\ManifoldTextDiffer:

Public Member Functions

 __construct (MessageLocalizer $localizer, ?Language $contentLanguage, $diffEngine, $externalPath, $wikidiff2Options)
 
 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.
 
 getEngineForFormat (string $format)
 Get the text differ name which will be used for the specified format.
 
 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.
 
 injectDeps (TextDiffer $differ)
 Initialize an object which may be a subclass of BaseTextDiffer, passing down injected dependencies.
 
 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.
 
 setEngine (string $name)
 Disable text differs apart from the one with the given name.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Diff\TextDiffer\TextDiffer
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

A TextDiffer which acts as a container for other TextDiffers, and dispatches requests to them.

Since
1.41

Definition at line 18 of file ManifoldTextDiffer.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::__construct ( MessageLocalizer $localizer,
?Language $contentLanguage,
$diffEngine,
$externalPath,
$wikidiff2Options )
Access: internal
For use by DifferenceEngine, ContentHandler
Parameters
MessageLocalizer$localizer
Language | null$contentLanguage
string | null$diffEngineThe DiffEngine config variable
string | false | null$externalPathThe ExternalDiffEngine config variable
array$wikidiff2OptionsThe Wikidiff2Options config variable

Definition at line 43 of file ManifoldTextDiffer.php.

Member Function Documentation

◆ addModules()

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

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

Parameters
OutputPage$out
string$format
Returns
void

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 98 of file ManifoldTextDiffer.php.

◆ addRowWrapper()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 94 of file ManifoldTextDiffer.php.

◆ getCacheKeys()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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>

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 102 of file ManifoldTextDiffer.php.

◆ getEngineForFormat()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::getEngineForFormat ( string $format)

Get the text differ name which will be used for the specified format.

Parameters
string$format
Returns
string|null

Definition at line 175 of file ManifoldTextDiffer.php.

◆ getFormatContext()

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

Get the context for a given format.

Returns one of the CONTEXT_* constants.

Parameters
string$format
Returns
string

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 90 of file ManifoldTextDiffer.php.

◆ getFormats()

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

Get the supported format names.

Returns
string[]

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 61 of file ManifoldTextDiffer.php.

◆ getName()

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

Get a stable unique name to identify this differ in a cache key.

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 57 of file ManifoldTextDiffer.php.

◆ getPreferredFormatBatch()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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[]

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 123 of file ManifoldTextDiffer.php.

◆ getTablePrefixes()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 119 of file ManifoldTextDiffer.php.

◆ hasFormat()

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

Determine whether we support the specified format.

Parameters
string$format
Returns
bool

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 66 of file ManifoldTextDiffer.php.

◆ injectDeps()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::injectDeps ( TextDiffer $differ)

Initialize an object which may be a subclass of BaseTextDiffer, passing down injected dependencies.

Parameters
TextDiffer$differ

Definition at line 218 of file ManifoldTextDiffer.php.

◆ localize()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 115 of file ManifoldTextDiffer.php.

◆ render()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 71 of file ManifoldTextDiffer.php.

◆ renderBatch()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::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.

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 80 of file ManifoldTextDiffer.php.

◆ setEngine()

MediaWiki\Diff\TextDiffer\ManifoldTextDiffer::setEngine ( string $name)

Disable text differs apart from the one with the given name.

Parameters
string$name

Definition at line 163 of file ManifoldTextDiffer.php.


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