mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 04:44:48 -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
|
@ -61,7 +61,7 @@ try{
|
|||
catch(Exceptions\InvalidFileException | Exceptions\EbookNotFoundException){
|
||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||
}
|
||||
?><?= Template::Header(['title' => 'Your Download Has Started!', 'downloadUrl' => $downloadUrl]) ?>
|
||||
?><?= Template::Header(title: 'Your Download Has Started!', downloadUrl: $downloadUrl) ?>
|
||||
<main class="donate">
|
||||
<h1>Your Download Has Started!</h1>
|
||||
<div class="thank-you-container">
|
||||
|
|
|
@ -71,7 +71,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
|
||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||
}
|
||||
?><?= Template::Header(['title' => strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', 'ogType' => 'book', 'coverUrl' => $ebook->DistCoverUrl, 'highlight' => 'ebooks', 'description' => 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'canonicalUrl' => SITE_URL . $ebook->Url]) ?>
|
||||
?><?= Template::Header(title: strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', ogType: 'book', coverUrl: $ebook->DistCoverUrl, highlight: 'ebooks', description: 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, canonicalUrl: SITE_URL . $ebook->Url) ?>
|
||||
<main>
|
||||
<article class="ebook" typeof="schema:Book" about="<?= $ebook->Url ?>">
|
||||
<meta property="schema:description" content="<?= Formatter::EscapeHtml($ebook->Description) ?>"/>
|
||||
|
@ -126,7 +126,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||
<p>
|
||||
<?= Template::CollectionDescriptor(['collectionMembership' => $collectionMembership]) ?>.
|
||||
<?= Template::CollectionDescriptor(collectionMembership: $collectionMembership) ?>.
|
||||
</p>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
|
@ -188,7 +188,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<p class="us-pd-warning">This ebook is thought to be free of copyright restrictions in the United States. It may still be under copyright in other countries. If you’re not located in the United States, you must check your local laws to verify that this ebook is free of copyright restrictions in the country you’re located in before accessing, downloading, or using it.</p>
|
||||
|
||||
<div class="downloads-container">
|
||||
<?= Template::RealisticEbook(['ebook' => $ebook]) ?>
|
||||
<?= Template::RealisticEbook(ebook: $ebook) ?>
|
||||
<div>
|
||||
<section id="download">
|
||||
<h3>Download for ereaders</h3>
|
||||
|
@ -383,13 +383,13 @@ catch(Exceptions\EbookNotFoundException){
|
|||
</section>
|
||||
|
||||
<? if(Session::$User?->Benefits->CanEditEbooks){ ?>
|
||||
<?= Template::EbookMetadata(['ebook' => $ebook]) ?>
|
||||
<?= Template::EbookMetadata(ebook: $ebook) ?>
|
||||
<? } ?>
|
||||
|
||||
<? if(sizeof($carousel) > 0){ ?>
|
||||
<aside id="more-ebooks">
|
||||
<h2>More free<? if($carouselTag !== null){ ?> <?= strtolower($carouselTag->Name) ?><? } ?> ebooks</h2>
|
||||
<?= Template::EbookCarousel(['carousel' => $carousel, 'isMultiSize' => true]) ?>
|
||||
<?= Template::EbookCarousel(carousel: $carousel, isMultiSize: true) ?>
|
||||
</aside>
|
||||
<? } ?>
|
||||
</article>
|
||||
|
|
|
@ -7,8 +7,8 @@ $pages = 0;
|
|||
$perPage = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
|
||||
$query = HttpInput::Str(GET, 'query') ?? '';
|
||||
$tags = HttpInput::Array(GET, 'tags') ?? [];
|
||||
$view = Enums\ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '');
|
||||
$sort = Enums\EbookSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
|
||||
$view = Enums\ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '') ?? Enums\ViewType::Grid;
|
||||
$sort = Enums\EbookSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '') ?? Enums\EbookSortType::Default;
|
||||
$queryString = '';
|
||||
$queryStringParams = [];
|
||||
$queryStringWithoutPage = '';
|
||||
|
@ -38,13 +38,8 @@ try{
|
|||
$sort = Enums\EbookSortType::Newest;
|
||||
}
|
||||
|
||||
// If we're passed string values that are the same as the defaults, set them to null so that we can have cleaner query strings in the navigation footer.
|
||||
if($view === Enums\ViewType::Grid){
|
||||
$view = null;
|
||||
}
|
||||
|
||||
if(($sort == Enums\EbookSortType::Newest && $query == '') || ($sort == Enums\EbookSortType::Relevance && $query != '')){
|
||||
$sort = null;
|
||||
$sort = Enums\EbookSortType::Default;
|
||||
}
|
||||
|
||||
if(sizeof($tags) == 1 && mb_strtolower($tags[0]) == 'all'){
|
||||
|
@ -61,11 +56,12 @@ try{
|
|||
$queryStringParams['tags'] = $tags;
|
||||
}
|
||||
|
||||
if($view !== null){
|
||||
// If we're passed string values that are the same as the defaults, don't include them in the query string so that we can have cleaner query strings in the navigation footer.
|
||||
if($view != Enums\ViewType::Grid){
|
||||
$queryStringParams['view'] = $view->value;
|
||||
}
|
||||
|
||||
if($sort !== null){
|
||||
if($sort != Enums\EbookSortType::Default){
|
||||
$queryStringParams['sort'] = $sort->value;
|
||||
}
|
||||
|
||||
|
@ -134,7 +130,7 @@ catch(Exceptions\PageOutOfBoundsException){
|
|||
header('Location: ' . $url);
|
||||
exit();
|
||||
}
|
||||
?><?= Template::Header(['title' => $pageTitle, 'highlight' => 'ebooks', 'description' => $pageDescription, 'canonicalUrl' => $canonicalUrl]) ?>
|
||||
?><?= Template::Header(title: $pageTitle, highlight: 'ebooks', description: $pageDescription, canonicalUrl: $canonicalUrl) ?>
|
||||
<main class="ebooks">
|
||||
<h1><?= $pageHeader ?></h1>
|
||||
<?= Template::DonationCounter() ?>
|
||||
|
@ -142,11 +138,12 @@ catch(Exceptions\PageOutOfBoundsException){
|
|||
|
||||
<?= Template::DonationAlert() ?>
|
||||
|
||||
<?= Template::SearchForm(['query' => $query, 'tags' => $tags, 'sort' => $sort, 'view' => $view, 'perPage' => $perPage]) ?>
|
||||
<?= Template::SearchForm(query: $query, tags: $tags, sort: $sort, view: $view, perPage: $perPage) ?>
|
||||
|
||||
<? if(sizeof($ebooks) == 0){ ?>
|
||||
<p class="no-results">No ebooks matched your filters. You can try different filters, or <a href="/ebooks">browse all of our ebooks</a>.</p>
|
||||
<? }else{ ?>
|
||||
<?= Template::EbookGrid(['ebooks' => $ebooks, 'view' => $view]) ?>
|
||||
<?= Template::EbookGrid(ebooks: $ebooks, view: $view) ?>
|
||||
<? } ?>
|
||||
<? if(sizeof($ebooks) > 0){ ?>
|
||||
<nav class="pagination">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue