| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Widget; |
| 4 |
|
| 5 |
use OOUI\Widget; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class ComplexTitleInputWidget extends Widget { |
| 14 |
|
| 15 |
protected $config; |
| 16 |
|
| 17 |
protected $namespace = null; |
| 18 |
|
| 19 |
protected $title = null; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function __construct( array $config = [] ) { |
| 31 |
|
| 32 |
$config = array_merge( |
| 33 |
[ |
| 34 |
'namespace' => [], |
| 35 |
'title' => [], |
| 36 |
], |
| 37 |
$config |
| 38 |
); |
| 39 |
|
| 40 |
parent::__construct( $config ); |
| 41 |
|
| 42 |
|
| 43 |
$this->config = $config; |
| 44 |
$this->namespace = new NamespaceInputWidget( $config['namespace'] ); |
| 45 |
$this->title = new TitleInputWidget( array_merge( |
| 46 |
$config['title'], |
| 47 |
[ |
| 48 |
'relative' => true, |
| 49 |
'namespace' => $config['namespace']['value'] ?? null, |
| 50 |
] |
| 51 |
) ); |
| 52 |
|
| 53 |
|
| 54 |
$this |
| 55 |
->addClasses( [ 'mw-widget-complexTitleInputWidget' ] ) |
| 56 |
->appendContent( $this->namespace, $this->title ); |
| 57 |
} |
| 58 |
|
| 59 |
protected function getJavaScriptClassName() { |
| 60 |
return 'mw.widgets.ComplexTitleInputWidget'; |
| 61 |
} |
| 62 |
|
| 63 |
public function getConfig( &$config ) { |
| 64 |
$config['namespace'] = $this->config['namespace']; |
| 65 |
$config['namespace']['dropdown']['$overlay'] = true; |
| 66 |
$config['title'] = $this->config['title']; |
| 67 |
$config['title']['$overlay'] = true; |
| 68 |
return parent::getConfig( $config ); |
| 69 |
} |
| 70 |
} |