From: vincent@cubedesigners.com Date: Thu, 28 Jun 2018 09:51:26 +0000 (+0000) Subject: #2119 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=10dbaeafb8b51806afe018857b2822bad3efdc86;p=cubeextranet.git #2119 --- diff --git a/inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php b/inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php index 4672bbbc5..1867c1761 100644 --- a/inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/diaporama/class.ws.html5.compiler.php @@ -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() { diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 34253ac47..6b6025604 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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; } 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 1ae437bfd..46c6738a4 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -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 .= '
'; + $res .= ''; + if (null !== $slide['caption']) { + $res .= '

' . $slide['caption'] . '

'; + } + + $res .= '
'; // .fb-slideshow-slide + } + + $res = '
'. $res .'
'; + + $res .= ''; + + return $res; + } + + + protected function _orderSlidesByFilename($a, $b) + { + return strcmp($a['path'], $b['path']); + } +}