mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 18:11:52 -04:00
Add special 'query-ebook-url' parameter to /artworks to get covers matching exactly the ebook URL
This commit is contained in:
parent
3ebe6fe457
commit
801b5f524a
2 changed files with 9 additions and 2 deletions
|
@ -501,7 +501,7 @@ class Artwork extends PropertiesBase{
|
|||
// We don't check if it exists, because the book might not be published yet.
|
||||
// But we do a basic check that the string includes one _. It might not include a dash, for example anonymous_poetry
|
||||
if($this->EbookUrl !== null){
|
||||
if(!preg_match('|^https://standardebooks.org/ebooks/|ius', $this->EbookUrl)){
|
||||
if(!preg_match('|^https://standardebooks.org/ebooks/[^/]+?/[^/]+?|ius', $this->EbookUrl)){
|
||||
$error->Add(new Exceptions\EbookNotFoundException('Invalid ebook. Expected S.E. URL.'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
$page = HttpInput::Int(GET, 'page') ?? 1;
|
||||
$perPage = HttpInput::Int(GET, 'per-page') ?? ARTWORK_PER_PAGE;
|
||||
$query = HttpInput::Str(GET, 'query') ?? '';
|
||||
$queryEbookUrl = HttpInput::Str(GET, 'query-ebook-url');
|
||||
$status = HttpInput::Str(GET, 'status') ?? null;
|
||||
$filterArtworkStatus = $status;
|
||||
$sort = HttpInput::Str(GET, 'sort');
|
||||
|
@ -64,7 +65,13 @@ if($isSubmitterView && !in_array($status, array('all', ArtworkStatus::Unverified
|
|||
$filterArtworkStatus = $status;
|
||||
}
|
||||
|
||||
$artworks = Library::FilterArtwork($query != '' ? $query : null, $filterArtworkStatus, $sort, $submitterUserId);
|
||||
if($queryEbookUrl !== null){
|
||||
$artworks = Db::Query('SELECT * from Artworks where EbookUrl = ? and Status = ?', [$queryEbookUrl, ArtworkStatus::Approved], 'Artwork');
|
||||
}
|
||||
else{
|
||||
$artworks = Library::FilterArtwork($query != '' ? $query : null, $filterArtworkStatus, $sort, $submitterUserId);
|
||||
}
|
||||
|
||||
$pageTitle = 'Browse Artwork';
|
||||
$pages = ceil(sizeof($artworks) / $perPage);
|
||||
$totalArtworkCount = sizeof($artworks);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue