]> _ Git - cubeextranet.git/commitdiff
wip #903 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 1 Feb 2018 17:09:10 +0000 (17:09 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 1 Feb 2018 17:09:10 +0000 (17:09 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index ffcaa223737ecb0e7660351ab78dd940b737fe2c..27f004cca9fcc56528875c49ee15da9d5edb5d9f 100644 (file)
@@ -58,6 +58,7 @@ class wsHTML5Compiler {
                'js/libs/fluidbook/fluidbook.scorm.js',
                'js/libs/fluidbook/menu/fluidbook.chapters.js',
                'js/libs/fluidbook/menu/fluidbook.index.js',
+               'js/libs/fluidbook/fluidbook.landingpage.js',
                'js/libs/fluidbook/fluidbook.js',
                'js/main.js');
 
@@ -806,9 +807,24 @@ class wsHTML5Compiler {
                        $ignore = split(',', $ignore);
                }
 
+               if ($this->book->parametres->externalChaptersHTML != '') {
+                       $d = $this->unzipFile($this->book->parametres->externalChaptersHTML, false, 'data/chapters/');
+                       $meta = $this->getConfigZIP($d['dir']);
+                       $this->config->externalChaptersSize = new stdClass();
+                       $this->config->externalChaptersSize->width = $meta['width'];
+                       $this->config->externalChaptersSize->height = $meta['height'];
+                       $this->vdir->copyDirectory($d['dir'], $d['fdir']);
+               }
+
                $daoDoc = new wsDAODocument($core->con);
                $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);
 
+               // Custom landing page content
+               if ($this->book->parametres->landingPage != '') {
+                       $d = $this->unzipFile($this->book->parametres->landingPage, false, 'data/landing-page/');
+                       $this->vdir->copyDirectory($d['dir'], $d['fdir']);
+               }
+
                if ($this->book->parametres->tabsHTML5 != '') {
                        $links[] = [
                                'page' => 'background',
@@ -1667,4 +1683,50 @@ class wsHTML5Compiler {
 
        }
 
+
+       public function unzipFile($file, $moveAssets = false, $baseDir = null) {
+               $fdir = is_null($baseDir) ? 'data/links/' . $file : $baseDir;
+
+               $tmp = CubeIT_Files::tmpdir();
+               $dir = $tmp . '/' . $fdir;
+               if (file_exists($dir) && is_file($dir)) {
+                       unlink($dir);
+               }
+               if (!file_exists($dir)) {
+                       mkdir($dir, 0777, true);
+               }
+               $unzip = new cubeCommandLine('unzip');
+               $unzip->setArg(null, $this->wdir . '/' . $file);
+               $unzip->setArg('d', $dir);
+               $unzip->execute();
+
+               if ($moveAssets) {
+                       `mv $dir/Assets/* $dir`;
+                       rmdir($dir . '/Assets');
+               }
+
+               return array('dir' => $dir, 'fdir' => $fdir);
+       }
+
+       public function getConfigZIP($d) {
+               $res = array('width' => 0, 'height' => 0);
+               if (file_exists($d . '/index.html')) {
+                       $doc = new DOMDocument();
+                       $doc->loadHTMLFile($d . '/index.html');
+                       $xpath = new DOMXPath($doc);
+                       $c = $xpath->query("//canvas");
+                       foreach ($c as $canvas) {
+                               /* @var $canvas DOMElement */
+                               $res['width'] = intval((string)$canvas->getAttribute('width'));
+                               $res['height'] = intval((string)$canvas->getAttribute('height'));
+                       }
+
+                       $r = array('html' => 'index.html', 'inject' => array(), 'injectcss' => array(), 'injectjs' => array());
+               } else {
+                       $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js'));
+               }
+               $res = array_merge($res, $r);
+               return $res;
+       }
+
 }
index 0e1a1a0f73a7e83bf44848beb89c932371dc0247..d04bfda46ef93682be36d769491652ccc33e7a8c 100644 (file)
@@ -231,27 +231,7 @@ class wsHTML5Link {
        }
 
        public function unzipFile($file, $moveAssets = false) {
-               $fdir = 'data/links/' . $file;
-
-               $tmp = CubeIT_Files::tmpdir();
-               $dir = $tmp . '/' . $fdir;
-               if (file_exists($dir) && is_file($dir)) {
-                       unlink($dir);
-               }
-               if (!file_exists($dir)) {
-                       mkdir($dir, 0777, true);
-               }
-               $unzip = new cubeCommandLine('unzip');
-               $unzip->setArg(null, $this->compiler->wdir . '/' . $file);
-               $unzip->setArg('d', $dir);
-               $unzip->execute();
-
-               if ($moveAssets) {
-                       `mv $dir/Assets/* $dir`;
-                       rmdir($dir . '/Assets');
-               }
-
-               return array('dir' => $dir, 'fdir' => $fdir);
+        return $this->compiler->unzipFile($file, $moveAssets);
        }
 
        public function getCssScale() {
@@ -965,24 +945,7 @@ class htmlMultimediaLink extends wsHTML5Link {
        }
 
        public function getConfigZIP($d) {
-               $res = array('width' => $this->video_width, 'height' => $this->video_height);
-               if (file_exists($d . '/index.html')) {
-                       $doc = new DOMDocument();
-                       $doc->loadHTMLFile($d . '/index.html');
-                       $xpath = new DOMXPath($doc);
-                       $c = $xpath->query("//canvas");
-                       foreach ($c as $canvas) {
-                               /* @var $canvas DOMElement */
-                               $res['width'] = intval((string)$canvas->getAttribute('width'));
-                               $res['height'] = intval((string)$canvas->getAttribute('height'));
-                       }
-
-                       $r = array('html' => 'index.html', 'inject' => array(), 'injectcss' => array(), 'injectjs' => array());
-               } else {
-                       $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js'));
-               }
-               $res = array_merge($res, $r);
-               return $res;
+               return $this->compiler->getConfigZIP($d);
        }
 
        public function getConfigHTML($d, $html) {