From 4a8394e24b03a744e78857b57d729f03e53fdc1f Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 21 Apr 2017 18:49:53 +0000 Subject: [PATCH] done #1364 @1 --- inc/ws/Controlleur/class.ws.maintenance.php | 6 --- inc/ws/DAO/class.ws.dao.book.php | 4 +- inc/ws/Util/class.ws.util.php | 13 +++++++ inc/ws/Util/html5/class.ws.html5.compiler.php | 39 +++++++++++-------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 8fe652b87..25478665b 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1177,10 +1177,4 @@ class wsMaintenance { $runs = $api->batchUnsubscribe('69f69a2bb8', array_keys($unsubscribe)); echo '
' . print_r($runs, true) . '
'; } - - public function excel2array() { - - echo json_encode(wsUtil::excelToArray("/home/wesco/15296.xlsx")); - } - } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index dfb010d4a..afb60a319 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1468,7 +1468,7 @@ class wsDAOBook extends commonDAO { $formats = array('jpg', 'png', 'jpeg'); $referencesFile = self::getWorkingFile($book->parametres->basketReferences, $book_id, 'commerce'); - if (file_exists($referencesFile)) { + if (file_exists($referencesFile) || CubeIT_Util_Url::isDistant($referencesFile)) { $ext = CubeIT_Files::getExtension($referencesFile); if ($ext == 'xml') { $xml = simplexml_load_file($referencesFile); @@ -1531,7 +1531,7 @@ class wsDAOBook extends commonDAO { public static function getWorkingFile($path, $book_id, $dir = "") { - if (substr($path, 0, 1) == '/' && file_exists($path)) { + if (CubeIT_Util_Url::isDistant($path) || (substr($path, 0, 1) == '/' && file_exists($path))) { return $path; } diff --git a/inc/ws/Util/class.ws.util.php b/inc/ws/Util/class.ws.util.php index d72c850a3..0e5198063 100644 --- a/inc/ws/Util/class.ws.util.php +++ b/inc/ws/Util/class.ws.util.php @@ -3,6 +3,19 @@ class wsUtil { public static function excelToArray($excelFile) { $worksheets = array(); + + if (CubeIT_Util_Url::isDistant($excelFile)) { + $tmp = CubeIT_Files::tempnam(); + copy($excelFile, $tmp); + + $hash = hash_file('sha256', $tmp); + $dest = WS_CACHE . '/xlsx2array/' . $hash . '.xlsx'; + + if (!file_exists($dest)) { + copy($tmp, $dest); + } + $excelFile = $dest; + } if (!file_exists($excelFile)) { return array(); } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index ac828ad34..2a0fa221f 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -71,6 +71,7 @@ class wsHTML5Compiler { 'js/libs/fluidbook/fluidbook.pad.js', 'js/libs/fluidbook/fluidbook.audiodescription.js', 'js/libs/fluidbook/fluidbook.privacy.js', + 'js/libs/fluidbook/fluidbook.zoom.js', 'js/libs/fluidbook/views/fluidbook.chapters.js', 'js/libs/fluidbook/views/fluidbook.index.js', 'js/libs/fluidbook/fluidbook.js', @@ -184,7 +185,6 @@ class wsHTML5Compiler { $this->assets = WS_COMPILE_ASSETS . '/player/' . ($location == 'git' ? 'branches' : $location) . '/' . $branch; } - $this->phonegap = $phonegap; $this->standalone = $standalone || $this->phonegap; $this->appcache = $appcache; @@ -872,7 +872,7 @@ class wsHTML5Compiler { } if (!$reminimize) { - if (filemtime(__FILE__) > $mintime || filemtime(__DIR__ . 'class.ws.html5.links.php') > $mintime) { + if (filemtime(__FILE__) > $mintime || filemtime(__DIR__ . '/class.ws.html5.links.php') > $mintime) { $reminimize = true; } } @@ -881,7 +881,7 @@ class wsHTML5Compiler { $js = ''; foreach ($files as $file) { $js .= file_get_contents($this->assets . '/' . $file); - $js .= "\n\n"; + $js .= ";\n\n"; } $tmp = cubeFiles::tempnam(); file_put_contents($tmp, $js); @@ -894,15 +894,15 @@ class wsHTML5Compiler { $uglify->execute(); //$uglify->debug(); } - - $js = file_get_contents($minimized); - file_put_contents($this->vdir . '/data/' . $jsfinal . '.js', $js); + $dest = $this->vdir . '/data/' . $jsfinal . '.js'; + 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'); } + } public function writeTexts() { @@ -970,13 +970,13 @@ class wsHTML5Compiler { } if ($this->config->basket) { - if (file_exists($this->config->basketReferences)) { + if (file_exists($this->config->basketReferences) || CubeIT_Util_Url::isDistant($this->config->basketReferences)) { $referencesFile = $this->config->basketReferences; } else { $referencesFile = $this->wdir . '/commerce/' . $this->config->basketReferences; } - if (file_exists($referencesFile)) { + if (file_exists($referencesFile) || CubeIT_Util_Url::isDistant($referencesFile)) { $ext = CubeIT_Files::getExtension($referencesFile); if ($ext == 'xlsx') { $this->config->basketReferences = wsUtil::excelToArray($referencesFile); @@ -1254,7 +1254,6 @@ class wsHTML5Compiler { $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}'; $res[] = '.link a.displayArea.animating {' . self::writeCSSUA('transition', 'opacity ' . $this->book->parametres->linkBlinkTime . 's ease-in') . '}'; - // Bookmarks if (!isset($this->book->parametres->bookmarkCornerSize)) { $this->book->parametres->bookmarkCornerSize = 10; @@ -1421,6 +1420,20 @@ class wsHTML5Compiler { `cp -a $source $this->vdir/$dest`; } + public function simpleCopyLinkFile($source, $dest, $addVdir = true) { + 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); + } + public function copyLinkFile($source, $dest, $video = false) { if ($video && $this->book->parametres->mobileVideosPath != '') { @@ -1447,13 +1460,7 @@ class wsHTML5Compiler { $s = $origDir . $so; if (file_exists($s)) { $d = $this->vdir . '/' . $dest . '/' . $so; - if (!file_exists(dirname($d))) { - mkdir(dirname($d), 0777, true); - } - if (file_exists($d) && filemtime($d) >= filemtime($s) && filesize($d) == filesize($s)) { - continue; - } - $this->copy($s, $d); + $this->simpleCopyLinkFile($s, $d, false); } } } -- 2.39.5