diff options
author | Gergő Tisza <tgr.huwiki@gmail.com> | 2023-11-03 22:49:08 -0700 |
---|---|---|
committer | Bartosz Dziewoński <dziewonski@fastmail.fm> | 2023-11-06 23:24:51 +0000 |
commit | de18cff244e8fab2e1ab2470c3b444e76b305e12 (patch) | |
tree | 4f12986264bc1bc189bc25f3f2734bf3b9c4f10c /includes/widget/CheckMatrixWidget.php | |
parent | 9d9c782fb350c37c315a2a4f3026db8b836eed5c (diff) | |
download | mediawikicore-de18cff244e8fab2e1ab2470c3b444e76b305e12.tar.gz mediawikicore-de18cff244e8fab2e1ab2470c3b444e76b305e12.zip |
htmlform: Support HTML tooltips in checkmatrix
Bug: T290790
Bug: T254222
Change-Id: I69e8217c408acca6bd7f19e7e274b255336dccd2
Diffstat (limited to 'includes/widget/CheckMatrixWidget.php')
-rw-r--r-- | includes/widget/CheckMatrixWidget.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/includes/widget/CheckMatrixWidget.php b/includes/widget/CheckMatrixWidget.php index c0cad2bdd2cc..58c0b13de3d1 100644 --- a/includes/widget/CheckMatrixWidget.php +++ b/includes/widget/CheckMatrixWidget.php @@ -20,6 +20,8 @@ class CheckMatrixWidget extends \OOUI\Widget { /** @var array */ protected $tooltips; /** @var array */ + protected $tooltipsHtml; + /** @var array */ protected $values; /** @var array */ protected $forcedOn; @@ -43,6 +45,9 @@ class CheckMatrixWidget extends \OOUI\Widget { * - Array of column-row tags to be displayed as disabled but unavailable to change. * - tooltips * - Optional associative array mapping row labels to tooltips (as text, will be escaped). + * - tooltips-html + * - Optional associative array mapping row labels to tooltips (as HTML). Takes precedence + * over text tooltips. */ public function __construct( array $config = [] ) { // Configuration initialization @@ -56,6 +61,7 @@ class CheckMatrixWidget extends \OOUI\Widget { $this->rows = $config['rows'] ?? []; $this->columns = $config['columns'] ?? []; $this->tooltips = $config['tooltips'] ?? []; + $this->tooltipsHtml = $config['tooltips-html'] ?? []; $this->values = $config['values'] ?? []; @@ -183,7 +189,11 @@ class CheckMatrixWidget extends \OOUI\Widget { * @return string Tooltip. Null if none is available. */ private function getTooltip( $label ) { - return $this->tooltips[ $label ] ?? null; + if ( isset( $this->tooltipsHtml[ $label ] ) ) { + return new \OOUI\HtmlSnippet( $this->tooltipsHtml[ $label ] ); + } else { + return $this->tooltips[ $label ] ?? null; + } } protected function getJavaScriptClassName() { @@ -197,6 +207,7 @@ class CheckMatrixWidget extends \OOUI\Widget { 'rows' => $this->rows, 'columns' => $this->columns, 'tooltips' => $this->tooltips, + 'tooltipsHtml' => $this->tooltipsHtml, 'forcedOff' => $this->forcedOff, 'forcedOn' => $this->forcedOn, 'values' => $this->values, |