From: Vincent Vanwaelscappel Date: Tue, 5 Oct 2021 13:26:32 +0000 (+0200) Subject: wip #4750 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=40c9d1fb668d9a49256d8aa890515b4bbb6e35f8;p=odl.git wip #4750 @1 --- diff --git "a/app/Http/Controllers/Admin/M\303\251diath\303\250queCrudController.php" "b/app/Http/Controllers/Admin/M\303\251diath\303\250queCrudController.php" deleted file mode 100644 index bbf6242..0000000 --- "a/app/Http/Controllers/Admin/M\303\251diath\303\250queCrudController.php" +++ /dev/null @@ -1,28 +0,0 @@ -out = storage_path('fluidbook/out/'); } + /** + * @param $id + * @return string + */ + protected function _getAssetFile($id) + { + /** @var Asset $asset */ + $asset = Asset::find($id); + $path = $asset->getMediaInField($asset->getAttributeValue('file_upload'))->first()->getPath(); + $spl = new \SplFileInfo($path); + $fname = $spl->getFilename(); + if (file_exists($path)) { + $dir = resource_path('fluidbook/working/'); + Files::mkdir($dir); + copy($path, $dir . $fname); + } + return $fname; + } + public function getLinks() { - return $this->getLinksFromPDF(); + $links = $this->getLinksFromPDF(); + $res = []; + foreach ($links as $k => $link) { + $e = explode(':', $link['to']); + if ($e[0] === 'pdf') { + $ee = explode('#', $e[1]); + $link['type'] = 16; + $link['to'] = $this->_getAssetFile($ee[0]); + $link['target'] = '_popupiframe'; + $link['extras'] = 'page=' . ($ee[1] ?? 1); + } else if (stripos($e[0], 'video/') === 0) { + $link['type'] = 4; + $link['inline'] = $e[0] === 'video/inline'; + $link['to'] = $this->_getAssetFile($e[1]); + if ($link['inline']) { + $link['video_auto_start'] = false; + $link['video_controls'] = true; + $link['loop'] = false; + $link['sound'] = true; + } else { + $link['video_auto_start'] = true; + $link['video_controls'] = true; + $link['loop'] = false; + $link['sound'] = true; + } + } + $res[$k] = $link; + } + + return $res; } + + } diff --git a/app/Models/Asset.php b/app/Models/Asset.php index c92561b..a85b687 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -25,13 +25,16 @@ class Asset extends CubistMagicAbstractModel $this->addField('title', Text::class, 'Titre', ['column' => true]); $this->addField('type', SelectFromArray::class, 'Type', - ['options' => [ - 'image' => 'Image', - 'inlinevideo' => 'Vidéo (intégrée à la page)', - 'popupvideo' => 'Vidéo (popup)', - 'pdf' => 'Document PDF', - 'download' => 'Fichier à télécharger'], - 'column' => true, + [ + 'options' => + [ + 'image' => 'Image', + 'inlinevideo' => 'Vidéo (intégrée à la page)', + 'popupvideo' => 'Vidéo (popup)', + 'pdf' => 'Document PDF', + //'download' => 'Fichier à télécharger'], + 'column' => true, + ] ]); $this->addField('file_upload', Files::class, 'Fichier'); $this->addField('keywords', Tags::class, 'Mots-clé', ['column' => true]);