namespace App\Http\Controllers;
+use App\Models\Asset;
+use App\Models\AssetTheme;
use App\Models\Publication;
use App\Models\Resource;
use Cubist\Backpack\Magic\PageData;
protected function _getMediaLibraryFromCMS()
{
- return [];
+ return ['themes' => PageData::fromEntities(AssetTheme::all()), 'assets' => PageData::fromEntities(Asset::whereNotNull('theme')->get())];
}
protected function _getResourcesFromCMS()
{
- $res = Resource::find('1')->getPageData();
- return $res;
+ return Resource::find('1')->getPageData();
}
}
'column' => true,
]);
$this->addField('file_upload', Files::class, 'Fichier', ['maxFiles' => 100]);
- $this->addField('theme', SelectFromModel::class, 'Thème', ['optionsmodel' => AssetTheme::class, 'allows_null' => true, 'column' => true]);
+ $this->addField('file_thumb', Files::class, 'Miniature', ['when' => ['type' => ['audio', 'video']], 'hint' => 'Image utilisée sur la page "Médiathèque"']);
+ $this->addField('theme', SelectFromModel::class, 'Thème', ['when' => ['type' => ['audio', 'video']], 'optionsmodel' => AssetTheme::class, 'allows_null' => true, 'column' => true, 'hint' => 'Choisir un thème pour ajouter à la page "Médiathèque"']);
$this->addField('keywords', Tags::class, 'Mots-clé', ['column' => true]);
}
py-2.5 px-5 rounded-full border
peer-checked:bg-white peer-checked:text-black
transition">
- {{ $theme }}
+ {{ $theme['name'] }}
</span>
</label>
@endforeach
@foreach ($media as $item)
@php
+ $theme=$themes[$item['theme']];
$player_data = [
'ID' => $item['id'],
'player' => [
'sources' => [
[
'src' => $item['file'],
- 'type' => $item['mime_type'],
]
]
],
{{-- Width is 25% minus the gutters (2 * 0.625rem that comes from mx-2.5) --}}
float-left w-[calc(100%/2-1.25rem)] md:w-[calc(100%/3-1.25rem)] lg:w-[calc(100%/4-1.25rem)] mx-2.5 mb-16
media-{{ $item['type'] }}
- theme-{{ $item['theme']['id'] }}"
+ theme-{{ $item['theme'] }}"
>
<div class="media-item-image relative bg-cover bg-no-repeat rounded-md pb-[56.25%]" style="background-image:url({{ $item['image'] }})">
</x-duration>
</div>
{{-- THEME LABEL --}}
- <div class="mt-2.5 font-secondary font-medium text-xs leading-none" style="color:{{ $item['theme']['color'] }}">
- {{ $item['theme']['title'] }}
+ <div class="mt-2.5 font-secondary font-medium text-xs leading-none" style="color:{{ $theme['color'] }}">
+ {{ $theme['name'] }}
</div>
{{-- Set min height of 2 lines so intial float layout is less likely to have misplaced blocks --}}
<div class="mt-1.5 font-semibold leading-snug min-h-[2.75em]">
@section('content')
@php
+
+
// TEMPORARY DATA MOCKUP
$media = [
[
'audio' => 'Podcast',
];
- $themes = [
- '1' => "Gouvernance",
- '5' => "Responsabilité sociétale et environnementale",
- '2' => "Communication",
- '6' => "Recherche et innovation",
- '3' => "Organisation",
- '7' => "Qualité de service à l'usager",
- '4' => "Système d'information",
- '8' => "Conditions techniques",
- ];
+ $theme_order=[1,5,2,6,3,7,4,8,9,10,11,12,13,14,15,16];
+
+ $themes=[];
+ foreach ($theme_order as $id){
+ if(isset($medialibrary['themes'][$id])){
+ $themes[$id]=$medialibrary['themes'][$id];
+ }
+ }
+
+ $media=[];
+
+
+ foreach ($medialibrary['assets'] as $a) {
+ $media[$a['id']]=[
+ 'id'=>$a->get('id'),
+ 'type'=>$a->get('type'),
+ 'theme'=>$a->get('theme'),
+ 'title'=>$a->get('title'),
+ 'file'=>$a->getImageURLbyCollection($a->get('file_upload')),
+ 'image'=>$a->getImageURLbyCollection($a->get('file_thumb')),
+ 'duration'=>45,
+ ];
+ }
@endphp
<div class="overflow-hidden py-2">{{-- vertical padding so accents don't get cropped --}}