From: Vincent Vanwaelscappel Date: Mon, 22 Aug 2022 15:31:40 +0000 (+0200) Subject: wip #5408 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ea04a6c3b674d34a9806442638c132b94cb29535;p=fluidbook_tools.git wip #5408 --- diff --git a/src/Compiler/CompilerInterface.php b/src/Compiler/CompilerInterface.php index e8f3edb..a16fef7 100644 --- a/src/Compiler/CompilerInterface.php +++ b/src/Compiler/CompilerInterface.php @@ -26,6 +26,8 @@ interface CompilerInterface public function getVirtualDirectory(): VirtualDirectory; public function getWorkingDir(): string; - + public function setWorkingDir(string $wdir); + + public function working_path($path = ''): string; } diff --git a/src/Compiler/FluidbookCompiler.php b/src/Compiler/FluidbookCompiler.php index d2fab22..5ce6a6d 100644 --- a/src/Compiler/FluidbookCompiler.php +++ b/src/Compiler/FluidbookCompiler.php @@ -40,7 +40,7 @@ trait FluidbookCompiler $this->wdir = $wdir; } - public function working_path($path = '') + public function working_path($path = ''):string { $res = $this->getWorkingDir(); return $path ? $res . '/' . $path : $res; diff --git a/src/Links/HTMLMultimediaLink.php b/src/Links/HTMLMultimediaLink.php index 8be0da2..35483a3 100644 --- a/src/Links/HTMLMultimediaLink.php +++ b/src/Links/HTMLMultimediaLink.php @@ -40,8 +40,7 @@ class HTMLMultimediaLink extends Link $dir = $fdir; $d = array('fdir' => $fdir, 'dir' => $dir); - $file = $this->compiler->wdir . '/' . $this->alternative; - $this->compiler->getVirtualDirectory()->copy($this->compiler->wdir . '/' . $this->alternative, $d['dir'] . '/' . $this->alternative); + $this->compiler->getVirtualDirectory()->copy( $this->compiler->working_path($this->alternative), $d['dir'] . '/' . $this->alternative); $this->_config = $this->getConfigHTML($d['dir'], $this->alternative); $this->copyExternalFile($d['dir'] . '/' . $this->alternative); } diff --git a/src/Links/HTMLMultimediaPopupImage.php b/src/Links/HTMLMultimediaPopupImage.php index 8cd5925..bc547af 100644 --- a/src/Links/HTMLMultimediaPopupImage.php +++ b/src/Links/HTMLMultimediaPopupImage.php @@ -2,6 +2,8 @@ namespace Fluidbook\Tools\Links; +use Cubist\Util\Graphics\Image; + class HTMLMultimediaPopupImage extends NormalLink { public $clickToClose = 0; @@ -16,7 +18,7 @@ class HTMLMultimediaPopupImage extends NormalLink public function getAdditionnalContent() { $res = parent::getAdditionnalContent(); - $dim = CubeIT_Image::getimagesize($this->wdir . '/' . $this->alternative); + $dim = Image::getimagesize($this->compiler->working_path($this->alternative)); $markup = '
'; $read = ''; diff --git a/src/Links/SlideshowLink.php b/src/Links/SlideshowLink.php index 35fbf8b..abb3e7b 100644 --- a/src/Links/SlideshowLink.php +++ b/src/Links/SlideshowLink.php @@ -164,7 +164,7 @@ class SlideshowLink extends NormalLink foreach ($slides as $slide) { - $image_path_relative = str_replace($this->compiler->wdir, '', $slide['path']); + $image_path_relative = str_replace($this->compiler->getWorkingDir() . "/", '', $slide['path']); $image_info = Image::getimagesize($slide['path']); $image_info_json = ($image_info) ? json_encode(['width' => $image_info[0], 'height' => $image_info[1], 'ratio' => round($image_info[0] / $image_info[1], 4)]) : ''; diff --git a/src/Links/VideoLink.php b/src/Links/VideoLink.php index 0c6bebb..8777a28 100644 --- a/src/Links/VideoLink.php +++ b/src/Links/VideoLink.php @@ -4,6 +4,7 @@ namespace Fluidbook\Tools\Links; use Cubist\Util\Files\Files; use Cubist\Util\Url; +use Fluidbook\Tools\Compiler\CompilerInterface; use Illuminate\Support\Facades\Cache; class VideoLink extends Link @@ -62,6 +63,13 @@ class VideoLink extends Link return $res; } + /** + * @param $data + * @param $w + * @param $h + * @param $compiler CompilerInterface + * @return array + */ public static function getVideoAttributes($data, $w = null, $h = null, $compiler = null) { $attr['name'] = VideoPopupLink::getBasename($data->to); @@ -75,13 +83,13 @@ class VideoLink extends Link $attr['sound'] = ($data->video_sound_on ? '1' : '0'); $attr['hidelinksonplay'] = $data->hidelinksonplay; $attr['link-id'] = $data->uid; - $attr['backgroundcolor'] = isset($data->backgroundColor) ? $data->backgroundColor : '#000000'; + $attr['backgroundcolor'] = $data->backgroundColor ?? '#000000'; if (!is_null($w) && !is_null($h)) { $attr['width'] = $w; $attr['height'] = $h; } else if (!is_null($compiler) && Url::isLocal($data->to)) { - $path = file_exists($data->to) ? $data->to : $compiler->wdir . '/' . $data->to; + $path = file_exists($data->to) ? $data->to : $compiler->working_path($data->to); $dim = Cache::remember('videosize_' . Files::hashFileAttributes($path), 86400, function () use ($path) { $e = explode(',', `ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 $path`);