MediaWiki  master
HTMLInfoField.php
Go to the documentation of this file.
1 <?php
2 
7 class HTMLInfoField extends HTMLFormField {
19  public function __construct( $info ) {
20  $info['nodata'] = true;
21 
22  parent::__construct( $info );
23  }
24 
29  public function getDefault() {
30  $default = parent::getDefault();
31  if ( $default instanceof Closure ) {
32  $default = $default( $this->mParams );
33  }
34  return $default;
35  }
36 
41  public function getInputHTML( $value ) {
42  return !empty( $this->mParams['raw'] ) ? $value : htmlspecialchars( $value );
43  }
44 
49  public function getInputOOUI( $value ) {
50  if ( !empty( $this->mParams['raw'] ) ) {
51  $value = new OOUI\HtmlSnippet( $value );
52  }
53 
54  return new OOUI\LabelWidget( [
55  'label' => $value,
56  ] );
57  }
58 
63  public function getTableRow( $value ) {
64  if ( !empty( $this->mParams['rawrow'] ) ) {
65  return $value;
66  }
67 
68  return parent::getTableRow( $value );
69  }
70 
77  public function getDiv( $value ) {
78  if ( !empty( $this->mParams['rawrow'] ) ) {
79  return $value;
80  }
81 
82  return parent::getDiv( $value );
83  }
84 
91  public function getRaw( $value ) {
92  if ( !empty( $this->mParams['rawrow'] ) ) {
93  return $value;
94  }
95 
96  return parent::getRaw( $value );
97  }
98 
105  public function getOOUI( $value ) {
106  if ( !empty( $this->mParams['rawrow'] ) ) {
107  if ( !( $value instanceof OOUI\FieldLayout ) ) {
108  wfDeprecatedMsg( __METHOD__ . ": 'default' parameter as a string when using " .
109  "'rawrow' was deprecated in MediaWiki 1.32 (must be a FieldLayout or subclass)",
110  '1.32' );
111  }
112  return $value;
113  }
114 
115  return parent::getOOUI( $value );
116  }
117 
122  protected function needsLabel() {
123  return false;
124  }
125 }
HTMLInfoField\getOOUI
getOOUI( $value)
Stable to override.
Definition: HTMLInfoField.php:105
HTMLInfoField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
Definition: HTMLInfoField.php:41
HTMLInfoField\getDefault
getDefault()
Stable to override.mixed Stable to override
Definition: HTMLInfoField.php:29
HTMLInfoField\getInputOOUI
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
Definition: HTMLInfoField.php:49
HTMLInfoField\__construct
__construct( $info)
Stable to call.
Definition: HTMLInfoField.php:19
wfDeprecatedMsg
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
Definition: GlobalFunctions.php:1058
HTMLInfoField\getRaw
getRaw( $value)
Stable to override.
Definition: HTMLInfoField.php:91
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:9
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:122
HTMLInfoField
An information field (text blob), not a proper input.
Definition: HTMLInfoField.php:7
HTMLInfoField\getTableRow
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever....
Definition: HTMLInfoField.php:63
HTMLInfoField\getDiv
getDiv( $value)
Stable to override.
Definition: HTMLInfoField.php:77