diff --git a/.gitignore b/.gitignore index 4519587..ddbff90 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ public/uploads/* /public/medias/* !public/medias/.gitkeep +/storage/export_arcadia/* +!storage/export_arcadia/.gitkeep + /storage/*.key /vendor .env diff --git a/app/Article.php b/app/Article.php new file mode 100644 index 0000000..11528e1 --- /dev/null +++ b/app/Article.php @@ -0,0 +1,16 @@ +belongsToMany('App\Media', 'medias_articles', 'article_id', 'media_id'); + } +} diff --git a/app/Console/Commands/DeleteMediaArchive.php b/app/Console/Commands/DeleteMediaArchive.php new file mode 100644 index 0000000..380557d --- /dev/null +++ b/app/Console/Commands/DeleteMediaArchive.php @@ -0,0 +1,99 @@ +info('Vous allez supprimer définitivement tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete).'); + + $choice = $this->choice('Etes-vous sûr de vouloir lancer ce traitement ?' , ['y', 'n'], 'y'); + + if($choice != "y"){ + $this->error('Choix incorrect'); + die(); + } + + $sujets = Sujet::where('sujet_dam', 1)->get(); + + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); + } + $this->line("[0] Tous les sujets"); + + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + + if($sujetId == ""){ + $this->error('Id de sujet incorrect'); + die(); + } + + if($sujetId == 0){ + $medias = Media::onlyTrashed()->with('Sujet.formats')->get(); + }else{ + $medias = Media::onlyTrashed()->where('sujet_id', $sujetId)->with('Sujet.formats')->get(); + } + + if($medias->count() == 0){ + $this->error('Aucun média a supprimer'); + die(); + } + + $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); + + foreach ($medias as $media) { + // supprime les fichiers médias stockés sur disque + $files = Storage::files($media->folder."/"); + $filepath = preg_quote($media->folder.$media->uid, '/'); + $matchingFiles = preg_grep('/^'.$filepath.'/', $files); + Storage::delete($matchingFiles); + // supprime le media en bdd + $media->forceDelete(); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Console/Commands/ImportArcadiaFiles.php b/app/Console/Commands/ImportArcadiaFiles.php new file mode 100644 index 0000000..302db55 --- /dev/null +++ b/app/Console/Commands/ImportArcadiaFiles.php @@ -0,0 +1,185 @@ +info('Démarrage du traitement'); + $files = Storage::disk('arcadia')->files(); + $bar = $this->output->createProgressBar(count($files)-1); + $bar->start(); + + // ---- Pour chaque fichier + foreach ($files as $filename) { + + if($filename == ".gitignore") continue; + + // ---- Récupération du contenu + $files = Storage::disk('arcadia')->get($filename); + $fileContent = simplexml_load_string($files); + + // ---- traitement du fichier + if(substr($filename, 0, 11) == "DAM_ARTICLE"){ + foreach ($fileContent->dam as $row) { + $record = Article::where('noArt', $row->noArt)->first(); + if($record){ // Update record + $record->libCcial = $row->libCcial; + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->codFamVte = $row->codFamVte; + $record->libFamVte = $row->libFamVte; + $record->codGencodAdm = $row->codGencodAdm; + $record->codGencodSymb = $row->codGencodSymb; + $record->codGencodPds = $row->codGencodPds; + $record->save(); + }else{ // Insert new record + $record = new Article(); + $record->noArt = $row->noArt; + $record->libCcial = $row->libCcial; + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->codFamVte = $row->codFamVte; + $record->libFamVte = $row->libFamVte; + $record->codGencodAdm = $row->codGencodAdm; + $record->codGencodSymb = $row->codGencodSymb; + $record->codGencodPds = $row->codGencodPds; + $record->save(); + } + } + }elseif (substr($filename, 0, 10) == "DAM_MARQUE") { + foreach ($fileContent->dam as $row) { + $record = Marque::where('codMarq', $row->codMarq)->first(); + if($record){ // Update record + $record->libMarq = $row->libMarq; + $record->save(); + }else{ // Insert new record + $record = new Marque(); + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->save(); + } + } + }elseif (substr($filename, 0, 15) == "DAM_MEDIA_SUJET") { + foreach ($fileContent->mediaSujet as $row) { + $record = Sujet::where('codeSujet', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Sujet(); + $record->codeSujet = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + }elseif (substr($filename, 0, 20) == "DAM_MEDIA_TYPE_MEDIA") { + foreach ($fileContent->mediatypemedia as $row) { + $record = Typemedia::where('codeTypemedia', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Typemedia(); + $record->codeTypemedia = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + }elseif (substr($filename, 0, 17) == "DAM_MEDIA_TYPEVUE") { + foreach ($fileContent->mediatypesvue as $row) { + $record = Typevue::where('codeTypevue', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->mediasujet->code; + $record->save(); + }else{ // Insert new record + $record = new Typevue(); + $record->codeTypevue = $row->code; + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->mediasujet->code; + $record->save(); + } + } + }elseif (substr($filename, 0, 18) == "DAM_MEDIA_VARIANTE") { + foreach ($fileContent->mediavariante as $row) { + $record = Variante::where('codeVariante', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->children()[0]->code; + $record->typevue_id = $row->CodeTypeVue->mediatypesvue->code; + $record->save(); + }else{ // Insert new record + $record = new Variante(); + $record->codeVariante = $row->code; + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->children()[0]->code; + $record->typevue_id = $row->CodeTypeVue->mediatypesvue->code; + $record->save(); + } + } + }elseif (substr($filename, 0, 20) == "DAM_SITE_PROD_GROUPE") { + foreach ($fileContent->SITE_PROD_GRP as $row) { + $record = Site::where('id', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Site(); + $record->id = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + } + + // ---- Suppression du fichier + Storage::disk('arcadia')->delete($filename); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Console/Commands/RegenerateThumbnails.php b/app/Console/Commands/RegenerateThumbnails.php new file mode 100644 index 0000000..6b935d3 --- /dev/null +++ b/app/Console/Commands/RegenerateThumbnails.php @@ -0,0 +1,94 @@ +info('Vous allez regénérer toutes les miniatures des médias.'); + + $sujets = Sujet::where('sujet_dam', 1)->get(); + + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); + } + $this->line("[0] Tous les sujets"); + + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + + if($sujetId == ""){ + $this->error('Id de sujet incorrect'); + die(); + } + + if($sujetId == 0){ + $medias = Media::where('typemedia_id', 1)->with('Sujet.formats')->get(); + }else{ + $medias = Media::where('sujet_id', $sujetId)->where('typemedia_id', 1)->with('Sujet.formats')->get(); + } + + if($medias->count() == 0){ + $this->error('Aucun média n\'a été trouvé'); + die(); + } + + $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); + + foreach ($medias as $media) { + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Etiquette.php b/app/Etiquette.php index 36ffe1c..486b6f1 100644 --- a/app/Etiquette.php +++ b/app/Etiquette.php @@ -12,4 +12,12 @@ class Etiquette extends Model * @var string */ protected $primaryKey = 'etiquette_id'; + + /** + * Get the medias for the etiquette. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Format.php b/app/Format.php new file mode 100644 index 0000000..65540ff --- /dev/null +++ b/app/Format.php @@ -0,0 +1,31 @@ +belongsToMany('App\Sujet', 'sujets_formats', 'format_id', 'sujet_id'); + } + +} diff --git a/app/Http/Controllers/DossierController.php b/app/Http/Controllers/DossierController.php index 7a8d79d..d56121b 100644 --- a/app/Http/Controllers/DossierController.php +++ b/app/Http/Controllers/DossierController.php @@ -7,6 +7,8 @@ use App\Sujet; use App\Marque; use App\Media; use App\Typevue; +use App\Variante; +use App\Format; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -22,7 +24,7 @@ class DossierController extends Controller Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $dossiers = Dossier::whereNull('parent_id') ->get(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.index')->with([ 'dossiers'=> $dossiers, @@ -39,7 +41,7 @@ class DossierController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $marques = Marque::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.create')->with(['marques'=> $marques, 'sujets'=> $sujets]); } @@ -111,7 +113,7 @@ class DossierController extends Controller $dossierMarques = $dossier->marques; $marques = Marque::all(); $dossierSujets = $dossier->sujets; - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.edit')->with(['dossier'=> $dossier, 'dossierMarques' => $dossierMarques, 'marques' => $marques, 'sujets'=> $sujets]); } @@ -186,15 +188,30 @@ class DossierController extends Controller public function loadFolder(Request $request) { $response = array(); + $userId = Auth::user()->id; $sujetId = $request->input('sujetId'); $marques = Auth::user()->marques()->pluck("marque_id"); $response['data'] = Dossier::where('sujet_id', $sujetId) - ->whereNull('parent_id') - ->whereHas("marques", function($query) use ($marques){ - $query->whereIn("marque_id", $marques); - })->get(); - $response['count'] = Media::where('sujet_id', $sujetId)->whereNull('dossier_id')->count(); + ->whereNull('parent_id') + ->whereHas("marques", function($query) use ($marques){ + $query->whereIn("marque_id", $marques); + })->get(); + $response['count'] = Media::where('sujet_id', $sujetId) + ->whereNull('dossier_id') + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->count(); $response['typevues'] = Typevue::where('sujet_id', $sujetId)->get(); + $response['variantes'] = Variante::where('sujet_id', $sujetId)->get(); + + + $FormatsSujet = Format::whereHas('sujets', function ($query) use ($sujetId) { + $query->where('sujet_id',$sujetId); + })->get(); + $FormatsSystem = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', 1)->get(); + $response['formats'] = $FormatsSujet->merge($FormatsSystem); if(Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')] )){ $response['draggable'] = true; diff --git a/app/Http/Controllers/MediaController.php b/app/Http/Controllers/MediaController.php index af6f34e..b1402ca 100644 --- a/app/Http/Controllers/MediaController.php +++ b/app/Http/Controllers/MediaController.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use App\Sujet; +use App\Format; use App\Media; use App\Typemedia; use App\Langue; @@ -13,10 +14,14 @@ use App\Copyright; use App\Etiquette; use App\Site; use App\Marque; +use App\Tag; +use App\Article; +use App\Http\Traits\MediaTools; class MediaController extends Controller { + use MediaTools; /** * Display a listing of the resource. @@ -39,7 +44,7 @@ class MediaController extends Controller 'copyrights'=> $copyrights, 'etiquettes'=> $etiquettes, 'sites'=> $sites, - 'marques'=> $marques, + 'marques'=> $marques ]); } @@ -50,6 +55,7 @@ class MediaController extends Controller public function loadMedia(Request $request) { $response = array(); + $userId = Auth::user()->id; $dossier_id = $request->input('dossier_id'); $sujet_id = $request->input('sujet_id'); $offset = $request->input('offset'); @@ -58,9 +64,29 @@ class MediaController extends Controller $order = $request->input('order'); if($dossier_id == "0"){ - $response['data'] = Media::where('sujet_id', $sujet_id)->whereNull('dossier_id')->with('Etiquette')->offset($offset)->limit($limit)->orderBy($orderField, $order)->get(); + $response['data'] = Media::where('sujet_id', $sujet_id) + ->whereNull('dossier_id') + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->with('Etiquette') + ->offset($offset) + ->limit($limit) + ->orderBy($orderField, $order) + ->get(); }else{ - $response['data'] = Media::where('sujet_id', $sujet_id)->where('dossier_id', $dossier_id)->with('Etiquette')->offset($offset)->limit($limit)->orderBy($orderField, $order)->get(); + $response['data'] = Media::where('sujet_id', $sujet_id) + ->where('dossier_id', $dossier_id) + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->with('Etiquette') + ->offset($offset) + ->limit($limit) + ->orderBy($orderField, $order) + ->get(); } if(Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')] )){ $response['draggable'] = true; @@ -103,12 +129,18 @@ class MediaController extends Controller */ public function removeMedia(Request $request) { + $deletedMediasList = array(); Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); - $medias = $request->input('medias'); - Media::destroy($medias); + $deleteMedias = $request->input('medias'); - return json_encode(true); + $medias = Media::whereIn('id', $deleteMedias)->whereNull('arcadia_id')->get(); + foreach ($medias as $media) { + $deletedMediasList[] = $media->id; + $media->delete(); + } + + return json_encode($deletedMediasList); } /** @@ -117,14 +149,38 @@ class MediaController extends Controller */ public function getOneMedia(Request $request) { + $host = $request->getSchemeAndHttpHost(); $response = array(); $media_id = $request->input('media_id'); - $media = Media::where('id', $media_id)->with('sujet')->with('sites')->with('marques')->with('tags:libelle')->first(); + $media = Media::where('id', $media_id)->with('sujet')->with('sites')->with('marques')->with('articles')->with('tags:libelle')->first(); if($media){ + // stock le média $response['data'] = $media; + // stock les tags foreach ($media->tags as $tag) { $response['tags'][] = $tag->libelle; } + // stock les vignettes existantes + $files = Storage::files($media->folder."/"); + $filepath = preg_quote($media->folder.$media->uid, '/'); + $matchingFiles = preg_grep('/^'.$filepath.'/', $files); + foreach ($matchingFiles as $matchingFile) { + $im = new \imagick($matchingFile); + $imageprops = $im->getImageGeometry(); + $path_parts = pathinfo($matchingFile); + + $fileInfo = array(); + $fileInfo['url'] = $host."/".$matchingFile; + $fileInfo['resolution'] = $imageprops['width']."x".$imageprops['height']."px"; + $fileInfo['extension'] = $path_parts['extension']; + $fileInfo['libelle'] = $path_parts['filename']; + if(strpos($fileInfo['libelle'], '_')){ + $fileInfo['libelle'] = "Format ".substr($fileInfo['libelle'], strpos($fileInfo['libelle'], '_')+1); + }else{ + $fileInfo['libelle'] = "Format original"; + } + $response['vignettes'][] = $fileInfo; + } } return json_encode($response); @@ -138,8 +194,71 @@ class MediaController extends Controller { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]); $response = array(); + $mediaUpdate = (object) $request->input('media'); + + $media = Media::where('id', $mediaUpdate->id)->first(); + if($media){ + $media->libelle = $mediaUpdate->libelle; + $media->typevue_id = $mediaUpdate->typevue_id; + $media->variante_id = $mediaUpdate->variante_id; + $media->langue_id = $mediaUpdate->langue_id; + $media->commentaire = $mediaUpdate->commentaire; + $media->version = $mediaUpdate->version; + if( ($mediaUpdate->statut == config('services.statut.public') || $mediaUpdate->statut == config('services.statut.public_etendue')) && $media->statut == config('services.statut.brouillon')){ + $media->published_at = date("Y-m-d H:i:s"); + } + $media->statut = $mediaUpdate->statut; + $media->copyright_id = $mediaUpdate->copyright_id; + $media->etiquette_id = $mediaUpdate->etiquette_id; + $media->save(); + + // MAJ des tags + $media->tags()->detach(); + if(isset($mediaUpdate->tags)){ + foreach($mediaUpdate->tags as $tag){ + $oTag = Tag::where('libelle', $tag)->first(); + if(!$oTag){ + $oTag = new Tag(); + $oTag->libelle = $tag; + $oTag->save(); + } + $media->tags()->attach($oTag->id); + } + } + // ---- Les sites + $media->sites()->detach(); + $sSites = $mediaUpdate->sites; + if($sSites != ""){ + $sites = explode(",", $sSites); + foreach($sites as $siteId){ + $media->sites()->attach($siteId); + } + } + + // ---- Les marques + $media->marques()->detach(); + $sMarques = $mediaUpdate->marques; + if($sMarques != ""){ + $marques = explode(",", $sMarques); + foreach($marques as $marqueId){ + $media->marques()->attach($marqueId); + } + } + + // ---- Les articles + $media->articles()->detach(); + $sArticles = $mediaUpdate->articles; + if($sArticles){ + $articles = explode(",", $sArticles); + foreach($articles as $articleId){ + $media->articles()->attach($articleId); + } + } + } + + $response = true; return json_encode($response); } @@ -184,10 +303,117 @@ class MediaController extends Controller $media = Media::where('id', $media_id)->first(); if($media){ - Storage::put($media->source, base64_decode($image)); + $mediaPath = $media->folder.$media->uid.".".$media->extension; + Storage::put($mediaPath, base64_decode($image)); + + $im = new \imagick($mediaPath); + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + $resolutions = $im->getImageResolution(); + $im->destroy(); + $media->resolution = $resolutions['x']; + if($media->resolution != 0){ + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); + }else{ + $media->largeur_mm = ""; + $media->hauteur_mm = ""; + } + $media->taille = $this->formatBytes($this->get_file_size($mediaPath)); + $media->save(); + + // Regénération des miniatures de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); $response = $media; } return json_encode($response); } + + /** + * Applique un Id Arcadia à un média + * + */ + public function setIdArcdadia(Request $request) + { + Auth::user()->authorizeRoles([config('roles.const.ADMIN')]); + $response = false; + $media_id = $request->input('media_id'); + $arcadia_id = $request->input('arcadia_id'); + + $media = Media::where('id', $media_id)->first(); + if($media){ + $media->arcadia_id = $arcadia_id; + $media->save(); + $response = true; + } + + return json_encode($response); + } + + /** + * Renvoie un article par ID Arcadia + * + */ + public function getArticle(Request $request) + { + $response = array(); + $arcadia_id = $request->input('arcadia_id'); + + $article = Article::where('noArt', $arcadia_id)->first(); + if($article){ + $response['article'] = $article; + }else{ + $response = false; + } + return json_encode($response); + } + + /** + * Renvoie un article par ID Arcadia + * + */ + public function downloadMedia(Request $request) + { + if(!$user = Auth::user()) abort(404, 'Erreur lors du téléchargement'); + + // obtention du format + $formatId = $request->input('format'); + if($formatId != 0){ + $format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('id', $formatId)->first(); + if(!$format) abort(404, 'Erreur lors du téléchargement'); + }else{ + $format = ""; + } + + $mediasId = $request->input('medias'); + $medias = explode(",", $mediasId); + if(sizeof($medias) == 1){ + $media = Media::where('id', $mediasId)->first(); + if($media){ + $fp = $this->get_mediaPath($media, $format); + } + }else{ + // create zip archive + $zip_file = public_path() . '/uploads/DAM_'.uniqid().'_'.date("Ymd").'.zip'; + $zip = new \ZipArchive(); + $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); + + // add file to archive + foreach ($medias as $mediaId) { + $media = Media::where('id', $mediaId)->first(); + if($media){ + $fp = $this->get_mediaPath($media, $format); + $zip->addFile($fp, basename($fp)); + } + } + $zip->close(); + $fp = $zip_file; + } + return response()->download($fp)->deleteFileAfterSend(true); + } + } diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php index fc99ada..5389345 100644 --- a/app/Http/Controllers/UploadController.php +++ b/app/Http/Controllers/UploadController.php @@ -42,6 +42,7 @@ class UploadController extends Controller { } $extension = strtolower($files->getClientOriginalExtension()); + $originalName = str_replace( ".".$extension, "", $files->getClientOriginalName()); if (!in_array($extension, $acceptFileTypes)) return array("false"); if($is_chunked_upload){ @@ -95,9 +96,15 @@ class UploadController extends Controller { // on créé un média en bdd $media = new Media(); - $media->libelle = $filename; + $media->dossier_id = $dossier_id; + $media->sujet_id = $sujet_id; + $media->libelle = $originalName; $media->extension = $extension; - $media->source = $destinationPath.$filename; + $media->folder = $destinationPath; + if($user = Auth::user()){ + $media->created_by= $user->id; + } + $media->uid = $uid; $media->taille = $this->formatBytes($this->get_file_size($destinationPath.$filename)); switch ($extension) { @@ -107,26 +114,36 @@ class UploadController extends Controller { case 'jpg': case 'png': $media->typemedia_id = 1; - list($width, $height) = getimagesize($destinationPath.$filename); - $media->largeur = $width; - $media->hauteur = $height; - $media->resolution = $this->get_dpi($destinationPath.$filename); + $im = new \imagick($destinationPath.$filename); + + if($extension == "gif" ){ + $im->setIteratorIndex(0); + } + + $resolutions = $im->getImageResolution(); + $media->resolution = $resolutions['x']; + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + if($media->resolution != 0){ - $media->largeur_mm = ceil(($width * 2.54 / $media->resolution)*10); - $media->hauteur_mm = ceil(($height * 2.54 / $media->resolution)*10); - } - - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_thumb.'.$extension, 200); - if($width >= 1500){ - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_preview.'.$extension, 1500); + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); }else{ - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_preview.'.$extension, $width); + $media->largeur_mm = ""; + $media->hauteur_mm = ""; } + $media->save(); + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); break; // Illustration/Vectorielle (2) case 'svg': $media->typemedia_id = 2; + $media->save(); break; // Vidéo (3) case 'mp4': @@ -137,6 +154,7 @@ class UploadController extends Controller { $media->hauteur = $fileInfo['video']['resolution_y']; $media->duree = $fileInfo['playtime_string']; } + $media->save(); break; // Audio (4) case 'mp3': @@ -145,6 +163,7 @@ class UploadController extends Controller { if($fileInfo = $getID3->analyze($destinationPath.$filename)){ $media->duree= $fileInfo['playtime_string']; } + $media->save(); break; // Document (5) case 'ai': @@ -155,44 +174,37 @@ class UploadController extends Controller { default: $media->typemedia_id = 5; + if(in_array($extension, array("pdf", "ai", "psd")) ){ $im = new \imagick(); $im->readImage($destinationPath.$filename); - if($extension == "pdf" || $extension == "psd"){ + if($extension == "pdf" || $extension == "psd" || $extension == "ai"){ $im->setIteratorIndex(0); } - //$im->setImageFormat('jpg'); - //list($width,$height) = $im->getImageGeometry(); $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + $resolutions = $im->getImageResolution(); + $media->resolution = $resolutions['x']; - $width = $imageprops['width']; - $height = $imageprops['height']; - - // create preview - $fp = $destinationPath.$uid.'_preview.png'; - if($width >= 1500){ - //$newHeight = (1500 * $height) / $width; - //$im->resizeImage(1500,$newHeight, \imagick::FILTER_LANCZOS, 0.9, true); - $im->thumbnailImage(1500, 1500 , true); + if($media->resolution != 0){ + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); + }else{ + $media->largeur_mm = ""; + $media->hauteur_mm = ""; } - $im->writeImage($fp); - - // create thumb - //$newHeight = (200 * $height) / $width; - //$im->resizeImage(200, $newHeight, \imagick::FILTER_LANCZOS, 0.9, true); - $im->thumbnailImage(200, 200 , true); - $fp = $destinationPath.$uid.'_thumb.png'; - $im->writeImage($fp); + $media->save(); + $im->destroy(); + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); } break; } - - - $media->dossier_id = $dossier_id; - $media->sujet_id = $sujet_id; - $media->save(); } $filest = array(); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1d36444..b16dd15 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -21,7 +21,7 @@ class UserController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $users = User::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.index')->with(['users'=> $users, 'sujets'=> $sujets]); } @@ -35,7 +35,7 @@ class UserController extends Controller Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $roles = config('roles.label'); $marques = Marque::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.create')->with(['roles'=> $roles, 'marques'=> $marques, 'sujets'=> $sujets]); } @@ -87,6 +87,9 @@ class UserController extends Controller foreach($sujets as $sujetId){ $user->sujets()->attach($sujetId); } + }else{ + session()->flash('error', "Vous devez ajouter au moins un sujet."); + return redirect()->route('user.create'); } session()->flash('message', "L'utilisateur à été enregistré"); @@ -160,7 +163,7 @@ class UserController extends Controller $userMarques = $user->marques; $marques = Marque::all(); $userSujets = $user->sujets; - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.edit')->with(['user'=> $user, 'roles'=> $roles, 'userMarques' => $userMarques, 'marques' => $marques, 'userSujets' => $userSujets, 'sujets'=> $sujets]); } @@ -206,6 +209,9 @@ class UserController extends Controller foreach($sujets as $sujetId){ $user->sujets()->attach($sujetId); } + }else{ + session()->flash('error', "Vous devez ajouter au moins un sujet."); + return redirect()->route('user.edit', ['user' => $user]); } session()->flash('message', "L'utilisateur à été mis à jour"); diff --git a/app/Http/Traits/MediaTools.php b/app/Http/Traits/MediaTools.php index 232832e..5c4f08b 100644 --- a/app/Http/Traits/MediaTools.php +++ b/app/Http/Traits/MediaTools.php @@ -5,10 +5,85 @@ use Illuminate\Support\Facades\Storage; trait MediaTools { public function get_file_size($file_path) { - return $this->fix_integer_overflow(filesize($file_path)); } + public function create_thumb($media) { + $formats = $media->sujet->formats; + + $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; + $im = new \imagick($mediaPath); + $im->setImageBackgroundColor('#ffffff'); + $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); + $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); + $im->stripImage(); + if(in_array($media->extension, array("pdf", "ai", "psd")) ){ + $im->setIteratorIndex(0); + } + + foreach ($formats as $format) { + + $fp = public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + $targetWidth = $format->largeur; + if($format->hauteur == 0){ + $targetHeight = floor(($media->hauteur*$format->largeur)/$media->largeur); + }else{ + $targetHeight = $format->hauteur; + } + + $im->setImageFormat($format->extension); + if($media->largeur >= $targetWidth || $media->hauteur >= $targetHeight){ + $im->thumbnailImage($targetWidth, $targetHeight , true); + } + $im->writeImage($fp); + } + $im->destroy(); + } + + + public function create_sys_thumb($media) { + $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; + $im = new \imagick(); + $im->readImage($mediaPath); + + if(in_array($media->extension, array("pdf", "ai", "psd")) ){ + $extension = "png"; + $im->setIteratorIndex(0); + }else{ + $extension = $media->extension; + } + + // create preview + $fp = public_path()."/".$media->folder.$media->uid.'_preview.'.$extension; + if($media->extension == "gif" ){ + if($media->largeur >= 1500 || $media->hauteur >= 1500 || $media->largeur == ""){ + $im = $im->coalesceImages(); + foreach ($im as $frame) { + $frame->thumbnailImage(1500, 1500); + $frame->setImagePage(1500, 1500, 0, 0); + } + $im = $im->deconstructImages(); + } + $im->writeImages($fp, true); + }else{ + if($media->largeur >= 1500 || $media->hauteur >= 1500 || $media->largeur == ""){ + $im->thumbnailImage(1500, 1500 , true); + } + $im->writeImage($fp); + } + + + // create thumb + $im->setImageBackgroundColor('#ffffff'); + $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); + $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); + $im->stripImage(); + $fp = public_path()."/".$media->folder.$media->uid.'_thumb.'.$extension; + $im->thumbnailImage(200, 200 , true); + $im->writeImage($fp); + $im->destroy(); + } + public function get_mediaFolder() { $mediaPath = "medias/"; $directories = Storage::allDirectories($mediaPath ); @@ -74,149 +149,32 @@ trait MediaTools { } } - public function get_dpi($filename){ + // ---- Renvoi le chemin attendu d'un média selon le format demandé + public function get_mediaPath($media, $format = "") { - // open the file and read first 20 bytes. - $a = fopen($filename,'r'); - $string = fread($a,20); - fclose($a); + // format original + if($format == ""){ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } - // get the value of byte 14th up to 18th - $data = bin2hex(substr($string,14,4)); - $x = substr($data,0,4); - $y = substr($data,4,4); - //return array(hexdec($x),hexdec($y)); - return hexdec($x); + // format spécifique + if($format->system == 0){ + if(in_array($media->extension, array("gif", "jpeg", "jpg", "png", "pdf", "ai", "psd")) ){ + return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + }else{ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } + } + + // format système (thumb et preview) + if($format->system == 1){ + if(in_array($media->extension, array("gif", "jpeg", "jpg", "png")) ){ + return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + }elseif(in_array($media->extension, array("pdf", "ai", "psd"))){ + return public_path()."/".$media->folder.$media->uid.'.png'; + }else{ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } + } } - - - /** - * @param $src - a valid file location - * @param $dest - a valid file target - * @param $targetWidth - desired output width - * @param $targetHeight - desired output height or null - */ - function createThumbnail($src, $dest, $targetWidth, $targetHeight = null) { - - - - // Link image type to correct image loader and saver - // - makes it easier to add additional types later on - // - makes the function easier to read - $IMAGETYPE_JPEG = 2; - $IMAGETYPE_PNG = 3; - $IMAGETYPE_GIF = 1; - $IMAGE_HANDLERS = [ - 2 => [ - 'load' => 'imagecreatefromjpeg', - 'save' => 'imagejpeg', - 'quality' => 50 - ], - 3 => [ - 'load' => 'imagecreatefrompng', - 'save' => 'imagepng', - 'quality' => 5 - ], - 1 => [ - 'load' => 'imagecreatefromgif', - 'save' => 'imagegif', - 'quality' => 0 - ] - ]; - - // 1. Load the image from the given $src - // - see if the file actually exists - // - check if it's of a valid image type - // - load the image resource - - // get the type of the image - // we need the type to determine the correct loader - $type = exif_imagetype($src); - - // if no valid type or no handler found -> exit - if (!$type || !$IMAGE_HANDLERS[$type]) { - return null; - } - - // load the image with the correct loader - $image = call_user_func($IMAGE_HANDLERS[$type]['load'], $src); - - // no image found at supplied location -> exit - if (!$image) { - return null; - } - - - // 2. Create a thumbnail and resize the loaded $image - // - get the image dimensions - // - define the output size appropriately - // - create a thumbnail based on that size - // - set alpha transparency for GIFs and PNGs - // - draw the final thumbnail - - // get original image width and height - $width = imagesx($image); - $height = imagesy($image); - - // maintain aspect ratio when no height set - if ($targetHeight == null) { - - // get width to height ratio - $ratio = $width / $height; - - // if is portrait - // use ratio to scale height to fit in square - if ($width > $height) { - $targetHeight = floor($targetWidth / $ratio); - } - // if is landscape - // use ratio to scale width to fit in square - else { - $targetHeight = $targetWidth; - $targetWidth = floor($targetWidth * $ratio); - } - } - - // create duplicate image based on calculated target size - $thumbnail = imagecreatetruecolor($targetWidth, $targetHeight); - - // set transparency options for GIFs and PNGs - if ($type == $IMAGETYPE_GIF || $type == $IMAGETYPE_PNG) { - - // make image transparent - imagecolortransparent( - $thumbnail, - imagecolorallocate($thumbnail, 0, 0, 0) - ); - - // additional settings for PNGs - if ($type == $IMAGETYPE_PNG) { - imagealphablending($thumbnail, false); - imagesavealpha($thumbnail, true); - } - } - - // copy entire source image to duplicate image and resize - imagecopyresampled( - $thumbnail, - $image, - 0, 0, 0, 0, - $targetWidth, $targetHeight, - $width, $height - ); - - - // 3. Save the $thumbnail to disk - // - call the correct save method - // - set the correct quality level - - // save the duplicate version of the image to disk - return call_user_func( - $IMAGE_HANDLERS[$type]['save'], - $thumbnail, - $dest, - $IMAGE_HANDLERS[$type]['quality'] - ); - } - } diff --git a/app/Marque.php b/app/Marque.php index a49eaf7..e32f368 100644 --- a/app/Marque.php +++ b/app/Marque.php @@ -12,7 +12,7 @@ class Marque extends Model * * @var string */ - protected $primaryKey = 'COD_MARQUE'; + protected $primaryKey = 'codMarq'; /** * The users that belong to the marque. diff --git a/app/Media.php b/app/Media.php index 22c46d9..4da7058 100644 --- a/app/Media.php +++ b/app/Media.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Media extends Model { use SoftDeletes; + protected $with = "owner"; protected $table = "medias"; /** @@ -74,6 +75,14 @@ class Media extends Model return $this->belongsToMany('App\Tag', 'medias_tags', 'media_id', 'tag_id'); } + /** + * The articles that belong to the media. + */ + public function articles() + { + return $this->belongsToMany('App\Article', 'medias_articles', 'media_id', 'article_id'); + } + /** * The sites that belong to the media. */ @@ -89,4 +98,12 @@ class Media extends Model { return $this->belongsToMany('App\Marque', 'medias_marques', 'media_id', 'marque_id'); } + + /** + * Get the user that owns the media. + */ + public function owner() + { + return $this->belongsTo('App\User', 'created_by'); + } } diff --git a/app/Scopes/SystemScope.php b/app/Scopes/SystemScope.php new file mode 100644 index 0000000..967050d --- /dev/null +++ b/app/Scopes/SystemScope.php @@ -0,0 +1,21 @@ +where('system', 0); + } +} \ No newline at end of file diff --git a/app/Sujet.php b/app/Sujet.php index ee05d1a..6760dd2 100644 --- a/app/Sujet.php +++ b/app/Sujet.php @@ -6,14 +6,13 @@ use Illuminate\Database\Eloquent\Model; class Sujet extends Model { - - + /** * The primary key associated with the table. * * @var string */ - protected $primaryKey = 'CODE_SUJET'; + protected $primaryKey = 'codeSujet'; /** * The users that belong to the sujet. @@ -31,6 +30,22 @@ class Sujet extends Model return $this->hasMany('App\Dossier'); } + /** + * Get the variantes for the sujet. + */ + public function variantes() + { + return $this->hasMany('App\Variante'); + } + + /** + * Get the typeVue for the sujet. + */ + public function typeVues() + { + return $this->hasMany('App\Typevue'); + } + /** * Get the medias for the sujet. */ @@ -38,4 +53,12 @@ class Sujet extends Model { return $this->hasMany('App\Media'); } + + /** + * The formats that belong to the sujet. + */ + public function formats() + { + return $this->belongsToMany('App\Format', 'sujets_formats', 'sujet_id', 'format_id'); + } } diff --git a/app/Tag.php b/app/Tag.php index a985c4d..8bff813 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; class Tag extends Model { + public $timestamps = false; /** * The media that belong to the tags. */ @@ -14,4 +15,5 @@ class Tag extends Model { return $this->belongsToMany('App\Media', 'medias_tags', 'tag_id', 'media_id'); } + } diff --git a/app/Typemedia.php b/app/Typemedia.php index 7b8a584..3770a31 100644 --- a/app/Typemedia.php +++ b/app/Typemedia.php @@ -13,5 +13,13 @@ class Typemedia extends Model * * @var string */ - protected $primaryKey = 'CODE_TYPEMEDIA'; + protected $primaryKey = 'codeTypemedia'; + + /** + * Get the media for the Typemedia. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Typevue.php b/app/Typevue.php index 3d646dd..4178697 100644 --- a/app/Typevue.php +++ b/app/Typevue.php @@ -11,5 +11,29 @@ class Typevue extends Model * * @var string */ - protected $primaryKey = 'CODE_TYPEVUE'; + protected $primaryKey = 'codeTypevue'; + + /** + * Get the variantes for the Typevue. + */ + public function variantes() + { + return $this->hasMany('App\Variante'); + } + + /** + * Get the sujet that owns the Typevue. + */ + public function sujet() + { + return $this->belongsTo('App\Sujet', 'sujet_id'); + } + + /** + * Get the medias for the Typevue. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/User.php b/app/User.php index fa38dcd..09eb1b2 100644 --- a/app/User.php +++ b/app/User.php @@ -91,4 +91,12 @@ class User extends Authenticatable { return $this->belongsToMany('App\Sujet', 'sujets_users', 'user_id', 'sujet_id'); } + + /** + * Get the medias for the user. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Variante.php b/app/Variante.php new file mode 100644 index 0000000..bab2a4e --- /dev/null +++ b/app/Variante.php @@ -0,0 +1,32 @@ +belongsTo('App\Sujet', 'sujet_id'); + } + + /** + * Get the typeVue that owns the variante. + */ + public function typeVue() + { + return $this->belongsTo('App\Typevue', 'typevue_id'); + } +} diff --git a/config/filesystems.php b/config/filesystems.php index 910571a..607760d 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -55,6 +55,11 @@ return [ 'visibility' => 'public', ], + 'arcadia' => [ + 'driver' => 'local', + 'root' => storage_path('export_arcadia'), + ], + 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), diff --git a/config/services.php b/config/services.php index f026b2c..32d22af 100644 --- a/config/services.php +++ b/config/services.php @@ -44,4 +44,9 @@ return [ ], ], + 'statut' => [ + 'brouillon' => 0, + 'public' => 1, + 'public_etendue' => 2, + ], ]; diff --git a/public/css/app.css b/public/css/app.css index 69f09ab..597d958 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -123,7 +123,6 @@ body { color: #aaaaaa; background-size: 6.1px 5.3px; height: 100%; - overflow: hidden; } ol, @@ -13006,6 +13005,28 @@ readers do not read off random characters that represent icons */ right: -22px; } +#form_download { + padding: 30px; + min-width: 300px; +} + +#form_download h3 { + font-size: 14px; + margin-bottom: 12px; + font-weight: bold; + color: #ffffff; +} + +#form_download hr { + color: #24272e; + border-bottom: 1px solid #2c2f36; + margin-bottom: 20px; +} + +#form_download p { + margin-bottom: 40px; +} + /****************************************** TEMPLATE ******************************************/ @@ -13256,6 +13277,7 @@ p { } input[type=text], +input[type=number], input[type=password], input[type=email], input[type=url], @@ -13266,6 +13288,7 @@ select { } input[type=text].is-invalid, +input[type=number].is-invalid, input[type=password].is-invalid, input[type=email].is-invalid, input[type=url].is-invalid, @@ -13693,6 +13716,7 @@ table tfoot tr:hover { .media_manager .main_content header .action_wrapper .order select { padding: 5px 0px; + color: #3b3b3b; } .media_manager .main_content .scrollLoader { @@ -14105,7 +14129,7 @@ table tfoot tr:hover { height: 100%; background-color: #333333; position: absolute; - z-index: 999999999999; + z-index: 99990; left: 0; top: 0; } @@ -14134,6 +14158,7 @@ table tfoot tr:hover { font-size: 18px; position: relative; padding: 12px; + border: none; } #form_media header .form_media_close:after { @@ -14163,6 +14188,19 @@ table tfoot tr:hover { z-index: 1; } +#form_media header .form_media_download { + float: right; + font-size: 18px; + position: relative; + padding: 12px; + border: none; +} + +#form_media header .form_media_download:hover { + background-color: transparent; + color: #ffffff; +} + #form_media .main_content { height: calc(100% - 43px); } @@ -14216,6 +14254,10 @@ table tfoot tr:hover { background-color: #272626; } +#form_media .main_content .tab.tab_edit .button_bar a { + display: inline-block; +} + #form_media .main_content .tab.tab_edit .cloud_tag_plugin { position: relative; } @@ -14294,6 +14336,10 @@ table tfoot tr:hover { width: 100%; } +#form_media .main_content .tab .wrapper .article_selector .remove_article { + color: #aaaaaa; +} + /****************************************** PAGE LOGIN ******************************************/ diff --git a/public/js/app.js b/public/js/app.js index 37b4347..db2afe6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -10825,7 +10825,7 @@ window.initSelector = function ($selector) { }); $($selector + " .selector_dataValues").val(datavalue.join()); // Recherche d'un élément - $($selector + " .selector_filter").on('keyup', function (event) { + $($selector + " .selector_filter").off().on('keyup', function (event) { var options = $(this).parent($selector).find(".selector_choices li"); var search = $(this).val(); $(options).each(function () { @@ -10837,7 +10837,7 @@ window.initSelector = function ($selector) { }); }); // Ajout d'un élément - $($selector + " .selector_choices").on("click", "li", function () { + $($selector + " .selector_choices").off().on("click", "li", function () { if (!$(this).hasClass('selected')) { var id = $(this).attr("data-value"); var text = $(this).html(); @@ -10848,7 +10848,7 @@ window.initSelector = function ($selector) { } }); // Suppression d'un élément - $($selector + " .selector_values").on("click", "li", function () { + $($selector + " .selector_values").off().on("click", "li", function () { var id = $(this).attr("data-value"); var text = $(this).html(); $(this).parent().parent().find('.selector_choices li[data-value="' + id + '"]').removeClass('selected'); @@ -11462,6 +11462,12 @@ $(document).ready(function () { $(this).attr("aria-grabbed", "true"); event.originalEvent.dataTransfer.setData('Text', $(this).attr("data-id")); } + }); // ---- Restreint le Drag aux images + + $("html").on("dragstart", function (event) { + if (!$(event.target).hasClass('imageItem')) { + return false; + } }); // ---- déselectionne les éléments si on clique en dehors $(".main_content .media_container").on("click", function (event) { @@ -11488,7 +11494,20 @@ $(document).ready(function () { if ($target.hasClass('editItem')) { // Editer un média $(this).dblclick(); - } else if ($target.hasClass('downloadItem')) {// Télécharger le média + } else if ($target.hasClass('downloadItem')) { + // Télécharger le média + var medias = []; + medias.push($(this).attr("data-id")); + $("#form_download").fancybox({ + type: 'inline', + opts: { + animationDuration: 350, + animationEffect: 'material' + }, + beforeShow: function beforeShow() { + $("#form_download .medias").val(medias.join()); + } + }).trigger("click"); } else if ($target.hasClass('addBasket')) {// ajouter le média au panier } else if ($target.hasClass('deleteItem')) { // supprimer le média @@ -11628,69 +11647,92 @@ $(document).ready(function () { $("#form_media .form_media_retouch").show(); // on active l'onglet retouche $("#form_media .form_media_preview").show(); // on active l'onglet aperçu - // charge l'image de preview - $(".tab_preview").html('
'); - $("#openseadragon").css('width', '100%'); - $("#openseadragon").css('height', minHeight); - viewer = OpenSeadragon({ - id: "openseadragon", - tileSources: { - type: "image", - url: imgPreview - } - }); // charge l'image pour la retouche + if ($(this).attr('data-ext') == 'gif') { + // charge le gif + $(".tab_preview").html('
+