MediaWiki master
HTMLInfoField.php
Go to the documentation of this file.
1<?php
2
4
5use Closure;
7
24 public function __construct( $info ) {
25 $info['nodata'] = true;
26
27 parent::__construct( $info );
28 }
29
34 public function getDefault() {
35 $default = parent::getDefault();
36 if ( $default instanceof Closure ) {
37 $default = $default( $this->mParams );
38 }
39 return $default;
40 }
41
46 public function getInputHTML( $value ) {
47 return !empty( $this->mParams['raw'] ) ? $value : htmlspecialchars( $value );
48 }
49
54 public function getInputOOUI( $value ) {
55 if ( !empty( $this->mParams['raw'] ) ) {
56 $value = new \OOUI\HtmlSnippet( $value );
57 }
58
59 return ( new \OOUI\LabelWidget( [
60 'label' => $value,
61 'id' => $this->mID
62 ] ) )
63 // In case the information text contains any form elements, avoid treating it
64 // as a clickable label (T428359). Maybe it shouldn't be a `<label>` in the first place…
65 ->setAttributes( [ 'for' => '' ] );
66 }
67
72 public function getTableRow( $value ) {
73 if ( !empty( $this->mParams['rawrow'] ) ) {
74 return $value;
75 }
76
77 return parent::getTableRow( $value );
78 }
79
86 public function getDiv( $value ) {
87 if ( !empty( $this->mParams['rawrow'] ) ) {
88 return $value;
89 }
90
91 return parent::getDiv( $value );
92 }
93
100 public function getRaw( $value ) {
101 if ( !empty( $this->mParams['rawrow'] ) ) {
102 return $value;
103 }
104
105 return parent::getRaw( $value );
106 }
107
114 public function getOOUI( $value ) {
115 if ( !empty( $this->mParams['rawrow'] ) ) {
116 if ( !( $value instanceof \OOUI\FieldLayout ) ) {
117 wfDeprecatedMsg( __METHOD__ . ": 'default' parameter as a string when using " .
118 "'rawrow' was deprecated in MediaWiki 1.32 (must be a FieldLayout or subclass)",
119 '1.32' );
120 }
121 return $value;
122 }
123
124 return parent::getOOUI( $value );
125 }
126
128 public function getCodex( $value ) {
129 if ( !empty( $this->mParams['rawrow'] ) ) {
130 return $value;
131 }
132
133 return parent::getCodex( $value );
134 }
135
140 protected function needsLabel() {
141 return false;
142 }
143}
144
146class_alias( HTMLInfoField::class, 'HTMLInfoField' );
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
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....
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
getCodex( $value)
Get the Codex version of the div.1.42string HTML
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....
The parent class to generate form fields.