MediaWiki
master
DifferenceEngineSlotDiffRenderer.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\Context\DerivativeContext
;
24
use
MediaWiki\MediaWikiServices
;
25
use
MediaWiki\Output\OutputPage
;
26
34
class
DifferenceEngineSlotDiffRenderer
extends
SlotDiffRenderer
{
35
37
private
$differenceEngine;
38
42
public
function
__construct
(
DifferenceEngine
$differenceEngine ) {
43
$this->differenceEngine = clone $differenceEngine;
44
45
// Set state to loaded. This should not matter to any of the methods invoked by
46
// the adapter, but just in case a load does get triggered somehow, make sure it's a no-op.
47
$fakeContent = MediaWikiServices::getInstance()
48
->getContentHandlerFactory()
49
->getContentHandler(
CONTENT_MODEL_WIKITEXT
)
50
->makeEmptyContent();
51
$this->differenceEngine->
setContent
( $fakeContent, $fakeContent );
52
53
$this->differenceEngine->markAsSlotDiffRenderer();
54
}
55
57
public
function
getDiff
(
Content
$oldContent =
null
,
Content
$newContent =
null
) {
58
$this->
normalizeContents
( $oldContent, $newContent );
59
return
$this->differenceEngine->generateContentDiffBody( $oldContent, $newContent );
60
}
61
63
public
function
addModules
(
OutputPage
$output ) {
64
$oldContext =
null
;
65
if
( $output !== $this->differenceEngine->
getOutput
() ) {
66
$oldContext = $this->differenceEngine->getContext();
67
$newContext =
new
DerivativeContext
( $oldContext );
68
$newContext->setOutput( $output );
69
$this->differenceEngine->setContext( $newContext );
70
}
71
$this->differenceEngine->showDiffStyle();
72
if
( $oldContext ) {
73
$this->differenceEngine->setContext( $oldContext );
74
}
75
}
76
78
public
function
getExtraCacheKeys
() {
79
return
$this->differenceEngine->getExtraCacheKeys();
80
}
81
82
}
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition
Defines.php:222
DifferenceEngineSlotDiffRenderer
B/C adapter for turning a DifferenceEngine into a SlotDiffRenderer.
Definition
DifferenceEngineSlotDiffRenderer.php:34
DifferenceEngineSlotDiffRenderer\addModules
addModules(OutputPage $output)
Add modules needed for correct styling/behavior of the diff.to override
Definition
DifferenceEngineSlotDiffRenderer.php:63
DifferenceEngineSlotDiffRenderer\__construct
__construct(DifferenceEngine $differenceEngine)
Definition
DifferenceEngineSlotDiffRenderer.php:42
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:57
DifferenceEngineSlotDiffRenderer\getExtraCacheKeys
getExtraCacheKeys()
Return any extra keys to split the diff cache by.to override string[]
Definition
DifferenceEngineSlotDiffRenderer.php:78
DifferenceEngine
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Definition
DifferenceEngine.php:79
DifferenceEngine\setContent
setContent(Content $oldContent, Content $newContent)
Use specified text instead of loading from the database.
Definition
DifferenceEngine.php:2039
MediaWiki\Context\ContextSource\getOutput
getOutput()
Definition
ContextSource.php:151
MediaWiki\Context\DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition
DerivativeContext.php:47
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
Definition
MediaWikiServices.php:239
MediaWiki\Output\OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition
OutputPage.php:96
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 Jul 26 2024 23:23:08 for MediaWiki by
1.10.0