39 private $revisionLookup;
42 private $contentHandlerFactory;
45 private $differenceEngine;
55 parent::__construct(
'ComparePages' );
56 $this->revisionLookup = $revisionLookup;
57 $this->contentHandlerFactory = $contentHandlerFactory;
68 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
71 $form = HTMLForm::factory(
'ooui', [
76 'label-message' =>
'compare-page1',
84 'label-message' =>
'compare-rev1',
87 'validation-callback' => [ $this,
'checkExistingRevision' ],
93 'label-message' =>
'compare-page2',
101 'label-message' =>
'compare-rev2',
103 'section' =>
'page2',
104 'validation-callback' => [ $this,
'checkExistingRevision' ],
116 $form->setMethod(
'get' )
117 ->setSubmitTextMsg(
'compare-submit' )
118 ->setSubmitCallback( [ $this,
'showDiff' ] )
121 if ( $this->differenceEngine ) {
122 $this->differenceEngine->showDiffPage(
true );
132 $rev1 = $this->revOrTitle( $data[
'Revision1'], $data[
'Page1'] );
133 $rev2 = $this->revOrTitle( $data[
'Revision2'], $data[
'Page2'] );
135 if ( $rev1 && $rev2 ) {
137 $revisionRecord = $this->revisionLookup->getRevisionById( $rev1 );
138 $contentModel = $revisionRecord->getSlot(
142 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
143 $this->differenceEngine = $contentHandler->createDifferenceEngine( $form->
getContext(),
147 ( $data[
'Action'] ==
'purge' ),
148 ( $data[
'Unhide'] ==
'1' )
153 private function revOrTitle( $revision,
$title ) {
170 if ( $value ===
'' || $value ===
null ) {
173 $revisionRecord = $this->revisionLookup->getRevisionById( (
int)$value );
174 if ( $revisionRecord ===
null ) {
175 return $this->
msg(
'compare-revision-not-exists' )->parseAsBlock();
getContext()
Get the base IContextSource object.
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Implements Special:ComparePages.
showDiff( $data, HTMLForm $form)
execute( $par)
Show a form for filtering namespace and username.
checkExistingRevision( $value, $alldata)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(RevisionLookup $revisionLookup, IContentHandlerFactory $contentHandlerFactory)
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.