wiki.techinc.nl/includes/htmlform/CollapsibleFieldsetLayout.php
thiemowmde 918aed5f77 htmlform: Use more compact PHP features in places
Some of these classes are really huge, up to 2000 lines and more. I
hope this makes the source code a little more readable.

Change-Id: I3d4b2a042a34c14e6ea0ea30ea31ca53448d8d59
2023-07-07 13:11:05 +02:00

36 lines
860 B
PHP

<?php
/*
* @stable to extend
*/
class CollapsibleFieldsetLayout extends OOUI\FieldsetLayout {
/**
* @stable to call
* @inheritDoc
*/
public function __construct( array $config = [] ) {
parent::__construct( $config );
$this->addClasses( [ 'mw-collapsibleFieldsetLayout', 'mw-collapsible' ] );
if ( $config['collapsed'] ?? false ) {
$this->addClasses( [ 'mw-collapsed' ] );
}
$this->header->addClasses( [ 'mw-collapsible-toggle' ] );
$this->group->addClasses( [ 'mw-collapsible-content' ] );
$this->header->appendContent(
new OOUI\IconWidget( [
'icon' => 'expand',
'label' => wfMessage( 'collapsible-expand' )->text(),
] ),
new OOUI\IconWidget( [
'icon' => 'collapse',
'label' => wfMessage( 'collapsible-collapse' )->text(),
] )
);
$this->header->setAttributes( [
'role' => 'button',
] );
}
}