From f79bf36749523c3e893bf58e483f9c0a8d72bbbb Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 1 Feb 2018 17:09:10 +0000 Subject: [PATCH] wip #903 @1 --- .../html5/master/class.ws.html5.compiler.php | 62 +++++++++++++++++++ .../html5/master/class.ws.html5.links.php | 41 +----------- 2 files changed, 64 insertions(+), 39 deletions(-) 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 ffcaa2237..27f004cca 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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; + } + } 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 0e1a1a0f7..d04bfda46 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -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) { -- 2.39.5