mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 04:44:48 -04:00
Move delete form and more multi select fixes
This commit is contained in:
parent
93b8008c7e
commit
8e8cbb0c5e
10 changed files with 136 additions and 24 deletions
69
www/ebook-placeholders/delete.php
Normal file
69
www/ebook-placeholders/delete.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?
|
||||
use function Safe\session_unset;
|
||||
|
||||
session_start();
|
||||
|
||||
/** @var string $identifier Passed from script this is included from. */
|
||||
$ebook = HttpInput::SessionObject('ebook', Ebook::class);
|
||||
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
|
||||
|
||||
try{
|
||||
if($ebook === null){
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
}
|
||||
|
||||
if(!$ebook->IsPlaceholder() || $ebook->EbookPlaceholder === null){
|
||||
throw new Exceptions\EbookNotFoundException();
|
||||
}
|
||||
|
||||
if(Session::$User === null){
|
||||
throw new Exceptions\LoginRequiredException();
|
||||
}
|
||||
|
||||
if(!Session::$User->Benefits->CanEditEbookPlaceholders){
|
||||
throw new Exceptions\InvalidPermissionsException();
|
||||
}
|
||||
|
||||
if($exception){
|
||||
http_response_code(Enums\HttpCode::UnprocessableContent->value);
|
||||
session_unset();
|
||||
}
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||
}
|
||||
catch(Exceptions\LoginRequiredException){
|
||||
Template::RedirectToLogin();
|
||||
}
|
||||
catch(Exceptions\InvalidPermissionsException){
|
||||
Template::ExitWithCode(Enums\HttpCode::Forbidden);
|
||||
}
|
||||
?>
|
||||
<?= Template::Header(
|
||||
[
|
||||
'title' => 'Delete ' . $ebook->Title,
|
||||
'css' => ['/css/ebook-placeholder.css'],
|
||||
'highlight' => '',
|
||||
'description' => 'Delete ' . $ebook->Title
|
||||
]
|
||||
) ?>
|
||||
<main>
|
||||
<section class="narrow">
|
||||
<nav class="breadcrumbs">
|
||||
<a href="<?= $ebook->AuthorsUrl ?>"><?= $ebook->AuthorsString ?></a> →
|
||||
<a href="<?= $ebook->Url ?>"><?= Formatter::EscapeHtml($ebook->Title) ?></a> →
|
||||
</nav>
|
||||
<h1>Delete</h1>
|
||||
|
||||
<?= Template::Error(['exception' => $exception]) ?>
|
||||
|
||||
<form method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $ebook->Url ?>">
|
||||
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Delete->value ?>" />
|
||||
<p>Are you sure you want to permanently delete <i><?= Formatter::EscapeHtml($ebook->Title) ?></i>?</p>
|
||||
<div class="footer">
|
||||
<button class="delete">Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
<?= Template::Footer() ?>
|
|
@ -41,15 +41,19 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
?>
|
||||
<?= Template::Header(
|
||||
[
|
||||
'title' => 'Edit Ebook Placeholder for ' . $ebook->Title,
|
||||
'title' => 'Edit ' . $ebook->Title,
|
||||
'css' => ['/css/ebook-placeholder.css'],
|
||||
'highlight' => '',
|
||||
'description' => 'Edit the ebook placeholder for ' . $ebook->Title
|
||||
'description' => 'Edit ' . $ebook->Title
|
||||
]
|
||||
) ?>
|
||||
<main>
|
||||
<section class="narrow">
|
||||
<h1>Edit Ebook Placeholder</h1>
|
||||
<nav class="breadcrumbs">
|
||||
<a href="<?= $ebook->AuthorsUrl ?>"><?= $ebook->AuthorsString ?></a> →
|
||||
<a href="<?= $ebook->Url ?>"><?= Formatter::EscapeHtml($ebook->Title) ?></a> →
|
||||
</nav>
|
||||
<h1>Edit</h1>
|
||||
|
||||
<?= Template::Error(['exception' => $exception]) ?>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue