| @@ -1,12 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Photonic_Plugin\Lightboxes; |
| 3 | 4 | |
| 4 | -use Photonic_Plugin\Modules\Core; | |
| 5 | +use Photonic_Plugin\Components\Photo; | |
| 6 | +use Photonic_Plugin\Platforms\Base; | |
| 7 | +use Photonic_Plugin\Lightboxes\Features\Show_Videos_Inline; | |
| 5 | 8 | |
| 6 | -require_once('Lightbox.php'); | |
| 9 | +require_once 'Lightbox.php'; | |
| 10 | +require_once 'Features/Show_Videos_Inline.php'; | |
| 7 | 11 | |
| 8 | 12 | class Fancybox3 extends Lightbox { |
| 13 | + use Show_Videos_Inline { | |
| 14 | + get_video_markup as get_inline_video_markup; | |
| 15 | + get_grid_link as get_inline_video_grid_link; | |
| 16 | + } | |
| 17 | + | |
| 9 | 18 | protected function __construct() { |
| 10 | 19 | $this->library = 'fancybox3'; |
| 11 | 20 | parent::__construct(); |
| 12 | 21 | } |
| @@ -12,24 +21,51 @@ | ||
| 12 | 21 | } |
| 13 | 22 | |
| 14 | 23 | /** |
| 15 | 24 | * @param $rel_id |
| 16 | - * @param Core $module | |
| 25 | + * @param Base $module | |
| 17 | 26 | * @return array |
| 18 | 27 | */ |
| 19 | - function get_gallery_attributes($rel_id, $module) { | |
| 28 | + public function get_gallery_attributes($rel_id, Base $module): array { | |
| 20 | 29 | return [ |
| 21 | - 'class' => $this->class = ['photonic-launch-gallery', 'launch-gallery-fancybox', 'fancybox'], | |
| 22 | - 'rel' => ['lightbox-photonic-'.$module->provider.'-stream-'.(empty($rel_id) ? $module->gallery_index : $rel_id)], | |
| 30 | + 'class' => $this->class = ['photonic-lb', 'photonic-fancybox', 'fancybox'], | |
| 31 | + 'rel' => ['lightbox-photonic-' . $module->provider . '-stream-' . (empty($rel_id) ? $module->gallery_index : $rel_id)], | |
| 23 | 32 | 'specific' => [ |
| 24 | - 'data-fancybox' => ['lightbox-photonic-'.$module->provider.'-stream-'.(empty($rel_id) ? $module->gallery_index : $rel_id)] | |
| 33 | + 'data-fancybox' => 'lightbox-photonic-' . $module->provider . '-stream-' . (empty($rel_id) ? $module->gallery_index : $rel_id) | |
| 25 | 34 | ], |
| 26 | 35 | ]; |
| 27 | 36 | } |
| 28 | 37 | |
| 29 | - function get_photo_attributes($photo_data, $module) { | |
| 30 | - if (in_array($module->provider, ['google', 'flickr'])) { | |
| 31 | - return !empty($photo_data['video']) ? ' data-html5-href="'.$photo_data['video'].'" ': ''; | |
| 38 | + public function get_photo_attributes(array $photo_data, Base $module): array { | |
| 39 | + $out = parent::get_photo_attributes($photo_data, $module); | |
| 40 | + if (in_array($module->provider, ['google', 'flickr'], true)) { | |
| 41 | + if (!empty($photo_data['video'])) { | |
| 42 | + $out['data-html5-href'] = $photo_data['video']; | |
| 43 | + } | |
| 32 | 44 | } |
| 33 | - return ''; | |
| 45 | + return $out; | |
| 34 | 46 | } |
| 35 | -} | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * {@inheritDoc} | |
| 50 | + */ | |
| 51 | + public function get_video_markup(Photo $photo, Base $module, string $indent): string { | |
| 52 | + if (in_array($module->provider, ['flickr', 'google'], true)) { | |
| 53 | + return $this->get_inline_video_markup($photo, $module, $indent); | |
| 54 | + } | |
| 55 | + else { | |
| 56 | + return parent::get_video_markup($photo, $module, $indent); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * {@inheritDoc} | |
| 62 | + */ | |
| 63 | + public function get_grid_link(Photo $photo, array $short_code, Base $module): string { | |
| 64 | + if (!empty($photo->video) && in_array($module->provider, ['flickr', 'google'], true)) { | |
| 65 | + return $this->get_inline_video_grid_link($photo, $short_code, $module); | |
| 66 | + } | |
| 67 | + else { | |
| 68 | + return parent::get_grid_link($photo, $short_code, $module); | |
| 69 | + } | |
| 70 | + } | |
| 71 | +} | |