45 $this->
id =
$config[
'id'] ??
null;
48 $this->rows =
$config[
'rows'] ?? [];
49 $this->columns =
$config[
'columns'] ?? [];
50 $this->tooltips =
$config[
'tooltips'] ?? [];
54 $this->forcedOn =
$config[
'forcedOn'] ?? [];
55 $this->forcedOff =
$config[
'forcedOff'] ?? [];
58 $table = new \OOUI\Tag(
'table' );
59 $table->addClasses( [
'mw-htmlform-matrix mw-widget-checkMatrixWidget-matrix' ] );
60 $thead = new \OOUI\Tag(
'thead' );
61 $table->appendContent( $thead );
62 $tr = new \OOUI\Tag(
'tr' );
65 $tr->appendContent( $this->
getCellTag(
"\u{00A0}" ) );
66 foreach ( $this->columns
as $columnLabel => $columnTag ) {
68 $this->
getCellTag(
new \OOUI\HtmlSnippet( $columnLabel ),
'th' )
71 $thead->appendContent( $tr );
74 $tbody = new \OOUI\Tag(
'tbody' );
75 $table->appendContent( $tbody );
76 foreach ( $this->rows
as $rowLabel => $rowTag ) {
77 $tbody->appendContent(
83 $this->addClasses( [
'mw-widget-checkMatrixWidget' ] );
84 $this->appendContent( $table );
96 $row = new \OOUI\Tag(
'tr' );
98 $labelFieldConfig = $tooltip ? [
'help' => $tooltip ] : [];
100 $labelField = new \OOUI\FieldLayout(
103 'label' =>
new \OOUI\HtmlSnippet( $label ),
105 ] + $labelFieldConfig
107 $row->appendContent( $this->
getCellTag( $labelField ) );
110 foreach ( $this->columns
as $columnTag ) {
111 $thisTag =
"$columnTag-$tag";
114 $checkbox = new \OOUI\CheckboxInputWidget( [
116 'name' => $this->
name ?
"{$this->name}[]" :
null,
117 'id' => $this->
id ?
"{$this->id}-$thisTag" :
null,
122 $row->appendContent( $this->
getCellTag( $checkbox ) );
134 $cell = new \OOUI\Tag( $tagElement );
148 return in_array( $tagName, (
array)$this->
values,
true ) ||
150 in_array( $tagName, (
array)$this->forcedOn,
true );
163 $this->isDisabled() ||
165 in_array( $tagName, (
array)$this->forcedOn,
true ) ||
166 in_array( $tagName, (
array)$this->forcedOff,
true )
177 return $this->tooltips[ $label ] ??
null;
181 return 'mw.widgets.CheckMatrixWidget';
195 return parent::getConfig(
$config );