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 / BackgroundSlideshow.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
BackgroundSlideshow.php
76 lines
1 <?php
2
3 namespace Kubio\Core\Background;
4
5 use Kubio\Core\Element;
6 use Kubio\Core\ElementBase;
7 use Kubio\Core\LodashBasic;
8 use Kubio\Core\StyleManager\ParserUtils;
9 use Kubio\Core\Utils;
10
11 use function array_merge;
12
13 class BackgroundSlideshow extends ElementBase {
14
15 function __construct( $value ) {
16 parent::__construct( $value, BackgroundDefaults::getDefaultSlideShow() );
17 }
18
19 function getMergedValue() {
20 if ( ! $this->_merged ) {
21 $this->_merged = LodashBasic::mergeSkipSeqArray( $this->default, $this->value );
22 }
23 return $this->_merged;
24 }
25
26
27 function __toString() {
28 $slides = $this->get( 'slides' );
29 $duration_str = ParserUtils::toValueUnitString( $this->get( 'duration' ) );
30 $speed_str = ParserUtils::toValueUnitString( $this->get( 'speed' ) );
31
32 $slides_els = array();
33
34 foreach ( $slides as $index => $slide ) {
35 $slides_els[] = new Element(
36 Element::DIV,
37 array(
38 'style' => $this->getSlideStyle( $slide, $index ),
39 'className' => array( 'slideshow-image' ),
40 )
41 );
42 }
43
44 $slideshow = Utils::useJSComponentProps(
45 'slideshow',
46 array(
47 'duration' => $duration_str,
48 'speed' => $speed_str,
49 )
50 );
51 return new Element(
52 Element::DIV,
53 array_merge(
54 $slideshow,
55 array(
56 'className' => array(
57 'background-layer',
58 'kubio-slideshow',
59 ),
60 )
61 ),
62 $slides_els
63 ) . '';
64 }
65
66 function getSlideStyle( $slide, $index ) {
67 $url = $slide['url'];
68 $url = kubio_wpml_get_translated_media_url( $url );
69 $style = array(
70 'backgroundImage' => "url(\"$url\")",
71 'zIndex' => $index,
72 );
73 return $style;
74 }
75 }
76