Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| VisualEditorHooks | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| onVisualEditorBeforeEditor | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace FileImporter; |
| 4 | |
| 5 | use MediaWiki\Extension\VisualEditor\VisualEditorBeforeEditorHook; |
| 6 | use MediaWiki\Output\OutputPage; |
| 7 | use MediaWiki\Skin\Skin; |
| 8 | use MediaWiki\Title\Title; |
| 9 | |
| 10 | /** |
| 11 | * All hooks from the VisualEditor extension which is optional to use with this extension. |
| 12 | * @license GPL-2.0-or-later |
| 13 | */ |
| 14 | class VisualEditorHooks implements VisualEditorBeforeEditorHook { |
| 15 | |
| 16 | /** |
| 17 | * Same parameters as {@see \MediaWiki\Hook\BeforePageDisplayHook}. |
| 18 | */ |
| 19 | public function onVisualEditorBeforeEditor( OutputPage $output, Skin $skin ): bool { |
| 20 | // The context gets changed to be that of a file page in WikiEditor::runEditFormInitialHook |
| 21 | // so re-construct the original title from the request. |
| 22 | $requestTitle = Title::newFromText( $output->getRequest()->getVal( 'title' ) ); |
| 23 | return !$requestTitle || !$requestTitle->isSpecial( 'ImportFile' ); |
| 24 | } |
| 25 | |
| 26 | } |