mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- add podcast sidebar navigation - add podcast dashboard with latest episodes - add pagination to podcast episodes - add components helper to reuse ui components (button, data_table, etc.) - enhance podcast and episode forms by splitting them into form sections - add hint tooltips to podcast and episode forms - transform radio inputs as buttons for better ux - replace explicit field by parental_advisory - replace author field by publisher - add podcasts_categories table to set multiple categories - use choices.js to enhance multiselect fields - update Language files - update js dependencies to latest versions closes #31, #9
74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\EpisodeModel;
|
|
use App\Models\PodcastModel;
|
|
|
|
class Episode extends BaseController
|
|
{
|
|
/**
|
|
* @var \App\Entities\Podcast
|
|
*/
|
|
protected $podcast;
|
|
|
|
/**
|
|
* @var \App\Entities\Episode|null
|
|
*/
|
|
protected $episode;
|
|
|
|
public function _remap($method, ...$params)
|
|
{
|
|
$this->podcast = (new PodcastModel())->getPodcastByName($params[0]);
|
|
|
|
if (
|
|
count($params) > 1 &&
|
|
!($this->episode = (new EpisodeModel())->getEpisodeBySlug(
|
|
$this->podcast->id,
|
|
$params[1]
|
|
))
|
|
) {
|
|
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
|
}
|
|
|
|
return $this->$method();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
self::triggerWebpageHit($this->episode->podcast_id);
|
|
|
|
if (
|
|
!($cachedView = cache(
|
|
"page_podcast{$this->episode->podcast_id}_episode{$this->episode->id}"
|
|
))
|
|
) {
|
|
$previousNextEpisodes = (new EpisodeModel())->getPreviousNextEpisodes(
|
|
$this->episode,
|
|
$this->podcast->type
|
|
);
|
|
|
|
$data = [
|
|
'previousEpisode' => $previousNextEpisodes['previous'],
|
|
'nextEpisode' => $previousNextEpisodes['next'],
|
|
'podcast' => $this->podcast,
|
|
'episode' => $this->episode,
|
|
];
|
|
|
|
// The page cache is set to a decade so it is deleted manually upon podcast update
|
|
return view('episode', $data, [
|
|
'cache' => DECADE,
|
|
'cache_name' => "page_podcast{$this->episode->podcast_id}_episode{$this->episode->id}",
|
|
]);
|
|
}
|
|
|
|
return $cachedView;
|
|
}
|
|
}
|