2016-05-28 00:02:55 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 00:30:41 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\OOUI;
|
2016-05-28 00:02:55 +00:00
|
|
|
|
|
|
|
use OOUI\IconElement;
|
|
|
|
use OOUI\LabelElement;
|
|
|
|
use OOUI\Tag;
|
2020-01-14 05:09:42 +00:00
|
|
|
use OOUI\TitledElement;
|
2016-05-28 00:02:55 +00:00
|
|
|
use OOUI\Widget;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget combining a label and icon
|
|
|
|
*/
|
|
|
|
class LabelIconWidget extends Widget {
|
|
|
|
use IconElement;
|
|
|
|
use LabelElement;
|
|
|
|
use TitledElement;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $config Configuration options
|
2017-10-14 13:45:13 +00:00
|
|
|
* - string|HtmlSnippet $config['label'] Label text
|
|
|
|
* - string $config['title'] Title text
|
|
|
|
* - string $config['icon'] Icon key
|
2016-05-28 00:02:55 +00:00
|
|
|
*/
|
|
|
|
public function __construct( $config ) {
|
|
|
|
parent::__construct( $config );
|
|
|
|
|
2019-02-23 20:26:35 +00:00
|
|
|
$tableRow = new Tag( 'div' );
|
|
|
|
$tableRow->setAttributes( [
|
2016-05-28 00:02:55 +00:00
|
|
|
'class' => 'oo-ui-labelIconWidget-row',
|
2016-12-05 18:51:07 +00:00
|
|
|
] );
|
2016-05-28 00:02:55 +00:00
|
|
|
|
2019-02-23 20:26:35 +00:00
|
|
|
$icon = new Tag( 'div' );
|
|
|
|
$label = new Tag( 'div' );
|
2016-05-28 00:02:55 +00:00
|
|
|
|
2019-02-23 20:26:35 +00:00
|
|
|
$this->initializeIconElement( array_merge( $config, [ 'iconElement' => $icon ] ) );
|
|
|
|
$this->initializeLabelElement( array_merge( $config, [ 'labelElement' => $label ] ) );
|
2016-05-28 00:02:55 +00:00
|
|
|
$this->initializeTitledElement( $config );
|
|
|
|
|
|
|
|
$this->addClasses( [ 'oo-ui-labelIconWidget' ] );
|
2019-02-23 20:26:35 +00:00
|
|
|
$tableRow->appendContent( $icon, $label );
|
|
|
|
$this->appendContent( $tableRow );
|
2016-05-28 00:02:55 +00:00
|
|
|
}
|
|
|
|
}
|