Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* This file contains \QUI\Slider\Controls\Logo\Carousel
*/
namespace QUI\Slider\Controls\Logo;
use QUI;
/**
* Class Carousel
*
* @package QUI\Slider\Controls\Logo\Carousel
*/
class Carousel extends QUI\Control
{
/**
* constructor
*
* @param array $attributes
*/
public function __construct($attributes = [])
{
// default options
$this->setAttributes([
'class' => 'quiqqer-slider-logoCarousel',
'nodeName' => 'section',
'site' => '',
'Project' => false,
'folderId' => false,
'perView' => 3,
'maxImgHeight' => 100,
'delay' => 3000,
'minSlideWidth' => 150,
'logoBackgroundColor' => false,
'order' => false,
'data-qui' => 'package/quiqqer/slider/bin/Logo/Carousel',
'grayscale' => false,
'hoverpause' => false
]);
$this->addCSSFile(
\dirname(__FILE__).'/Carousel.css'
);
parent::__construct($attributes);
}
/**
* (non-PHPdoc)
*
* @see \QUI\Control::create()
*/
public function getBody()
{
$Engine = QUI::getTemplateManager()->getEngine();
$Project = $this->getProject();
$Media = $Project->getMedia();
$folderId = $this->getAttribute('folderId');
$Folder = false;
$maxImageHeight = '200px';
if ($this->getAttribute('maxImgHeight') != '') {
$maxImageHeight = $this->getAttribute('maxImgHeight');
}
$perView = 3;
if ($this->getAttribute('perView') != '') {
$perView = $this->getAttribute('perView');
}
$delay = 2000;
if ($this->getAttribute('delay') != '') {
$delay = $this->getAttribute('delay');
}
$grayscale = false;
if ($this->getAttribute('grayscale') != '') {
$grayscale = $this->getAttribute('grayscale');
}
$hoverpause = false;
if ($this->getAttribute('hoverpause') != '') {
$hoverpause = $this->getAttribute('hoverpause');
}
$minSlideWidth = 150;
if ($this->getAttribute('minSlideWidth') != '') {
$minSlideWidth = $this->getAttribute('minSlideWidth');
}
$this->setJavaScriptControlOption('perview', intval($perView));
$this->setJavaScriptControlOption('delay', intval($delay));
$this->setJavaScriptControlOption('hoverpause', boolval($hoverpause));
$this->setJavaScriptControlOption('minslidewidth', intval($minSlideWidth));
/* @var $Folder \QUI\Projects\Media\Folder */
if (\strpos($folderId, 'image.php') !== false) {
try {
$Folder = QUI\Projects\Media\Utils::getMediaItemByUrl(
$folderId
);
} catch (QUI\Exception $Exception) {
$Folder = false;
}
} elseif ($folderId) {
try {
$Folder = $Media->get((int)$folderId);
} catch (QUI\Exception $Exception) {
$Folder = false;
}
}
switch ($this->getAttribute('order')) {
case 'title DESC':
case 'title ASC':
case 'name DESC':
case 'name ASC':
case 'c_date DESC':
case 'c_date ASC':
case 'e_date DESC':
case 'e_date ASC':
case 'priority DESC':
case 'priority ASC':
$order = $this->getAttribute('order');
break;
default:
$order = 'name DESC';
break;
}
$images = $Folder->getImages([
'order' => $order
]);
if ($this->getAttribute('max') && \count($images) > $this->getAttribute('max')) {
$images = \array_slice($images, 0, $this->getAttribute('max'));
}
$this->setStyles([
'--qui--logoCarousel-height' => $maxImageHeight."px"
]);
$Engine->assign([
'this' => $this,
'images' => $images,
'maxImgHeight' => $maxImageHeight,
'grayscale' => $grayscale,
'logoBackgroundColor' => $this->getAttribute('logoBackgroundColor')
]);
return $Engine->fetch($this->getTemplate());
}
/**
* Return the control template
*
* @return string
*/
protected function getTemplate()
{
return \dirname(__FILE__).'/Carousel.html';
}
}