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  'id' => $this->mID
57  ] );
58  }
59 
64  public function getTableRow( $value ) {
65  if ( !empty( $this->mParams['rawrow'] ) ) {
66  return $value;
67  }
68 
69  return parent::getTableRow( $value );
70  }
71 
78  public function getDiv( $value ) {
79  if ( !empty( $this->mParams['rawrow'] ) ) {
80  return $value;
81  }
82 
83  return parent::getDiv( $value );
84  }
85 
92  public function getRaw( $value ) {
93  if ( !empty( $this->mParams['rawrow'] ) ) {
94  return $value;
95  }
96 
97  return parent::getRaw( $value );
98  }
99 
106  public function getOOUI( $value ) {
107  if ( !empty( $this->mParams['rawrow'] ) ) {
108  if ( !( $value instanceof OOUI\FieldLayout ) ) {
109  wfDeprecatedMsg( __METHOD__ . ": 'default' parameter as a string when using " .
110  "'rawrow' was deprecated in MediaWiki 1.32 (must be a FieldLayout or subclass)",
111  '1.32' );
112  }
113  return $value;
114  }
115 
116  return parent::getOOUI( $value );
117  }
118 
123  protected function needsLabel() {
124  return false;
125  }
126 }
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
The parent class to generate form fields.
An information field (text blob), not a proper input.
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever....
getOOUI( $value)
getDiv( $value)
getDefault()
Stability: stableto override mixed
getRaw( $value)
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
__construct( $info)