Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| DuplicateObjectLabelsPager | |
0.00% |
0 / 29 |
|
0.00% |
0 / 8 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getFieldNames | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| formatValue | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
6 | |||
| getQueryInfo | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getTableClass | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIndexField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDefaultSort | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isFieldSortable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda pager for listing Objects with duplicate labels |
| 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\Html\Html; |
| 14 | use MediaWiki\Language\LanguageNameUtils; |
| 15 | use MediaWiki\Linker\LinkRenderer; |
| 16 | use MediaWiki\Page\LinkBatchFactory; |
| 17 | use MediaWiki\Pager\TablePager; |
| 18 | use MediaWiki\SpecialPage\SpecialPage; |
| 19 | use MediaWiki\Title\Title; |
| 20 | |
| 21 | class DuplicateObjectLabelsPager extends TablePager { |
| 22 | |
| 23 | /** |
| 24 | * @param SpecialPage $form |
| 25 | * @param LinkRenderer $linkRenderer |
| 26 | * @param LinkBatchFactory $linkBatchFactory |
| 27 | * @param LanguageNameUtils $languageUtils |
| 28 | */ |
| 29 | public function __construct( |
| 30 | SpecialPage $form, |
| 31 | LinkRenderer $linkRenderer, |
| 32 | private readonly LinkBatchFactory $linkBatchFactory, |
| 33 | private readonly LanguageNameUtils $languageUtils |
| 34 | ) { |
| 35 | parent::__construct( $form->getContext(), $linkRenderer ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @inheritDoc |
| 40 | */ |
| 41 | protected function getFieldNames() { |
| 42 | return [ |
| 43 | 'wlzlc_existing_zid' => $this->msg( 'wikilambda-special-listduplicateobjectlabels-existing' )->text(), |
| 44 | 'wlzlc_conflicting_zid' => $this->msg( 'wikilambda-special-listduplicateobjectlabels-conflicting' )->text(), |
| 45 | 'wlzlc_language' => $this->msg( 'wikilambda-special-listduplicateobjectlabels-language' )->text(), |
| 46 | ]; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @param string $field |
| 51 | * @param string $value |
| 52 | * @return string HTML |
| 53 | */ |
| 54 | public function formatValue( $field, $value ) { |
| 55 | $row = $this->mCurrentRow; |
| 56 | $linkRenderer = $this->getLinkRenderer(); |
| 57 | |
| 58 | if ( $field === 'wlzlc_language' ) { |
| 59 | $result = Html::element( |
| 60 | 'span', |
| 61 | [ 'class' => 'ext-wikilambda-language' ], |
| 62 | $this->languageUtils->getLanguageName( $value, $this->getLanguage()->getCode() ) |
| 63 | ); |
| 64 | } else { |
| 65 | $result = Html::rawElement( |
| 66 | 'span', |
| 67 | [ 'class' => 'ext-wikilambda-zobject' ], |
| 68 | $linkRenderer->makeLink( Title::makeTitleSafe( NS_MAIN, $row->$field ) ) |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | return $result; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @inheritDoc |
| 77 | */ |
| 78 | public function getQueryInfo() { |
| 79 | return [ |
| 80 | 'tables' => 'wikilambda_zobject_label_conflicts', |
| 81 | 'fields' => [ 'wlzlc_id', 'wlzlc_existing_zid', 'wlzlc_conflicting_zid', 'wlzlc_language' ], |
| 82 | 'conds' => [] |
| 83 | ]; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @inheritDoc |
| 88 | */ |
| 89 | protected function getTableClass() { |
| 90 | return parent::getTableClass() . ' ext-wikilambda-special-listduplicateobjectlabels '; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @inheritDoc |
| 95 | */ |
| 96 | public function getIndexField() { |
| 97 | return 'wlzlc_id'; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @inheritDoc |
| 102 | */ |
| 103 | public function getDefaultSort() { |
| 104 | return 'wlzlc_id'; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * @inheritDoc |
| 109 | */ |
| 110 | protected function isFieldSortable( $field ) { |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | } |