From 6e9e1185d141190b8d475294602ead2eedda698d Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 29 Sep 2017 09:09:21 +0000 Subject: [PATCH] wip #1704 @4 --- inc/ws/Util/class.ws.exporter.php | 2 +- inc/ws/Util/class.ws.tools.php | 4 + inc/ws/Util/class.ws.util.php | 10 +- .../bookedges/class.ws.html5.compiler.php | 222 +++++------------- .../html5/bookedges/class.ws.html5.links.php | 5 +- inc/ws/Util/html5/class.ws.html5.php | 37 +-- 6 files changed, 98 insertions(+), 182 deletions(-) diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index b9d7a3d2d..8513e965c 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -103,7 +103,7 @@ class wsExporter { ) ); if ($os == 'ios') { - //$phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_EXTERNALFILEUTIL); + $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_EXTERNALFILEUTIL); //$phonegap->addFeature(CubeIT_Mobile_Phonegap_IOS::FEATURE_WKWEBVIEW); } else if ($os == 'android') { $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_WEBINTENT); diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 4c55e9bd9..abf777e9f 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -158,6 +158,10 @@ class wsTools { if (!file_exists($source)) { return; } + $dir=dirname($dest); + if(!file_exists($dir)){ + mkdir($dir,0777,true); + } copy($source, $dest); touch($dest, filemtime($source)); } diff --git a/inc/ws/Util/class.ws.util.php b/inc/ws/Util/class.ws.util.php index 1d36bd512..95ddd19b1 100644 --- a/inc/ws/Util/class.ws.util.php +++ b/inc/ws/Util/class.ws.util.php @@ -47,7 +47,7 @@ class wsUtil { return $worksheets; } - public static function atlanticReferences($references, $dir) { + public static function atlanticReferences($references, $dir, $log = null, $copy = 'copy') { if (!file_exists($dir)) { mkdir($dir, 0777, true); } @@ -64,9 +64,15 @@ class wsUtil { $cache = WS_CACHE . '/atlantic/' . md5($url); if (!file_exists($cache)) { copy($url, $cache); + $copylog = ' (copy) '; + } else { + $copylog = ' '; } - copy($cache, $dir . '/' . $matches[1]); + call_user_func($copy, $cache, $dir . '/' . $matches[1]); $references[$i][$j][$k] = 'local/' . $matches[1]; + if (null !== $log) { + call_user_func($log, 'Done' . $copylog . $matches[1]); + } } } } diff --git a/inc/ws/Util/html5/bookedges/class.ws.html5.compiler.php b/inc/ws/Util/html5/bookedges/class.ws.html5.compiler.php index 99417ff2c..678bdd194 100644 --- a/inc/ws/Util/html5/bookedges/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/bookedges/class.ws.html5.compiler.php @@ -165,7 +165,6 @@ class wsHTML5Compiler { function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) { global $core; - $this->phonegapVersion = wsHTML5::getPhonegapVersion($phonegapVersion); $this->appcache = $appcache; $this->multiApp = $this->home = $home; @@ -198,16 +197,9 @@ class wsHTML5Compiler { } else { $this->dir = $dir; } - $this->vdir = $this->dir; + $this->vdir = new CubeIT_Files_VirtualDirectory($this->dir); $this->wdir = WS_BOOKS . '/working/' . $this->book_id . '/'; - // Clean the folder - `rm -rf $this->vdir`; - if (!file_exists($this->dir)) { - mkdir($this->dir, 0777, true); - } - $this->log('Clean vdir'); - $this->daoBook = new wsDAOBook($core->con); $this->book = $this->daoBook->selectById($book_id); $this->pages = $this->daoBook->getPagesOfBook($book_id); @@ -274,6 +266,7 @@ class wsHTML5Compiler { $time = $currenttime - $this->logtime; $log = $step . ' | ' . round($time, 3) . 's' . "\n"; fwrite($this->logfp, $log); + fflush($this->logfp); $this->logtime = $currenttime; } @@ -308,40 +301,21 @@ class wsHTML5Compiler { $this->log('Start compile process'); - $dirsToCreate = array('data/images', 'data/contents', 'data/background', 'data/thumbnails', 'data/style'); - if (in_array('flv', $this->getVideosFormats())) { - $dirsToCreate[] = 'swf'; - } - - foreach ($dirsToCreate as $dir) { - $d = $this->vdir . '/' . $dir; - if (!file_exists($d)) { - mkdir($d, 0777, true); - } - } - // Copy fonts folder - $from = $this->assets . '/style/fonts/*'; - $to = $this->vdir . '/style/fonts'; - if (!file_exists($to)) { - mkdir($to, 0777, true); - } - `cp -p -r $from $to`; + $from = $this->assets . '/style/fonts'; + $to = 'style/fonts'; + $this->vdir->copyDirectory($from, $to); // Copy images folder $from = $this->assets . '/images'; - $to = $this->vdir; - `cp -p -r $from $to`; + $to = 'images'; + $this->vdir->copyDirectory($from, $to); // Copy images folder $from = $this->assets . '/video'; - $to = $this->vdir; - `cp -p -r $from $to`; + $to = 'video'; + $this->vdir->copyDirectory($from, $to); - // Copy swf - if (file_exists($this->vdir . '/swf')) { - $this->copy($this->assets . '/swf/video.swf', $this->vdir . '/swf/video.swf'); - } $this->log('Copied assets'); $this->loadPlugins(); $this->log('Plugins loaded'); @@ -349,7 +323,7 @@ class wsHTML5Compiler { $this->log('Images written'); $linksCSS = $this->writeLinks(); $this->log('Links written'); - $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); + $this->writeCSS('data/style/style_%d.css', $linksCSS); $this->log('CSS written'); $this->writeLangs(); $this->log('Langs written'); @@ -361,8 +335,8 @@ class wsHTML5Compiler { $this->log('Extras written'); $this->writeJs(); $this->log('Js written'); - $this->writeCache(); - $this->log('Cache written'); + + $this->vdir->sync(true); } protected function loadPlugins() { @@ -389,12 +363,12 @@ class wsHTML5Compiler { if (file_exists($dir . '/plugin.js')) { $f = $d . '/plugin.js'; $this->pluginJs[] = $f; - $this->copy($dir . '/plugin.js', $this->vdir . '/' . $f); + $this->vdir->copy($dir . '/plugin.js', $f); } if (file_exists($dir . '/plugin.css')) { $f = $d . '/plugin.css'; $this->pluginCSS[] = $f; - $this->copy($dir . '/plugin.css', $this->vdir . '/' . $f); + $this->vdir->copy($dir . '/plugin.css', $f); } } @@ -422,55 +396,6 @@ class wsHTML5Compiler { return $res; } - protected function writeCache() { - if (!$this->appcache) { - return; - } - - $cacheFile = $this->vdir . '/cache.appcache'; - - if (file_exists($cacheFile)) { - unlink($cacheFile); - } - - $dest = realpath($this->vdir); - $lines = array(); - - $network = array('NETWORK:', '*'); - - $lines[] = 'CACHE MANIFEST'; - $lines[] = '# ' . date('Y-m-d H:i:s'); - $lines[] = ''; - $lines[] = 'index.html'; - $lines[] = ''; - $lines[] = 'FALLBACK:'; - $lines[] = '/ index.html'; - $lines[] = 'index.html* index.html'; - $lines[] = ''; - $lines[] = 'CACHE:'; - - $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dest), RecursiveIteratorIterator::SELF_FIRST); - - $exclude = array('index.html', 'indexu.html', 'widget.html', 'indext.html'); - - foreach ($iterator as $path) { - if (!$path->isFile()) { - continue; - } - - $p = str_replace($dest . '/', '', $path); - if (in_array($p, $exclude)) { - continue; - } - $lines[] = $p; - } - - $lines[] = ''; - $lines = array_merge($lines, $network); - - file_put_contents($cacheFile, implode("\n", $lines)); - } - /** * Helper function to add a unique script entry to the JS stack. * Normally this is a relative path but it can be an external URL. @@ -597,7 +522,7 @@ class wsHTML5Compiler { if ($this->theme->parametres->logoLoader) { $dim = getimagesize($this->themeRoot . '/' . $this->theme->parametres->logoLoader); if ($dim !== false) { - $this->copy($this->themeRoot . '/' . $this->theme->parametres->logoLoader, $this->vdir . '/data/images/' . $this->theme->parametres->logoLoader); + $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->logoLoader, 'data/images/' . $this->theme->parametres->logoLoader); $splash .= ''; } } @@ -651,9 +576,9 @@ class wsHTML5Compiler { $thtml = str_replace('', $$v, $thtml); } - file_put_contents($this->vdir . '/index.html', $html); - file_put_contents($this->vdir . '/indexu.html', $uhtml); - file_put_contents($this->vdir . '/indext.html', $uhtml); + $this->vdir->file_put_contents('index.html', $html); + $this->vdir->file_put_contents('indexu.html', $uhtml); + $this->vdir->file_put_contents('indext.html', $uhtml); // Write widget html if ($this->widget) { @@ -666,7 +591,7 @@ class wsHTML5Compiler { foreach ($vars as $v) { $whtml = str_replace('', $$v, $whtml); } - file_put_contents($this->vdir . '/widget.html', $whtml); + $this->vdir->file_put_contents('widget.html', $whtml); } } @@ -685,7 +610,7 @@ class wsHTML5Compiler { foreach ($vars as $v) { $manifest = str_replace('$' . $v, $this->book->parametres->$v, $manifest); } - file_put_contents($this->vdir . '/imsmanifest.xml', $manifest); + $this->vdir->file_put_contents('imsmanifest.xml', $manifest); } protected function writePrint() { @@ -694,7 +619,7 @@ class wsHTML5Compiler { return; } - $this->copy(WS_BOOKS . '/final/' . $this->book->book_id . '/data/' . $this->book->parametres->pdfName, $this->vdir . '/data/' . $this->book->parametres->pdfName); + $this->vdir->copy(WS_BOOKS . '/final/' . $this->book->book_id . '/data/' . $this->book->parametres->pdfName, 'data/' . $this->book->parametres->pdfName); return ''; } @@ -743,7 +668,7 @@ class wsHTML5Compiler { } $iso = l10n::getISOcodes(); if ($this->book->parametres->multilang != '') { - $flagsDir = $this->vdir . '/images/flags'; + $flagsDir = 'images/flags'; if (!file_exists($flagsDir)) { mkdir($flagsDir); } @@ -757,7 +682,7 @@ class wsHTML5Compiler { $ll = explode('-', $l[0]); - $this->copy(cubeMedia::getFlagFile($flag), $flagsDir . '/' . $flag . '.png'); + $this->vdir->copy(cubeMedia::getFlagFile($flag), $flagsDir . '/' . $flag . '.png'); $l[3] = cubeText::ucfirst($iso[$l[0]]); $l[4] = cubeCountry::getCountryName($flag, $ll[0]); $m[] = implode(',', $l); @@ -769,11 +694,11 @@ class wsHTML5Compiler { protected function writeExtras() { if ($this->theme->parametres->afterSearch != '') { - $this->copy($this->themeRoot . '/' . $this->theme->parametres->afterSearch, $this->vdir . '/data/images/' . $this->theme->parametres->afterSearch); + $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->afterSearch, 'data/images/' . $this->theme->parametres->afterSearch); } if ($this->book->parametres->externalArchives != '') { $this->addFilesInfos('archives', $this->wdir . '/' . $this->book->parametres->externalArchives); - $this->copy($this->wdir . '/' . $this->book->parametres->externalArchives, $this->vdir . '/data/images/' . $this->book->parametres->externalArchives); + $this->vdir->copy($this->wdir . '/' . $this->book->parametres->externalArchives, 'data/images/' . $this->book->parametres->externalArchives); } } @@ -897,7 +822,7 @@ class wsHTML5Compiler { protected function writeJs() { $config = $this->writeConfig(); - file_put_contents($this->vdir . '/data/datas.js', $config); + $this->vdir->file_put_contents('data/datas.js', $config); $finals = array('fluidbook' => $this->jsFiles); if ($this->book->parametres->scorm_enable) { $finals['scorm'] = array(); @@ -958,26 +883,22 @@ class wsHTML5Compiler { $uglify->execute(); $uglify->debug(); } - $dest = $this->vdir . '/data/' . $jsfinal . '.js'; - copy($minimized, $dest); + $dest = 'data/' . $jsfinal . '.js'; + $this->vdir->copy($minimized, $dest); } if ($this->phonegap) { - $this->copy(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap/' . $this->phonegapVersion . '/cordova-' . $this->phonegap . '.js', $this->vdir . '/data/cordova.js'); + $this->vdir->copy(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap/' . $this->phonegapVersion . '/cordova-' . $this->phonegap . '.js', 'data/cordova.js'); } } public function writeTexts() { $this->daoBook->makeTextsIndexes($this->book, $this->pages, $index, $textes, true); - $jsindex = 'var INDEX=' . $index . ';' . "\r"; - $jstexts = 'var TEXTS=' . $textes . ';' . "\r"; - - file_put_contents($this->vdir . '/data/search.index.js', $jsindex); - file_put_contents($this->vdir . '/data/search.texts.js', $jstexts); + $this->vdir->file_put_contents('data/search.index.js', 'var INDEX=' . $index . ';' . "\r"); if ($this->book->parametres->highlightResults) { - file_put_contents($this->vdir . '/data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r"); + $this->vdir->file_put_contents('data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r"); } } @@ -1050,7 +971,11 @@ class wsHTML5Compiler { $ext = CubeIT_Files::getExtension($referencesFile); if ($ext == 'xlsx') { $this->config->basketReferences = wsUtil::excelToArray($referencesFile); + if ($this->book->parametres->customLinkClass == 'AtlanticDownloadLink') { + $this->config->basketReferences = wsUtil::atlanticReferences($this->config->basketReferences, 'local/', array($this, 'log'), array($this->vdir, "copy")); + } } + $this->log("Done cart references"); } } $this->config->rasterizePages = cubeArray::parseRange($this->config->rasterizePages); @@ -1096,7 +1021,10 @@ class wsHTML5Compiler { $this->config->iconsDimensions = array(); $makepng = !$this->supportSVG(); foreach ($icons as $icon => $color) { - wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h); + $tmpdir = CubeIT_Files::tmpdir(); + wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $tmpdir, 4, $w, $h); + $this->vdir->copyDirectory($tmpdir, 'data/images'); + $this->vdir->addTemp($tmpdir); $this->config->iconsDimensions[$icon] = array($w, $h); } return $res; @@ -1104,9 +1032,6 @@ class wsHTML5Compiler { protected function writeImages() { global $core; - foreach ($this->getResolutions() as $r) { - mkdir($this->vdir . '/data/background/' . $r, 0777, true); - } $thumbs = array(); foreach ($this->pages as $page => $infos) { @@ -1126,7 +1051,7 @@ class wsHTML5Compiler { wsDocument::extractTexts($full, $orig); wsTools::optimizeSVG($orig, $opt); - $this->copy($opt, $this->vdir . '/data/contents/p' . $page . '.svg'); + $this->vdir->copy($opt, 'data/contents/p' . $page . '.svg'); } foreach ($this->getResolutions() as $r) { @@ -1135,12 +1060,12 @@ class wsHTML5Compiler { if ($backgroundsPrefix == 'p') { $srcPrefix = 'h'; } - $ok = $this->copy($docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg'); + $ok = $this->vdir->copy($docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg'); if (!$ok && $r = 300) { $this->maxRes = 150; } } - $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg'); + $this->vdir->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', 'data/thumbnails/p' . $page . '.jpg'); } $thumb = false; @@ -1188,14 +1113,14 @@ class wsHTML5Compiler { } $cache = WS_CACHE . '/thumbsprites/' . hash('sha256', $hash) . '.jpg'; - $dest = $this->vdir . '/data/thumbnails/s' . $k . '.jpg'; + $dest = 'data/thumbnails/s' . $k . '.jpg'; if (!file_exists($cache)) { $ratio = $this->width / $this->height; $thumbh = round(100 / $ratio); $cmd = 'montage ' . implode(' ', $files) . ' -geometry 100x' . $thumbh . '!+0+0 -background transparent -tile ' . $cols . 'x' . $srows . ' ' . $cache; $res .= `$cmd`; } - copy($cache, $dest); + $this->vdir->copy($cache, $dest); $k++; } return $res; @@ -1206,8 +1131,7 @@ class wsHTML5Compiler { $w = $size[0]; $h = $size[1]; - //$tmp = cubeFiles::tempnam() . '.png'; - $tmp = $this->vdir . '/covers.png'; + $tmp = cubeFiles::tempnam() . '.png'; $c = new cubeCommandLine('convert'); $c->setArg(null, ROOT . '/images/ws/shade-cover-app.png'); @@ -1215,31 +1139,18 @@ class wsHTML5Compiler { $c->setArg(null, $tmp); $c->execute(); + $res = cubeFiles::tempnam() . '.jpg'; + $convert = new cubeCommandLine('composite'); $cmd = '-compose Multiply '; $cmd .= $tmp . ' ' . $orig . ' '; - $cmd .= $this->vdir . '/cover.jpg'; + $cmd .= $res; $convert->setManualArg($cmd); $convert->execute(); - unlink($tmp); - } - - protected function copy($s, $t) { - if (!file_exists($s)) { - fb($s . ' dont exists'); - return false; - } - if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) { - return true; - } - if (!file_exists(dirname($t))) { - mkdir(dirname($t), 0777, true); - } + $this->vdir->copy($res, 'cover.jpg', true); - $res = copy($s, $t); - touch($t, filemtime($s)); - return true; + unlink($tmp); } protected function _lessBoolean($val) { @@ -1351,7 +1262,7 @@ class wsHTML5Compiler { $header .= 'height:' . $this->theme->parametres->menuHeight . 'px;'; $header .= 'background-color:' . wsHTML5::colorToCSS($this->theme->parametres->menuColor) . ';'; if ($this->theme->parametres->menuImage != '') { - $this->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); + $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, 'data/images/' . $this->theme->parametres->menuImage); $header .= 'background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; $header .= 'background-repeat:no-repeat;'; $header .= 'background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; @@ -1366,7 +1277,7 @@ class wsHTML5Compiler { // Logo $logo = '#logo{'; if ($this->theme->parametres->logo) { - $this->copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); + $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->logo, '/data/images/' . $this->theme->parametres->logo); $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); $logo .= 'background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; } @@ -1411,7 +1322,7 @@ class wsHTML5Compiler { // Archives if ($this->book->parametres->externalArchivesBack) { - $this->copy($this->wdir . '/' . $this->book->parametres->externalArchivesBack, $this->vdir . '/data/images/' . $this->book->parametres->externalArchivesBack); + $this->vdir->copy($this->wdir . '/' . $this->book->parametres->externalArchivesBack, 'data/images/' . $this->book->parametres->externalArchivesBack); $res[] = '.mview.archives{background-image:url("../images/' . $this->book->parametres->externalArchivesBack . '");}'; } @@ -1434,7 +1345,7 @@ class wsHTML5Compiler { $res = array_chunk($res, 3500); foreach ($res as $k => $css) { $this->stylesheets[] = 'data/style/style_' . $k . '.css'; - file_put_contents(sprintf($file, $k), implode("\n", $css)); + $this->vdir->file_put_contents(sprintf($file, $k), implode("\n", $css)); } return count($res); } @@ -1472,7 +1383,7 @@ class wsHTML5Compiler { $source_less = $this->assets . '/style/' . $f . '.less'; $destination_less = $tmp . '/' . $f . '.less'; - $destination_css = 'style/' . $f . '.css'; + $destination_css = $tmp . '/' . $f . '.css'; if (!file_exists($source_less)) { continue; @@ -1482,10 +1393,6 @@ class wsHTML5Compiler { if (!is_dir(dirname($destination_less))) { mkdir(dirname($destination_less), 0777, true); } - // Generated CSS file might be in a subfolder, so create if it doesn't exist - if (!is_dir(dirname($this->vdir . '/' . $f . '.css'))) { - mkdir(dirname($this->vdir . '/' . $f . '.css'), 0777, true); - } // Less files must be copied to temporary directory so they'll // have access to the variables generated in book-variables.less @@ -1493,13 +1400,14 @@ class wsHTML5Compiler { $less = new CubeIT_CommandLine('lessc'); $less->setArg('plugin', 'less-plugin-clean-css'); $less->setArg(null, $destination_less); - $less->setArg(null, $this->vdir . '/' . $destination_css); + $less->setArg(null, $destination_css); $less->execute(); - if (!file_exists($this->vdir . '/' . $destination_css)) { + if (!file_exists($destination_css)) { die($less->output); } + $this->vdir->copy($destination_css, 'style/' . $f . '.css'); if ($f != 'widget') { - $this->stylesheets[] = $destination_css; + $this->stylesheets[] = 'style/' . $f . '.css'; } } } @@ -1530,7 +1438,7 @@ class wsHTML5Compiler { $this->config->backgroundImageDimensions = array('width' => $dbi[0], 'height' => $dbi[1]); } - $this->copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); + $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, 'data/images/' . $this->theme->parametres->backgroundImage); $body .= 'background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; $body .= 'background-position:'; @@ -1593,14 +1501,8 @@ class wsHTML5Compiler { if ($addVdir) { $dest = $this->vdir . '/' . $dest; } - if (!file_exists(dirname($dest))) { - mkdir(dirname($dest), 0777, true); - } - if (file_exists($dest) && filemtime($dest) >= filemtime($source) && filesize($dest) == filesize($source)) { - return; - } - $this->copy($source, $dest); + $this->vdir->copy($source, $dest); } public function copyLinkFile($source, $dest, $video = false) { @@ -1628,7 +1530,7 @@ class wsHTML5Compiler { foreach ($source as $so) { $s = $origDir . $so; if (file_exists($s)) { - $d = $this->vdir . '/' . $dest . '/' . $so; + $d = $dest . '/' . $so; $this->simpleCopyLinkFile($s, $d, false); } } diff --git a/inc/ws/Util/html5/bookedges/class.ws.html5.links.php b/inc/ws/Util/html5/bookedges/class.ws.html5.links.php index 88d000e48..38778093c 100644 --- a/inc/ws/Util/html5/bookedges/class.ws.html5.links.php +++ b/inc/ws/Util/html5/bookedges/class.ws.html5.links.php @@ -227,13 +227,16 @@ class wsHTML5Link { public function unzipFile($file, $moveAssets = false) { $fdir = 'data/links/' . $file; - $dir = $this->compiler->vdir . '/' . $fdir; + + $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); diff --git a/inc/ws/Util/html5/class.ws.html5.php b/inc/ws/Util/html5/class.ws.html5.php index 44fbb07d3..38cc1bc01 100644 --- a/inc/ws/Util/html5/class.ws.html5.php +++ b/inc/ws/Util/html5/class.ws.html5.php @@ -22,12 +22,13 @@ class wsHTML5 { $masterDir = __DIR__ . '/master/'; $files = array('class.ws.html5.compiler.php', 'class.ws.html5.links.php'); - foreach ($files as $file) { - - if (file_exists($branchDir . $file)) { - require_once $branchDir . $file; - } else { - require_once $masterDir . $file; + if (!class_exists('wsHTML5Compiler', false)) { + foreach ($files as $file) { + if (file_exists($branchDir . $file)) { + require_once $branchDir . $file; + } else { + require_once $masterDir . $file; + } } } @@ -45,18 +46,18 @@ class wsHTML5 { public static function getPhonegapVersions() { $versions = array(); - $phonegap_dir = WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap'; - - if (is_dir($phonegap_dir)) { - $dr = opendir($phonegap_dir); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..' || $file == 'plugins') { - continue; - } - $versions[] = $file; - } - usort($versions, 'version_compare'); - } + $phonegap_dir = WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap'; + + if (is_dir($phonegap_dir)) { + $dr = opendir($phonegap_dir); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..' || $file == 'plugins') { + continue; + } + $versions[] = $file; + } + usort($versions, 'version_compare'); + } return $versions; } -- 2.39.5