From: Vincent Vanwaelscappel Date: Thu, 13 Jan 2022 20:21:48 +0000 (+0100) Subject: wip #5022 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9fe93972c9e46461852e21e6e1a6ef7dbe1de435;p=odl.git wip #5022 @0.5 --- diff --git a/app/Http/Controllers/FrontController.php b/app/Http/Controllers/FrontController.php index 84ded06..58033d1 100644 --- a/app/Http/Controllers/FrontController.php +++ b/app/Http/Controllers/FrontController.php @@ -66,24 +66,29 @@ class FrontController extends Controller { $res = []; + foreach (Menu::all() as $item) { + $res[] = array_merge(['title' => $item->title], self::getLinkData($item->link)); + } + return $res; + } + + public static function getLinkData($link) + { $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_')) { - $assetId = substr($item->link, 6); - /** @var Asset $asset */ - $asset = Asset::find($assetId); - $link['type'] = $asset->type; - $link['url'] = $asset->getFirstMediaUrl($asset->file_upload); - } else { - $link['type'] = 'page'; - $link['url'] = $map[$item->link] ?? $item->link; - } - $res[] = $link; + $res = []; + if (str_starts_with($link, 'asset_')) { + $assetId = substr($link, 6); + /** @var Asset $asset */ + $asset = Asset::find($assetId); + $res['type'] = $asset->type; + $res['url'] = $asset->getFirstMediaUrl($asset->file_upload); + } else { + $res['type'] = 'page'; + $res['url'] = isset($map[$link]) ? '/front' . $map[$link] : $link; } return $res; } diff --git a/resources/views/components/link.blade.php b/resources/views/components/link.blade.php index ce1b5b0..dc8ed75 100644 --- a/resources/views/components/link.blade.php +++ b/resources/views/components/link.blade.php @@ -3,11 +3,14 @@ use Illuminate\Support\Str; if (!Str::startsWith($href, 'http') && !Str::startsWith($href, '/tools/')) { - $map=['home'=>'accueil.html','resources'=>'/ressources.html','medialibrary'=>'/mediatheque.html']; - if(isset($map[$href])){ - $href=$map[$href]; + $linkData=\App\Http\Controllers\FrontController::getLinkData($href); + + $href=$linkData['url']; + if($linkData['type']==='pdf'){ + $attributes["@click.prevent"]='openPDF($el.attributes.href.value)'; + }else if($linkData['type']=='video'){ + $attributes['@click.prevent']='openPDF($el.attributes.href.value)'; } - $href = '/front' . $href; // Prefix URLs for frontend preview } @endphp diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index f444795..745fac6 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -109,7 +109,7 @@ {{-- MENU OVERLAY --}} -