PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / trunk
Kubio AI Page Builder vtrunk
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 1 year ago BackgroundDefaults.php 2 years ago BackgroundImage.php 1 year ago BackgroundOverlay.php 1 year ago BackgroundSlideshow.php 1 year ago BackgroundVideo.php 1 year ago
BackgroundOverlay.php
93 lines
1 <?php
2
3 namespace Kubio\Core\Background;
4 use Kubio\Core\Element;
5 use Kubio\Core\ElementBase;
6 use function array_push;
7
8 class BackgroundOverlay extends ElementBase {
9 const SHAPE_NONE = 'none';
10
11 function __construct( $value ) {
12 parent::__construct( $value, BackgroundDefaults::getDefaultOverlay() );
13 }
14
15 function getOverlayShapeStyle() {
16 $tile_style = array(
17 'backgroundPosition' => 'top left',
18 'backgroundRepeat' => 'repeat',
19 );
20 $non_tile = array(
21 'backgroundPosition' => 'center center',
22 'backgroundRepeat' => 'no-repeat',
23 'backgroundSize' => 'cover',
24 );
25 $style = $this->get( 'shape.isTile' ) ? $tile_style : $non_tile;
26
27 $style['filter'] = 'invert(' . $this->get( 'shape.light' ) . '%)';
28 return $style;
29 }
30
31 function getOverlayLayerComputedStyle() {
32 $style = array();
33 switch ( $this->get( 'type' ) ) {
34 case 'color':
35 $style = array(
36 'backgroundColor' => $this->get( 'color.value' ),
37 'opacity' => $this->get( 'color.opacity' ),
38 );
39 break;
40 case 'gradient':
41 $style = array(
42 'backgroundImage' => $this->get( 'gradient' ),
43 );
44 break;
45 }
46 return $style;
47 }
48
49 function showShape() {
50 return $this->get( 'shape.value' ) !== self::SHAPE_NONE;
51 }
52
53 function getShapeLayerClasses() {
54 $classes = array( 'shape-layer' );
55 if ( $this->showShape() ) {
56 array_push( $classes, 'kubio-shape-' . $this->get( 'shape.value' ) );
57 }
58 return $classes;
59 }
60
61 function __toString() {
62 if ( ! $this->get( 'enabled' ) ) {
63 return '';
64 }
65
66 $shape = $this->showShape() ? new Element(
67 Element::DIV,
68 array(
69 'style' => $this->getOverlayShapeStyle(),
70 'className' => $this->getShapeLayerClasses(),
71 ),
72 array()
73 ) : null;
74
75 return new Element(
76 Element::DIV,
77 array(
78 'className' => 'overlay-layer',
79 ),
80 array(
81 new Element(
82 Element::DIV,
83 array(
84 'className' => 'overlay-image-layer',
85 'style' => $this->getOverlayLayerComputedStyle(),
86 )
87 ),
88 $shape,
89 )
90 ) . '';
91 }
92 }
93