| 1 |
<?php |
| 2 |
|
| 3 |
namespace Photonic_Plugin\Lightboxes; |
| 4 |
|
| 5 |
use Photonic_Plugin\Components\Photo; |
| 6 |
use Photonic_Plugin\Platforms\Base; |
| 7 |
use Photonic_Plugin\Lightboxes\Features\Show_Videos_Inline; |
| 8 |
|
| 9 |
require_once 'Lightbox.php'; |
| 10 |
require_once 'Features/Show_Videos_Inline.php'; |
| 11 |
|
| 12 |
class VenoBox 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 |
|
| 18 |
protected function __construct() { |
| 19 |
$this->library = 'venobox'; |
| 20 |
parent::__construct(); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* @param $rel_id |
| 25 |
* @param Base $module |
| 26 |
* @return array |
| 27 |
*/ |
| 28 |
public function get_gallery_attributes($rel_id, Base $module): array { |
| 29 |
return [ |
| 30 |
'class' => $this->class, |
| 31 |
'rel' => ['lightbox-photonic-' . $module->provider . '-stream-' . (empty($rel_id) ? $module->gallery_index : $rel_id)], |
| 32 |
'specific' => [ |
| 33 |
'data-gall' => 'photonic-' . $module->provider . '-stream-' . (empty($rel_id) ? $module->gallery_index : $rel_id) |
| 34 |
], |
| 35 |
]; |
| 36 |
} |
| 37 |
|
| 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-vbtype'] = 'inline'; |
| 43 |
$out['data-html5-href'] = $photo_data['video']; |
| 44 |
} |
| 45 |
} |
| 46 |
elseif (!empty($photo_data['video'])) { |
| 47 |
$out['data-vbtype'] = 'video'; |
| 48 |
} |
| 49 |
return $out; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* {@inheritDoc} |
| 54 |
*/ |
| 55 |
public function get_video_markup(Photo $photo, Base $module, string $indent): string { |
| 56 |
if (in_array($module->provider, ['flickr', 'google'], true)) { |
| 57 |
return $this->get_inline_video_markup($photo, $module, $indent); |
| 58 |
} |
| 59 |
else { |
| 60 |
return parent::get_video_markup($photo, $module, $indent); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* {@inheritDoc} |
| 66 |
*/ |
| 67 |
public function get_grid_link(Photo $photo, array $short_code, Base $module): string { |
| 68 |
if (!empty($photo->video) && in_array($module->provider, ['flickr', 'google'], true)) { |
| 69 |
return $this->get_inline_video_grid_link($photo, $short_code, $module); |
| 70 |
} |
| 71 |
else { |
| 72 |
return parent::get_grid_link($photo, $short_code, $module); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
|