2020-05-31 19:15:52 +00:00
|
|
|
<?php
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-05-31 19:15:52 +00:00
|
|
|
|
|
|
|
namespace App\Entities;
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
use App\Models\EpisodeModel;
|
2020-05-31 19:15:52 +00:00
|
|
|
use CodeIgniter\Entity;
|
|
|
|
|
|
|
|
class Podcast extends Entity
|
|
|
|
{
|
2020-06-26 14:34:52 +00:00
|
|
|
protected $link;
|
2020-06-30 18:17:41 +02:00
|
|
|
protected \CodeIgniter\Files\File $image;
|
|
|
|
protected $image_media_path;
|
2020-06-26 14:34:52 +00:00
|
|
|
protected $image_url;
|
|
|
|
protected $episodes;
|
|
|
|
|
2020-05-31 19:15:52 +00:00
|
|
|
protected $casts = [
|
2020-06-12 19:31:10 +00:00
|
|
|
'id' => 'integer',
|
2020-05-31 19:15:52 +00:00
|
|
|
'title' => 'string',
|
|
|
|
'name' => 'string',
|
|
|
|
'description' => 'string',
|
2020-06-26 14:34:52 +00:00
|
|
|
'image_uri' => 'string',
|
2020-05-31 19:15:52 +00:00
|
|
|
'language' => 'string',
|
2020-06-12 19:31:10 +00:00
|
|
|
'category' => 'string',
|
2020-05-31 19:15:52 +00:00
|
|
|
'explicit' => 'boolean',
|
2020-06-26 14:34:52 +00:00
|
|
|
'author_name' => '?string',
|
|
|
|
'author_email' => '?string',
|
2020-05-31 19:15:52 +00:00
|
|
|
'owner_name' => '?string',
|
|
|
|
'owner_email' => '?string',
|
2020-06-26 14:34:52 +00:00
|
|
|
'type' => 'string',
|
2020-05-31 19:15:52 +00:00
|
|
|
'copyright' => '?string',
|
|
|
|
'block' => 'boolean',
|
|
|
|
'complete' => 'boolean',
|
2020-06-12 19:31:10 +00:00
|
|
|
'episode_description_footer' => '?string',
|
2020-05-31 19:15:52 +00:00
|
|
|
'custom_html_head' => '?string',
|
|
|
|
];
|
2020-06-26 14:34:52 +00:00
|
|
|
|
2020-06-30 18:17:41 +02:00
|
|
|
public function setImage(\CodeIgniter\HTTP\Files\UploadedFile $image = null)
|
|
|
|
{
|
|
|
|
if ($image) {
|
|
|
|
helper('media');
|
|
|
|
|
|
|
|
$this->attributes['image_uri'] = save_podcast_media(
|
|
|
|
$image,
|
|
|
|
$this->attributes['name'],
|
|
|
|
'cover'
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImage()
|
|
|
|
{
|
|
|
|
return new \CodeIgniter\Files\File($this->getImageMediaPath());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImageMediaPath()
|
|
|
|
{
|
|
|
|
return media_path($this->attributes['image_uri']);
|
|
|
|
}
|
|
|
|
|
2020-06-26 14:34:52 +00:00
|
|
|
public function getImageUrl()
|
|
|
|
{
|
|
|
|
return media_url($this->attributes['image_uri']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLink()
|
|
|
|
{
|
|
|
|
return base_url(route_to('podcast_view', $this->attributes['name']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFeedUrl()
|
|
|
|
{
|
|
|
|
return base_url(route_to('podcast_feed', $this->attributes['name']));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEpisodes()
|
|
|
|
{
|
|
|
|
$episode_model = new EpisodeModel();
|
|
|
|
|
|
|
|
return $episode_model
|
|
|
|
->where('podcast_id', $this->attributes['id'])
|
|
|
|
->findAll();
|
|
|
|
}
|
2020-05-31 19:15:52 +00:00
|
|
|
}
|