+++ /dev/null
-<?php
-
-namespace App\Http\Controllers\Admin;
-
-class MédiathèqueCrudController extends \Cubist\Backpack\Magic\Controllers\CubistMagicController
-{
- use \Cubist\Backpack\Magic\Operations\CreateOperation;
- use \Cubist\Backpack\Magic\Operations\UpdateOperation;
- use \Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
- use \Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
- use \Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
- use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
- use \Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
- use \Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
-
-
-
- /*
- __('Element de la médiathèque')
- __('Eléments de la médiathèque')
- */
-
- protected $_modelNamespace = 'App\Models\Asset';
- protected $_routeURL = 'médiathèque';
- protected $_singular = 'Element de la médiathèque';
- protected $_plural = 'Eléments de la médiathèque';
- protected $_oneInstance= false;
-}
namespace App\Jobs;
+use App\Models\Asset;
use App\Models\Publication;
+use Cubist\Util\Files\Files;
use Cubist\Util\Zip;
use Fluidbook\Tools\Compiler\Compiler;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
$this->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;
}
+
+
}
$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]);