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']);
return ' data-slideshow="' . rawurlencode($this->generateSlideshow()) . '" ';
}
- public function keep() {
- return true;
- }
+// public function keep() {
+// return true;
+// }
public function getDefaultTooltip() {
return 'view slideshow';
$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
}