MediaWiki  1.33.0
HTMLInfoField.php
Go to the documentation of this file.
1 <?php
2 
6 class HTMLInfoField extends HTMLFormField {
16  public function __construct( $info ) {
17  $info['nodata'] = true;
18 
19  parent::__construct( $info );
20  }
21 
22  public function getDefault() {
23  $default = parent::getDefault();
24  if ( $default instanceof Closure ) {
25  $default = $default( $this->mParams );
26  }
27  return $default;
28  }
29 
30  public function getInputHTML( $value ) {
31  return !empty( $this->mParams['raw'] ) ? $value : htmlspecialchars( $value );
32  }
33 
34  public function getInputOOUI( $value ) {
35  if ( !empty( $this->mParams['raw'] ) ) {
36  $value = new OOUI\HtmlSnippet( $value );
37  }
38 
39  return new OOUI\LabelWidget( [
40  'label' => $value,
41  ] );
42  }
43 
44  public function getTableRow( $value ) {
45  if ( !empty( $this->mParams['rawrow'] ) ) {
46  return $value;
47  }
48 
49  return parent::getTableRow( $value );
50  }
51 
57  public function getDiv( $value ) {
58  if ( !empty( $this->mParams['rawrow'] ) ) {
59  return $value;
60  }
61 
62  return parent::getDiv( $value );
63  }
64 
70  public function getRaw( $value ) {
71  if ( !empty( $this->mParams['rawrow'] ) ) {
72  return $value;
73  }
74 
75  return parent::getRaw( $value );
76  }
77 
83  public function getOOUI( $value ) {
84  if ( !empty( $this->mParams['rawrow'] ) ) {
85  if ( !( $value instanceof OOUI\FieldLayout ) ) {
86  wfDeprecated( "'default' parameter as a string when using 'rawrow' " .
87  "(must be a FieldLayout or subclass)", '1.32' );
88  }
89  return $value;
90  }
91 
92  return parent::getOOUI( $value );
93  }
94 
95  protected function needsLabel() {
96  return false;
97  }
98 }
HTMLInfoField\getOOUI
getOOUI( $value)
Definition: HTMLInfoField.php:83
HTMLInfoField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLInfoField.php:30
HTMLInfoField\getDefault
getDefault()
Definition: HTMLInfoField.php:22
HTMLInfoField\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
Definition: HTMLInfoField.php:34
php
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:35
HTMLInfoField\__construct
__construct( $info)
Definition: HTMLInfoField.php:16
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1078
HTMLInfoField\getRaw
getRaw( $value)
Definition: HTMLInfoField.php:70
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
HTMLInfoField\needsLabel
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
Definition: HTMLInfoField.php:95
HTMLInfoField
An information field (text blob), not a proper input.
Definition: HTMLInfoField.php:6
$value
$value
Definition: styleTest.css.php:49
HTMLInfoField\getTableRow
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
Definition: HTMLInfoField.php:44
HTMLInfoField\getDiv
getDiv( $value)
Definition: HTMLInfoField.php:57