]> _ Git - cubeextranet.git/commitdiff
#2119
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 28 Jun 2018 09:51:26 +0000 (09:51 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 28 Jun 2018 09:51:26 +0000 (09:51 +0000)
inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 4672bbbc5b625ec75daf7ac0570d5b9cf69d37c2..1867c1761b9815492cd8882898d41a8a46d72adc 100644 (file)
@@ -695,13 +695,20 @@ class wsHTML5Compiler {
                }
        }
 
-       protected function writeScorm() {
-               $manifest = file_get_contents($this->assets . '/_imsmanifest.xml');
+       protected function writeScorm()
+       {
+               if ($this->book->parametres->scorm_version == '1.2') {
+                       $manifestfile = '_imsmanifest.12.xml';
+               } elseif ($this->book->parametres->scorm_version = '2004') {
+                       $manifestfile = '_imsmanifest.2004.xml';
+               }
+
+               $manifest = file_get_contents($this->assets . '/' . $manifestfile);
                if (!$this->book->parametres->scorm_title) {
                        $this->book->parametres->scorm_title = $this->book->parametres->title;
                }
-               if (!$this->book->parametres->scorm_id) {
-                       $this->book->parametres->scorm_id = 'fb_' . $this->book->parametres->id;
+               if (!$this->book->parametres->scorm_id || ($this->book->book_id > 16614 && $this->book->parametres->scorm_id == 'MFMCTE091mobile')) {
+                       $this->book->parametres->scorm_id = 'fb_' . $this->book->book_id;
                }
                if (!$this->book->parametres->scorm_org) {
                        $this->book->parametres->scorm_org = 'Fluidbook';
@@ -723,6 +730,9 @@ class wsHTML5Compiler {
                        $variables[$f[0]] = $f[1];
                }
                $this->config->scorm_variables = $this->book->parametres->scorm_variables = $variables;
+               if ($this->book->parametres->scorm_quizdata) {
+                       $this->config->scorm_quizdata = wsUtil::excelToArray($this->wdir . '/' . $this->book->parametres->scorm_quizdata);
+               }
        }
 
        protected function writePrint() {
index 34253ac4712797aea2486fb54b21a25f39211dd7..6b6025604c5741c4a430c44ca27652786d4d1cfb 100644 (file)
@@ -59,6 +59,7 @@ class wsHTML5Compiler
                'js/libs/fluidbook/menu/fluidbook.chapters.js',
                'js/libs/fluidbook/menu/fluidbook.index.js',
                'js/libs/fluidbook/fluidbook.landingpage.js',
+               'js/libs/fluidbook/fluidbook.slideshow.js',
                'js/libs/fluidbook/fluidbook.js',
                'js/main.js');
 
@@ -1789,14 +1790,13 @@ class wsHTML5Compiler
 
                }
                $origDir = $this->wdir;
-
+               $types = $this->getVideosFormats();
                if ($video) {
                        wsTools::encodeWebVideos($origDir . $source, null, true);
                        $e = explode('.', $source);
                        array_pop($e);
                        $base = implode('.', $e);
                        $source = array();
-                       $types = $this->getVideosFormats();
                        foreach ($types as $type) {
                                $source[] = $base . '.' . $type;
                        }
index 1ae437bfdad841c2be553eab3ecc2e936854edd4..46c6738a404c41a692f979b400e7662e93c5922d 100644 (file)
@@ -147,6 +147,9 @@ class wsHTML5Link
                        case 29:
                                return new facebookLikeLink($id, $init, $compiler);
                                break;
+            case 30:
+                return new slideshowLink($id, $init, $compiler);
+                               break;
                        default:
                                return null;
                }
@@ -1535,3 +1538,105 @@ class zoomLink extends normalLink
                return array_merge(['zoomPopup'], parent::getClasses());
        }
 }
+
+
+class slideshowLink extends normalLink {
+
+    protected $path;
+    protected $path_absolute;
+
+    public function getURL() {
+
+        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 '#/slideshow/' . $this->uid;
+    }
+
+    public function getAdditionnalContent() {
+        return ' data-slideshow="' . rawurlencode($this->generateSlideshow()) . '" ';
+    }
+
+//    public function keep() {
+//        return true;
+//    }
+
+    public function getDefaultTooltip() {
+        return 'view slideshow';
+    }
+
+    public function generateSlideshow() {
+
+        $this->compiler->addJs('js/libs/slick/slick.js');
+        $this->compiler->addLess('slick/slick-bundle');
+        $this->compiler->addLess('fluidbook.slideshow');
+
+               $extensions = ['jpg', 'png', 'jpeg', 'gif'];
+
+        $slideshowID = 'slideshow_' . $this->uid;
+        $XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist
+
+               $this->getURL();
+
+               $slides = [];
+        // 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);
+            foreach ($slideshowData->image as $img) {
+                $full_path = $this->path_absolute . '/' . $img->_name;
+                               $slides[] = ['caption' => $img->_caption, 'path' => $full_path];
+            }
+
+        } 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;
+                               }
+                               $ext = mb_strtolower($afile->getExtension());
+                               if (!in_array($ext, $extensions)) {
+                                       continue;
+                               }
+                               $slides[] = ['path' => $afile->getPathname(), 'caption' => null];
+                               uasort($slides, [$this, '_orderSlidesByFilename']);
+                       }
+        }
+
+               $res = '';
+               foreach ($slides as $slide) {
+            $res .= '<div class="fb-slideshow-slide">';
+                       $res .= '<img class="fb-slideshow-slide-image" src="' . $this->compiler->vdir->relativePath($slide['path']) . '">';
+                       if (null !== $slide['caption']) {
+                               $res .= '<p class="fb-slideshow-slide-caption">' . $slide['caption'] . '</p>';
+            }
+
+            $res .= '</div>'; // .fb-slideshow-slide
+        }
+
+        $res  = '<div class="fb-slideshow" id="'. $slideshowID .'">'. $res .'</div>';
+
+        $res .= '<script>';
+        $res .= 'fluidbook.slideshow.initSlideshow("'. $slideshowID .'");';
+        $res .= '</script>';
+
+        return $res;
+    }
+
+
+       protected function _orderSlidesByFilename($a, $b)
+       {
+               return strcmp($a['path'], $b['path']);
+       }
+}