diff --git a/_api_app/app/Sites/Sections/Entries/Galleries/GalleryGridRenderService.php b/_api_app/app/Sites/Sections/Entries/Galleries/GalleryGridRenderService.php new file mode 100644 index 000000000..eb77782d5 --- /dev/null +++ b/_api_app/app/Sites/Sections/Entries/Galleries/GalleryGridRenderService.php @@ -0,0 +1,93 @@ +getGalleryItemsData($entry); + $galleryItems = $this->generateGalleryItems($galleryItemsData, $entry, $storageService, $siteSettings); + $galleryType = isset($entry['mediaCacheData']['@attributes']['type']) ? $entry['mediaCacheData']['@attributes']['type'] : $siteTemplateSettings['entryLayout']['defaultGalleryType']; + + $data = parent::getViewData( + $entry, + $siteSettings, + $siteTemplateSettings, + $storageService, + $isEditMode, + $isLoopAvailable, + $asRowGallery, + $galleryItemsData, + $galleryItems, + $galleryType + ); + + $data['galleryClassList'] = $this->getGalleryClassList($galleryItemsData, $galleryType, $entry, $siteSettings); + $data['items'] = $galleryItems; + $data['gridColumnsMobile'] = $this->getGridColumns($entry, 'grid_columns_mobile', '1'); + $data['gridColumnsDesktop'] = $this->getGridColumns($entry, 'grid_columns_desktop', '2'); + $data['gridColumnsLargeDesktop'] = $this->getGridColumns($entry, 'grid_columns_large_desktop', '3'); + $data['gridGap'] = ! empty($entry['mediaCacheData']['@attributes']['grid_gap']) ? $entry['mediaCacheData']['@attributes']['grid_gap'] : false; + + return $data; + } + + public function getGalleryClassList($galleryItemsData, $galleryType, $entry, $siteSettings) + { + $classes = parent::getGalleryClassList($galleryItemsData, $galleryType, $entry, $siteSettings); + + $classes[] = 'xGridShowCaptions-' . $this->getGridShowCaptions($entry); + + return implode(' ', $classes); + } + + private function getGridColumns($entry, $attribute, $default) + { + return ! empty($entry['mediaCacheData']['@attributes'][$attribute]) ? $entry['mediaCacheData']['@attributes'][$attribute] : $default; + } + + private function getGridShowCaptions($entry) + { + return ! empty($entry['mediaCacheData']['@attributes']['grid_show_captions']) ? $entry['mediaCacheData']['@attributes']['grid_show_captions'] : 'yes'; + } + + public function render( + $entry, + $siteSettings, + $siteTemplateSettings, + $storageService, + $isEditMode, + $isLoopAvailable, + $asRowGallery + ) { + if ($isEditMode && empty($entry['mediaCacheData']['file'])) { + return view('Sites/Sections/Entries/Galleries/editEmptyGallery'); + } + + $data = $this->getViewData( + $entry, + $siteSettings, + $siteTemplateSettings, + $storageService, + $isEditMode, + $isLoopAvailable, + $asRowGallery, + null, + null, + null + ); + + return view('Sites/Sections/Entries/Galleries/galleryGrid', $data); + } +} diff --git a/_api_app/app/Sites/Sections/Entries/Galleries/galleryGrid.twig b/_api_app/app/Sites/Sections/Entries/Galleries/galleryGrid.twig new file mode 100644 index 000000000..fbf68deda --- /dev/null +++ b/_api_app/app/Sites/Sections/Entries/Galleries/galleryGrid.twig @@ -0,0 +1,41 @@ +