Debian Codegraph @

vendor/oojs/oojs-ui/php/layouts/PanelLayout.php

raw
1 <?php
2
3 namespace OOUI;
4
5 /**
6 * Layout that expands to cover the entire area of its parent, with optional scrolling and padding.
7 */
8 class PanelLayout extends Layout {
9 /** @var bool */
10 protected $preserveContent;
11
12 /**
13 * @param array $config Configuration options
14 * - bool $config['scrollable'] Allow vertical scrolling (default: false)
15 * - bool $config['padded'] Pad the content from the edges (default: false)
16 * - bool $config['expanded'] Expand size to fill the entire parent element
17 * (default: true)
18 * - bool $config['framed'] Wrap in a frame to visually separate from outside content
19 * (default: false)
20 * - bool $config['preserveContent'] Preserve DOM content when infusing (default: true)
21 */
22 public function __construct( array $config = [] ) {
23 $this->preserveContent = $config['preserveContent'] ?? true;
24
25 // Parent constructor
26 parent::__construct( $config );
27
28 // Initialization
29 $this->addClasses( [ 'oo-ui-panelLayout' ] );
30 if ( $config['scrollable'] ?? false ) {
31 $this->addClasses( [ 'oo-ui-panelLayout-scrollable' ] );
32 }
33 if ( $config['padded'] ?? false ) {
34 $this->addClasses( [ 'oo-ui-panelLayout-padded' ] );
35 }
36 if ( $config['expanded'] ?? true ) {
37 $this->addClasses( [ 'oo-ui-panelLayout-expanded' ] );
38 }
39 if ( $config['framed'] ?? false ) {
40 $this->addClasses( [ 'oo-ui-panelLayout-framed' ] );
41 }
42 }
43
44 /** @inheritDoc */
45 public function getConfig( &$config ) {
46 if ( !$this->preserveContent ) {
47 $config['preserveContent'] = false;
48 }
49 if ( $this->hasClass( 'oo-ui-panelLayout-scrollable' ) ) {
50 $config['scrollable'] = true;
51 }
52 if ( $this->hasClass( 'oo-ui-panelLayout-padded' ) ) {
53 $config['padded'] = true;
54 }
55 if ( !$this->hasClass( 'oo-ui-panelLayout-expanded' ) ) {
56 $config['expanded'] = false;
57 }
58 if ( $this->hasClass( 'oo-ui-panelLayout-framed' ) ) {
59 $config['framed'] = true;
60 }
61 return parent::getConfig( $config );
62 }
63 }