Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
HTMLFieldsetCheckUser
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 wrapForm
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace MediaWiki\CheckUser\CheckUser\Widgets;
4
5use CollapsibleFieldsetLayout;
6use OOUI\Element;
7use OOUI\FieldsetLayout;
8use OOUI\HtmlSnippet;
9use OOUI\PanelLayout;
10use OOUI\Widget;
11use OOUIHTMLForm;
12
13class HTMLFieldsetCheckUser extends OOUIHTMLForm {
14
15    /** @var string a custom CSS class to apply to the fieldset layout */
16    public $outerClass = '';
17
18    /**
19     * This returns the html but not wrapped in a form
20     * element, so that it can be optionally added by SpecialCheckUser.
21     *
22     * @inheritDoc
23     */
24    public function wrapForm( $html ) {
25        if ( is_string( $this->mWrapperLegend ) ) {
26            $phpClass = $this->mCollapsible ? CollapsibleFieldsetLayout::class : FieldsetLayout::class;
27            $content = new $phpClass( [
28                'label' => $this->mWrapperLegend,
29                'collapsed' => $this->mCollapsed,
30                'items' => [
31                    new Widget( [
32                        'content' => new HtmlSnippet( $html )
33                    ] ),
34                ],
35            ] + Element::configFromHtmlAttributes( $this->mWrapperAttributes ) );
36        } else {
37            $content = new HtmlSnippet( $html );
38        }
39
40        // Include a wrapper for style, if requested.
41        return new PanelLayout( [
42            'classes' => [ 'mw-htmlform-ooui-wrapper', $this->outerClass ],
43            'expanded' => false,
44            'padded' => $this->mWrapperLegend !== false,
45            'framed' => $this->mWrapperLegend !== false,
46            'content' => $content,
47        ] );
48    }
49}