Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ComplexTitleInputWidget | |
0.00% |
0 / 26 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
getJavaScriptClassName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConfig | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Widget; |
4 | |
5 | use OOUI\Widget; |
6 | |
7 | /** |
8 | * Complex title input widget. |
9 | * |
10 | * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt |
11 | * @license MIT |
12 | */ |
13 | class ComplexTitleInputWidget extends Widget { |
14 | /** @var array */ |
15 | protected $config; |
16 | protected $namespace = null; |
17 | protected $title = null; |
18 | |
19 | /** |
20 | * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field. |
21 | * |
22 | * @param array $config Configuration options |
23 | * - array $config['namespace'] Configuration for the NamespaceInputWidget dropdown |
24 | * with list of namespaces |
25 | * - array $config['title'] Configuration for the TitleInputWidget text field |
26 | * @phan-param array{namespace?:array,title?:array} $config |
27 | */ |
28 | public function __construct( array $config = [] ) { |
29 | // Configuration initialization |
30 | $config = array_merge( |
31 | [ |
32 | 'namespace' => [], |
33 | 'title' => [], |
34 | ], |
35 | $config |
36 | ); |
37 | |
38 | parent::__construct( $config ); |
39 | |
40 | // Properties |
41 | $this->config = $config; |
42 | $this->namespace = new NamespaceInputWidget( $config['namespace'] ); |
43 | $this->title = new TitleInputWidget( array_merge( |
44 | $config['title'], |
45 | [ |
46 | 'relative' => true, |
47 | 'namespace' => $config['namespace']['value'] ?? null, |
48 | ] |
49 | ) ); |
50 | |
51 | // Initialization |
52 | $this |
53 | ->addClasses( [ 'mw-widget-complexTitleInputWidget' ] ) |
54 | ->appendContent( $this->namespace, $this->title ); |
55 | } |
56 | |
57 | protected function getJavaScriptClassName() { |
58 | return 'mw.widgets.ComplexTitleInputWidget'; |
59 | } |
60 | |
61 | public function getConfig( &$config ) { |
62 | $config['namespace'] = $this->config['namespace']; |
63 | $config['namespace']['dropdown']['$overlay'] = true; |
64 | $config['title'] = $this->config['title']; |
65 | $config['title']['$overlay'] = true; |
66 | return parent::getConfig( $config ); |
67 | } |
68 | } |