From: stephen@cubedesigners.com Date: Tue, 3 Apr 2018 16:12:42 +0000 (+0000) Subject: WIP #1945 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=34d14c1f74b6567a2b35b9367fee83fb9e1b5097;p=cubeextranet.git WIP #1945 @2 --- diff --git a/inc/ws/Util/html5/diaporama/class.ws.html5.links.php b/inc/ws/Util/html5/diaporama/class.ws.html5.links.php index 1d0919cc9..a43a6416e 100644 --- a/inc/ws/Util/html5/diaporama/class.ws.html5.links.php +++ b/inc/ws/Util/html5/diaporama/class.ws.html5.links.php @@ -1329,15 +1329,13 @@ class slideshowLink extends normalLink { public function getURL() { - // ToDo: see htmlMultimediaLink's getConfigOAM() function for reading XML file - - - if (!empty($this->to)) { - $d = $this->unzipFile($this->to, false); - //$this->_config = $this->getConfigZIP($d['dir']); - $this->copyExternalDir($d['dir'], $d['fdir']); + if (empty($this->to)) { + return ''; } + $d = $this->unzipFile($this->to, false); + $this->copyExternalDir($d['dir'], $d['fdir']); + $this->path = $d['fdir']; $this->path_absolute = $this->compiler->vdir->path($d['fdir']); @@ -1348,9 +1346,9 @@ class slideshowLink extends normalLink { return ' data-slideshow="' . rawurlencode($this->generateSlideshow()) . '" '; } - public function keep() { - return true; - } +// public function keep() { +// return true; +// } public function getDefaultTooltip() { return 'view slideshow'; @@ -1363,14 +1361,40 @@ class slideshowLink extends normalLink { $this->compiler->addLess('fluidbook.slideshow'); $slideshowID = 'slideshow_' . $this->uid; + $XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist $res = ''; - $files = glob($this->path_absolute . '/*.jpg'); // ToDo: make this more robust and support multiple extensions (see: https://stackoverflow.com/a/45088052) - foreach ($files as $file) { + // If the zip file contained a slideshow.xml file, use that for fetching images and their captions + if (file_exists($XML_path)) { + + $slideshow_XML = simplexml_load_file($XML_path); + $slideshowData = CubeIT_Util_Xml::toObject($slideshow_XML); + $slides = []; + + foreach ($slideshowData->image as $img) { + $full_path = $this->path_absolute . '/' . $img->_name; + $slides[$full_path] = $img->_caption; + } + + } else { + // Or by default, just get all the images that were in the zip file... + $files = glob($this->path_absolute . '/*.jpg'); // ToDo: make this more robust and support multiple extensions (see: https://stackoverflow.com/a/45088052) + + // Match the format of the array returned from the XML version (path is the key, caption is the value) + // Since we have no captions, we will set all the values to null. + $slides = array_fill_keys($files, null); + } + + foreach ($slides as $file => $caption) { + $res .= '
'; - $res .= '
'; - $res .= '

Caption goes here

'; + $res .= ''; + + if ($caption) { + $res .= '

' . $caption . '

'; + } + $res .= '
'; // .fb-slideshow-slide }