MediaWiki master
MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer Class Reference

Inherits MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Collaboration diagram for MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer:

Public Member Functions

 __construct ( $options)
 
 doRenderBatch (string $oldText, string $newText, array $formats)
 Subclasses should override this to render diffs in the specified formats.
 
 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.
 
 localize (string $format, string $diff, array $options=[])
 Expand messages in the diff text using the current MessageLocalizer.
 
- Public Member Functions inherited from MediaWiki\Diff\TextDiffer\BaseTextDiffer
 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.
 
 hasFormat (string $format)
 Determine whether we support the specified format.
 
 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.
 
 setLocalizer (MessageLocalizer $localizer)
 

Static Public Member Functions

static isInstalled ()
 Determine whether the extension is installed (or mocked for testing)
 

Static Public Attributes

static string null $fakeVersionForTesting = null
 Fake wikidiff2 extension version for PHPUnit testing.
 

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.
 
- Protected Member Functions inherited from MediaWiki\Diff\TextDiffer\BaseTextDiffer
 getLocalizer ()
 Provide a MessageLocalizer, or throw if setLocalizer() has not been called.
 
 localizeLineNumbers ( $text, $reducedLineNumbers)
 Replace a common convention for language-independent line numbers with the text in the language of the current localizer.
 
 validateFormats ( $formats)
 Throw an exception if any of the formats in the array is not supported.
 

Detailed Description

Since
1.41

Definition at line 11 of file Wikidiff2TextDiffer.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer::__construct ( $options)
Parameters
array$options

Definition at line 59 of file Wikidiff2TextDiffer.php.

Member Function Documentation

◆ doRenderBatch()

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

Subclasses should override this to render diffs in the specified formats.

The $formats array is guaranteed to not be empty and to contain only formats supported by the subclass.

Parameters
string$oldText
string$newText
array$formats
Returns
array

Reimplemented from MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Definition at line 110 of file Wikidiff2TextDiffer.php.

◆ getCacheKeys()

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

Reimplemented from MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Definition at line 83 of file Wikidiff2TextDiffer.php.

◆ getFormatContext()

MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer::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 79 of file Wikidiff2TextDiffer.php.

◆ getFormats()

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

Get the supported format names.

Returns
string[]

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 184 of file Wikidiff2TextDiffer.php.

◆ getName()

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

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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 75 of file Wikidiff2TextDiffer.php.

◆ getPreferredFormatBatch()

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

Reimplemented from MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Definition at line 243 of file Wikidiff2TextDiffer.php.

◆ getTablePrefixes()

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

Reimplemented from MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Definition at line 188 of file Wikidiff2TextDiffer.php.

◆ isInstalled()

static MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer::isInstalled ( )
static

Determine whether the extension is installed (or mocked for testing)

Returns
bool

Definition at line 51 of file Wikidiff2TextDiffer.php.

◆ localize()

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

Reimplemented from MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Definition at line 205 of file Wikidiff2TextDiffer.php.

Member Data Documentation

◆ $fakeVersionForTesting

string null MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer::$fakeVersionForTesting = null
static

Fake wikidiff2 extension version for PHPUnit testing.

Definition at line 44 of file Wikidiff2TextDiffer.php.


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