Skip to content
Code-Schnipsel Gruppen Projekte

feat: quiqqer v2 compatibility

Zusammengeführt Henning Leutz schlägt vor, next in master zu mergen.
3 Dateien
+ 65
62
Änderungen vergleichen
  • Nebeneinander
  • In der Reihe
Dateien
3
@@ -8,6 +8,12 @@
use QUI;
use QUI\Projects\Media\Folder;
use function array_slice;
use function count;
use function dirname;
/**
* Class Carousel
*
@@ -20,28 +26,28 @@ class Carousel extends QUI\Control
*
* @param array $attributes
*/
public function __construct($attributes = [])
public function __construct(array $attributes = [])
{
// default options
$this->setAttributes([
'class' => 'quiqqer-slider-logoCarousel',
'nodeName' => 'section',
'site' => '',
'Project' => false,
'folderId' => false,
'perView' => 3,
'maxImgHeight' => 100,
'delay' => 3000,
'minSlideWidth' => 150,
'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
'order' => false,
'data-qui' => 'package/quiqqer/slider/bin/Logo/Carousel',
'grayscale' => false,
'hoverpause' => false
]);
$this->addCSSFile(
\dirname(__FILE__).'/Carousel.css'
dirname(__FILE__) . '/Carousel.css'
);
parent::__construct($attributes);
@@ -52,13 +58,13 @@ public function __construct($attributes = [])
*
* @see \QUI\Control::create()
*/
public function getBody()
public function getBody(): string
{
$Engine = QUI::getTemplateManager()->getEngine();
$Project = $this->getProject();
$Media = $Project->getMedia();
$Engine = QUI::getTemplateManager()->getEngine();
$Project = $this->getProject();
$Media = $Project->getMedia();
$folderId = $this->getAttribute('folderId');
$Folder = false;
$Folder = false;
$maxImageHeight = '200px';
if ($this->getAttribute('maxImgHeight') != '') {
@@ -95,20 +101,18 @@ public function getBody()
$this->setJavaScriptControlOption('hoverpause', boolval($hoverpause));
$this->setJavaScriptControlOption('minslidewidth', intval($minSlideWidth));
/* @var $Folder \QUI\Projects\Media\Folder */
if (\strpos($folderId, 'image.php') !== false) {
/* @var $Folder Folder */
if (str_contains($folderId, 'image.php')) {
try {
$Folder = QUI\Projects\Media\Utils::getMediaItemByUrl(
$folderId
);
} catch (QUI\Exception $Exception) {
$Folder = false;
} catch (QUI\Exception) {
}
} elseif ($folderId) {
try {
$Folder = $Media->get((int)$folderId);
} catch (QUI\Exception $Exception) {
$Folder = false;
} catch (QUI\Exception) {
}
}
@@ -135,19 +139,19 @@ public function getBody()
'order' => $order
]);
if ($this->getAttribute('max') && \count($images) > $this->getAttribute('max')) {
$images = \array_slice($images, 0, $this->getAttribute('max'));
if ($this->getAttribute('max') && count($images) > $this->getAttribute('max')) {
$images = array_slice($images, 0, $this->getAttribute('max'));
}
$this->setStyles([
'--qui--logoCarousel-height' => $maxImageHeight."px"
'--qui--logoCarousel-height' => $maxImageHeight . "px"
]);
$Engine->assign([
'this' => $this,
'images' => $images,
'maxImgHeight' => $maxImageHeight,
'grayscale' => $grayscale,
'this' => $this,
'images' => $images,
'maxImgHeight' => $maxImageHeight,
'grayscale' => $grayscale,
'logoBackgroundColor' => $this->getAttribute('logoBackgroundColor')
]);
@@ -159,8 +163,8 @@ public function getBody()
*
* @return string
*/
protected function getTemplate()
protected function getTemplate(): string
{
return \dirname(__FILE__).'/Carousel.html';
return dirname(__FILE__) . '/Carousel.html';
}
}