2025-01-31 18:20:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-01-27 20:39:15 +03:00
|
|
|
namespace openvk\Web\Models\Entities;
|
2025-01-31 18:20:13 +03:00
|
|
|
|
2021-01-27 20:39:15 +03:00
|
|
|
use openvk\Web\Models\Repositories\Videos;
|
|
|
|
|
|
|
|
class VideoAlbum extends MediaCollection
|
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
public const SPECIAL_ADDED = 16;
|
|
|
|
public const SPECIAL_UPLOADED = 32;
|
|
|
|
|
2021-01-27 20:39:15 +03:00
|
|
|
protected $tableName = "video_playlists";
|
|
|
|
protected $relTableName = "vp_relations";
|
|
|
|
protected $entityTableName = "videos";
|
|
|
|
protected $entityClassName = 'openvk\Web\Models\Entities\Video';
|
2025-01-31 18:20:13 +03:00
|
|
|
|
2021-01-27 20:39:15 +03:00
|
|
|
protected $specialNames = [
|
|
|
|
16 => "_added_album",
|
|
|
|
32 => "_uploaded_album",
|
|
|
|
];
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
public function getCoverURL(): ?string
|
2021-01-27 20:39:15 +03:00
|
|
|
{
|
|
|
|
$cover = $this->getCoverVideo();
|
2025-01-31 18:20:13 +03:00
|
|
|
if (!$cover) {
|
2021-01-27 20:39:15 +03:00
|
|
|
return "/assets/packages/static/openvk/img/camera_200.png";
|
2025-01-31 18:20:13 +03:00
|
|
|
}
|
|
|
|
|
2021-01-27 20:39:15 +03:00
|
|
|
return $cover->getThumbnailURL();
|
|
|
|
}
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
public function getCoverVideo(): ?Photo
|
2021-01-27 20:39:15 +03:00
|
|
|
{
|
|
|
|
$cover = $this->getRecord()->cover_video;
|
2025-01-31 18:20:13 +03:00
|
|
|
if (!$cover) {
|
2021-01-27 20:39:15 +03:00
|
|
|
$vids = iterator_to_array($this->fetch(1, 1));
|
2025-01-31 18:20:13 +03:00
|
|
|
$vid = $vids[0] ?? null;
|
|
|
|
if (!$vid || $vid->isDeleted()) {
|
|
|
|
return null;
|
|
|
|
} else {
|
2021-01-27 20:39:15 +03:00
|
|
|
return $vid;
|
2025-01-31 18:20:13 +03:00
|
|
|
}
|
2021-01-27 20:39:15 +03:00
|
|
|
}
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
return (new Videos())->get($cover);
|
2021-01-27 20:39:15 +03:00
|
|
|
}
|
|
|
|
}
|