PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 1.6.4
Kubio AI Page Builder v1.6.4
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / Core / Background / BackgroundOverlay.php
kubio / lib / src / Core / Background Last commit date
Background.php 4 years ago BackgroundDefaults.php 4 years ago BackgroundImage.php 4 years ago BackgroundOverlay.php 4 years ago BackgroundSlideshow.php 4 years ago BackgroundVideo.php 3 years ago
BackgroundOverlay.php
95 lines
1 <?php
2
3 namespace Kubio\Core\Background;
4 use Kubio\Config;
5 use Kubio\Core\Element;
6 use Kubio\Core\ElementBase;
7 use function array_push;
8
9 class BackgroundOverlay extends ElementBase {
10 const SHAPE_NONE = 'none';
11
12 function __construct( $value ) {
13 parent::__construct( $value, BackgroundDefaults::getDefaultOverlay() );
14 }
15
16 function getOverlayShapeStyle() {
17 $tile_style = array(
18 'backgroundPosition' => 'top left',
19 'backgroundRepeat' => 'repeat',
20 );
21 $non_tile = array(
22 'backgroundPosition' => 'center center',
23 'backgroundRepeat' => 'no-repeat',
24 'backgroundSize' => 'cover',
25 );
26 $style = $this->get( 'shape.isTile' ) ? $tile_style : $non_tile;
27
28 $style['filter'] = 'invert(' . $this->get( 'shape.light' ) . '%)';
29 return $style;
30 }
31
32 function getOverlayLayerComputedStyle() {
33 $style = array();
34 switch ( $this->get( 'type' ) ) {
35 case 'color':
36 $style = array(
37 'backgroundColor' => $this->get( 'color.value' ),
38 'opacity' => $this->get( 'color.opacity' ),
39 );
40 break;
41 case 'gradient':
42 $style = array(
43 'backgroundImage' => $this->get( 'gradient' ),
44 );
45 break;
46 }
47 return $style;
48 }
49
50 function showShape() {
51 return $this->get( 'shape.value' ) !== self::SHAPE_NONE;
52 }
53
54 function getShapeLayerClasses() {
55 $classes = array( 'shape-layer' );
56 if ( $this->showShape() ) {
57 array_push( $classes, 'kubio-shape-' . $this->get( 'shape.value' ) );
58 }
59 return $classes;
60 }
61
62 function __toString() {
63 if ( ! $this->get( 'enabled' ) ) {
64 return '';
65 }
66
67 $shape = $this->showShape() ? new Element(
68 Element::DIV,
69 array(
70 'style' => $this->getOverlayShapeStyle(),
71 'className' => $this->getShapeLayerClasses(),
72 ),
73 array()
74 ) : null;
75
76 return new Element(
77 Element::DIV,
78 array(
79 'className' => 'overlay-layer',
80 ),
81 array(
82 new Element(
83 Element::DIV,
84 array(
85 'className' => 'overlay-image-layer',
86 'style' => $this->getOverlayLayerComputedStyle(),
87 )
88 ),
89 $shape,
90 )
91 ) . '';
92 }
93 }
94
95