| 1 |
<?php |
| 2 |
|
| 3 |
namespace Photonic_Plugin\Components; |
| 4 |
|
| 5 |
use Photonic_Plugin\Core\Photonic; |
| 6 |
use Photonic_Plugin\Layouts\Core_Layout; |
| 7 |
use Photonic_Plugin\Platforms\Base; |
| 8 |
|
| 9 |
require_once 'Pagination.php'; |
| 10 |
|
| 11 |
class Album_List implements Printable { |
| 12 |
public array $albums = []; |
| 13 |
|
| 14 |
public string $title_position; |
| 15 |
public array $row_constraints = []; |
| 16 |
public string $indent = ''; |
| 17 |
public array $short_code = []; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var Pagination $pagination |
| 21 |
*/ |
| 22 |
public Pagination $pagination; |
| 23 |
|
| 24 |
public string $type = ''; |
| 25 |
public string $singular_type = ''; |
| 26 |
public $level_1_count_display; |
| 27 |
public bool $album_opens_gallery = false; |
| 28 |
|
| 29 |
public array $gallery_attributes = []; |
| 30 |
|
| 31 |
public function __construct(array $short_code) { |
| 32 |
$this->pagination = new Pagination(); |
| 33 |
$this->short_code = $short_code; |
| 34 |
|
| 35 |
$this->gallery_attributes['photo-count'] = empty($short_code['photo_count']) ? $short_code['count'] : $short_code['photo_count']; |
| 36 |
|
| 37 |
$data = [ |
| 38 |
'photo-more' => 'photo_more', |
| 39 |
'overlay-size' => 'overlay_size', |
| 40 |
'overlay-crop' => 'overlay_crop', |
| 41 |
'overlay-video-size' => 'overlay_video_size', |
| 42 |
'thumb-size' => 'thumb_size', |
| 43 |
]; |
| 44 |
|
| 45 |
foreach ($data as $attr => $value) { |
| 46 |
if (isset($short_code[$value])) { |
| 47 |
$this->gallery_attributes[$attr] = $short_code[$value]; |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
private function custom_sort(Base $module) { |
| 53 |
$this->albums = apply_filters('photonic_custom_sort_albums', $this->albums, $module->provider); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* {@inheritDoc} |
| 58 |
*/ |
| 59 |
public function html(Base $module, Core_Layout $layout, bool $print = false): string { |
| 60 |
$ret = ''; |
| 61 |
|
| 62 |
$this->custom_sort($module); |
| 63 |
|
| 64 |
if (is_a($layout, 'Photonic_Plugin\Layouts\Level_Two_Gallery')) { |
| 65 |
$ret = $layout->generate_level_2_gallery($this, $this->short_code, $module); |
| 66 |
} |
| 67 |
|
| 68 |
if ($print) { |
| 69 |
echo wp_kses($ret, Photonic::$safe_tags); |
| 70 |
} |
| 71 |
|
| 72 |
return wp_kses($ret, Photonic::$safe_tags); |
| 73 |
} |
| 74 |
} |
| 75 |
|