$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;
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);
public function getCacheDir($path): string
{
- return Files::mkdir(protected_path('fluidbookpublication/cache/' . $path));
+ return Files::mkdir($this->getFluidbook()->protected_path('fluidbookpublication/cache/' . $path));
}
$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);
$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';
}
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';
$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();
protected function packager_path($path = '')
{
- return protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
+ return $this->book->protected_path('fluidbookpublication/packager/' . ltrim($path, '/'));
}
{
$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);
}
}
- $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;
}
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;
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)
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) {
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()
{
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);
+ });
+ }
}
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);
+ }
+}