3 namespace MediaWiki\HTMLForm\Field
;
6 use MediaWiki\HTMLForm\HTMLFormField
;
9 * An information field (text blob), not a proper input.
12 class HTMLInfoField
extends HTMLFormField
{
17 * In addition to the usual HTMLFormField parameters, this can take the following fields:
18 * - default: the value (text) of the field. Unlike other form field types, HTMLInfoField can
19 * take a closure as a default value, which will be evaluated with $info as its only parameter.
20 * - raw: if true, the value won't be escaped.
21 * - rawrow: if true, the usual wrapping of form fields (e.g. into a table row + cell when
22 * display mode is table) will not happen and the value must contain it already.
24 public function __construct( $info ) {
25 $info['nodata'] = true;
27 parent
::__construct( $info );
34 public function getDefault() {
35 $default = parent
::getDefault();
36 if ( $default instanceof Closure
) {
37 $default = $default( $this->mParams
);
46 public function getInputHTML( $value ) {
47 return !empty( $this->mParams
['raw'] ) ?
$value : htmlspecialchars( $value );
54 public function getInputOOUI( $value ) {
55 if ( !empty( $this->mParams
['raw'] ) ) {
56 $value = new \OOUI\
HtmlSnippet( $value );
59 return new \OOUI\
LabelWidget( [
69 public function getTableRow( $value ) {
70 if ( !empty( $this->mParams
['rawrow'] ) ) {
74 return parent
::getTableRow( $value );
79 * @param string $value
83 public function getDiv( $value ) {
84 if ( !empty( $this->mParams
['rawrow'] ) ) {
88 return parent
::getDiv( $value );
93 * @param string $value
97 public function getRaw( $value ) {
98 if ( !empty( $this->mParams
['rawrow'] ) ) {
102 return parent
::getRaw( $value );
106 * @stable to override
107 * @param mixed $value If not FieldLayout or subclass has been deprecated.
108 * @return \OOUI\FieldLayout
111 public function getOOUI( $value ) {
112 if ( !empty( $this->mParams
['rawrow'] ) ) {
113 if ( !( $value instanceof \OOUI\FieldLayout
) ) {
114 wfDeprecatedMsg( __METHOD__
. ": 'default' parameter as a string when using " .
115 "'rawrow' was deprecated in MediaWiki 1.32 (must be a FieldLayout or subclass)",
121 return parent
::getOOUI( $value );
124 public function getCodex( $value ) {
125 if ( !empty( $this->mParams
['rawrow'] ) ) {
129 return parent
::getCodex( $value );
134 * @stable to override
136 protected function needsLabel() {
141 /** @deprecated class alias since 1.42 */
142 class_alias( HTMLInfoField
::class, 'HTMLInfoField' );