@php $lang = $lang ?? session('locale', 'ms'); $galleries = \App\Models\Backend\ContentPhotoGallery::with(['translations', 'photoLists']) ->where('gallery_status', 'ACTIVE') ->where('gallery_portal', 'redd-plus') ->where('gallery_cat', '!=', 'NEWS') ->orderBy('gallery_sort') ->orderBy('gallery_date', 'desc') ->get(); // Pilih terjemahan album ikut bahasa semasa, fallback ke main / pertama $gTrans = function ($g) use ($lang) { return $g->translations->firstWhere('gallery_translation_language', $lang) ?? $g->translations->firstWhere('gallery_translation_main', 1) ?? $g->translations->first(); }; // Senarai gambar setiap album (baris utama) + deskripsi ikut bahasa $galleryPhotos = $galleries->mapWithKeys(function ($g) use ($lang) { $all = $g->photoLists; $mains = $all->where('photo_main', 1)->sortBy('photo_sort'); return ['g' . $g->gallery_id => $mains->map(function ($p) use ($all, $lang) { $tr = $all->first(fn ($x) => (int) $x->photo_parent_id === (int) $p->photo_id && $x->photo_language === $lang); return [ 'url' => image_url($p->photo_url), 'descr' => plain_text($tr->photo_descr ?? $p->photo_descr), ]; })->values()]; }); // Deskripsi penuh setiap album (plain text) untuk modal "Read more" $galleryDescr = $galleries->mapWithKeys(fn ($g) => [ 'g' . $g->gallery_id => plain_text($gTrans($g)?->gallery_translation_descr, false), ]); $videos = \App\Models\Backend\ContentVideo::with('translations')->where('video_page', 'redd-plus')->where('video_status', 'ACTIVE')->orderBy('video_sorting')->get(); $videoData = $videos->mapWithKeys(function ($v) use ($lang) { $vt = $v->translations->firstWhere('video_translation_language', $lang) ?? $v->translations->firstWhere('video_translation_main', 1) ?? $v->translations->first(); $ytId = null; if ($v->video_url && preg_match('/[?&]v=([A-Za-z0-9_-]+)/', $v->video_url, $m)) { $ytId = $m[1]; } elseif ($v->video_url && preg_match('#youtu\.be/([A-Za-z0-9_-]+)#', $v->video_url, $m)) { $ytId = $m[1]; } if ($ytId) { $type = 'youtube'; $src = 'https://www.youtube.com/embed/' . $ytId; } elseif ($v->video_upload) { $type = 'upload'; $src = \Illuminate\Support\Facades\Storage::url($v->video_upload); } elseif ($v->video_external) { $type = 'external'; $src = $v->video_external; } else { $type = 'none'; $src = ''; } $thumb = $v->video_img ? \Illuminate\Support\Facades\Storage::url($v->video_img) : ($ytId ? 'https://img.youtube.com/vi/' . $ytId . '/hqdefault.jpg' : ''); return ['v' . $v->video_id => [ 'type' => $type, 'src' => $src, 'title' => $vt?->video_translation_title ?? 'Untitled', 'descr' => (string) ($vt?->video_translation_content ?? ''), 'descr_text' => trim(preg_replace('/[\s\x{00A0}]+/u', ' ', html_entity_decode(strip_tags((string) ($vt?->video_translation_content ?? '')), ENT_QUOTES, 'UTF-8'))), 'thumb' => $thumb, ]]; }); @endphp
Photos and videos showcasing REDD Plus Malaysia activities and initiatives.
{{ $gDescr }}
@endif @if($gDescr !== '' || $photos->count())There are no images yet.
Video gallery is being prepared. Stay tuned for updates on REDD Plus Malaysia activities.