]> _ Git - fluidbook_tools.git/commitdiff
wip #5408
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 15:31:40 +0000 (17:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 Aug 2022 15:31:40 +0000 (17:31 +0200)
src/Compiler/CompilerInterface.php
src/Compiler/FluidbookCompiler.php
src/Links/HTMLMultimediaLink.php
src/Links/HTMLMultimediaPopupImage.php
src/Links/SlideshowLink.php
src/Links/VideoLink.php

index e8f3edb729e1a8e2fde84734d3ea5059794fec21..a16fef70b640f246bbdfd35a9dc54a9d32f90b42 100644 (file)
@@ -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;
 }
index d2fab220423f57c2dc80e92224fe4c4b58738729..5ce6a6d7861354d5ef75adbfe17c8f973550b458 100644 (file)
@@ -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;
index 8be0da21f43acc60de2bf020ea3c0c214036823c..35483a3bf61d3bdc78f2006722f335c2852fcf44 100644 (file)
@@ -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);
             }
index 8cd59256dd712993fb0582a4acf0640dbb6e7654..bc547af54d11ae407cea2237bfbec442f8cac509 100644 (file)
@@ -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 = '<div class="multimediaContainer" data-click-to-close="' . $this->clickToClose . '"><img data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" src="' . Link::getUniversalLocation($this->alternative) . '" width="' . $dim[0] . '" height="' . $dim[1] . '" class="multimedia" /></div>';
         $read = '';
index 35fbf8bf2ac332760355b4993564f5740d2455ef..abb3e7b7058b1a3e057f03813d03b781a06a11e8 100644 (file)
@@ -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)]) : '';
index 0c6bebb5c803256c366acd96fdda9aafac7ed940..8777a28c76ea1f4364043c034b19d7bf9e4ee616 100644 (file)
@@ -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`);