]> _ Git - cubeextranet.git/commitdiff
WIP #1945 @2
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Apr 2018 16:12:42 +0000 (16:12 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 3 Apr 2018 16:12:42 +0000 (16:12 +0000)
inc/ws/Util/html5/diaporama/class.ws.html5.links.php

index 1d0919cc9ee643308ad8080cdca06a6845c6b5f8..a43a6416ec9e69d1beb74a88cf95228b623d3e7a 100644 (file)
@@ -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 .= '<div class="fb-slideshow-slide">';
-            $res .= '<img src="'. $this->compiler->vdir->relativePath($file) .'"><br>';
-            $res .= '<p>Caption goes here</p>';
+            $res .= '<img class="fb-slideshow-slide-image" src="'. $this->compiler->vdir->relativePath($file) .'">';
+
+            if ($caption) {
+                $res .= '<p class="fb-slideshow-slide-caption">' . $caption . '</p>';
+            }
+
             $res .= '</div>'; // .fb-slideshow-slide
         }