Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
UsersMultiselectWidget | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
9 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
getJavaScriptClassName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getConfig | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Widget; |
4 | |
5 | /** |
6 | * Widget to select multiple users. |
7 | * |
8 | * @copyright 2017 MediaWiki Widgets Team and others; see AUTHORS.txt |
9 | * @license MIT |
10 | */ |
11 | class UsersMultiselectWidget extends TagMultiselectWidget { |
12 | /** @var bool */ |
13 | protected $ipAllowed; |
14 | |
15 | /** @var bool */ |
16 | protected $ipRangeAllowed; |
17 | |
18 | /** @var array */ |
19 | protected $ipRangeLimits; |
20 | |
21 | /** |
22 | * @param array $config Configuration options |
23 | * - bool $config['ipAllowed'] Accept valid IP addresses |
24 | * - bool $config['ipRangeAllowed'] Accept valid IP ranges |
25 | * - array $config['ipRangeLimits'] Maximum allowed IP range sizes |
26 | */ |
27 | public function __construct( array $config = [] ) { |
28 | parent::__construct( $config ); |
29 | |
30 | if ( isset( $config['ipAllowed'] ) ) { |
31 | $this->ipAllowed = $config['ipAllowed']; |
32 | } |
33 | |
34 | if ( isset( $config['ipRangeAllowed'] ) ) { |
35 | $this->ipRangeAllowed = $config['ipRangeAllowed']; |
36 | } |
37 | |
38 | if ( isset( $config['ipRangeLimits'] ) ) { |
39 | $this->ipRangeLimits = $config['ipRangeLimits']; |
40 | } |
41 | } |
42 | |
43 | protected function getJavaScriptClassName() { |
44 | return 'mw.widgets.UsersMultiselectWidget'; |
45 | } |
46 | |
47 | public function getConfig( &$config ) { |
48 | if ( $this->ipAllowed !== null ) { |
49 | $config['ipAllowed'] = $this->ipAllowed; |
50 | } |
51 | |
52 | if ( $this->ipRangeAllowed !== null ) { |
53 | $config['ipRangeAllowed'] = $this->ipRangeAllowed; |
54 | } |
55 | |
56 | if ( $this->ipRangeLimits !== null ) { |
57 | $config['ipRangeLimits'] = $this->ipRangeLimits; |
58 | } |
59 | |
60 | return parent::getConfig( $config ); |
61 | } |
62 | |
63 | } |