]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - vendor/oojs/oojs-ui/php/layouts/FieldsetLayout.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / oojs / oojs-ui / php / layouts / FieldsetLayout.php
diff --git a/vendor/oojs/oojs-ui/php/layouts/FieldsetLayout.php b/vendor/oojs/oojs-ui/php/layouts/FieldsetLayout.php
new file mode 100644 (file)
index 0000000..a161008
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+namespace OOUI;
+
+/**
+ * Layout made of a fieldset and optional legend.
+ *
+ * Just add FieldLayout items.
+ */
+class FieldsetLayout extends Layout {
+       use IconElement;
+       use LabelElement;
+       use GroupElement;
+
+       /* Static Properties */
+
+       public static $tagName = 'fieldset';
+
+       protected $header;
+
+       /**
+        * @param array $config Configuration options
+        * @param FieldLayout[] $config['items'] Items to add
+        */
+       public function __construct( array $config = [] ) {
+               // Parent constructor
+               parent::__construct( $config );
+
+               // Traits
+               $this->initializeIconElement( $config );
+               $this->initializeLabelElement( $config );
+               $this->initializeGroupElement( $config );
+
+               // Properties
+               $this->header = new Tag( 'legend' );
+
+               // Initialization
+               $this->header
+                       ->addClasses( [ 'oo-ui-fieldsetLayout-header' ] )
+                       ->appendContent( $this->icon, $this->label );
+               $this->group->addClasses( [ 'oo-ui-fieldsetLayout-group' ] );
+               $this
+                       ->addClasses( [ 'oo-ui-fieldsetLayout' ] )
+                       ->prependContent( $this->header, $this->group );
+               if ( isset( $config['items'] ) ) {
+                       $this->addItems( $config['items'] );
+               }
+       }
+}