Refactor Library::FilterEbooks and Template::SearchForm to accept EbookSort

This commit is contained in:
Mike Colagrosso 2024-01-29 23:45:31 -07:00 committed by Alex Cabal
parent 980ed8cea9
commit d95d9b3349
3 changed files with 13 additions and 17 deletions

View file

@ -8,7 +8,7 @@ try{
$tags = HttpInput::GetArray('tags') ?? [];
$collection = HttpInput::Str(GET, 'collection');
$view = HttpInput::Str(GET, 'view');
$sort = HttpInput::Str(GET, 'sort');
$sort = EbookSort::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
$pages = 0;
$totalEbooks = 0;
$collectionObject = null;
@ -35,15 +35,11 @@ try{
$view = mb_strtolower($view);
}
if($sort !== null){
$sort = mb_strtolower($sort);
}
if($view === 'grid'){
$view = null;
}
if($sort === 'newest'){
if($sort == EbookSort::Newest){
$sort = null;
}
@ -103,7 +99,7 @@ try{
}
if($sort !== null){
$queryString .= '&sort=' . urlencode($sort);
$queryString .= '&sort=' . urlencode($sort->value);
}
if($perPage !== EBOOKS_PER_PAGE){