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 ) {
156 } elseif ( $title ) {
157 return Title::newFromText( $title )->getLatestRevID();
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();
187class_alias( SpecialComparePages::class,
'SpecialComparePages' );
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
getContext()
Get the base IContextSource object.
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 By default the message key is the canonical name of...
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...