Completely type hint template functions and switch to named arguments

This commit is contained in:
Alex Cabal 2025-03-04 16:08:55 -06:00
parent 6108b5e53d
commit 124e8343fc
125 changed files with 542 additions and 450 deletions

View file

@ -27,7 +27,7 @@ catch(Safe\Exceptions\ApcuException){
$title = preg_replace('/s$/', '', ucfirst($class));
?><?= Template::Header(['title' => 'Downloads by ' . $title, 'highlight' => '', 'description' => 'Download zip files containing all of the Standard Ebooks in a given collection.']) ?>
?><?= Template::Header(title: 'Downloads by ' . $title, description: 'Download zip files containing all of the Standard Ebooks in a given collection.') ?>
<main>
<section class="bulk-downloads">
<h1>Down­loads by <?= $title ?></h1>
@ -80,7 +80,10 @@ $title = preg_replace('/s$/', '', ucfirst($class));
</tbody>
</table>
<? }else{ ?>
<?= Template::BulkDownloadTable(['label' => $title, 'collections' => $collection]); ?>
<?
/** @var array<stdClass> $collection */
?>
<?= Template::BulkDownloadTable(label: $title, collections: $collection); ?>
<? } ?>
</section>
</main>

View file

@ -54,7 +54,7 @@ catch(Exceptions\InvalidFileException){
Template::ExitWithCode(Enums\HttpCode::NotFound);
}
?><?= Template::Header(['title' => 'Downloading Ebook Collections', 'highlight' => '', 'description' => 'Download zip files containing all of the Standard Ebooks released in a given month.']) ?>
?><?= Template::Header(title: 'Downloading Ebook Collections', description: 'Download zip files containing all of the Standard Ebooks released in a given month.') ?>
<main>
<section class="narrow">
<h1>Downloading Ebook Collections</h1>

View file

@ -1,13 +1,12 @@
<?
use function Safe\apcu_fetch;
$collection = null;
$collectionUrlName = HttpInput::Str(GET, 'collection');
$collection = null;
$authorUrlName = HttpInput::Str(GET, 'author');
$canDownload = false;
try{
$collection = null;
$collectionUrlName = HttpInput::Str(GET, 'collection');
$authorUrlName = HttpInput::Str(GET, 'author');
$canDownload = false;
if(Session::$User?->Benefits->CanBulkDownload){
$canDownload = true;
}
@ -33,10 +32,6 @@ try{
break;
}
}
if($collection === null){
throw new Exceptions\CollectionNotFoundException();
}
}
if($authorUrlName !== null){
@ -65,6 +60,10 @@ try{
throw new Exceptions\AuthorNotFoundException();
}
}
if($collection === null){
throw new Exceptions\CollectionNotFoundException();
}
}
catch(Exceptions\AuthorNotFoundException){
Template::ExitWithCode(Enums\HttpCode::NotFound);
@ -73,17 +72,17 @@ catch(Exceptions\CollectionNotFoundException){
Template::ExitWithCode(Enums\HttpCode::NotFound);
}
?><?= Template::Header(['title' => 'Download ', 'highlight' => '', 'description' => 'Download zip files containing all of the Standard Ebooks released in a given month.']) ?>
?><?= Template::Header(title: 'Download ', description: 'Download zip files containing all of the Standard Ebooks released in a given month.') ?>
<main>
<section class="bulk-downloads">
<h1>Download the <?= $collection?->Label ?> Collection</h1>
<h1>Download the <?= $collection->Label ?> Collection</h1>
<? if($canDownload){ ?>
<p>Select the ebook format in which youd like to download this collection.</p>
<p>You can also read about <a href="/help/how-to-use-our-ebooks#which-file-to-download">which ebook format to download</a>.</p>
<? }else{ ?>
<p><a href="/about#patrons-circle">Patrons circle members</a> can download zip files containing all of the ebooks in a collection. You can <a href="/donate#patrons-circle">join the Patrons Circle</a> with a small donation in support of our continuing mission to create free, beautiful digital literature.</p>
<? } ?>
<?= Template::BulkDownloadTable(['label' => 'Collection', 'collections' => [$collection]]); ?>
<?= Template::BulkDownloadTable(label: 'Collection', collections: [$collection]); ?>
</section>
</main>
<?= Template::Footer() ?>

View file

@ -4,7 +4,7 @@ if(Session::$User?->Benefits->CanBulkDownload){
$canDownload = true;
}
?><?= Template::Header(['title' => 'Bulk Ebook Downloads', 'highlight' => '', 'description' => 'Download zip files containing all of the Standard Ebooks released in a given month.']) ?>
?><?= Template::Header(title: 'Bulk Ebook Downloads', description: 'Download zip files containing all of the Standard Ebooks released in a given month.') ?>
<main>
<section class="narrow has-hero">
<h1>Bulk Ebook Down­loads</h1>