2016-05-28 00:02:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace EchoOOUI;
|
|
|
|
|
|
|
|
use OOUI\IconElement;
|
|
|
|
use OOUI\LabelElement;
|
|
|
|
use OOUI\TitledElement;
|
|
|
|
use OOUI\Tag;
|
|
|
|
use OOUI\Widget;
|
2017-10-13 11:48:05 +00:00
|
|
|
use OOUI\HtmlSnippet;
|
2016-05-28 00:02:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Widget combining a label and icon
|
|
|
|
*/
|
|
|
|
class LabelIconWidget extends Widget {
|
|
|
|
use IconElement;
|
|
|
|
use LabelElement;
|
|
|
|
use TitledElement;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $config Configuration options
|
|
|
|
* @param string|HtmlSnippet $config['label'] Label text
|
|
|
|
* @param string $config['title'] Title text
|
|
|
|
* @param string $config['icon'] Icon key
|
|
|
|
*/
|
|
|
|
public function __construct( $config ) {
|
|
|
|
parent::__construct( $config );
|
|
|
|
|
|
|
|
$this->tableRow = new Tag( 'div' );
|
2016-12-05 18:51:07 +00:00
|
|
|
$this->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
|
|
|
|
|
|
|
$this->icon = new Tag( 'div' );
|
|
|
|
$this->label = new Tag( 'div' );
|
|
|
|
|
|
|
|
$this->initializeIconElement( array_merge( $config, [ 'iconElement' => $this->icon ] ) );
|
|
|
|
$this->initializeLabelElement( array_merge( $config, [ 'labelElement' => $this->label ] ) );
|
|
|
|
$this->initializeTitledElement( $config );
|
|
|
|
|
|
|
|
$this->addClasses( [ 'oo-ui-labelIconWidget' ] );
|
|
|
|
$this->tableRow->appendContent( $this->icon, $this->label );
|
|
|
|
$this->appendContent( $this->tableRow );
|
|
|
|
}
|
|
|
|
}
|