Move enums into their own namespace

This commit is contained in:
Alex Cabal 2024-11-08 16:34:21 -06:00
parent c3c588cc1b
commit be5574eaec
45 changed files with 164 additions and 154 deletions

View file

@ -48,8 +48,8 @@ class Artwork{
public ?bool $IsPublishedInUs = null;
public ?string $Exception = null;
public ?string $Notes = null;
public ?ImageMimeType $MimeType = null;
public ?ArtworkStatusType $Status = null;
public ?Enums\ImageMimeType $MimeType = null;
public ?Enums\ArtworkStatusType $Status = null;
protected ?string $_UrlName = null;
protected ?string $_Url = null;
@ -290,7 +290,7 @@ class Artwork{
return true;
}
if(($user->Benefits->CanReviewArtwork || $user->UserId == $this->SubmitterUserId) && ($this->Status == ArtworkStatusType::Unverified || $this->Status == ArtworkStatusType::Declined)){
if(($user->Benefits->CanReviewArtwork || $user->UserId == $this->SubmitterUserId) && ($this->Status == Enums\ArtworkStatusType::Unverified || $this->Status == Enums\ArtworkStatusType::Declined)){
// Editors can edit an artwork, and submitters can edit their own artwork, if it's not yet approved.
return true;
}
@ -308,7 +308,7 @@ class Artwork{
return true;
}
if($user->Benefits->CanReviewArtwork && $user->UserId != $this->SubmitterUserId && ($this->Status == ArtworkStatusType::Unverified || $this->Status == ArtworkStatusType::Declined)){
if($user->Benefits->CanReviewArtwork && $user->UserId != $this->SubmitterUserId && ($this->Status == Enums\ArtworkStatusType::Unverified || $this->Status == Enums\ArtworkStatusType::Declined)){
// Editors can change the status of artwork they did not submit themselves, and that is not yet approved.
return true;
}
@ -661,7 +661,7 @@ class Artwork{
* @throws Exceptions\InvalidImageUploadException
*/
public function Create(?string $imagePath = null): void{
$this->MimeType = ImageMimeType::FromFile($imagePath);
$this->MimeType = Enums\ImageMimeType::FromFile($imagePath);
$this->Validate($imagePath, true);
@ -729,7 +729,7 @@ class Artwork{
$this->_UrlName = null;
if($imagePath !== null){
$this->MimeType = ImageMimeType::FromFile($imagePath);
$this->MimeType = Enums\ImageMimeType::FromFile($imagePath);
// Manually set the updated timestamp, because if we only update the image and nothing else, the row's updated timestamp won't change automatically.
$this->Updated = NOW;
@ -880,7 +880,7 @@ class Artwork{
$artwork->CompletedYear = HttpInput::Int(POST, 'artwork-year');
$artwork->CompletedYearIsCirca = HttpInput::Bool(POST, 'artwork-year-is-circa') ?? false;
$artwork->Tags = HttpInput::Str(POST, 'artwork-tags') ?? [];
$artwork->Status = ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '') ?? ArtworkStatusType::Unverified;
$artwork->Status = Enums\ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '') ?? Enums\ArtworkStatusType::Unverified;
$artwork->EbookUrl = HttpInput::Str(POST, 'artwork-ebook-url');
$artwork->IsPublishedInUs = HttpInput::Bool(POST, 'artwork-is-published-in-us') ?? false;
$artwork->PublicationYear = HttpInput::Int(POST, 'artwork-publication-year');

View file

@ -4,7 +4,7 @@ use function Safe\preg_replace;
class ArtworkTag extends Tag{
public function __construct(){
$this->Type = TagType::Artwork;
$this->Type = Enums\TagType::Artwork;
}
// *******
@ -45,7 +45,7 @@ class ArtworkTag extends Tag{
$error->Add(new Exceptions\InvalidArtworkTagNameException());
}
if($this->Type != TagType::Artwork){
if($this->Type != Enums\TagType::Artwork){
$error->Add(new Exceptions\InvalidArtworkTagTypeException($this->Type));
}
@ -77,7 +77,7 @@ class ArtworkTag extends Tag{
from Tags
where Name = ?
and Type = ?
', [$artworkTag->Name, TagType::Artwork], ArtworkTag::class);
', [$artworkTag->Name, Enums\TagType::Artwork], ArtworkTag::class);
if(isset($result[0])){
return $result[0];

View file

@ -10,7 +10,7 @@ class Collection{
public int $CollectionId;
public string $Name;
public string $UrlName;
public ?CollectionType $Type = null;
public ?Enums\CollectionType $Type = null;
protected ?string $_Url = null;
protected function GetUrl(): string{
@ -85,7 +85,7 @@ class Collection{
$error->Add(new Exceptions\CollectionUrlNameRequiredException());
}
if($this->Type !== null && ($this->Type != CollectionType::Series && $this->Type != CollectionType::Set)){
if($this->Type !== null && ($this->Type != Enums\CollectionType::Series && $this->Type != Enums\CollectionType::Set)){
$error->Add(new Exceptions\InvalidCollectionTypeException($this->Type));
}

View file

@ -775,7 +775,7 @@ class Ebook{
$cm->SequenceNumber = (int)$s;
}
foreach($xml->xpath('/package/metadata/meta[@refines="#' . $id . '"][@property="collection-type"]') ?: [] as $s){
$cm->Collection->Type = CollectionType::tryFrom((string)$s) ?? CollectionType::Unknown;
$cm->Collection->Type = Enums\CollectionType::tryFrom((string)$s) ?? Enums\CollectionType::Unknown;
}
$collectionMemberships[] = $cm;
}
@ -901,32 +901,32 @@ class Ebook{
foreach($xml->xpath('/package/metadata/dc:source') ?: [] as $element){
$ebookSource = new EbookSource();
$ebookSource->Url = (string)$element;
$ebookSource->Type = EbookSourceType::Other;
$ebookSource->Type = Enums\EbookSourceType::Other;
if(mb_stripos($ebookSource->Url, 'gutenberg.org/') !== false){
$ebookSource->Type = EbookSourceType::ProjectGutenberg;
$ebookSource->Type = Enums\EbookSourceType::ProjectGutenberg;
}
elseif(mb_stripos($ebookSource->Url, 'gutenberg.net.au/') !== false){
$ebookSource->Type = EbookSourceType::ProjectGutenbergAustralia;
$ebookSource->Type = Enums\EbookSourceType::ProjectGutenbergAustralia;
}
elseif(mb_stripos($ebookSource->Url, 'gutenberg.ca/') !== false){
$ebookSource->Type = EbookSourceType::ProjectGutenbergCanada;
$ebookSource->Type = Enums\EbookSourceType::ProjectGutenbergCanada;
}
elseif(mb_stripos($ebookSource->Url, 'archive.org/details') !== false){
// `/details` excludes Wayback Machine URLs which may sometimes occur, for example in Lyrical Ballads.
$ebookSource->Type = EbookSourceType::InternetArchive;
$ebookSource->Type = Enums\EbookSourceType::InternetArchive;
}
elseif(mb_stripos($ebookSource->Url, 'hathitrust.org/') !== false){
$ebookSource->Type = EbookSourceType::HathiTrust;
$ebookSource->Type = Enums\EbookSourceType::HathiTrust;
}
elseif(mb_stripos($ebookSource->Url, 'wikisource.org/') !== false){
$ebookSource->Type = EbookSourceType::Wikisource;
$ebookSource->Type = Enums\EbookSourceType::Wikisource;
}
elseif(mb_stripos($ebookSource->Url, 'books.google.com/') !== false || mb_stripos($ebookSource->Url, 'google.com/books/') !== false){
$ebookSource->Type = EbookSourceType::GoogleBooks;
$ebookSource->Type = Enums\EbookSourceType::GoogleBooks;
}
elseif(mb_stripos($ebookSource->Url, 'www.fadedpage.com') !== false){
$ebookSource->Type = EbookSourceType::FadedPage;
$ebookSource->Type = Enums\EbookSourceType::FadedPage;
}
$sources[] = $ebookSource;

View file

@ -4,7 +4,7 @@ use Safe\DateTimeImmutable;
class EbookSource{
public ?int $EbookId = null;
public EbookSourceType $Type;
public Enums\EbookSourceType $Type;
public string $Url;
public ?int $SortOrder = null;

View file

@ -1,7 +1,7 @@
<?
class EbookTag extends Tag{
public function __construct(){
$this->Type = TagType::Ebook;
$this->Type = Enums\TagType::Ebook;
}
// *******
@ -48,7 +48,7 @@ class EbookTag extends Tag{
$error->Add(new Exceptions\EbookTagNameRequiredException());
}
if($this->Type != TagType::Ebook){
if($this->Type != Enums\TagType::Ebook){
$error->Add(new Exceptions\InvalidEbookTagTypeException($this->Type));
}
@ -81,7 +81,7 @@ class EbookTag extends Tag{
from Tags
where Name = ?
and Type = ?
', [$name, TagType::Ebook], EbookTag::class);
', [$name, Enums\TagType::Ebook], EbookTag::class);
if(isset($result[0])){
return $result[0];

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum ArtworkSortType: string{
case CreatedNewest = 'created-newest';
case ArtistAlpha = 'artist-alpha';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum ArtworkStatusType: string{
case Unverified = 'unverified';
case Declined = 'declined';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum CollectionType: string{
case Series = 'series';
case Set = 'set';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum EbookFormatType: string{
case Epub = 'epub';
case Azw3 = 'azw3';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum EbookSortType: string{
case Newest = 'newest';
case AuthorAlpha = 'author-alpha';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum EbookSourceType: string{
case ProjectGutenberg = 'project_gutenberg';
case ProjectGutenbergAustralia = 'project_gutenberg_australia';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
use function Safe\mime_content_type;
enum ImageMimeType: string{

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum PaymentProcessorType: string{
case FracturedAtlas = 'fractured_atlas';
}

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum TagType: string{
case Artwork = 'artwork';
case Ebook = 'ebook';

View file

@ -1,4 +1,6 @@
<?
namespace Enums;
enum ViewType: string{
case Grid = 'grid';
case List = 'list';

View file

@ -1,13 +1,11 @@
<?
namespace Exceptions;
use \TagType;
class InvalidArtworkTagTypeException extends AppException{
/** @var string $message */
protected $message = 'Type should be `TagType::Artwork`.';
protected $message = 'Type should be `Enums\TagType::Artwork`.';
public function __construct(?TagType $tagType){
public function __construct(?\Enums\TagType $tagType){
if($tagType !== null){
$this->message .= ' Type provided: ' . $tagType->value;
}

View file

@ -1,14 +1,11 @@
<?php
<?
namespace Exceptions;
use \CollectionType;
class InvalidCollectionTypeException extends AppException{
/** @var string $message */
protected $message = 'Collection type should be `series` or `set` according to the EPUB specification.';
public function __construct(?CollectionType $collectionType){
public function __construct(?\Enums\CollectionType $collectionType){
if($collectionType !== null){
$this->message .= ' Type provided: ' . $collectionType->value;
}

View file

@ -1,13 +1,11 @@
<?
namespace Exceptions;
use \TagType;
class InvalidEbookTagTypeException extends AppException{
/** @var string $message */
protected $message = 'Type should be `TagType::Ebook`.';
protected $message = 'Type should be `Enums\TagType::Ebook`.';
public function __construct(?TagType $tagType){
public function __construct(?\Enums\TagType $tagType){
if($tagType !== null){
$this->message .= ' Type provided: ' . $tagType->value;
}

View file

@ -1,5 +1,4 @@
<?php
<?
namespace Exceptions;
class InvalidFileUploadException extends AppException{

View file

@ -1,5 +1,4 @@
<?php
<?
namespace Exceptions;
class InvalidImageUploadException extends AppException{

View file

@ -1,5 +1,4 @@
<?php
<?
namespace Exceptions;
class InvalidMimeTypeException extends AppException{

View file

@ -8,11 +8,11 @@ use function Safe\unlink;
class Image{
public string $Path;
public ?ImageMimeType $MimeType = null;
public ?Enums\ImageMimeType $MimeType = null;
public function __construct(string $path){
$this->Path = $path;
$this->MimeType = ImageMimeType::FromFile($path);
$this->MimeType = Enums\ImageMimeType::FromFile($path);
}
/**
@ -22,16 +22,16 @@ class Image{
*/
private function GetImageHandle(){
switch($this->MimeType){
case ImageMimeType::JPG:
case Enums\ImageMimeType::JPG:
$handle = \Safe\imagecreatefromjpeg($this->Path);
break;
case ImageMimeType::BMP:
case Enums\ImageMimeType::BMP:
$handle = \Safe\imagecreatefrombmp($this->Path);
break;
case ImageMimeType::PNG:
case Enums\ImageMimeType::PNG:
$handle = \Safe\imagecreatefrompng($this->Path);
break;
case ImageMimeType::TIFF:
case Enums\ImageMimeType::TIFF:
$handle = $this->GetImageHandleFromTiff();
break;
default:

View file

@ -16,7 +16,7 @@ class Library{
* @param array<string> $tags
* @return array{ebooks: array<Ebook>, ebooksCount: int}
*/
public static function FilterEbooks(string $query = null, array $tags = [], EbookSortType $sort = null, int $page = 1, int $perPage = EBOOKS_PER_PAGE): array{
public static function FilterEbooks(string $query = null, array $tags = [], Enums\EbookSortType $sort = null, int $page = 1, int $perPage = EBOOKS_PER_PAGE): array{
$limit = $perPage;
$offset = (($page - 1) * $perPage);
$joinContributors = '';
@ -25,15 +25,15 @@ class Library{
$whereCondition = 'where true';
$orderBy = 'e.EbookCreated desc';
if($sort == EbookSortType::AuthorAlpha){
if($sort == Enums\EbookSortType::AuthorAlpha){
$joinContributors = 'inner join Contributors con using (EbookId)';
$whereCondition .= ' AND con.MarcRole = "aut"';
$orderBy = 'con.SortName, e.EbookCreated desc';
}
elseif($sort == EbookSortType::ReadingEase){
elseif($sort == Enums\EbookSortType::ReadingEase){
$orderBy = 'e.ReadingEase desc';
}
elseif($sort == EbookSortType::Length){
elseif($sort == Enums\EbookSortType::Length){
$orderBy = 'e.WordCount';
}
@ -200,7 +200,7 @@ class Library{
/**
* @return array{artworks: array<Artwork>, artworksCount: int}
*/
public static function FilterArtwork(?string $query = null, ?string $status = null, ?ArtworkSortType $sort = null, ?int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{
public static function FilterArtwork(?string $query = null, ?string $status = null, ?Enums\ArtworkSortType $sort = null, ?int $submitterUserId = null, int $page = 1, int $perPage = ARTWORK_PER_PAGE): array{
// $status is either the string value of an ArtworkStatus enum, or one of these special statuses:
// null: same as "all"
// "all": Show all approved and in use artwork
@ -214,29 +214,29 @@ class Library{
if($status === null || $status == 'all'){
$statusCondition = 'Status = ?';
$params[] = ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
}
elseif($status == 'all-admin'){
$statusCondition = 'true';
}
elseif($status == 'all-submitter' && $submitterUserId !== null){
$statusCondition = '(Status = ? or (Status = ? and SubmitterUserId = ?))';
$params[] = ArtworkStatusType::Approved->value;
$params[] = ArtworkStatusType::Unverified->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Unverified->value;
$params[] = $submitterUserId;
}
elseif($status == 'unverified-submitter' && $submitterUserId !== null){
$statusCondition = 'Status = ? and SubmitterUserId = ?';
$params[] = ArtworkStatusType::Unverified->value;
$params[] = Enums\ArtworkStatusType::Unverified->value;
$params[] = $submitterUserId;
}
elseif($status == 'in-use'){
$statusCondition = 'Status = ? and EbookUrl is not null';
$params[] = ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
}
elseif($status == ArtworkStatusType::Approved->value){
elseif($status == Enums\ArtworkStatusType::Approved->value){
$statusCondition = 'Status = ? and EbookUrl is null';
$params[] = ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
}
else{
$statusCondition = 'Status = ?';
@ -244,10 +244,10 @@ class Library{
}
$orderBy = 'art.Created desc';
if($sort == ArtworkSortType::ArtistAlpha){
if($sort == Enums\ArtworkSortType::ArtistAlpha){
$orderBy = 'a.Name';
}
elseif($sort == ArtworkSortType::CompletedNewest){
elseif($sort == Enums\ArtworkSortType::CompletedNewest){
$orderBy = 'art.CompletedYear desc';
}
@ -364,13 +364,13 @@ class Library{
}
elseif($status == 'all-submitter' && $submitterUserId !== null){
$statusCondition = '(Status = ? or (Status = ? and SubmitterUserId = ?))';
$params[] = ArtworkStatusType::Approved->value;
$params[] = ArtworkStatusType::Unverified->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Unverified->value;
$params[] = $submitterUserId;
}
else{
$statusCondition = 'Status = ?';
$params[] = ArtworkStatusType::Approved->value;
$params[] = Enums\ArtworkStatusType::Approved->value;
}
$params[] = $artistUrlName; // a.UrlName

View file

@ -10,7 +10,7 @@ class Payment{
public int $PaymentId;
public ?int $UserId = null;
public DateTimeImmutable $Created;
public PaymentProcessorType $Processor;
public Enums\PaymentProcessorType $Processor;
public string $TransactionId;
public float $Amount;
public float $Fee;

View file

@ -8,7 +8,7 @@ class Tag{
public int $TagId;
public string $Name;
public TagType $Type;
public Enums\TagType $Type;
protected ?string $_UrlName = null;
protected ?string $_Url = null;
}

View file

@ -73,7 +73,7 @@ function InsertTransaction(string $transactionId): bool{
values (utc_timestamp(),
?,
?)',
[PaymentProcessorType::FracturedAtlas, $transactionId]);
[Enums\PaymentProcessorType::FracturedAtlas, $transactionId]);
return true;
}

View file

@ -69,9 +69,9 @@ try{
$driver = FirefoxDriver::start($capabilities);
foreach($pendingPayments as $pendingPayment){
$pendingPayment->Processor = PaymentProcessorType::from($pendingPayment->Processor);
$pendingPayment->Processor = Enums\PaymentProcessorType::from($pendingPayment->Processor);
switch($pendingPayment->Processor){
case PaymentProcessorType::FracturedAtlas:
case Enums\PaymentProcessorType::FracturedAtlas:
$log->Write('Processing donation ' . $pendingPayment->TransactionId . ' ...');
if(Db::QueryBool('

View file

@ -87,7 +87,7 @@ $isEditForm = $isEditForm ?? false;
type="file"
name="artwork-image"
<? if(!$isEditForm){ ?>required="required"<? } ?>
accept="<?= implode(',', ImageMimeType::Values()) ?>"
accept="<?= implode(',', Enums\ImageMimeType::Values()) ?>"
/>
</label>
</fieldset>
@ -179,9 +179,9 @@ $isEditForm = $isEditForm ?? false;
<span>Artwork approval status</span>
<span>
<select name="artwork-status">
<option value="<?= ArtworkStatusType::Unverified->value ?>"<? if($artwork->Status == ArtworkStatusType::Unverified){ ?> selected="selected"<? } ?>>Unverified</option>
<option value="<?= ArtworkStatusType::Declined->value ?>"<? if($artwork->Status == ArtworkStatusType::Declined){ ?> selected="selected"<? } ?>>Declined</option>
<option value="<?= ArtworkStatusType::Approved->value ?>"<? if($artwork->Status == ArtworkStatusType::Approved){ ?> selected="selected"<? } ?>>Approved</option>
<option value="<?= Enums\ArtworkStatusType::Unverified->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Unverified){ ?> selected="selected"<? } ?>>Unverified</option>
<option value="<?= Enums\ArtworkStatusType::Declined->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Declined){ ?> selected="selected"<? } ?>>Declined</option>
<option value="<?= Enums\ArtworkStatusType::Approved->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Approved){ ?> selected="selected"<? } ?>>Approved</option>
</select>
</span>
</label>

View file

@ -13,11 +13,11 @@
}
switch($artwork->Status){
case ArtworkStatusType::Unverified:
case Enums\ArtworkStatusType::Unverified:
$class .= ' unverified';
break;
case ArtworkStatusType::Declined:
case Enums\ArtworkStatusType::Declined:
$class .= ' declined';
break;
}

View file

@ -4,10 +4,10 @@
* @var array<Ebook> $ebooks
*/
$view = $view ?? ViewType::Grid;
$view = $view ?? Enums\ViewType::Grid;
$collection = $collection ?? null;
?>
<ol class="ebooks-list<? if($view == ViewType::List){ ?> list<? }else{ ?> grid<? } ?>"<? if($collection !== null){ ?> typeof="schema:BookSeries" about="<?= $collection->Url ?>"<? } ?>>
<ol class="ebooks-list<? if($view == Enums\ViewType::List){ ?> list<? }else{ ?> grid<? } ?>"<? if($collection !== null){ ?> typeof="schema:BookSeries" about="<?= $collection->Url ?>"<? } ?>>
<? if($collection !== null){ ?>
<meta property="schema:name" content="<?= Formatter::EscapeHtml($collection->Name) ?>"/>
<? } ?>
@ -26,7 +26,7 @@ $collection = $collection ?? null;
</a>
</div>
<p><a href="<?= $ebook->Url ?>" property="schema:url"><span property="schema:name"><?= Formatter::EscapeHtml($ebook->Title) ?></span></a></p>
<? if($view == ViewType::Grid){ ?>
<? if($view == Enums\ViewType::Grid){ ?>
<? foreach($ebook->Authors as $author){ ?>
<p class="author" typeof="schema:Person" property="schema:author" resource="<?= $ebook->AuthorsUrl ?>"><? if($author->Name != 'Anonymous'){ ?><a href="<?= Formatter::EscapeHtml(SITE_URL . $ebook->AuthorsUrl) ?>" property="schema:url"><span property="schema:name"><?= Formatter::EscapeHtml($author->Name) ?></span></a><? } ?></p>
<? } ?>

View file

@ -1,8 +1,8 @@
<?
/**
* @var array<string> $tags
* @var EbookSortType $sort
* @var ViewType $view
* @var Enums\EbookSortType $sort
* @var Enums\ViewType $view
* @var int $perPage
*/
@ -24,10 +24,10 @@ $isAllSelected = sizeof($tags) == 0 || in_array('all', $tags);
<span>Sort</span>
<span>
<select name="sort">
<option value="<?= EbookSortType::Newest->value ?>"<? if($sort == EbookSortType::Newest){ ?> selected="selected"<? } ?>>S.E. release date (new &#x2192; old)</option>
<option value="<?= EbookSortType::AuthorAlpha->value ?>"<? if($sort == EbookSortType::AuthorAlpha){ ?> selected="selected"<? } ?>>Author name (a &#x2192; z)</option>
<option value="<?= EbookSortType::ReadingEase->value ?>"<? if($sort == EbookSortType::ReadingEase){ ?> selected="selected"<? } ?>>Reading ease (easy &#x2192; hard)</option>
<option value="<?= EbookSortType::Length->value ?>"<? if($sort == EbookSortType::Length){ ?> selected="selected"<? } ?>>Length (short &#x2192; long)</option>
<option value="<?= Enums\EbookSortType::Newest->value ?>"<? if($sort == Enums\EbookSortType::Newest){ ?> selected="selected"<? } ?>>S.E. release date (new &#x2192; old)</option>
<option value="<?= Enums\EbookSortType::AuthorAlpha->value ?>"<? if($sort == Enums\EbookSortType::AuthorAlpha){ ?> selected="selected"<? } ?>>Author name (a &#x2192; z)</option>
<option value="<?= Enums\EbookSortType::ReadingEase->value ?>"<? if($sort == Enums\EbookSortType::ReadingEase){ ?> selected="selected"<? } ?>>Reading ease (easy &#x2192; hard)</option>
<option value="<?= Enums\EbookSortType::Length->value ?>"<? if($sort == Enums\EbookSortType::Length){ ?> selected="selected"<? } ?>>Length (short &#x2192; long)</option>
</select>
</span>
</label>
@ -35,8 +35,8 @@ $isAllSelected = sizeof($tags) == 0 || in_array('all', $tags);
<span>View</span>
<span>
<select name="view">
<option value="<?= ViewType::Grid->value ?>"<? if($view == ViewType::Grid){ ?> selected="selected"<? } ?>>Grid</option>
<option value="<?= ViewType::List->value ?>"<? if($view == ViewType::List){ ?> selected="selected"<? } ?>>List</option>
<option value="<?= Enums\ViewType::Grid->value ?>"<? if($view == Enums\ViewType::Grid){ ?> selected="selected"<? } ?>>Grid</option>
<option value="<?= Enums\ViewType::List->value ?>"<? if($view == Enums\ViewType::List){ ?> selected="selected"<? } ?>>List</option>
</select>
</span>
</label>

View file

@ -33,9 +33,9 @@ try{
// If the artwork is not approved, and we're not an admin or the submitter when they can edit, don't show it.
if(
($GLOBALS['User'] === null && $artwork->Status != ArtworkStatusType::Approved)
($GLOBALS['User'] === null && $artwork->Status != Enums\ArtworkStatusType::Approved)
||
($GLOBALS['User'] !== null && $artwork->Status != ArtworkStatusType::Approved && $artwork->SubmitterUserId != $GLOBALS['User']->UserId && !$isReviewerView)
($GLOBALS['User'] !== null && $artwork->Status != Enums\ArtworkStatusType::Approved && $artwork->SubmitterUserId != $GLOBALS['User']->UserId && !$isReviewerView)
){
throw new Exceptions\InvalidPermissionsException();
}
@ -182,9 +182,9 @@ catch(Exceptions\InvalidPermissionsException){
<span>Artwork approval status</span>
<span>
<select name="artwork-status">
<option value="<?= ArtworkStatusType::Unverified->value ?>"<? if($artwork->Status == ArtworkStatusType::Unverified){ ?> selected="selected"<? } ?>>Unverified</option>
<option value="<?= ArtworkStatusType::Declined->value ?>"<? if($artwork->Status == ArtworkStatusType::Declined){ ?> selected="selected"<? } ?>>Declined</option>
<option value="<?= ArtworkStatusType::Approved->value ?>"<? if($artwork->Status == ArtworkStatusType::Approved){ ?> selected="selected"<? } ?>>Approved</option>
<option value="<?= Enums\ArtworkStatusType::Unverified->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Unverified){ ?> selected="selected"<? } ?>>Unverified</option>
<option value="<?= Enums\ArtworkStatusType::Declined->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Declined){ ?> selected="selected"<? } ?>>Declined</option>
<option value="<?= Enums\ArtworkStatusType::Approved->value ?>"<? if($artwork->Status == Enums\ArtworkStatusType::Approved){ ?> selected="selected"<? } ?>>Approved</option>
</select>
</span>
</label>

View file

@ -5,7 +5,7 @@ $query = HttpInput::Str(GET, 'query');
$queryEbookUrl = HttpInput::Str(GET, 'query-ebook-url');
$status = HttpInput::Str(GET, 'status');
$filterArtworkStatus = $status;
$sort = ArtworkSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
$sort = Enums\ArtworkSortType::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
$pages = 0;
$totalArtworkCount = 0;
$pageDescription = '';
@ -26,7 +26,7 @@ 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($sort == ArtworkSortType::CreatedNewest){
if($sort == Enums\ArtworkSortType::CreatedNewest){
$sort = null;
}
@ -45,25 +45,25 @@ try{
}
}
if(!$isReviewerView && !$isSubmitterView && !in_array($status, array('all', ArtworkStatusType::Approved->value, 'in-use'))){
$status = ArtworkStatusType::Approved->value;
if(!$isReviewerView && !$isSubmitterView && !in_array($status, array('all', Enums\ArtworkStatusType::Approved->value, 'in-use'))){
$status = Enums\ArtworkStatusType::Approved->value;
$filterArtworkStatus = $status;
}
if($isReviewerView && !in_array($status, array('all', ArtworkStatusType::Unverified->value, ArtworkStatusType::Declined->value, ArtworkStatusType::Approved->value, 'in-use'))
&& !in_array($filterArtworkStatus, array('all-admin', ArtworkStatusType::Unverified->value, ArtworkStatusType::Declined->value, ArtworkStatusType::Approved->value, 'in-use'))){
$status = ArtworkStatusType::Approved->value;
if($isReviewerView && !in_array($status, array('all', Enums\ArtworkStatusType::Unverified->value, Enums\ArtworkStatusType::Declined->value, Enums\ArtworkStatusType::Approved->value, 'in-use'))
&& !in_array($filterArtworkStatus, array('all-admin', Enums\ArtworkStatusType::Unverified->value, Enums\ArtworkStatusType::Declined->value, Enums\ArtworkStatusType::Approved->value, 'in-use'))){
$status = Enums\ArtworkStatusType::Approved->value;
$filterArtworkStatus = $status;
}
if($isSubmitterView && !in_array($status, array('all', ArtworkStatusType::Unverified->value, ArtworkStatusType::Approved->value, 'in-use'))
&& !in_array($filterArtworkStatus, array('all-submitter', 'unverified-submitter', ArtworkStatusType::Approved->value, 'in-use'))){
$status = ArtworkStatusType::Approved->value;
if($isSubmitterView && !in_array($status, array('all', Enums\ArtworkStatusType::Unverified->value, Enums\ArtworkStatusType::Approved->value, 'in-use'))
&& !in_array($filterArtworkStatus, array('all-submitter', 'unverified-submitter', Enums\ArtworkStatusType::Approved->value, 'in-use'))){
$status = Enums\ArtworkStatusType::Approved->value;
$filterArtworkStatus = $status;
}
if($queryEbookUrl !== null){
$artworks = Db::Query('SELECT * from Artworks where EbookUrl = ? and Status = ? limit 1', [$queryEbookUrl, ArtworkStatusType::Approved], Artwork::class);
$artworks = Db::Query('SELECT * from Artworks where EbookUrl = ? and Status = ? limit 1', [$queryEbookUrl, Enums\ArtworkStatusType::Approved], Artwork::class);
$totalArtworkCount = sizeof($artworks);
}
else{
@ -139,9 +139,9 @@ catch(Exceptions\PageOutOfBoundsException){
<span>
<select name="status" size="1">
<option value="all"<? if($status === null){ ?> selected="selected"<? } ?>>All</option>
<? if($isReviewerView || $isSubmitterView){ ?><option value="<?= ArtworkStatusType::Unverified->value ?>"<? if($status == ArtworkStatusType::Unverified->value){ ?> selected="selected"<? } ?>>Unverified</option><? } ?>
<? if($isReviewerView){ ?><option value="<?= ArtworkStatusType::Declined->value ?>"<? if($status == ArtworkStatusType::Declined->value){ ?> selected="selected"<? } ?>>Declined</option><? } ?>
<option value="<?= ArtworkStatusType::Approved->value ?>"<? if($status == ArtworkStatusType::Approved->value){ ?> selected="selected"<? } ?>>Approved, not in use</option>
<? if($isReviewerView || $isSubmitterView){ ?><option value="<?= Enums\ArtworkStatusType::Unverified->value ?>"<? if($status == Enums\ArtworkStatusType::Unverified->value){ ?> selected="selected"<? } ?>>Unverified</option><? } ?>
<? if($isReviewerView){ ?><option value="<?= Enums\ArtworkStatusType::Declined->value ?>"<? if($status == Enums\ArtworkStatusType::Declined->value){ ?> selected="selected"<? } ?>>Declined</option><? } ?>
<option value="<?= Enums\ArtworkStatusType::Approved->value ?>"<? if($status == Enums\ArtworkStatusType::Approved->value){ ?> selected="selected"<? } ?>>Approved, not in use</option>
<option value="in-use"<? if($status == 'in-use'){ ?> selected="selected"<? } ?>>In use</option>
</select>
</span>
@ -153,9 +153,9 @@ catch(Exceptions\PageOutOfBoundsException){
<span>Sort</span>
<span>
<select name="sort">
<option value="<?= ArtworkSortType::CreatedNewest->value ?>"<? if($sort == ArtworkSortType::CreatedNewest){ ?> selected="selected"<? } ?>>Date added (new &#x2192; old)</option>
<option value="<?= ArtworkSortType::ArtistAlpha->value ?>"<? if($sort == ArtworkSortType::ArtistAlpha){ ?> selected="selected"<? } ?>>Artist name (a &#x2192; z)</option>
<option value="<?= ArtworkSortType::CompletedNewest->value ?>"<? if($sort == ArtworkSortType::CompletedNewest){ ?> selected="selected"<? } ?>>Date of artwork completion (new &#x2192; old)</option>
<option value="<?= Enums\ArtworkSortType::CreatedNewest->value ?>"<? if($sort == Enums\ArtworkSortType::CreatedNewest){ ?> selected="selected"<? } ?>>Date added (new &#x2192; old)</option>
<option value="<?= Enums\ArtworkSortType::ArtistAlpha->value ?>"<? if($sort == Enums\ArtworkSortType::ArtistAlpha){ ?> selected="selected"<? } ?>>Artist name (a &#x2192; z)</option>
<option value="<?= Enums\ArtworkSortType::CompletedNewest->value ?>"<? if($sort == Enums\ArtworkSortType::CompletedNewest){ ?> selected="selected"<? } ?>>Date of artwork completion (new &#x2192; old)</option>
</select>
</span>
</label>

View file

@ -36,7 +36,7 @@ try{
$artwork->Artist = new Artist();
if($GLOBALS['User']->Benefits->CanReviewOwnArtwork){
$artwork->Status = ArtworkStatusType::Approved;
$artwork->Status = Enums\ArtworkStatusType::Approved;
}
}
}

View file

@ -24,12 +24,12 @@ try{
// Only approved reviewers can set the status to anything but unverified when uploading.
// The submitter cannot review their own submissions unless they have special permission.
if($artwork->Status !== ArtworkStatusType::Unverified && !$artwork->CanStatusBeChangedBy($GLOBALS['User'])){
if($artwork->Status !== Enums\ArtworkStatusType::Unverified && !$artwork->CanStatusBeChangedBy($GLOBALS['User'])){
throw new Exceptions\InvalidPermissionsException();
}
// If the artwork is approved, set the reviewer
if($artwork->Status !== ArtworkStatusType::Unverified){
if($artwork->Status !== Enums\ArtworkStatusType::Unverified){
$artwork->ReviewerUserId = $GLOBALS['User']->UserId;
}
@ -58,7 +58,7 @@ try{
$artwork->SubmitterUserId = $originalArtwork->SubmitterUserId;
$artwork->Status = $originalArtwork->Status; // Overwrite any value got from POST because we need permission to change the status
$newStatus = ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '');
$newStatus = Enums\ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '');
if($newStatus !== null){
if($originalArtwork->Status != $newStatus && !$originalArtwork->CanStatusBeChangedBy($GLOBALS['User'])){
throw new Exceptions\InvalidPermissionsException();
@ -89,7 +89,7 @@ try{
// We can PATCH the status, the ebook www filesystem path, or both.
if(isset($_POST['artwork-status'])){
$newStatus = ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '');
$newStatus = Enums\ArtworkStatusType::tryFrom(HttpInput::Str(POST, 'artwork-status') ?? '');
if($newStatus !== null){
if($artwork->Status != $newStatus && !$artwork->CanStatusBeChangedBy($GLOBALS['User'])){
throw new Exceptions\InvalidPermissionsException();

View file

@ -50,7 +50,7 @@ catch(Exceptions\CollectionNotFoundException){
<? 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' => ViewType::Grid, 'collection' => $collectionObject]) ?>
<?= Template::EbookGrid(['ebooks' => $ebooks, 'view' => Enums\ViewType::Grid, 'collection' => $collectionObject]) ?>
<? } ?>
<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>

View file

@ -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>

View file

@ -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;

View file

@ -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 Kindles library. Despite what youve 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 Kindles library. Despite what youve 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>
<? } ?>

View file

@ -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;
}

View file

@ -9,7 +9,7 @@ try{
$count = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
if($query !== ''){
$ebooks = Library::FilterEbooks($query, [], EbookSortType::Newest, $startPage, $count)['ebooks'];
$ebooks = Library::FilterEbooks($query, [], Enums\EbookSortType::Newest, $startPage, $count)['ebooks'];
}
}
catch(\Exception){

View file

@ -9,7 +9,7 @@ try{
$count = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
if($query !== ''){
$ebooks = Library::FilterEbooks($query, [], EbookSortType::Newest, $startPage, $count)['ebooks'];
$ebooks = Library::FilterEbooks($query, [], Enums\EbookSortType::Newest, $startPage, $count)['ebooks'];
}
}
catch(\Exception){

View file

@ -9,7 +9,7 @@ try{
$count = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
if($query !== ''){
$ebooks = Library::FilterEbooks($query, [], EbookSortType::Newest, $startPage, $count)['ebooks'];
$ebooks = Library::FilterEbooks($query, [], Enums\EbookSortType::Newest, $startPage, $count)['ebooks'];
}
}
catch(\Exception){

View file

@ -39,7 +39,7 @@ try{
values (utc_timestamp(),
?,
?)
', [PaymentProcessorType::FracturedAtlas, $transactionId]);
', [Enums\PaymentProcessorType::FracturedAtlas, $transactionId]);
$log->Write('Donation ID: ' . $transactionId);
}