/
Bootstrap4Carousel.php
52 lines (36 loc) · 1.12 KB
/
Bootstrap4Carousel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace denis909\yii;
class Bootstrap4Carousel extends \yii\base\Widget
{
const CAROUSEL_ITEM = Bootstrap4CarouselItem::class;
public $theme;
public $items = [];
public $previousLabel = 'Previous';
public $nextLabel = 'Next';
public $enableControls = true;
public $enableIndicators = true;
public $active;
public function run()
{
$active = $this->active;
if (($active !== null) && !array_key_exists($active, $this->items))
{
$active = null;
}
if ($this->items && ($active === null))
{
$keys = array_keys($this->items);
$active = array_shift($keys);
}
return $this->render('carousel', [
'active' => $active,
'items' => $this->items,
'previousLabel' => $this->previousLabel,
'nextLabel' => $this->nextLabel,
'enableControls' => $this->enableControls,
'enableIndicators' => $this->enableIndicators,
'theme' => $this->theme,
'carouselItemClass' => static::CAROUSEL_ITEM
]);
}
}