From: stephen@cubedesigners.com Date: Thu, 24 Sep 2020 17:33:14 +0000 (+0000) Subject: WIP #3881 @8 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=41196170040cd73d8b1442adf5acad82531747c9;p=cubeextranet.git WIP #3881 @8 --- diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 7de817732..57d19a6a0 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -1177,7 +1177,7 @@ class webVideoLink extends videoLink public function getEmbed() { - return ''; + return ''; } public function getEmbedURL() @@ -2202,6 +2202,7 @@ class slideshowLink extends normalLink protected $path; protected $path_absolute; + protected $allowed_extensions; public function getURL() { @@ -2240,46 +2241,60 @@ class slideshowLink extends normalLink $this->compiler->addLess('slick/slick-bundle'); $this->compiler->addLess('fluidbook.slideshow'); - $extensions = ['jpg', 'png', 'jpeg', 'gif']; + $this->allowed_extensions = ['jpg', 'png', 'jpeg', 'gif']; $slideshowID = 'slideshow_' . $this->uid; $XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist + // Default Slick settings (can be overridden by slideshow.xml) + $slick_settings = [ + 'autoplay' => false, + 'fade' => false, + ]; + $this->getURL(); $slides = []; + // If the zip file contained a slideshow.xml file, use that for fetching images and their captions - $thumbnails = true; if (file_exists($XML_path)) { $slideshow_XML = simplexml_load_string(file_get_contents($XML_path)); $slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML); - $images = []; - if (is_array($slideshowData->image)) { - $images = $slideshowData->image; - } else if (is_object($slideshowData->image)) { - $images = [$slideshowData->image]; + $thumbnails = isset($slideshowData->_thumbnails) && $slideshowData->_thumbnails !== 'false'; + + // Allow "fade" transition to be enabled + if (isset($slideshowData->_effect) && $slideshowData->_effect == 'fade') { + $slick_settings['fade'] = true; } - foreach ($images as $img) { - $full_path = $this->path_absolute . '/' . $img->_name; - $slides[] = ['caption' => $img->_caption, 'path' => $full_path]; + if (isset($slideshowData->_autoplay) && $slideshowData->_autoplay == 'true') { + $slick_settings['autoplay'] = true; } - $thumbnails = $slideshowData->_thumbnails !== 'false' && $slideshowData->_thumbnails; - } else { - // Or by default, just get all the images that were in the zip file... - $afiles = CubeIT_Files::getRecursiveDirectoryIterator($this->path_absolute); - foreach ($afiles as $afile) { - /** @var SplFileInfo $afile */ - if (!$afile->isFile()) { - continue; + if (isset($slideshowData->image)) { + $images = []; + if (is_array($slideshowData->image)) { + $images = $slideshowData->image; + } else if (is_object($slideshowData->image)) { + $images = [$slideshowData->image]; } - $ext = mb_strtolower($afile->getExtension()); - if (!in_array($ext, $extensions)) { - continue; + foreach ($images as $img) { + $full_path = $this->path_absolute . '/' . $img->_name; + $slides[] = ['caption' => $img->_caption, 'path' => $full_path]; } - $slides[] = ['path' => $afile->getPathname(), 'caption' => null]; - uasort($slides, [$this, '_orderSlidesByFilename']); } + + // It's possible that images are not defined in the slideshow.xml structure. + // In this case, we attempt to read the images from the directory... + if (empty($slides)) { + $slides = $this->_getSlidesFromDirectory($this->path_absolute); + } + + + } else { + // Or by default, just get all the images that were in the zip file... + $slides = $this->_getSlidesFromDirectory($this->path_absolute); + + $thumbnails = (count($slides) > 1); } $res = ''; @@ -2292,7 +2307,7 @@ class slideshowLink extends normalLink $res .= ''; // .fb-slideshow-slide } - $res = '
' . $res . '
'; + $res = '
' . $res . '
'; $res .= '