28 private $differenceEngine;
34 parent::__construct(
'ComparePages' );
45 $this->
getOutput()->addModuleStyles(
'mediawiki.special' );
48 $form = HTMLForm::factory(
'ooui', [
53 'label-message' =>
'compare-page1',
61 'label-message' =>
'compare-rev1',
64 'validation-callback' => $this->checkExistingRevision( ... ),
70 'label-message' =>
'compare-page2',
78 'label-message' =>
'compare-rev2',
81 'validation-callback' => $this->checkExistingRevision( ... ),
94 ->setSubmitTextMsg(
'compare-submit' )
95 ->setSubmitCallback( $this->showDiff( ... ) )
98 if ( $this->differenceEngine ) {
99 $this->differenceEngine->showDiffPage(
true );
107 private function showDiff( $data,
HTMLForm $form ) {
108 $rev1 = $this->revOrTitle( $data[
'Revision1'], $data[
'Page1'] );
109 $rev2 = $this->revOrTitle( $data[
'Revision2'], $data[
'Page2'] );
111 if ( $rev1 && $rev2 ) {
113 $revisionRecord = $this->revisionLookup->getRevisionById( $rev1 );
114 $contentModel = $revisionRecord->getSlot(
118 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
119 $this->differenceEngine = $contentHandler->createDifferenceEngine( $form->
getContext(),
123 ( $data[
'Action'] ==
'purge' ),
124 ( $data[
'Unhide'] ==
'1' )
129 private function revOrTitle( ?
string $revision, ?
string $title ): ?int {
131 return (
int)$revision;
132 } elseif ( $title ) {
133 return Title::newFromText( $title )->getLatestRevID();
143 private function checkExistingRevision( $value ) {
144 if ( $value ===
'' || $value ===
null ) {
147 $revisionRecord = $this->revisionLookup->getRevisionById( (
int)$value );
148 if ( $revisionRecord ===
null ) {
149 return $this->
msg(
'compare-revision-not-exists' )->parseAsBlock();
162class_alias( SpecialComparePages::class,
'SpecialComparePages' );
if(!defined('MW_SETUP_CALLBACK'))
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.
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.
execute( $par)
Show a form for filtering namespace and username.
__construct(private readonly RevisionLookup $revisionLookup, private readonly IContentHandlerFactory $contentHandlerFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...