MediaWiki master
|
The base class for specific implementations of TextDiffer, apart from ManifoldTextDiffer. More...
Inherits MediaWiki\Diff\TextDiffer\TextDiffer.
Inherited by MediaWiki\Diff\TextDiffer\ExternalTextDiffer, MediaWiki\Diff\TextDiffer\PhpTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
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. | |
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. | |
setLocalizer (MessageLocalizer $localizer) | |
Public Member Functions inherited from MediaWiki\Diff\TextDiffer\TextDiffer | |
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. | |
Protected Member Functions | |
doRenderBatch (string $oldText, string $newText, array $formats) | |
Subclasses should override this to render diffs in the specified formats. | |
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. | |
The base class for specific implementations of TextDiffer, apart from ManifoldTextDiffer.
A place for protected utility functions.
Definition at line 18 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::addModules | ( | OutputPage | $out, |
string | $format ) |
Modify the OutputPage, adding any headers required by the specified format.
OutputPage | $out | |
string | $format |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Definition at line 94 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::addRowWrapper | ( | string | $format, |
string | $diffText ) |
Make the context consistent by adding a colspan=4 wrapper around plain HTML output.
string | $format | |
string | $diffText |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Definition at line 44 of file BaseTextDiffer.php.
|
abstractprotected |
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.
string | $oldText | |
string | $newText | |
array | $formats |
Reimplemented in MediaWiki\Diff\TextDiffer\ExternalTextDiffer, MediaWiki\Diff\TextDiffer\PhpTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::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.
string[] | $formats |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Reimplemented in MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
Definition at line 97 of file BaseTextDiffer.php.
|
protected |
Provide a MessageLocalizer, or throw if setLocalizer() has not been called.
Definition at line 36 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::getPreferredFormatBatch | ( | string | $format | ) |
Given a format, get a list of formats which can be generated at the same time with minimal additional CPU cost.
string | $format |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Reimplemented in MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
Definition at line 109 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::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.
string | $format |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Reimplemented in MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
Definition at line 105 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::hasFormat | ( | string | $format | ) |
Determine whether we support the specified format.
string | $format |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Definition at line 40 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::localize | ( | string | $format, |
string | $diff, | ||
array | $options = [] ) |
Expand messages in the diff text using the current MessageLocalizer.
Perform any other necessary post-cache transformations.
string | $format | |
string | $diff | |
array | $options | An associative array of options, may contain:
|
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Reimplemented in MediaWiki\Diff\TextDiffer\PhpTextDiffer, and MediaWiki\Diff\TextDiffer\Wikidiff2TextDiffer.
Definition at line 101 of file BaseTextDiffer.php.
|
protected |
Replace a common convention for language-independent line numbers with the text in the language of the current localizer.
string | $text | |
bool | $reducedLineNumbers |
Definition at line 122 of file BaseTextDiffer.php.
References $matches.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::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.
string | $oldText | |
string | $newText | |
string | $format |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Definition at line 69 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::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.
string | $oldText | |
string | $newText | |
string[] | $formats |
Implements MediaWiki\Diff\TextDiffer\TextDiffer.
Definition at line 74 of file BaseTextDiffer.php.
MediaWiki\Diff\TextDiffer\BaseTextDiffer::setLocalizer | ( | MessageLocalizer | $localizer | ) |
MessageLocalizer | $localizer |
Definition at line 25 of file BaseTextDiffer.php.
|
protected |
Throw an exception if any of the formats in the array is not supported.
string[] | $formats |
Definition at line 62 of file BaseTextDiffer.php.