]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - vendor/oojs/oojs-ui/php/layouts/FieldsetLayout.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / oojs / oojs-ui / php / layouts / FieldsetLayout.php
1 <?php
2
3 namespace OOUI;
4
5 /**
6  * Layout made of a fieldset and optional legend.
7  *
8  * Just add FieldLayout items.
9  */
10 class FieldsetLayout extends Layout {
11         use IconElement;
12         use LabelElement;
13         use GroupElement;
14
15         /* Static Properties */
16
17         public static $tagName = 'fieldset';
18
19         protected $header;
20
21         /**
22          * @param array $config Configuration options
23          * @param FieldLayout[] $config['items'] Items to add
24          */
25         public function __construct( array $config = [] ) {
26                 // Parent constructor
27                 parent::__construct( $config );
28
29                 // Traits
30                 $this->initializeIconElement( $config );
31                 $this->initializeLabelElement( $config );
32                 $this->initializeGroupElement( $config );
33
34                 // Properties
35                 $this->header = new Tag( 'legend' );
36
37                 // Initialization
38                 $this->header
39                         ->addClasses( [ 'oo-ui-fieldsetLayout-header' ] )
40                         ->appendContent( $this->icon, $this->label );
41                 $this->group->addClasses( [ 'oo-ui-fieldsetLayout-group' ] );
42                 $this
43                         ->addClasses( [ 'oo-ui-fieldsetLayout' ] )
44                         ->prependContent( $this->header, $this->group );
45                 if ( isset( $config['items'] ) ) {
46                         $this->addItems( $config['items'] );
47                 }
48         }
49 }