MediaWiki REL1_40
TextSlotDiffRenderer Class Reference

Renders a slot diff by doing a text diff on the native representation. More...

Inherits SlotDiffRenderer.

Collaboration diagram for TextSlotDiffRenderer:

Public Member Functions

 getDiff (Content $oldContent=null, Content $newContent=null)
 Get a diff between two content objects.One of them might be null (meaning a slot was created or removed), but both cannot be. $newContent (or if it's null then $oldContent) must have the same content model that was used to obtain this diff renderer.

Parameters
Content | null$oldContent
Content | null$newContent
Returns
string HTML, one or more

 
 getExtraCacheKeys ()
 Return any extra keys to split the diff cache by.
Stability: stable
to override
Returns
string[]

 
 getTextDiff (string $oldText, string $newText)
 Diff the text representations of two content objects (or just two pieces of text in general).
 
 setEngine ( $type, $executable=null)
 Set which diff engine to use.
 
 setLanguage (Language $language)
 
 setStatsdDataFactory (IBufferingStatsdDataFactory $statsdDataFactory)
 
- Public Member Functions inherited from SlotDiffRenderer
 addModules (OutputPage $output)
 Add modules needed for correct styling/behavior of the diff.
 

Static Public Member Functions

static diff ( $oldText, $newText)
 Convenience helper to use getTextDiff without an instance.
 

Public Attributes

const ENGINE_EXTERNAL = 'external'
 Use an external executable.
 
const ENGINE_PHP = 'php'
 Use the PHP diff implementation (DiffEngine).
 
const ENGINE_WIKIDIFF2 = 'wikidiff2'
 Use the wikidiff2 PHP module.
 
const ENGINE_WIKIDIFF2_INLINE = 'wikidiff2inline'
 Use the wikidiff2 PHP module.
 

Protected Member Functions

 getTextDiffInternal ( $oldText, $newText)
 Diff the text representations of two content objects (or just two pieces of text in general).
 
- Protected Member Functions inherited from SlotDiffRenderer
 normalizeContents (Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null)
 Helper method to normalize the input of getDiff().
 

Detailed Description

Renders a slot diff by doing a text diff on the native representation.

If you want to use this without content objects (to call getTextDiff() on some non-content-related texts), obtain an instance with ContentHandler::getForModelID( CONTENT_MODEL_TEXT ) ->getSlotDiffRenderer( RequestContext::getMain() )

Definition at line 38 of file TextSlotDiffRenderer.php.

Member Function Documentation

◆ diff()

static TextSlotDiffRenderer::diff ( $oldText,
$newText )
static

Convenience helper to use getTextDiff without an instance.

Parameters
string$oldText
string$newText
Returns
string

Definition at line 78 of file TextSlotDiffRenderer.php.

References CONTENT_MODEL_TEXT.

◆ getDiff()

TextSlotDiffRenderer::getDiff ( Content $oldContent = null,
Content $newContent = null )

Get a diff between two content objects.One of them might be null (meaning a slot was created or removed), but both cannot be. $newContent (or if it's null then $oldContent) must have the same content model that was used to obtain this diff renderer.

Parameters
Content | null$oldContent
Content | null$newContent
Returns
string HTML, one or more

Reimplemented from SlotDiffRenderer.

Definition at line 124 of file TextSlotDiffRenderer.php.

References getTextDiff(), and SlotDiffRenderer\normalizeContents().

◆ getExtraCacheKeys()

TextSlotDiffRenderer::getExtraCacheKeys ( )

Return any extra keys to split the diff cache by.

Stability: stable
to override
Returns
string[]

Reimplemented from SlotDiffRenderer.

Definition at line 65 of file TextSlotDiffRenderer.php.

◆ getTextDiff()

TextSlotDiffRenderer::getTextDiff ( string $oldText,
string $newText )

Diff the text representations of two content objects (or just two pieces of text in general).

Parameters
string$oldText
string$newText
Returns
string HTML, one or more

tags.

Definition at line 139 of file TextSlotDiffRenderer.php.

References getTextDiffInternal().

Referenced by getDiff().

◆ getTextDiffInternal()

TextSlotDiffRenderer::getTextDiffInternal ( $oldText,
$newText )
protected

Diff the text representations of two content objects (or just two pieces of text in general).

This does the actual diffing, getTextDiff() wraps it with logging and resource limiting.

Parameters
string$oldText
string$newText
Returns
string
Exceptions
Exception

Definition at line 191 of file TextSlotDiffRenderer.php.

References wfEscapeWikiText(), and wfTempDir().

Referenced by getTextDiff().

◆ setEngine()

TextSlotDiffRenderer::setEngine ( $type,
$executable = null )

Set which diff engine to use.

Parameters
string$typeOne of the ENGINE_* constants.
string | null$executablePath to an external executable, only when type is ENGINE_EXTERNAL.

Definition at line 107 of file TextSlotDiffRenderer.php.

References $type, ENGINE_EXTERNAL, ENGINE_PHP, ENGINE_WIKIDIFF2, and ENGINE_WIKIDIFF2_INLINE.

◆ setLanguage()

TextSlotDiffRenderer::setLanguage ( Language $language)
Parameters
Language$language

Definition at line 98 of file TextSlotDiffRenderer.php.

◆ setStatsdDataFactory()

TextSlotDiffRenderer::setStatsdDataFactory ( IBufferingStatsdDataFactory $statsdDataFactory)
Parameters
IBufferingStatsdDataFactory$statsdDataFactory

Definition at line 91 of file TextSlotDiffRenderer.php.

Member Data Documentation

◆ ENGINE_EXTERNAL

const TextSlotDiffRenderer::ENGINE_EXTERNAL = 'external'

Use an external executable.

Definition at line 50 of file TextSlotDiffRenderer.php.

Referenced by ContentHandler\getSlotDiffRendererWithOptions(), and setEngine().

◆ ENGINE_PHP

const TextSlotDiffRenderer::ENGINE_PHP = 'php'

Use the PHP diff implementation (DiffEngine).

Definition at line 41 of file TextSlotDiffRenderer.php.

Referenced by ContentHandler\getSlotDiffRendererWithOptions(), and setEngine().

◆ ENGINE_WIKIDIFF2

const TextSlotDiffRenderer::ENGINE_WIKIDIFF2 = 'wikidiff2'

Use the wikidiff2 PHP module.

Definition at line 44 of file TextSlotDiffRenderer.php.

Referenced by ContentHandler\getSlotDiffRendererWithOptions(), and setEngine().

◆ ENGINE_WIKIDIFF2_INLINE

const TextSlotDiffRenderer::ENGINE_WIKIDIFF2_INLINE = 'wikidiff2inline'

Use the wikidiff2 PHP module.

Definition at line 47 of file TextSlotDiffRenderer.php.

Referenced by ContentHandler\getSlotDiffRendererWithOptions(), and setEngine().


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