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