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 }
64
69 public function getTableRow( $value ) {
70 if ( !empty( $this->mParams['rawrow'] ) ) {
71 return $value;
72 }
73
74 return parent::getTableRow( $value );
75 }
76
83 public function getDiv( $value ) {
84 if ( !empty( $this->mParams['rawrow'] ) ) {
85 return $value;
86 }
87
88 return parent::getDiv( $value );
89 }
90
97 public function getRaw( $value ) {
98 if ( !empty( $this->mParams['rawrow'] ) ) {
99 return $value;
100 }
101
102 return parent::getRaw( $value );
103 }
104
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)",
116 '1.32' );
117 }
118 return $value;
119 }
120
121 return parent::getOOUI( $value );
122 }
123
124 public function getCodex( $value ) {
125 if ( !empty( $this->mParams['rawrow'] ) ) {
126 return $value;
127 }
128
129 return parent::getCodex( $value );
130 }
131
136 protected function needsLabel() {
137 return false;
138 }
139}
140
142class_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.
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.