Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 32 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
SizeFilterWidget | |
0.00% |
0 / 32 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 27 |
|
0.00% |
0 / 1 |
6 | |||
getJavaScriptClassName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConfig | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Widget; |
4 | |
5 | use OOUI\LabelWidget; |
6 | use OOUI\RadioSelectInputWidget; |
7 | use OOUI\TextInputWidget; |
8 | use OOUI\Widget; |
9 | |
10 | /** |
11 | * Select and input widget. |
12 | * |
13 | * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt |
14 | * @license MIT |
15 | */ |
16 | class SizeFilterWidget extends Widget { |
17 | /** @var array */ |
18 | protected $config; |
19 | /** @var LabelWidget */ |
20 | protected $label; |
21 | /** @var RadioSelectInputWidget */ |
22 | protected $radioselectinput; |
23 | /** @var TextInputWidget */ |
24 | protected $textinput; |
25 | |
26 | /** |
27 | * RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size |
28 | * |
29 | * @param array $config Configuration options |
30 | * - array $config['textinput'] Configuration for the TextInputWidget |
31 | * - array $config['radioselectinput'] Configuration for the RadioSelectWidget |
32 | * - bool $config['selectMin'] Whether to select 'min', false would select 'max' |
33 | */ |
34 | public function __construct( array $config = [] ) { |
35 | // Configuration initialization |
36 | $config = array_merge( [ |
37 | 'selectMin' => true, |
38 | 'textinput' => [], |
39 | 'radioselectinput' => [] |
40 | ], $config ); |
41 | $config['textinput'] = array_merge( [ |
42 | 'type' => 'number' |
43 | ], $config['textinput'] ); |
44 | $config['radioselectinput'] = array_merge( [ 'options' => [ |
45 | [ |
46 | 'data' => 'min', |
47 | 'label' => wfMessage( 'minimum-size' )->text() |
48 | ], |
49 | [ |
50 | 'data' => 'max', |
51 | 'label' => wfMessage( 'maximum-size' )->text() |
52 | ] |
53 | ] ], $config['radioselectinput'] ); |
54 | |
55 | // Parent constructor |
56 | parent::__construct( $config ); |
57 | |
58 | // Properties |
59 | $this->config = $config; |
60 | $this->radioselectinput = new RadioSelectInputWidget( $config[ 'radioselectinput'] ); |
61 | $this->textinput = new TextInputWidget( $config[ 'textinput' ] ); |
62 | $this->label = new LabelWidget( [ 'label' => wfMessage( 'pagesize' )->text() ] ); |
63 | |
64 | // Initialization |
65 | $this->radioselectinput->setValue( $config[ 'selectMin' ] ? 'min' : 'max' ); |
66 | $this |
67 | ->addClasses( [ 'mw-widget-sizeFilterWidget' ] ) |
68 | ->appendContent( $this->radioselectinput, $this->textinput, $this->label ); |
69 | } |
70 | |
71 | protected function getJavaScriptClassName() { |
72 | return 'mw.widgets.SizeFilterWidget'; |
73 | } |
74 | |
75 | public function getConfig( &$config ) { |
76 | $config['textinput'] = $this->config['textinput']; |
77 | $config['radioselectinput'] = $this->config['radioselectinput']; |
78 | $config['selectMin'] = $this->config['selectMin']; |
79 | return parent::getConfig( $config ); |
80 | } |
81 | } |