MediaWiki
master
DifferenceEngineSlotDiffRenderer.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\MediaWikiServices
;
24
use
MediaWiki\Output\OutputPage
;
25
33
class
DifferenceEngineSlotDiffRenderer
extends
SlotDiffRenderer
{
34
36
private
$differenceEngine;
37
41
public
function
__construct
(
DifferenceEngine
$differenceEngine ) {
42
$this->differenceEngine = clone $differenceEngine;
43
44
// Set state to loaded. This should not matter to any of the methods invoked by
45
// the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
46
$fakeContent = MediaWikiServices::getInstance()
47
->getContentHandlerFactory()
48
->getContentHandler(
CONTENT_MODEL_WIKITEXT
)
49
->makeEmptyContent();
50
$this->differenceEngine->
setContent
( $fakeContent, $fakeContent );
51
52
$this->differenceEngine->markAsSlotDiffRenderer();
53
}
54
56
public
function
getDiff
(
Content
$oldContent =
null
,
Content
$newContent =
null
) {
57
$this->
normalizeContents
( $oldContent, $newContent );
58
return
$this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
59
}
60
62
public
function
addModules
(
OutputPage
$output ) {
63
$oldContext =
null
;
64
if
( $output !== $this->differenceEngine->
getOutput
() ) {
65
$oldContext = $this->differenceEngine->getContext();
66
$newContext =
new
DerivativeContext( $oldContext );
67
$newContext->setOutput( $output );
68
$this->differenceEngine->setContext( $newContext );
69
}
70
$this->differenceEngine->showDiffStyle();
71
if
( $oldContext ) {
72
$this->differenceEngine->setContext( $oldContext );
73
}
74
}
75
77
public
function
getExtraCacheKeys
() {
78
return
$this->differenceEngine->getExtraCacheKeys();
79
}
80
81
}
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition
Defines.php:218
DifferenceEngineSlotDiffRenderer
B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
Definition
DifferenceEngineSlotDiffRenderer.php:33
DifferenceEngineSlotDiffRenderer\addModules
addModules(OutputPage $output)
Add modules needed for correct styling/behavior of the diff.to override
Definition
DifferenceEngineSlotDiffRenderer.php:62
DifferenceEngineSlotDiffRenderer\__construct
__construct(DifferenceEngine $differenceEngine)
Definition
DifferenceEngineSlotDiffRenderer.php:41
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:56
DifferenceEngineSlotDiffRenderer\getExtraCacheKeys
getExtraCacheKeys()
Return any extra keys to split the diff cache by.to override string[]
Definition
DifferenceEngineSlotDiffRenderer.php:77
DifferenceEngine
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Definition
DifferenceEngine.php:77
DifferenceEngine\setContent
setContent(Content $oldContent, Content $newContent)
Use specified text instead of loading from the database.
Definition
DifferenceEngine.php:2029
MediaWiki\Context\ContextSource\getOutput
getOutput()
Definition
ContextSource.php:151
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
Definition
MediaWikiServices.php:240
MediaWiki\Output\OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition
OutputPage.php:95
SlotDiffRenderer
Renders a diff for a single slot (that is, a diff between two content objects).
Definition
SlotDiffRenderer.php:44
SlotDiffRenderer\normalizeContents
normalizeContents(Content &$oldContent=null, Content &$newContent=null, $allowedClasses=null)
Helper method to normalize the input of getDiff().
Definition
SlotDiffRenderer.php:111
Content
Base interface for representing page content.
Definition
Content.php:37
includes
diff
DifferenceEngineSlotDiffRenderer.php
Generated on Fri Mar 29 2024 10:08:56 for MediaWiki by
1.9.8