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

- add podcast:id tag - add podcast:funding tag - add podcast:social tag - add podcast:previousUrl tag - add missing platforms with icons - update platforms table to include social and funding platforms - rename platform_links table to podcasts_platforms - move podcast import methods from podcast controller - update import functionality to insert platforms from rss closes #73, #75, #76, #80
111 lines
2.9 KiB
PHP
111 lines
2.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\Admin;
|
|
|
|
use App\Models\PlatformModel;
|
|
use App\Models\PodcastModel;
|
|
use Config\Services;
|
|
|
|
class PodcastPlatform extends BaseController
|
|
{
|
|
/**
|
|
* @var \App\Entities\Podcast|null
|
|
*/
|
|
protected $podcast;
|
|
|
|
public function _remap($method, ...$params)
|
|
{
|
|
if (
|
|
!($this->podcast = (new PodcastModel())->getPodcastById($params[0]))
|
|
) {
|
|
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
|
}
|
|
unset($params[0]);
|
|
|
|
return $this->$method(...$params);
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return view('admin/podcast/platforms/dashboard');
|
|
}
|
|
|
|
public function platforms($platformType)
|
|
{
|
|
helper('form');
|
|
|
|
$data = [
|
|
'podcast' => $this->podcast,
|
|
'platformType' => $platformType,
|
|
'platforms' => (new PlatformModel())->getPlatformsWithLinks(
|
|
$this->podcast->id,
|
|
$platformType
|
|
),
|
|
];
|
|
|
|
replace_breadcrumb_params([0 => $this->podcast->title]);
|
|
return view('admin/podcast/platforms', $data);
|
|
}
|
|
|
|
public function attemptPlatformsUpdate($platformType)
|
|
{
|
|
$platformModel = new PlatformModel();
|
|
$validation = Services::validation();
|
|
|
|
$podcastsPlatformsData = [];
|
|
|
|
foreach (
|
|
$this->request->getPost('platforms')
|
|
as $platformSlug => $podcastPlatform
|
|
) {
|
|
$podcastPlatformUrl = $podcastPlatform['url'];
|
|
|
|
if (
|
|
!empty($podcastPlatformUrl) &&
|
|
$validation->check($podcastPlatformUrl, 'validate_url')
|
|
) {
|
|
array_push($podcastsPlatformsData, [
|
|
'platform_slug' => $platformSlug,
|
|
'podcast_id' => $this->podcast->id,
|
|
'link_url' => $podcastPlatformUrl,
|
|
'link_content' => $podcastPlatform['content'],
|
|
'is_visible' => array_key_exists(
|
|
'visible',
|
|
$podcastPlatform
|
|
)
|
|
? $podcastPlatform['visible'] == 'yes'
|
|
: false,
|
|
]);
|
|
}
|
|
}
|
|
|
|
$platformModel->savePodcastPlatforms(
|
|
$this->podcast->id,
|
|
$platformType,
|
|
$podcastsPlatformsData
|
|
);
|
|
|
|
return redirect()
|
|
->back()
|
|
->with('message', lang('Platforms.messages.updateSuccess'));
|
|
}
|
|
|
|
public function removePodcastPlatform($platformSlug)
|
|
{
|
|
(new PlatformModel())->removePodcastPlatform(
|
|
$this->podcast->id,
|
|
$platformSlug
|
|
);
|
|
|
|
return redirect()
|
|
->back()
|
|
->with('message', lang('Platforms.messages.removeLinkSuccess'));
|
|
}
|
|
}
|