Convert some constants to enums

This commit is contained in:
Alex Cabal 2024-01-14 22:32:47 -06:00
parent 793d832e92
commit 531e3600ea
14 changed files with 93 additions and 248 deletions

View file

@ -2,7 +2,7 @@
use function Safe\preg_replace;
$page = HttpInput::Int(GET, 'page') ?? 1;
$perPage = HttpInput::Int(GET, 'per-page') ?? COVER_ARTWORK_PER_PAGE;
$perPage = HttpInput::Int(GET, 'per-page') ?? ARTWORK_PER_PAGE;
$query = HttpInput::Str(GET, 'query', false) ?? '';
$status = HttpInput::Str(GET, 'status', false) ?? null;
$sort = HttpInput::Str(GET, 'sort', false);
@ -17,8 +17,8 @@ if($page <= 0){
$page = 1;
}
if($perPage != COVER_ARTWORK_PER_PAGE && $perPage != 40 && $perPage != 80){
$perPage = COVER_ARTWORK_PER_PAGE;
if($perPage != ARTWORK_PER_PAGE && $perPage != 40 && $perPage != 80){
$perPage = ARTWORK_PER_PAGE;
}
// If we're passed string values that are the same as the defaults,
@ -37,8 +37,8 @@ if($status == 'all'){
}
}
if(!$isAdminView && $status !== 'all' && $status != COVER_ARTWORK_STATUS_APPROVED && $status != COVER_ARTWORK_STATUS_IN_USE){
$status = COVER_ARTWORK_STATUS_APPROVED;
if(!$isAdminView && $status !== 'all' && $status != ArtworkStatus::Approved->value && $status != ArtworkStatus::InUse->value){
$status = ArtworkStatus::Approved->value;
}
$artworks = Library::FilterArtwork($query != '' ? $query : null, $status, $sort);
@ -65,7 +65,7 @@ if($sort !== null){
$queryString .= '&amp;sort=' . urlencode($sort);
}
if($perPage !== COVER_ARTWORK_PER_PAGE){
if($perPage !== ARTWORK_PER_PAGE){
$queryString .= '&amp;per-page=' . urlencode((string)$perPage);
}
@ -80,10 +80,10 @@ if($perPage !== COVER_ARTWORK_PER_PAGE){
<span>
<select name="status" size="1">
<option value="all"<? if($status === null){ ?> selected="selected"<? } ?>>All</option>
<? if($isAdminView){ ?><option value="<?= COVER_ARTWORK_STATUS_UNVERIFIED ?>"<? if($status == COVER_ARTWORK_STATUS_UNVERIFIED){ ?> selected="selected"<? } ?>>Unverified</option><? } ?>
<? if($isAdminView){ ?><option value="<?= COVER_ARTWORK_STATUS_DECLINED ?>"<? if($status == COVER_ARTWORK_STATUS_DECLINED){ ?> selected="selected"<? } ?>>Declined</option><? } ?>
<option value="<?= COVER_ARTWORK_STATUS_APPROVED ?>"<? if($status == COVER_ARTWORK_STATUS_APPROVED){ ?> selected="selected"<? } ?>>Approved</option>
<option value="<?= COVER_ARTWORK_STATUS_IN_USE ?>"<? if($status == COVER_ARTWORK_STATUS_IN_USE){ ?> selected="selected"<? } ?>>In use</option>
<? if($isAdminView){ ?><option value="<?= ArtworkStatus::Unverified->value ?>"<? if($status == ArtworkStatus::Unverified->value){ ?> selected="selected"<? } ?>>Unverified</option><? } ?>
<? if($isAdminView){ ?><option value="<?= ArtworkStatus::Declined->value ?>"<? if($status == ArtworkStatus::Declined->value){ ?> selected="selected"<? } ?>>Declined</option><? } ?>
<option value="<?= ArtworkStatus::Approved->value ?>"<? if($status == ArtworkStatus::Approved->value){ ?> selected="selected"<? } ?>>Approved</option>
<option value="<?= ArtworkStatus::InUse->value ?>"<? if($status == ArtworkStatus::InUse->value){ ?> selected="selected"<? } ?>>In use</option>
</select>
</span>
</label>