MediaWiki
master
DifferenceEngineSlotDiffRenderer.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\MediaWikiServices
;
24
32
class
DifferenceEngineSlotDiffRenderer
extends
SlotDiffRenderer
{
33
35
private
$differenceEngine
;
36
40
public
function
__construct
(
DifferenceEngine
$differenceEngine
) {
41
$this->differenceEngine = clone
$differenceEngine
;
42
43
// Set state to loaded. This should not matter to any of the methods invoked by
44
// the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
45
$fakeContent = MediaWikiServices::getInstance()
46
->getContentHandlerFactory()
47
->getContentHandler(
CONTENT_MODEL_WIKITEXT
)
48
->makeEmptyContent();
49
$this->differenceEngine->
setContent
( $fakeContent, $fakeContent );
50
51
$this->differenceEngine->markAsSlotDiffRenderer();
52
}
53
55
public
function
getDiff
(
Content
$oldContent =
null
,
Content
$newContent =
null
) {
56
$this->
normalizeContents
( $oldContent, $newContent );
57
return
$this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
58
}
59
61
public
function
addModules
(
OutputPage
$output ) {
62
$oldContext =
null
;
63
if
( $output !== $this->differenceEngine->
getOutput
() ) {
64
$oldContext = $this->differenceEngine->getContext();
65
$newContext =
new
DerivativeContext
( $oldContext );
66
$newContext->setOutput( $output );
67
$this->differenceEngine->setContext( $newContext );
68
}
69
$this->differenceEngine->showDiffStyle();
70
if
( $oldContext ) {
71
$this->differenceEngine->setContext( $oldContext );
72
}
73
}
74
76
public
function
getExtraCacheKeys
() {
77
return
$this->differenceEngine->getExtraCacheKeys();
78
}
79
80
}
DifferenceEngineSlotDiffRenderer\$differenceEngine
DifferenceEngine $differenceEngine
Definition:
DifferenceEngineSlotDiffRenderer.php:35
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition:
MediaWikiServices.php:172
DifferenceEngine\setContent
setContent(Content $oldContent, Content $newContent)
Use specified text instead of loading from the database.
Definition:
DifferenceEngine.php:1893
SlotDiffRenderer\normalizeContents
normalizeContents(Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null)
Helper method to normalize the input of getDiff().
Definition:
SlotDiffRenderer.php:78
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition:
DerivativeContext.php:32
DifferenceEngineSlotDiffRenderer\getDiff
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 remov...
Definition:
DifferenceEngineSlotDiffRenderer.php:55
ContextSource\getOutput
getOutput()
Definition:
ContextSource.php:125
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition:
OutputPage.php:47
DifferenceEngineSlotDiffRenderer\addModules
addModules(OutputPage $output)
Add modules needed for correct styling/behavior of the diff.Stable to override
Definition:
DifferenceEngineSlotDiffRenderer.php:61
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition:
Defines.php:219
DifferenceEngineSlotDiffRenderer\getExtraCacheKeys
getExtraCacheKeys()
Return any extra keys to split the diff cache by.Stable to override string[]
Definition:
DifferenceEngineSlotDiffRenderer.php:76
Content
Base interface for content objects.
Definition:
Content.php:35
DifferenceEngineSlotDiffRenderer\__construct
__construct(DifferenceEngine $differenceEngine)
Definition:
DifferenceEngineSlotDiffRenderer.php:40
SlotDiffRenderer
Renders a diff for a single slot (that is, a diff between two content objects).
Definition:
SlotDiffRenderer.php:40
DifferenceEngine
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Definition:
DifferenceEngine.php:59
DifferenceEngineSlotDiffRenderer
B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
Definition:
DifferenceEngineSlotDiffRenderer.php:32
includes
diff
DifferenceEngineSlotDiffRenderer.php
Generated on Tue Mar 2 2021 23:08:25 for MediaWiki by
1.8.19