]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6501 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Nov 2023 17:13:02 +0000 (18:13 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Nov 2023 17:13:02 +0000 (18:13 +0100)
app/Fluidbook/Compiler/Accessibility.php
app/Fluidbook/Compiler/Compiler.php
app/Fluidbook/Compiler/Search.php
app/Fluidbook/PDF.php
app/Fluidbook/Packager/Download.php
app/Fluidbook/Packager/Packager.php
app/Fluidbook/Packager/WindowsZIP.php
app/Models/FluidbookDocument.php
app/Models/FluidbookPublication.php
app/helpers.php

index a5ab4183d9921be66992163b5c9e09f118e9318f..9dec14be518ff36ff98d654d0105f94e78e0107e 100644 (file)
@@ -67,7 +67,7 @@ trait Accessibility
 
                 $hash = hash('sha256', $engine . ':' . $voice . '_^_' . $text);
                 $fname = $hash . '.mp3';
-                $dir = Files::mkdir(protected_path('audiodescription'));
+                $dir = Files::mkdir($this->getFluidbook()->protected_path('audiodescription'));
 
                 $file = $dir . $fname;
 
index 806e8da6fed70a2d8dd4c02987657b9ffa169809..a2eb7b09f807b2e1032c242091185c9e1a025354 100644 (file)
@@ -290,11 +290,10 @@ class Compiler extends Base implements CompilerInterface
 
     function __construct(FluidbookPublication $book, $scormVariant = false, $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
     {
-        ExcelToArray::setCache(protected_path('fluidbookpublication/cache/exceltoarray'));
+        ExcelToArray::setCache($book->protected_path('fluidbookpublication/cache/exceltoarray'));
 
         parent::__construct();
 
-
         $this->setFluidbook($book);
         $this->setCommand($command);
 
@@ -1596,7 +1595,7 @@ class Compiler extends Base implements CompilerInterface
 
     public function getCacheDir($path): string
     {
-        return Files::mkdir(protected_path('fluidbookpublication/cache/' . $path));
+        return Files::mkdir($this->getFluidbook()->protected_path('fluidbookpublication/cache/' . $path));
     }
 
 
@@ -2335,7 +2334,7 @@ class Compiler extends Base implements CompilerInterface
         $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : $baseDir;
 
         $zipPath = $this->wdir . '/' . $file;
-        $dir = protected_path('fluidbookpublication/cache/unzip') . '/' . Files::hashFileAttributes($zipPath) . '_' . ($moveAssets ? '1' : '0') . '_' . ($junkPaths ? '1' : '0');
+        $dir = $this->getFluidbook()->protected_path('fluidbookpublication/cache/unzip') . '/' . Files::hashFileAttributes($zipPath) . '_' . ($moveAssets ? '1' : '0') . '_' . ($junkPaths ? '1' : '0');
 
         if (!file_exists($dir)) {
             Files::mkdir($dir);
index 996613754a3f09558ad2557af140dd9612fa501c..f6dd7d1020efd62fe521510a2c1abdbac3e0804b 100644 (file)
@@ -21,7 +21,7 @@ trait Search
 
         $doIndex = $this->fluidbookSettings->search_mode !== 'robust';
 
-        $cacheDir = Files::mkdir(protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/'));
+        $cacheDir = Files::mkdir($this->getFluidbook()->protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/'));
         if ($doIndex) {
             $indexFile = $cacheDir . '/search.index.js';
         }
index 0b0a752b105a042d2d506a01fc92efd105975cad..a9f8a615951fa2808f2503433d77fd4dc6092d4d 100644 (file)
@@ -23,7 +23,7 @@ class PDF
             return false;
         }
 
-        $cacheDir = Files::mkdir(protected_path('fluidbookpublication/pdf/' . $fluidbook->id));
+        $cacheDir = Files::mkdir($fluidbook->protected_path('fluidbookpublication/pdf/' . $fluidbook->id));
 
         $normalPDF = $cacheDir . 'normal.pdf';
         $originalPDF = $cacheDir . 'original.pdf';
index c9b1ef2c1c7663e67461e3d514830c5965331cb1..683a52ad88df5ecb707861eeba69b4e6f2dbb454 100644 (file)
@@ -139,7 +139,7 @@ class Download extends DownloadBase
                 $res[] = $url;
             } else if ($this->action === 'loadbalancer') {
                 $path = $this->_compileandpackage(false);
-                $dest = protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/');
+                $dest = $this->entry->protected_path('fluidbookpublication/loadbalancer/' . $this->entry->id . '_' . $this->entry->hash . '/');
 
                 $rsync = new Rsync($path, $dest, true);
                 $rsync->execute();
index 6549e42eea44e0253d999f4324d58a88a2019200..304807549beb21b7620edb22499656d120a0bb39 100644 (file)
@@ -156,7 +156,7 @@ class Packager extends \App\Jobs\Base
 
     protected function packager_path($path = '')
     {
-        return protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
+        return $this->book->protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
     }
 
 
index bb40508a1aecb10d4c952f36ad2b8e8dbb1f9545..138304797f36c66951007f0507a4f657acef2eee 100644 (file)
@@ -136,7 +136,7 @@ class WindowsZIP extends Packager
     {
         $rand = 'sign-' . hash_file('sha256', $source) . '.exe';
         $remote = 'C:/Sign/' . $rand;
-        $local = protected_path('signedexe/' . $rand);
+        $local = $this->book->protected_path('signedexe/' . $rand);
         if (!file_exists($local)) {
             $ssh = new SSH2('paris.cubedesigners.com', 'vince', 'Y@mUC9mY2DOYWXkN', '22422');
             $ssh->send($source, $remote);
index e3a257a71f166175d57327a9dcc7d32495209f2e..b9cdac7c2f4e95fd9a4f38469ce7a1b86a9ab316 100644 (file)
@@ -215,11 +215,9 @@ class FluidbookDocument extends ToolboxModel
             }
         }
 
-        $res = rtrim(self::WS_DOCS . $this->id . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path), DIRECTORY_SEPARATOR);
-        if (!$path) {
-            $res .= DIRECTORY_SEPARATOR;
-        }
-        $res = Files::mkdir($res);
+        $base = 'fluidbookpublication/docs';
+        $res = Files::mkdir($this->region == 'UE' ? protected_path($base) : us_protected_path($base));
+
         if ($fname) {
             $res .= $fname;
         }
index 910718b514f07ba96f595eff146a8992a88b5360..03d73cf0b1c04e0287bb5fae3a1146e697c30f0b 100644 (file)
@@ -527,6 +527,15 @@ class FluidbookPublication extends ToolboxStatusModel
         return (float)$this->getDocumentSize($page)[1];
     }
 
+    public function protected_path($path)
+    {
+        if ($this->region === 'UE') {
+            return protected_path($path);
+        } else {
+            return us_protected_path($path);
+        }
+    }
+
     public function getFinalPath($theme = null, $scormVariant = false)
     {
         $dir = $this->id;
@@ -540,18 +549,18 @@ class FluidbookPublication extends ToolboxStatusModel
         if (null !== $theme && ($themeId != $this->theme)) {
             $dir .= '-' . $themeId;
         }
-        return protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
+        return $this->protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
     }
 
 
     public function getAssetDir()
     {
-        return Files::mkdir(protected_path('fluidbookpublication/working/' . $this->getAssetDirId()));
+        return Files::mkdir($this->protected_path('fluidbookpublication/working/' . $this->getAssetDirId()));
     }
 
     public function getPDFDir()
     {
-        return Files::mkdir(protected_path('fluidbookpublication/pdf/' . $this->id));
+        return Files::mkdir($this->protected_path('fluidbookpublication/pdf/' . $this->id));
     }
 
     public function asset_path($path)
@@ -902,7 +911,7 @@ class FluidbookPublication extends ToolboxStatusModel
             return $res;
         }
 
-        ExcelToArray::setCache(protected_path('fluidbookpublication/cache/exceltoarray'));
+        ExcelToArray::setCache($this->protected_path('fluidbookpublication/cache/exceltoarray'));
         $contents = ExcelToArray::excelToArrayFirstSheet($file);
 
         foreach ($contents as $row) {
@@ -1028,7 +1037,7 @@ class FluidbookPublication extends ToolboxStatusModel
 
     public function getPDFArchivesPath()
     {
-        return Files::mkdir(protected_path('fluidbookpublication/pdf/' . $this->id));
+        return Files::mkdir($this->protected_path('fluidbookpublication/pdf/' . $this->id));
     }
 
     public function getPDFArchivesList()
@@ -1053,4 +1062,11 @@ class FluidbookPublication extends ToolboxStatusModel
     {
         return parent::allowsPreview() && $this->getPagesNumber() > 0;
     }
+
+    public static function getProtectedPath($id, $path)
+    {
+        return cache()->tags([FluidbookPublication::class])->rememberForever("fluidbook_protectedpath_" . $id . '_' . $path, function () use ($id, $path) {
+            return FluidbookPublication::withoutGlobalScopes()->find($id)->protected_path($id);
+        });
+    }
 }
index 6d99ebcfa03821bd220bf2edafdbaa1ff4b79a7c..0336658b2a01fb68ed46e82afbdff6e25153d657 100644 (file)
@@ -10,3 +10,18 @@ if (!function_exists('dddd')) {
         return call_user_func_array('dd', func_get_args());
     }
 }
+
+
+if (!function_exists('us_path')) {
+    function us_path($path = '')
+    {
+        return base_path('/usstorage/' . $path);
+    }
+}
+
+if (!function_exists('us_protected_path')) {
+    function us_protected_path($path)
+    {
+        return us_path('/protected/' . $path);
+    }
+}