Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
58.21% |
39 / 67 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
HtmlSideSelectorComponent | |
58.21% |
39 / 67 |
|
75.00% |
3 / 4 |
5.17 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getHeaderHtml | |
0.00% |
0 / 28 |
|
0.00% |
0 / 1 |
2 | |||
getRowHtml | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
1 | |||
buildSideSelectorLabel | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace TwoColConflict\Html; |
4 | |
5 | use MediaWiki\Html\Html; |
6 | use MessageLocalizer; |
7 | use OOUI\RadioInputWidget; |
8 | |
9 | /** |
10 | * @license GPL-2.0-or-later |
11 | * @author Andrew Kostka <andrew.kostka@wikimedia.de> |
12 | */ |
13 | class HtmlSideSelectorComponent { |
14 | |
15 | private MessageLocalizer $messageLocalizer; |
16 | |
17 | public function __construct( MessageLocalizer $messageLocalizer ) { |
18 | $this->messageLocalizer = $messageLocalizer; |
19 | } |
20 | |
21 | /** |
22 | * @return string HTML |
23 | */ |
24 | public function getHeaderHtml(): string { |
25 | return Html::rawElement( |
26 | 'div', |
27 | [ 'class' => 'mw-twocolconflict-split-selection-container' ], |
28 | $this->buildSideSelectorLabel( 'twocolconflict-split-select-all' ) . |
29 | Html::rawElement( |
30 | 'div', |
31 | [ 'class' => [ |
32 | 'mw-twocolconflict-split-selection', |
33 | 'mw-twocolconflict-split-selection-header', |
34 | ] ], |
35 | Html::rawElement( 'div', [], new RadioInputWidget( [ |
36 | 'name' => 'mw-twocolconflict-side-selector', |
37 | 'title' => $this->messageLocalizer->msg( |
38 | 'twocolconflict-split-select-all-other-tooltip' |
39 | )->text(), |
40 | 'value' => 'other', |
41 | 'tabIndex' => '1', |
42 | ] ) ) . |
43 | Html::rawElement( 'div', [], new RadioInputWidget( [ |
44 | 'name' => 'mw-twocolconflict-side-selector', |
45 | 'title' => $this->messageLocalizer->msg( |
46 | 'twocolconflict-split-select-all-your-tooltip' |
47 | )->text(), |
48 | 'value' => 'your', |
49 | 'tabIndex' => '1', |
50 | ] ) ) |
51 | ) |
52 | ); |
53 | } |
54 | |
55 | /** |
56 | * @param int $rowNum Identifier for this line. |
57 | * |
58 | * @return string HTML |
59 | */ |
60 | public function getRowHtml( int $rowNum ): string { |
61 | return Html::rawElement( |
62 | 'div', |
63 | // Note: This CSS class is currently unused |
64 | [ 'class' => 'mw-twocolconflict-split-selection-container' ], |
65 | $this->buildSideSelectorLabel( 'twocolconflict-split-choose-version' ) . |
66 | Html::rawElement( |
67 | 'div', |
68 | [ 'class' => [ |
69 | 'mw-twocolconflict-split-selection', |
70 | 'mw-twocolconflict-split-selection-row' |
71 | ] ], |
72 | Html::rawElement( 'div', [], new RadioInputWidget( [ |
73 | 'name' => 'mw-twocolconflict-side-selector[' . $rowNum . ']', |
74 | 'title' => $this->messageLocalizer->msg( |
75 | 'twocolconflict-split-select-other-tooltip' |
76 | )->text(), |
77 | 'value' => 'other', |
78 | 'tabIndex' => '1', |
79 | ] ) ) . |
80 | Html::rawElement( 'div', [], new RadioInputWidget( [ |
81 | 'name' => 'mw-twocolconflict-side-selector[' . $rowNum . ']', |
82 | 'title' => $this->messageLocalizer->msg( |
83 | 'twocolconflict-split-select-your-tooltip' |
84 | )->text(), |
85 | 'value' => 'your', |
86 | 'selected' => true, |
87 | 'tabIndex' => '1', |
88 | ] ) ) |
89 | ) |
90 | ); |
91 | } |
92 | |
93 | /** |
94 | * @param string $msg |
95 | * |
96 | * @return string HTML |
97 | */ |
98 | private function buildSideSelectorLabel( string $msg ): string { |
99 | return Html::rawElement( |
100 | 'div', |
101 | [ 'class' => 'mw-twocolconflict-split-selector-label' ], |
102 | Html::element( |
103 | 'span', |
104 | [], |
105 | $this->messageLocalizer->msg( $msg )->text() |
106 | ) |
107 | ); |
108 | } |
109 | |
110 | } |