26 namespace MediaWiki\Specials;
48 private $differenceEngine;
58 parent::__construct(
'ComparePages' );
59 $this->revisionLookup = $revisionLookup;
60 $this->contentHandlerFactory = $contentHandlerFactory;
71 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
79 'label-message' =>
'compare-page1',
87 'label-message' =>
'compare-rev1',
90 'validation-callback' => [ $this,
'checkExistingRevision' ],
96 'label-message' =>
'compare-page2',
104 'label-message' =>
'compare-rev2',
106 'section' =>
'page2',
107 'validation-callback' => [ $this,
'checkExistingRevision' ],
119 $form->setMethod(
'get' )
120 ->setSubmitTextMsg(
'compare-submit' )
121 ->setSubmitCallback( [ $this,
'showDiff' ] )
124 if ( $this->differenceEngine ) {
125 $this->differenceEngine->showDiffPage(
true );
135 $rev1 = $this->revOrTitle( $data[
'Revision1'], $data[
'Page1'] );
136 $rev2 = $this->revOrTitle( $data[
'Revision2'], $data[
'Page2'] );
138 if ( $rev1 && $rev2 ) {
140 $revisionRecord = $this->revisionLookup->getRevisionById( $rev1 );
141 $contentModel = $revisionRecord->getSlot(
145 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
146 $this->differenceEngine = $contentHandler->createDifferenceEngine( $form->
getContext(),
150 ( $data[
'Action'] ==
'purge' ),
151 ( $data[
'Unhide'] ==
'1' )
156 private function revOrTitle( $revision, $title ) {
159 } elseif ( $title ) {
173 if ( $value ===
'' || $value ===
null ) {
176 $revisionRecord = $this->revisionLookup->getRevisionById( (
int)$value );
177 if ( $revisionRecord ===
null ) {
178 return $this->
msg(
'compare-revision-not-exists' )->parseAsBlock();
192 class_alias( SpecialComparePages::class,
'SpecialComparePages' );
getContext()
Get the base IContextSource object.
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Implements Special:ComparePages.
checkExistingRevision( $value, $alldata)
showDiff( $data, HTMLForm $form)
execute( $par)
Show a form for filtering namespace and username.
__construct(RevisionLookup $revisionLookup, IContentHandlerFactory $contentHandlerFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...