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
112 lines
2.5 KiB
PHP
112 lines
2.5 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\PageModel;
|
|
|
|
class Page extends BaseController
|
|
{
|
|
/**
|
|
* @var \App\Entities\Page|null
|
|
*/
|
|
protected $page;
|
|
|
|
public function _remap($method, ...$params)
|
|
{
|
|
if (count($params) > 0) {
|
|
if (!($this->page = (new PageModel())->find($params[0]))) {
|
|
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
|
}
|
|
}
|
|
|
|
return $this->$method();
|
|
}
|
|
|
|
function list()
|
|
{
|
|
$data = [
|
|
'pages' => (new PageModel())->findAll(),
|
|
];
|
|
|
|
return view('admin/page/list', $data);
|
|
}
|
|
|
|
function view()
|
|
{
|
|
return view('admin/page/view', ['page' => $this->page]);
|
|
}
|
|
|
|
function create()
|
|
{
|
|
helper('form');
|
|
|
|
return view('admin/page/create');
|
|
}
|
|
|
|
function attemptCreate()
|
|
{
|
|
$page = new \App\Entities\Page([
|
|
'title' => $this->request->getPost('title'),
|
|
'slug' => $this->request->getPost('slug'),
|
|
'content' => $this->request->getPost('content'),
|
|
]);
|
|
|
|
$pageModel = new PageModel();
|
|
|
|
if (!$pageModel->insert($page)) {
|
|
return redirect()
|
|
->back()
|
|
->withInput()
|
|
->with('errors', $pageModel->errors());
|
|
}
|
|
|
|
return redirect()
|
|
->route('page-list')
|
|
->with(
|
|
'message',
|
|
lang('Page.messages.createSuccess', [
|
|
'pageTitle' => $page->title,
|
|
])
|
|
);
|
|
}
|
|
|
|
function edit()
|
|
{
|
|
helper('form');
|
|
|
|
replace_breadcrumb_params([0 => $this->page->title]);
|
|
return view('admin/page/edit', ['page' => $this->page]);
|
|
}
|
|
|
|
function attemptEdit()
|
|
{
|
|
$this->page->title = $this->request->getPost('title');
|
|
$this->page->slug = $this->request->getPost('slug');
|
|
$this->page->content = $this->request->getPost('content');
|
|
|
|
$pageModel = new PageModel();
|
|
|
|
if (!$pageModel->update($this->page->id, $this->page)) {
|
|
return redirect()
|
|
->back()
|
|
->withInput()
|
|
->with('errors', $pageModel->errors());
|
|
}
|
|
|
|
return redirect()->route('page-list');
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
(new PageModel())->delete($this->page->id);
|
|
|
|
return redirect()->route('page-list');
|
|
}
|
|
}
|