MediaWiki master
MediaWiki\Diff\TextDiffer\PhpTextDiffer Class Reference

Inherits MediaWiki\Diff\TextDiffer\BaseTextDiffer.

Collaboration diagram for MediaWiki\Diff\TextDiffer\PhpTextDiffer:

Public Member Functions

 __construct (?Language $contentLanguage)
 
 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.
 
 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.
 
 getCacheKeys (array $formats)
 Get additional cache keys required by the specified formats.
 
 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.
 
 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)
 

Protected Member Functions

 doRenderBatch (string $oldText, string $newText, array $formats)
 Subclasses should override this to render diffs in the specified formats.
 
- 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.
 

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

Since
1.41

Definition at line 13 of file PhpTextDiffer.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Diff\TextDiffer\PhpTextDiffer::__construct ( ?Language $contentLanguage)

Definition at line 17 of file PhpTextDiffer.php.

Member Function Documentation

◆ doRenderBatch()

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

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 33 of file PhpTextDiffer.php.

◆ getFormatContext()

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

◆ getFormats()

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

Get the supported format names.

Returns
string[]

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 25 of file PhpTextDiffer.php.

◆ getName()

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

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

Implements MediaWiki\Diff\TextDiffer\TextDiffer.

Definition at line 21 of file PhpTextDiffer.php.

◆ localize()

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


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