mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 21:04:49 -04:00
Completely type hint template functions and switch to named arguments
This commit is contained in:
parent
6108b5e53d
commit
124e8343fc
125 changed files with 542 additions and 450 deletions
|
@ -40,12 +40,9 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
}
|
||||
?>
|
||||
<?= Template::Header(
|
||||
[
|
||||
'title' => 'Delete ' . $ebook->Title,
|
||||
'css' => ['/css/ebook-placeholder.css'],
|
||||
'highlight' => '',
|
||||
'description' => 'Delete ' . $ebook->Title
|
||||
]
|
||||
title: 'Delete ' . $ebook->Title,
|
||||
css: ['/css/ebook-placeholder.css'],
|
||||
description: 'Delete ' . $ebook->Title
|
||||
) ?>
|
||||
<main>
|
||||
<section class="narrow">
|
||||
|
@ -55,7 +52,7 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
</nav>
|
||||
<h1>Delete</h1>
|
||||
|
||||
<?= Template::Error(['exception' => $exception]) ?>
|
||||
<?= Template::Error(exception: $exception) ?>
|
||||
|
||||
<form method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $ebook->Url ?>">
|
||||
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Delete->value ?>" />
|
||||
|
|
|
@ -40,12 +40,9 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
}
|
||||
?>
|
||||
<?= Template::Header(
|
||||
[
|
||||
'title' => 'Edit ' . $ebook->Title,
|
||||
'css' => ['/css/ebook-placeholder.css'],
|
||||
'highlight' => '',
|
||||
'description' => 'Edit ' . $ebook->Title
|
||||
]
|
||||
title: 'Edit ' . $ebook->Title,
|
||||
css: ['/css/ebook-placeholder.css'],
|
||||
description: 'Edit ' . $ebook->Title
|
||||
) ?>
|
||||
<main>
|
||||
<section class="narrow">
|
||||
|
@ -55,11 +52,11 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
</nav>
|
||||
<h1>Edit</h1>
|
||||
|
||||
<?= Template::Error(['exception' => $exception]) ?>
|
||||
<?= Template::Error(exception: $exception) ?>
|
||||
|
||||
<form class="create-update-ebook-placeholder" method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $ebook->Url ?>" autocomplete="off">
|
||||
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Put->value ?>" />
|
||||
<?= Template::EbookPlaceholderForm(['ebook' => $ebook, 'isEditForm' => true]) ?>
|
||||
<?= Template::EbookPlaceholderForm(ebook: $ebook, isEditForm: true) ?>
|
||||
<div class="footer">
|
||||
<button>Save</button>
|
||||
</div>
|
||||
|
|
|
@ -24,12 +24,11 @@ catch(Exceptions\EbookNotFoundException){
|
|||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||
}
|
||||
?><?= Template::Header(
|
||||
[
|
||||
'title' => strip_tags($ebook->TitleWithCreditsHtml),
|
||||
'css' => ['/css/ebook-placeholder.css'],
|
||||
'highlight' => 'ebooks',
|
||||
'canonicalUrl' => SITE_URL . $ebook->Url
|
||||
])
|
||||
title: strip_tags($ebook->TitleWithCreditsHtml),
|
||||
css: ['/css/ebook-placeholder.css'],
|
||||
highlight: 'ebooks',
|
||||
canonicalUrl: SITE_URL . $ebook->Url
|
||||
)
|
||||
?>
|
||||
<main>
|
||||
<article class="ebook ebook-placeholder" typeof="schema:Book" about="<?= $ebook->Url ?>">
|
||||
|
@ -77,7 +76,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||
<p>
|
||||
<?= Template::CollectionDescriptor(['collectionMembership' => $collectionMembership]) ?>.
|
||||
<?= Template::CollectionDescriptor(collectionMembership: $collectionMembership) ?>.
|
||||
</p>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
|
@ -111,7 +110,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
</section>
|
||||
|
||||
<? if(Session::$User?->Benefits->CanEditEbooks || Session::$User?->Benefits->CanEditEbookPlaceholders){ ?>
|
||||
<?= Template::EbookMetadata(['ebook' => $ebook, 'showPlaceholderMetadata' => Session::$User->Benefits->CanEditEbookPlaceholders]) ?>
|
||||
<?= Template::EbookMetadata(ebook: $ebook, showPlaceholderMetadata: Session::$User->Benefits->CanEditEbookPlaceholders) ?>
|
||||
<? } ?>
|
||||
|
||||
<? if(Session::$User?->Benefits->CanEditProjects || Session::$User?->Benefits->CanManageProjects || Session::$User?->Benefits->CanReviewProjects){ ?>
|
||||
|
@ -123,7 +122,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<a href="<?= $ebook->ProjectInProgress->EditUrl ?>">Edit project</a>
|
||||
</p>
|
||||
<? } ?>
|
||||
<?= Template::ProjectDetailsTable(['project' => $ebook->ProjectInProgress, 'showTitle' => false]) ?>
|
||||
<?= Template::ProjectDetailsTable(project: $ebook->ProjectInProgress, showTitle: false) ?>
|
||||
</section>
|
||||
<? } ?>
|
||||
|
||||
|
@ -137,7 +136,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? if(sizeof($ebook->PastProjects) == 0){ ?>
|
||||
<p class="empty-notice">None.</p>
|
||||
<? }else{ ?>
|
||||
<?= Template::ProjectsTable(['projects' => $ebook->PastProjects, 'includeTitle' => false, 'showEditButton' => Session::$User->Benefits->CanEditProjects]) ?>
|
||||
<?= Template::ProjectsTable(projects: $ebook->PastProjects, includeTitle: false, showEditButton: Session::$User->Benefits->CanEditProjects) ?>
|
||||
<? } ?>
|
||||
</section>
|
||||
<? } ?>
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
<?
|
||||
use function Safe\session_unset;
|
||||
|
||||
session_start();
|
||||
|
||||
$isCreated = HttpInput::Bool(SESSION, 'is-ebook-placeholder-created') ?? false;
|
||||
$isOnlyProjectCreated = HttpInput::Bool(SESSION, 'is-only-ebook-project-created') ?? false;
|
||||
$isDeleted = HttpInput::Bool(SESSION, 'is-ebook-placeholder-deleted') ?? false;
|
||||
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
|
||||
$ebook = HttpInput::SessionObject('ebook', Ebook::class);
|
||||
$project = HttpInput::SessionObject('project', Project::class);
|
||||
$deletedEbookTitle = '';
|
||||
|
||||
try{
|
||||
if(Session::$User === null){
|
||||
|
@ -20,6 +11,16 @@ try{
|
|||
throw new Exceptions\InvalidPermissionsException();
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
$isCreated = HttpInput::Bool(SESSION, 'is-ebook-placeholder-created') ?? false;
|
||||
$isOnlyProjectCreated = HttpInput::Bool(SESSION, 'is-only-ebook-project-created') ?? false;
|
||||
$isDeleted = HttpInput::Bool(SESSION, 'is-ebook-placeholder-deleted') ?? false;
|
||||
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
|
||||
$ebook = HttpInput::SessionObject('ebook', Ebook::class);
|
||||
$project = HttpInput::SessionObject('project', Project::class);
|
||||
$deletedEbookTitle = '';
|
||||
|
||||
if($isCreated || $isOnlyProjectCreated){
|
||||
// We got here because an `Ebook` was successfully created.
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
|
@ -70,18 +71,15 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
}
|
||||
?>
|
||||
<?= Template::Header(
|
||||
[
|
||||
'title' => 'Create an Ebook Placeholder',
|
||||
'css' => ['/css/ebook-placeholder.css', '/css/project.css'],
|
||||
'highlight' => '',
|
||||
'description' => 'Create a placeholder for an ebook not yet in the collection.'
|
||||
]
|
||||
title: 'Create an Ebook Placeholder',
|
||||
css: ['/css/ebook-placeholder.css', '/css/project.css'],
|
||||
description: 'Create a placeholder for an ebook not yet in the collection.'
|
||||
) ?>
|
||||
<main>
|
||||
<section class="narrow">
|
||||
<h1>Create an Ebook Placeholder</h1>
|
||||
|
||||
<?= Template::Error(['exception' => $exception]) ?>
|
||||
<?= Template::Error(exception: $exception) ?>
|
||||
|
||||
<? if(isset($createdEbook)){ ?>
|
||||
<? if($isOnlyProjectCreated){ ?>
|
||||
|
@ -94,7 +92,7 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
<? } ?>
|
||||
|
||||
<form class="create-update-ebook-placeholder" method="<?= Enums\HttpMethod::Post->value ?>" action="/ebook-placeholders" autocomplete="off">
|
||||
<?= Template::EbookPlaceholderForm(['ebook' => $ebook]) ?>
|
||||
<?= Template::EbookPlaceholderForm(ebook: $ebook ?? new Ebook()) ?>
|
||||
<div class="footer">
|
||||
<button>Submit</button>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue