MediaWiki  REL1_31
Go to the documentation of this file.
1 <?php
3 namespace MediaWiki\Widget;
12 class ComplexNamespaceInputWidget extends \OOUI\Widget {
14  protected $config;
15  protected $namespace;
16  protected $associated = null;
17  protected $associatedLabel = null;
18  protected $invert = null;
19  protected $invertLabel = null;
38  public function __construct( array $config = [] ) {
39  // Configuration initialization
40  $config = array_merge(
41  [
42  // Config options for nested widgets
43  'namespace' => [],
44  'invert' => [],
45  'invertLabel' => [],
46  'associated' => [],
47  'associatedLabel' => [],
48  ],
49  $config
50  );
52  parent::__construct( $config );
54  // Properties
55  $this->config = $config;
57  $this->namespace = new NamespaceInputWidget( $config['namespace'] );
58  if ( $config['associated'] !== null ) {
59  $this->associated = new \OOUI\CheckboxInputWidget( array_merge(
60  [ 'value' => '1' ],
61  $config['associated']
62  ) );
63  // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
64  $this->associatedLabel = new \OOUI\FieldLayout(
65  $this->associated,
66  array_merge(
67  [ 'align' => 'inline' ],
68  $config['associatedLabel']
69  )
70  );
71  }
72  if ( $config['invert'] !== null ) {
73  $this->invert = new \OOUI\CheckboxInputWidget( array_merge(
74  [ 'value' => '1' ],
75  $config['invert']
76  ) );
77  // TODO Should use a LabelWidget? But they don't work like HTML <label>s yet
78  $this->invertLabel = new \OOUI\FieldLayout(
79  $this->invert,
80  array_merge(
81  [ 'align' => 'inline' ],
82  $config['invertLabel']
83  )
84  );
85  }
87  // Initialization
88  $this
89  ->addClasses( [ 'mw-widget-complexNamespaceInputWidget' ] )
90  ->appendContent( $this->namespace, $this->associatedLabel, $this->invertLabel );
91  }
93  protected function getJavaScriptClassName() {
94  return 'mw.widgets.ComplexNamespaceInputWidget';
95  }
97  public function getConfig( &$config ) {
98  $config = array_merge(
99  $config,
100  array_intersect_key(
101  $this->config,
102  array_fill_keys(
103  [
104  'namespace',
105  'invert',
106  'invertLabel',
107  'associated',
108  'associatedLabel'
109  ],
110  true
111  )
112  )
113  );
114  $config['namespace']['dropdown']['$overlay'] = true;
115  return parent::getConfig( $config );
116  }
117 }
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf the Licensor for the purpose of discussing and improving the but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work Grant of Copyright License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty free
Definition: APACHE-LICENSE-2.0.txt:69
Definition: ComplexNamespaceInputWidget.php:15
Definition: ComplexNamespaceInputWidget.php:18
the array() calling protocol came about after MediaWiki 1.4rc1.
Namespace input widget.
Definition: ComplexNamespaceInputWidget.php:12
__construct(array $config=[])
Definition: ComplexNamespaceInputWidget.php:38
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
Definition: ComplexNamespaceInputWidget.php:93
Definition: ComplexNamespaceInputWidget.php:97
Definition: ComplexNamespaceInputWidget.php:19
Namespace input widget.
Definition: NamespaceInputWidget.php:11
Definition: ComplexNamespaceInputWidget.php:14
Definition: ComplexNamespaceInputWidget.php:16
Definition: ComplexNamespaceInputWidget.php:3
Definition: ComplexNamespaceInputWidget.php:17
Principal Authors(major contributors, alphabetically) Bartosz DziewoƄski< matma.rex > Ed Sanders< esanders > James D. Forrester< jforrester > Kirsten Menger-Anderson< kmenger > Kunal Mehta< legoktm > Moriel Schottlender< moriel > Prateek Saxena< prtksxna > Roan Kattouw< roan > Rob Moen< rmoen > Timo Tijhof< krinklemail > Trevor Parscal< trevor > Volker E.< volker.e > Patch Contributors(minor contributors