diff --git a/lib/Artwork.php b/lib/Artwork.php index 136e0cc0..ed4cffd8 100644 --- a/lib/Artwork.php +++ b/lib/Artwork.php @@ -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'); diff --git a/lib/ArtworkTag.php b/lib/ArtworkTag.php index 7b27306c..e3313bb6 100644 --- a/lib/ArtworkTag.php +++ b/lib/ArtworkTag.php @@ -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]; diff --git a/lib/Collection.php b/lib/Collection.php index 416a245b..bb6af2a2 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -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)); } diff --git a/lib/Ebook.php b/lib/Ebook.php index 894ecb0b..e4c77a8f 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -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; diff --git a/lib/EbookSource.php b/lib/EbookSource.php index 5bb7f836..e417c409 100644 --- a/lib/EbookSource.php +++ b/lib/EbookSource.php @@ -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; diff --git a/lib/EbookTag.php b/lib/EbookTag.php index a38854fa..c7814332 100644 --- a/lib/EbookTag.php +++ b/lib/EbookTag.php @@ -1,7 +1,7 @@ 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]; diff --git a/lib/ArtworkSortType.php b/lib/Enums/ArtworkSortType.php similarity index 89% rename from lib/ArtworkSortType.php rename to lib/Enums/ArtworkSortType.php index 9f3a7ed2..5d9e2500 100644 --- a/lib/ArtworkSortType.php +++ b/lib/Enums/ArtworkSortType.php @@ -1,4 +1,6 @@ message .= ' Type provided: ' . $tagType->value; } diff --git a/lib/Exceptions/InvalidCollectionTypeException.php b/lib/Exceptions/InvalidCollectionTypeException.php index f113a82b..82b3bd87 100644 --- a/lib/Exceptions/InvalidCollectionTypeException.php +++ b/lib/Exceptions/InvalidCollectionTypeException.php @@ -1,14 +1,11 @@ -message .= ' Type provided: ' . $collectionType->value; } diff --git a/lib/Exceptions/InvalidEbookTagTypeException.php b/lib/Exceptions/InvalidEbookTagTypeException.php index 70f9f81d..a14f95dc 100644 --- a/lib/Exceptions/InvalidEbookTagTypeException.php +++ b/lib/Exceptions/InvalidEbookTagTypeException.php @@ -1,13 +1,11 @@ message .= ' Type provided: ' . $tagType->value; } diff --git a/lib/Exceptions/InvalidFileUploadException.php b/lib/Exceptions/InvalidFileUploadException.php index 30c4ea87..1467af80 100644 --- a/lib/Exceptions/InvalidFileUploadException.php +++ b/lib/Exceptions/InvalidFileUploadException.php @@ -1,5 +1,4 @@ -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: diff --git a/lib/Library.php b/lib/Library.php index e1388363..8fdda6fe 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -16,7 +16,7 @@ class Library{ * @param array $tags * @return array{ebooks: array, 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, 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 diff --git a/lib/Payment.php b/lib/Payment.php index 750f08e8..e39a94ff 100644 --- a/lib/Payment.php +++ b/lib/Payment.php @@ -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; diff --git a/lib/Tag.php b/lib/Tag.php index caeba4c5..e8a0394b 100644 --- a/lib/Tag.php +++ b/lib/Tag.php @@ -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; } diff --git a/scripts/ingest-fa-payments b/scripts/ingest-fa-payments index 8cfe99f4..0c1460e0 100755 --- a/scripts/ingest-fa-payments +++ b/scripts/ingest-fa-payments @@ -73,7 +73,7 @@ function InsertTransaction(string $transactionId): bool{ values (utc_timestamp(), ?, ?)', - [PaymentProcessorType::FracturedAtlas, $transactionId]); + [Enums\PaymentProcessorType::FracturedAtlas, $transactionId]); return true; } diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index d91e430d..fc742b81 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -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(' diff --git a/templates/ArtworkForm.php b/templates/ArtworkForm.php index 13e251ec..6d40e958 100644 --- a/templates/ArtworkForm.php +++ b/templates/ArtworkForm.php @@ -87,7 +87,7 @@ $isEditForm = $isEditForm ?? false; type="file" name="artwork-image" required="required" - accept="" + accept="" /> @@ -179,9 +179,9 @@ $isEditForm = $isEditForm ?? false; Artwork approval status diff --git a/templates/ArtworkList.php b/templates/ArtworkList.php index 0bbbf15c..846c5c9e 100644 --- a/templates/ArtworkList.php +++ b/templates/ArtworkList.php @@ -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; } diff --git a/templates/EbookGrid.php b/templates/EbookGrid.php index bce9b05f..94546b63 100644 --- a/templates/EbookGrid.php +++ b/templates/EbookGrid.php @@ -4,10 +4,10 @@ * @var array $ebooks */ -$view = $view ?? ViewType::Grid; +$view = $view ?? Enums\ViewType::Grid; $collection = $collection ?? null; ?> -
    typeof="schema:BookSeries" about="Url ?>"> +
      typeof="schema:BookSeries" about="Url ?>"> @@ -26,7 +26,7 @@ $collection = $collection ?? null;

      Title) ?>

      - + Authors as $author){ ?>

      Name != 'Anonymous'){ ?>Name) ?>

      diff --git a/templates/SearchForm.php b/templates/SearchForm.php index 4d33c1e4..884d84f8 100644 --- a/templates/SearchForm.php +++ b/templates/SearchForm.php @@ -1,8 +1,8 @@ $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); Sort @@ -35,8 +35,8 @@ $isAllSelected = sizeof($tags) == 0 || in_array('all', $tags); View diff --git a/www/artworks/get.php b/www/artworks/get.php index 34e8b635..b0bde130 100644 --- a/www/artworks/get.php +++ b/www/artworks/get.php @@ -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){ Artwork approval status diff --git a/www/artworks/index.php b/www/artworks/index.php index 14905b2e..ca01db6e 100644 --- a/www/artworks/index.php +++ b/www/artworks/index.php @@ -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){ @@ -153,9 +153,9 @@ catch(Exceptions\PageOutOfBoundsException){ Sort diff --git a/www/artworks/new.php b/www/artworks/new.php index 11ca4a7f..698a535c 100644 --- a/www/artworks/new.php +++ b/www/artworks/new.php @@ -36,7 +36,7 @@ try{ $artwork->Artist = new Artist(); if($GLOBALS['User']->Benefits->CanReviewOwnArtwork){ - $artwork->Status = ArtworkStatusType::Approved; + $artwork->Status = Enums\ArtworkStatusType::Approved; } } } diff --git a/www/artworks/post.php b/www/artworks/post.php index 6c17b9b9..4764df2c 100644 --- a/www/artworks/post.php +++ b/www/artworks/post.php @@ -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(); diff --git a/www/collections/get.php b/www/collections/get.php index 9b443b39..79e11c78 100644 --- a/www/collections/get.php +++ b/www/collections/get.php @@ -50,7 +50,7 @@ catch(Exceptions\CollectionNotFoundException){

      No ebooks matched your filters. You can try different filters, or browse all of our ebooks.

      - $ebooks, 'view' => ViewType::Grid, 'collection' => $collectionObject]) ?> + $ebooks, 'view' => Enums\ViewType::Grid, 'collection' => $collectionObject]) ?>

      We also have bulk ebook downloads and a list of collections available, as well as ebook catalog feeds for use directly in your ereader app or RSS reader.

      diff --git a/www/ebooks/author.php b/www/ebooks/author.php index 2ef636d7..a0f25364 100644 --- a/www/ebooks/author.php +++ b/www/ebooks/author.php @@ -31,7 +31,7 @@ catch(Exceptions\AuthorNotFoundException){ Download collection Feeds for this author

      - $ebooks, 'view' => ViewType::Grid]) ?> + $ebooks, 'view' => Enums\ViewType::Grid]) ?>

      We also have bulk ebook downloads and a list of collections available, as well as ebook catalog feeds for use directly in your ereader app or RSS reader.

      diff --git a/www/ebooks/download.php b/www/ebooks/download.php index dc2ca290..d10ba59d 100644 --- a/www/ebooks/download.php +++ b/www/ebooks/download.php @@ -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; diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 5e0648eb..eb9893ed 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -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){

      - Compatible epub All devices and apps except Kindles and Kobos. + Compatible epub All devices and apps except Kindles and Kobos.

      @@ -232,7 +232,7 @@ catch(Exceptions\EbookNotFoundException){
    1. - azw3 Kindle devices and apps.KindleCoverUrl !== null){ ?> Also download the Kindle cover thumbnail to see the cover in your Kindle’s library. Despite what you’ve been told, Kindle does not natively support epub. You may also be interested in our Kindle FAQ. Also see our Kindle FAQ. + azw3 Kindle devices and apps.KindleCoverUrl !== null){ ?> Also download the Kindle cover thumbnail to see the cover in your Kindle’s library. Despite what you’ve been told, Kindle does not natively support epub. You may also be interested in our Kindle FAQ. Also see our Kindle FAQ.

    2. @@ -241,7 +241,7 @@ catch(Exceptions\EbookNotFoundException){
    3. - kepub Kobo devices and apps. You may also be interested in our Kobo FAQ. + kepub Kobo devices and apps. You may also be interested in our Kobo FAQ.

    4. @@ -250,7 +250,7 @@ catch(Exceptions\EbookNotFoundException){
    5. - Advanced epub An advanced format that uses the latest technology not yet fully supported by most ereaders. + Advanced epub An advanced format that uses the latest technology not yet fully supported by most ereaders.

    6. @@ -338,15 +338,15 @@ catch(Exceptions\EbookNotFoundException){
    7. - Type == EbookSourceType::ProjectGutenberg){ ?> + Type == Enums\EbookSourceType::ProjectGutenberg){ ?> Transcription at Project Gutenberg - Type == EbookSourceType::ProjectGutenbergAustralia){ ?> + Type == Enums\EbookSourceType::ProjectGutenbergAustralia){ ?> Transcription at Project Gutenberg Australia - Type == EbookSourceType::ProjectGutenbergCanada){ ?> + Type == Enums\EbookSourceType::ProjectGutenbergCanada){ ?> Transcription at Project Gutenberg Canada - Type == EbookSourceType::Wikisource){ ?> + Type == Enums\EbookSourceType::Wikisource){ ?> Transcription at Wikisource - Type == EbookSourceType::FadedPage){ ?> + Type == Enums\EbookSourceType::FadedPage){ ?> Transcription at Faded Page Transcription @@ -364,11 +364,11 @@ catch(Exceptions\EbookNotFoundException){

    8. - Type == EbookSourceType::InternetArchive){ ?> + Type == Enums\EbookSourceType::InternetArchive){ ?> Page scans at the Internet Archive - Type == EbookSourceType::HathiTrust){ ?> + Type == Enums\EbookSourceType::HathiTrust){ ?> Page scans at HathiTrust - Type == EbookSourceType::GoogleBooks){ ?> + Type == Enums\EbookSourceType::GoogleBooks){ ?> Page scans at Google Books Page scans @@ -386,7 +386,7 @@ catch(Exceptions\EbookNotFoundException){

    9. - Type == EbookSourceType::Other){ ?>Url)) /* force type to (string) to satisfy PHPStan */ ?> + Type == Enums\EbookSourceType::Other){ ?>Url)) /* force type to (string) to satisfy PHPStan */ ?>

    10. diff --git a/www/ebooks/index.php b/www/ebooks/index.php index 5945fb7a..fd9d7e34 100644 --- a/www/ebooks/index.php +++ b/www/ebooks/index.php @@ -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; } diff --git a/www/feeds/atom/search.php b/www/feeds/atom/search.php index 6c4e85df..8ff93c1d 100644 --- a/www/feeds/atom/search.php +++ b/www/feeds/atom/search.php @@ -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){ diff --git a/www/feeds/opds/search.php b/www/feeds/opds/search.php index 0fcf5a79..a61a3e94 100644 --- a/www/feeds/opds/search.php +++ b/www/feeds/opds/search.php @@ -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){ diff --git a/www/feeds/rss/search.php b/www/feeds/rss/search.php index be070929..a318e56f 100644 --- a/www/feeds/rss/search.php +++ b/www/feeds/rss/search.php @@ -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){ diff --git a/www/webhooks/zoho.php b/www/webhooks/zoho.php index 624fffc3..1aeadd05 100644 --- a/www/webhooks/zoho.php +++ b/www/webhooks/zoho.php @@ -39,7 +39,7 @@ try{ values (utc_timestamp(), ?, ?) - ', [PaymentProcessorType::FracturedAtlas, $transactionId]); + ', [Enums\PaymentProcessorType::FracturedAtlas, $transactionId]); $log->Write('Donation ID: ' . $transactionId); }