namespace App\Fields;
+use App\Models\Asset;
use Cubist\Backpack\Magic\Fields\SelectFromArray;
class Link extends SelectFromArray
{
public function getOptions()
{
- return ['home' => 'Home',
+ $res = ['home' => 'Home',
'resources' => 'Ressources',
'medialibrary' => 'Mediathèque',
- 'tour' => 'Visite guidée',
'fluidbook' => 'Fluidbook',
- 'animation' => 'Animation d\'ouverture',
- 'search' => 'Moteur de recherche',
- 'menu' => 'Menu'];
+// 'animation' => 'Animation d\'ouverture',
+// 'search' => 'Moteur de recherche',
+// 'menu' => 'Menu'
+ ];
+
+ foreach (Asset::whereIn('type', ['audio', 'video', 'pdf'])->get() as $asset) {
+ $res['asset_' . $asset->id] = ucfirst($asset->type) . ' ' . $asset->id . ' - ' . $asset->title;
+ }
+
+ return $res;
}
}
use App\Models\Asset;
use App\Models\AssetTheme;
+use App\Models\Menu;
use App\Models\Publication;
use App\Models\Resource;
use Cubist\Backpack\Magic\PageData;
protected function _getDataFromCMS()
{
- return ['resources' => $this->_getResourcesFromCMS(), 'home' => $this->_getHomeFromCMS(), 'medialibrary' => $this->_getMediaLibraryFromCMS(), 'resources_pdf' => $this->_getResourcesPDFFromCMS()];
+ return ['menu' => $this->_getMenuFromCMS(), 'resources' => $this->_getResourcesFromCMS(), 'home' => $this->_getHomeFromCMS(), 'medialibrary' => $this->_getMediaLibraryFromCMS(), 'resources_pdf' => $this->_getResourcesPDFFromCMS()];
+ }
+
+ protected function _getMenuFromCMS()
+ {
+ $res = [];
+
+ $map = ['home' => '/accueil.html',
+ 'resources' => '/ressources.html',
+ 'medialibrary' => '/mediatheque.html',
+ 'fluidbook' => '/coeur/index.html'];
+
+ foreach (Menu::all() as $item) {
+ $link = ['title' => $item->title];
+ if (str_starts_with($item->link, 'asset_')) {
+ $link['type'] = $item->type;
+ $assetId = substr($item->link, 6);
+ /** @var Asset $asset */
+ $asset = Asset::find($assetId);
+ $link['url'] = $asset->getFirstMediaUrl($asset->file_upload);
+ } else {
+ $link['type'] = 'page';
+ $link['url'] = $map[$item->link] ?? $item->link;
+ }
+ $res[] = $link;
+ }
+ return $res;
}
protected function _getHomeFromCMS()
{
- $p=Publication::find('1');
- $res= $p->getPageData();
- if(null===$res->get('raccourcis')){
- $res->set('raccourcis',$p->getAttribute('raccourcis'));
+ $p = Publication::find('1');
+ $res = $p->getPageData();
+ if (null === $res->get('raccourcis')) {
+ $res->set('raccourcis', $p->getAttribute('raccourcis'));
}
return $res;
}
protected function _getMediaLibraryFromCMS()
{
- return ['themes' => PageData::fromEntities(AssetTheme::all()), 'assets' => PageData::fromEntities(Asset::whereNotNull('theme')->orderBy('code','ASC')->get())];
+ return ['themes' => PageData::fromEntities(AssetTheme::all()), 'assets' => PageData::fromEntities(Asset::whereNotNull('theme')->orderBy('code', 'ASC')->get())];
}
protected function _getResourcesPDFFromCMS()
<body x-data="app()"
@resize.window.debounce="measureWidth()"
class="font-primary p-8 @stack('extra_body_classes')">
-@endsection
-
-@section('main')
- {{--
- Content has constrained width so that nothing shifts when overlay is opened and scrolling is disabled.
- The body width changes when scrollbars are removed, which causes alignment problems, especially with
- fixed-position elements.
- --}}
- <div style="width: var(--content-width)">
- <x-header main="true" />
-
- <div class="min-h-content flex flex-col mx-22 pt-22 opacity-0" :class="{ 'opacity-0': maskContents }">
- @yield('content')
+ @endsection
+
+ @section('main')
+ {{--
+ Content has constrained width so that nothing shifts when overlay is opened and scrolling is disabled.
+ The body width changes when scrollbars are removed, which causes alignment problems, especially with
+ fixed-position elements.
+ --}}
+ <div style="width: var(--content-width)">
+ <x-header main="true"/>
+
+ <div class="min-h-content flex flex-col mx-22 pt-22 opacity-0" :class="{ 'opacity-0': maskContents }">
+ @yield('content')
+ </div>
</div>
- </div>
- {{-- MENU OVERLAY --}}
- <div class="overlay menu-overlay
+ {{-- MENU OVERLAY --}}
+ <div class="overlay menu-overlay
bg-blue text-white
z-30"
- x-show="menuOpen"
- x-transition.opacity.duration.500ms
- x-transition:leave.opacity.duration.500ms.delay.500ms
- x-cloak>
-
- <x-header logo-class="text-white" />
-
- <ul class="w-full font-medium text-6xl">
- @php
- $menu_links = [
- '/accueil.html' => 'Accueil',
- '/coeur/index.html' => 'Synthèse de l\'offre',
- '/ressources.html' => 'Offre',
- '/mediatheque.html' => 'Médiathèque',
- '/glossaire.html' => 'Glossaire',
- '/aide.html' => 'Aide',
- ];
- @endphp
-
- @foreach ($menu_links as $link => $text)
- {{-- Overflow is hidden for text entrance animation. --}}
- {{-- Extra padding and negative margin added so hover scale effect isn't clipped --}}
- <li class="overflow-hidden pl-4 -ml-4">
- <div x-show="menuOpen"
- class="transition transform ease-out-quint"
- style="transition-delay: {{ 250 + (50 * $loop->index) }}ms"
- x-transition:enter="duration-1000"
- x-transition:enter-start="translate-y-[100px]"
- x-transition:enter-end="translate-x-0"
- x-transition:leave="duration-500"
- x-transition:leave-start="translate-x-0"
- x-transition:leave-end="translate-y-[100px]">
- <x-link
- href="{{ $link }}"
- @click.prevent="menuOpen = false; setTimeout(() => window.location = $event.target.href, 200);"
- class="block py-8 text-current
+ x-show="menuOpen"
+ x-transition.opacity.duration.500ms
+ x-transition:leave.opacity.duration.500ms.delay.500ms
+ x-cloak>
+
+ <x-header logo-class="text-white"/>
+
+ <ul class="w-full font-medium text-6xl">
+ @foreach ($menu as $link)
+ {{-- Overflow is hidden for text entrance animation. --}}
+ {{-- Extra padding and negative margin added so hover scale effect isn't clipped --}}
+ <li class="overflow-hidden pl-4 -ml-4">
+ <div x-show="menuOpen"
+ class="transition transform ease-out-quint"
+ style="transition-delay: {{ 250 + (50 * $loop->index) }}ms"
+ x-transition:enter="duration-1000"
+ x-transition:enter-start="translate-y-[100px]"
+ x-transition:enter-end="translate-x-0"
+ x-transition:leave="duration-500"
+ x-transition:leave-start="translate-x-0"
+ x-transition:leave-end="translate-y-[100px]">
+ <x-link
+ href="{{ $link['url'] }}"
+ data-type="{{$link['type']}}"
+ @click.prevent="menuOpen = false; setTimeout(() => window.location = $event.target.href, 200);"
+ class="block py-8 text-current
transform origin-bottom-left
transition-transform duration-200
hover:scale-105">
- {{ $text }}
- </x-link>
- </div>
- </li>
- <li class="bg-blue-dark h-px
+ {{ $link['title'] }}
+ </x-link>
+ </div>
+ </li>
+ <li class="bg-blue-dark h-px
transform origin-left
transition ease-out-quint"
- x-show="menuOpen"
- style="transition-delay: {{ 250 + (50 * $loop->index) }}ms"
- x-transition:enter="duration-2000"
- x-transition:enter-start="scale-x-0"
- x-transition:enter-end="scale-x-100"
- x-transition:leave="duration-500"
- x-transition:leave-start="scale-x-100"
- x-transition:leave-end="scale-x-0">
- </li>
- @endforeach
- </ul>
- </div>
+ x-show="menuOpen"
+ style="transition-delay: {{ 250 + (50 * $loop->index) }}ms"
+ x-transition:enter="duration-2000"
+ x-transition:enter-start="scale-x-0"
+ x-transition:enter-end="scale-x-100"
+ x-transition:leave="duration-500"
+ x-transition:leave-start="scale-x-100"
+ x-transition:leave-end="scale-x-0">
+ </li>
+ @endforeach
+ </ul>
+ </div>
- {{-- Search Overlay --}}
- <x-search />
+ {{-- Search Overlay --}}
+ <x-search/>
@endsection