MediaWiki REL1_33
HTMLFormFieldWithButton.php
Go to the documentation of this file.
1<?php
7 protected $mButtonClass = '';
8
10 protected $mButtonId = '';
11
13 protected $mButtonName = '';
14
16 protected $mButtonType = 'submit';
17
19 protected $mButtonValue;
20
22 protected $mButtonFlags = [ 'progressive' ];
23
24 public function __construct( $info ) {
25 if ( isset( $info['buttonclass'] ) ) {
26 $this->mButtonClass = $info['buttonclass'];
27 }
28 if ( isset( $info['buttonid'] ) ) {
29 $this->mButtonId = $info['buttonid'];
30 }
31 if ( isset( $info['buttonname'] ) ) {
32 $this->mButtonName = $info['buttonname'];
33 }
34 if ( isset( $info['buttondefault'] ) ) {
35 $this->mButtonValue = $info['buttondefault'];
36 }
37 if ( isset( $info['buttontype'] ) ) {
38 $this->mButtonType = $info['buttontype'];
39 }
40 if ( isset( $info['buttonflags'] ) ) {
41 $this->mButtonFlags = $info['buttonflags'];
42 }
43 parent::__construct( $info );
44 }
45
46 public function getInputHTML( $value ) {
47 $attr = [
48 'class' => 'mw-htmlform-submit ' . $this->mButtonClass,
49 'id' => $this->mButtonId,
50 ] + $this->getAttributes( [ 'disabled', 'tabindex' ] );
51
52 return Html::input( $this->mButtonName, $this->mButtonValue, $this->mButtonType, $attr );
53 }
54
55 public function getInputOOUI( $value ) {
56 return new OOUI\ButtonInputWidget( [
57 'name' => $this->mButtonName,
58 'value' => $this->mButtonValue,
59 'type' => $this->mButtonType,
60 'label' => $this->mButtonValue,
61 'flags' => $this->mButtonFlags,
62 ] + OOUI\Element::configFromHtmlAttributes(
63 $this->getAttributes( [ 'disabled', 'tabindex' ] )
64 ) );
65 }
66
72 public function getElement( $element ) {
73 return $element . "\u{00A0}" . $this->getInputHTML( '' );
74 }
75}
Enables HTMLFormField elements to be build with a button.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
getElement( $element)
Combines the passed element with a button.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
__construct( $info)
Initialise the object.
The parent class to generate form fields.
getAttributes(array $list)
Returns the given attributes from the parameters.
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