Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SpecialListDuplicateObjectNames | |
0.00% |
0 / 30 |
|
0.00% |
0 / 6 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDescription | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isListed | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| userCanExecute | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| execute | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda Special:ListDuplicateObjectNames page |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
| 8 | * @license MIT |
| 9 | */ |
| 10 | |
| 11 | namespace MediaWiki\Extension\WikiLambda\Special; |
| 12 | |
| 13 | use MediaWiki\Language\LanguageNameUtils; |
| 14 | use MediaWiki\Page\LinkBatchFactory; |
| 15 | use MediaWiki\Parser\ParserOptions; |
| 16 | use MediaWiki\SpecialPage\SpecialPage; |
| 17 | use MediaWiki\User\User; |
| 18 | |
| 19 | class SpecialListDuplicateObjectNames extends SpecialPage { |
| 20 | private LanguageNameUtils $languageNameUtils; |
| 21 | private LinkBatchFactory $linkBatchFactory; |
| 22 | |
| 23 | public function __construct( |
| 24 | LanguageNameUtils $languageNameUtils, |
| 25 | LinkBatchFactory $linkBatchFactory |
| 26 | ) { |
| 27 | parent::__construct( 'ListDuplicateObjectNames' ); |
| 28 | |
| 29 | $this->languageNameUtils = $languageNameUtils; |
| 30 | $this->linkBatchFactory = $linkBatchFactory; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @inheritDoc |
| 35 | */ |
| 36 | protected function getGroupName() { |
| 37 | // Triggers use of message specialpages-group-wikilambda |
| 38 | return 'wikilambda'; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @inheritDoc |
| 43 | */ |
| 44 | public function getDescription() { |
| 45 | return $this->msg( 'wikilambda-special-listduplicateobjectlabels' ); |
| 46 | } |
| 47 | |
| 48 | /** @inheritDoc */ |
| 49 | public function isListed() { |
| 50 | // No usage allowed on client-mode wikis. |
| 51 | return $this->getConfig()->get( 'WikiLambdaEnableRepoMode' ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @inheritDoc |
| 56 | * |
| 57 | * @param User $user |
| 58 | * @return bool |
| 59 | */ |
| 60 | public function userCanExecute( User $user ) { |
| 61 | if ( !$this->getConfig()->get( 'WikiLambdaEnableRepoMode' ) ) { |
| 62 | // No usage allowed on client-mode wikis. |
| 63 | return false; |
| 64 | } |
| 65 | return parent::userCanExecute( $user ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @inheritDoc |
| 70 | */ |
| 71 | public function execute( $ignoredSubPage ) { |
| 72 | if ( !$this->userCanExecute( $this->getUser() ) ) { |
| 73 | $this->displayRestrictionError(); |
| 74 | } |
| 75 | |
| 76 | $this->setHeaders(); |
| 77 | $this->outputHeader( 'wikilambda-special-listduplicateobjectlabels-summary' ); |
| 78 | |
| 79 | $output = $this->getOutput(); |
| 80 | |
| 81 | $output->enableOOUI(); |
| 82 | |
| 83 | $output->addModuleStyles( [ 'mediawiki.special' ] ); |
| 84 | $this->addHelpLink( 'Help:Wikifunctions/Duplicate Object labels' ); |
| 85 | |
| 86 | $pager = new DuplicateObjectLabelsPager( |
| 87 | $this, |
| 88 | $this->getLinkRenderer(), |
| 89 | $this->linkBatchFactory, |
| 90 | $this->languageNameUtils |
| 91 | ); |
| 92 | |
| 93 | if ( $pager->getNumRows() === 0 ) { |
| 94 | $output->addWikiMsg( 'wikilambda-special-listduplicateobjectlabels-empty' ); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | $output->addParserOutputContent( |
| 99 | $pager->getFullOutput(), |
| 100 | ParserOptions::newFromContext( $this->getContext() ) |
| 101 | ); |
| 102 | } |
| 103 | } |