3 namespace MediaWiki\Widget
;
6 * Namespace input widget. Displays a dropdown box with the choice of available namespaces, plus two
7 * checkboxes to include associated namespace or to invert selection.
9 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
12 class ComplexNamespaceInputWidget
extends \OOUI\Widget
{
16 protected $associated = null;
17 protected $associatedLabel = null;
18 protected $invert = null;
19 protected $invertLabel = null;
22 * @param array $config Configuration options
23 * - array $config['namespace'] Configuration for the NamespaceInputWidget
24 * dropdown with list of namespaces
25 * - string $config['namespace']['includeAllValue'] If specified,
26 * add an "all namespaces" option to the dropdown, and use this as the input value for it
27 * - array|null $config['invert'] Configuration for the "invert selection"
28 * CheckboxInputWidget. If null, the checkbox will not be generated.
29 * - array|null $config['associated'] Configuration for the "include associated namespace"
30 * CheckboxInputWidget. If null, the checkbox will not be generated.
31 * - array $config['invertLabel'] Configuration for the FieldLayout with label
32 * wrapping the "invert selection" checkbox
33 * - string $config['invertLabel']['label'] Label text for the label
34 * - array $config['associatedLabel'] Configuration for the FieldLayout with label
35 * wrapping the "include associated namespace" checkbox
36 * - string $config['associatedLabel']['label'] Label text for the label
38 public function __construct( array $config = [] ) {
39 // Configuration initialization
40 $config = array_merge(
42 // Config options for nested widgets
47 'associatedLabel' => [],
52 parent
::__construct( $config );
55 $this->config
= $config;
57 $this->namespace = new NamespaceInputWidget( $config['namespace'] );
58 if ( $config['associated'] !== null ) {
59 $this->associated
= new \OOUI\
CheckboxInputWidget( array_merge(
63 // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
64 $this->associatedLabel
= new \OOUI\
FieldLayout(
67 [ 'align' => 'inline' ],
68 $config['associatedLabel']
72 if ( $config['invert'] !== null ) {
73 $this->invert
= new \OOUI\
CheckboxInputWidget( array_merge(
77 // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
78 $this->invertLabel
= new \OOUI\
FieldLayout(
81 [ 'align' => 'inline' ],
82 $config['invertLabel']
89 ->addClasses( [ 'mw-widget-complexNamespaceInputWidget' ] )
90 ->appendContent( $this->namespace, $this->associatedLabel
, $this->invertLabel
);
93 protected function getJavaScriptClassName() {
94 return 'mw.widgets.ComplexNamespaceInputWidget';
97 public function getConfig( &$config ) {
98 $config = array_merge(
114 $config['namespace']['dropdown']['$overlay'] = true;
115 return parent
::getConfig( $config );