From: Vincent Vanwaelscappel Date: Fri, 17 Feb 2023 12:34:40 +0000 (+0100) Subject: wip #5742 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8acef0f4ea5e1684ea137fa16ef62f4c0af180ee;p=fluidbook-toolbox.git wip #5742 @0.5 --- diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 4699a24d3..d69616acc 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -15,6 +15,7 @@ services: - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/' + - '/home/extranet/www/fluidbook/cache/unzip/:/application/storage/fluidbook/cache/unzip/' - '/home/extranet:/home/extranet' - '/data/extranet:/data/extranet' - '/mnt:/mnt' @@ -78,6 +79,7 @@ services: - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/' - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/' - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/' + - '/data/extranet/www/fluidbook/cache/unzip/:/application/storage/fluidbook/cache/unzip/' - '/home/extranet:/home/extranet' - '/data/extranet:/data/extranet' - '/mnt:/mnt' diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 5af7cf593..46843d9ed 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -31,6 +31,7 @@ use Cubist\Util\PHP; use Cubist\Util\Text; use Cubist\Util\Url; use Cubist\Util\WebVideo; +use Cubist\Util\Zip; use DOMDocument; use DOMElement; use DOMXPath; @@ -2528,11 +2529,11 @@ height="0" width="0" style="display:none;visibility:hidden"> { Log::error($e); - $c=explode('\\',get_class($link)); - $type=array_pop($c); - $type=str_replace('Link','',$type); + $c = explode('\\', get_class($link)); + $type = array_pop($c); + $type = str_replace('Link', '', $type); - throw new \Exception('Error on the '.$type.' link to ' . $link->to . ' on page ' . $link->page . ' with message : ' . $e->getMessage()); + throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . ' with message : ' . $e->getMessage()); } protected function _htmlLinkList($list) @@ -3662,24 +3663,18 @@ height="0" width="0" style="display:none;visibility:hidden"> public function unzipFile($file, $moveAssets = false, $baseDir = null) { - $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : $baseDir; + $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : commonTools::fixpath($baseDir); + + $zipPath = $this->wdir . '/' . $file; + $dir = storage_path('fluidbook/cache/unzip') . Files::hashFileAttributes($zipPath); - $tmp = Files::tmpdir(); - $dir = $tmp . '/' . $fdir; - if (file_exists($dir) && is_file($dir)) { - unlink($dir); - } if (!file_exists($dir)) { mkdir($dir, 0777, true); - } - $unzip = new CommandLine('unzip'); - $unzip->setArg(null, $this->wdir . '/' . $file); - $unzip->setArg('d', $dir); - $unzip->execute(); - - if ($moveAssets) { - `mv $dir/Assets/* $dir`; - rmdir($dir . '/Assets'); + Zip::extract($zipPath, $dir); + if ($moveAssets) { + `mv $dir/Assets/* $dir`; + rmdir($dir . '/Assets'); + } } return array('dir' => $dir, 'fdir' => $fdir); @@ -3713,8 +3708,7 @@ height="0" width="0" style="display:none;visibility:hidden"> } 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 array_merge($res, $r); } public function addFontKit($font)