mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 03:16:36 -04:00
Move enums into their own namespace
This commit is contained in:
parent
c3c588cc1b
commit
be5574eaec
45 changed files with 164 additions and 154 deletions
|
@ -31,7 +31,7 @@ catch(Exceptions\AuthorNotFoundException){
|
|||
<a class="button" href="<?= Formatter::EscapeHtml($authorUrl) ?>/downloads">Download collection</a>
|
||||
<a class="button" href="<?= Formatter::EscapeHtml($authorUrl) ?>/feeds">Feeds for this author</a>
|
||||
</p>
|
||||
<?= Template::EbookGrid(['ebooks' => $ebooks, 'view' => ViewType::Grid]) ?>
|
||||
<?= Template::EbookGrid(['ebooks' => $ebooks, 'view' => Enums\ViewType::Grid]) ?>
|
||||
<p class="feeds-alert">We also have <a href="/bulk-downloads">bulk ebook downloads</a> and a <a href="/collections">list of collections</a> available, as well as <a href="/feeds">ebook catalog feeds</a> for use directly in your ereader app or RSS reader.</p>
|
||||
<?= Template::ContributeAlert() ?>
|
||||
</main>
|
||||
|
|
|
@ -13,21 +13,21 @@ try{
|
|||
$identifier = EBOOKS_IDENTIFIER_PREFIX . $urlPath;
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
|
||||
$format = EbookFormatType::tryFrom(HttpInput::Str(GET, 'format') ?? '') ?? EbookFormatType::Epub;
|
||||
$format = Enums\EbookFormatType::tryFrom(HttpInput::Str(GET, 'format') ?? '') ?? Enums\EbookFormatType::Epub;
|
||||
switch($format){
|
||||
case EbookFormatType::Kepub:
|
||||
case Enums\EbookFormatType::Kepub:
|
||||
$downloadUrl = $ebook->KepubUrl;
|
||||
break;
|
||||
|
||||
case EbookFormatType::Azw3:
|
||||
case Enums\EbookFormatType::Azw3:
|
||||
$downloadUrl = $ebook->Azw3Url;
|
||||
break;
|
||||
|
||||
case EbookFormatType::AdvancedEpub:
|
||||
case Enums\EbookFormatType::AdvancedEpub:
|
||||
$downloadUrl = $ebook->AdvancedEpubUrl;
|
||||
break;
|
||||
|
||||
case EbookFormatType::Epub:
|
||||
case Enums\EbookFormatType::Epub:
|
||||
default:
|
||||
$downloadUrl = $ebook->EpubUrl;
|
||||
break;
|
||||
|
|
|
@ -45,21 +45,21 @@ try{
|
|||
// Divide our sources into transcriptions and scans.
|
||||
foreach($ebook->Sources as $source){
|
||||
switch($source->Type){
|
||||
case EbookSourceType::ProjectGutenberg:
|
||||
case EbookSourceType::ProjectGutenbergAustralia:
|
||||
case EbookSourceType::ProjectGutenbergCanada:
|
||||
case EbookSourceType::Wikisource:
|
||||
case EbookSourceType::FadedPage:
|
||||
case Enums\EbookSourceType::ProjectGutenberg:
|
||||
case Enums\EbookSourceType::ProjectGutenbergAustralia:
|
||||
case Enums\EbookSourceType::ProjectGutenbergCanada:
|
||||
case Enums\EbookSourceType::Wikisource:
|
||||
case Enums\EbookSourceType::FadedPage:
|
||||
$transcriptionSources[] = $source;
|
||||
break;
|
||||
|
||||
case EbookSourceType::InternetArchive:
|
||||
case EbookSourceType::HathiTrust:
|
||||
case EbookSourceType::GoogleBooks:
|
||||
case Enums\EbookSourceType::InternetArchive:
|
||||
case Enums\EbookSourceType::HathiTrust:
|
||||
case Enums\EbookSourceType::GoogleBooks:
|
||||
$scanSources[] = $source;
|
||||
break;
|
||||
|
||||
case EbookSourceType::Other:
|
||||
case Enums\EbookSourceType::Other:
|
||||
$otherSources[] = $source;
|
||||
break;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<meta property="schema:description" content="epub"/>
|
||||
<meta property="schema:encodingFormat" content="application/epub+zip"/>
|
||||
<p>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= EbookFormatType::Epub->value ?>" class="epub">Compatible epub</a></span> <span>—</span> <span>All devices and apps except Kindles and Kobos.</span>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= Enums\EbookFormatType::Epub->value ?>" class="epub">Compatible epub</a></span> <span>—</span> <span>All devices and apps except Kindles and Kobos.</span>
|
||||
</p>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
@ -232,7 +232,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<li property="schema:encoding" typeof="schema:MediaObject">
|
||||
<meta property="schema:encodingFormat" content="application/x-mobipocket-ebook"/>
|
||||
<p>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= EbookFormatType::Azw3->value ?>" class="amazon"><span property="schema:description">azw3</span></a></span> <span>—</span> <span>Kindle devices and apps.<? if($ebook->KindleCoverUrl !== null){ ?> Also download the <a href="<?= $ebook->KindleCoverUrl ?>">Kindle cover thumbnail</a> to see the cover in your Kindle’s library. Despite what you’ve been told, <a href="/help/how-to-use-our-ebooks#kindle-epub">Kindle does not natively support epub.</a> You may also be interested in our <a href="/help/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? }else{ ?> Also see our <a href="/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? } ?></span>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= Enums\EbookFormatType::Azw3->value ?>" class="amazon"><span property="schema:description">azw3</span></a></span> <span>—</span> <span>Kindle devices and apps.<? if($ebook->KindleCoverUrl !== null){ ?> Also download the <a href="<?= $ebook->KindleCoverUrl ?>">Kindle cover thumbnail</a> to see the cover in your Kindle’s library. Despite what you’ve been told, <a href="/help/how-to-use-our-ebooks#kindle-epub">Kindle does not natively support epub.</a> You may also be interested in our <a href="/help/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? }else{ ?> Also see our <a href="/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? } ?></span>
|
||||
</p>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
@ -241,7 +241,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<li property="schema:encoding" typeof="schema:MediaObject">
|
||||
<meta property="schema:encodingFormat" content="application/kepub+zip"/>
|
||||
<p>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= EbookFormatType::Kepub->value ?>" class="kobo"><span property="schema:description">kepub</span></a></span> <span>—</span> <span>Kobo devices and apps. You may also be interested in our <a href="/help/how-to-use-our-ebooks#kobo-faq">Kobo FAQ</a>.</span>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= Enums\EbookFormatType::Kepub->value ?>" class="kobo"><span property="schema:description">kepub</span></a></span> <span>—</span> <span>Kobo devices and apps. You may also be interested in our <a href="/help/how-to-use-our-ebooks#kobo-faq">Kobo FAQ</a>.</span>
|
||||
</p>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
@ -250,7 +250,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<li property="schema:encoding" typeof="schema:MediaObject">
|
||||
<meta property="schema:encodingFormat" content="application/epub+zip"/>
|
||||
<p>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= EbookFormatType::AdvancedEpub->value ?>" class="epub"><span property="schema:description">Advanced epub</span></a></span> <span>—</span> <span>An advanced format that uses the latest technology not yet fully supported by most ereaders.</span>
|
||||
<span><a property="schema:contentUrl" rel="nofollow" href="<?= $ebook->Url ?>/download?format=<?= Enums\EbookFormatType::AdvancedEpub->value ?>" class="epub"><span property="schema:description">Advanced epub</span></a></span> <span>—</span> <span>An advanced format that uses the latest technology not yet fully supported by most ereaders.</span>
|
||||
</p>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
@ -338,15 +338,15 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? foreach($transcriptionSources as $source){ ?>
|
||||
<li>
|
||||
<p>
|
||||
<? if($source->Type == EbookSourceType::ProjectGutenberg){ ?>
|
||||
<? if($source->Type == Enums\EbookSourceType::ProjectGutenberg){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="project-gutenberg">Transcription at Project Gutenberg</a>
|
||||
<? }elseif($source->Type == EbookSourceType::ProjectGutenbergAustralia){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::ProjectGutenbergAustralia){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="project-gutenberg">Transcription at Project Gutenberg Australia</a>
|
||||
<? }elseif($source->Type == EbookSourceType::ProjectGutenbergCanada){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::ProjectGutenbergCanada){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="project-gutenberg">Transcription at Project Gutenberg Canada</a>
|
||||
<? }elseif($source->Type == EbookSourceType::Wikisource){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::Wikisource){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="wikisource">Transcription at Wikisource</a>
|
||||
<? }elseif($source->Type == EbookSourceType::FadedPage){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::FadedPage){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="globe">Transcription at Faded Page</a>
|
||||
<? }else{?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="globe">Transcription</a>
|
||||
|
@ -364,11 +364,11 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? foreach($scanSources as $source){ ?>
|
||||
<li>
|
||||
<p>
|
||||
<? if($source->Type == EbookSourceType::InternetArchive){ ?>
|
||||
<? if($source->Type == Enums\EbookSourceType::InternetArchive){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="internet-archive">Page scans at the Internet Archive</a>
|
||||
<? }elseif($source->Type == EbookSourceType::HathiTrust){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::HathiTrust){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="hathitrust">Page scans at HathiTrust</a>
|
||||
<? }elseif($source->Type == EbookSourceType::GoogleBooks){ ?>
|
||||
<? }elseif($source->Type == Enums\EbookSourceType::GoogleBooks){ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="google">Page scans at Google Books</a>
|
||||
<? }else{ ?>
|
||||
<a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="globe">Page scans</a>
|
||||
|
@ -386,7 +386,7 @@ catch(Exceptions\EbookNotFoundException){
|
|||
<? foreach($otherSources as $source){ ?>
|
||||
<li>
|
||||
<p>
|
||||
<? if($source->Type == EbookSourceType::Other){ ?><a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="globe"><?= Formatter::EscapeHtml(preg_replace(['|https?://(en\.)?|', '|/.+$|'], '', (string)$source->Url)) /* force type to (string) to satisfy PHPStan */ ?></a><? } ?>
|
||||
<? if($source->Type == Enums\EbookSourceType::Other){ ?><a href="<?= Formatter::EscapeHtml($source->Url) ?>" class="globe"><?= Formatter::EscapeHtml(preg_replace(['|https?://(en\.)?|', '|/.+$|'], '', (string)$source->Url)) /* force type to (string) to satisfy PHPStan */ ?></a><? } ?>
|
||||
</p>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
|
|
@ -6,8 +6,8 @@ $pages = 0;
|
|||
$perPage = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
|
||||
$query = HttpInput::Str(GET, 'query') ?? '';
|
||||
$tags = HttpInput::Array(GET, 'tags') ?? [];
|
||||
$view = ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '');
|
||||
$sort = EbookSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
|
||||
$view = Enums\ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '');
|
||||
$sort = Enums\EbookSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
|
||||
$queryString = '';
|
||||
$queryStringParams = [];
|
||||
$queryStringWithoutPage = '';
|
||||
|
@ -23,11 +23,11 @@ try{
|
|||
|
||||
// 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 === ViewType::Grid){
|
||||
if($view === Enums\ViewType::Grid){
|
||||
$view = null;
|
||||
}
|
||||
|
||||
if($sort == EbookSortType::Newest){
|
||||
if($sort == Enums\EbookSortType::Newest){
|
||||
$sort = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue