mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 15:20:32 -04:00
Artwork system: More options for reviewers submitting new artwork
This commit is contained in:
parent
8e955bf357
commit
017baef7d3
6 changed files with 66 additions and 37 deletions
|
@ -309,6 +309,15 @@ class Artwork extends PropertiesBase{
|
|||
$error->Add(new Exceptions\InvalidMimeTypeException());
|
||||
}
|
||||
|
||||
// Check the ebook www filesystem path.
|
||||
// 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->EbookWwwFilesystemPath !== null){
|
||||
if(mb_stripos($this->EbookWwwFilesystemPath, '_') === false){
|
||||
$error->Add(new Exceptions\InvalidEbookException('Invalid ebook. Expected file system slug like “c-s-lewis_poetry”.'));
|
||||
}
|
||||
}
|
||||
|
||||
// Check for existing Artwork objects with the same URL but different Artwork IDs.
|
||||
try{
|
||||
$existingArtwork = Artwork::GetByUrl($this->Artist->UrlName, $this->UrlName);
|
||||
|
|
|
@ -273,7 +273,12 @@ class Library{
|
|||
try{
|
||||
$results = apcu_fetch($variable);
|
||||
}
|
||||
catch(Safe\Exceptions\ApcuException){
|
||||
catch(Safe\Exceptions\ApcuException $ex){
|
||||
try{
|
||||
// If we can't fetch this variable, rebuild the whole cache.
|
||||
apcu_fetch('is-cache-fresh');
|
||||
}
|
||||
catch(Safe\Exceptions\ApcuException $ex){
|
||||
Library::RebuildCache();
|
||||
try{
|
||||
$results = apcu_fetch($variable);
|
||||
|
@ -291,6 +296,7 @@ class Library{
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_array($results)){
|
||||
$results = [$results];
|
||||
|
@ -686,6 +692,8 @@ class Library{
|
|||
}
|
||||
|
||||
apcu_delete($lockVar);
|
||||
|
||||
apcu_store('is-cache-fresh', true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,5 +5,5 @@ $artwork = $artwork ?? null;
|
|||
<? if($artwork->Status === COVER_ARTWORK_STATUS_APPROVED){ ?>Approved<? } ?>
|
||||
<? if($artwork->Status === COVER_ARTWORK_STATUS_DECLINED){ ?>Declined<? } ?>
|
||||
<? if($artwork->Status === COVER_ARTWORK_STATUS_UNVERIFIED){ ?>Unverified<? } ?>
|
||||
<? if($artwork->Status === COVER_ARTWORK_STATUS_IN_USE){ ?>In use<? if($artwork->Ebook !== null && $artwork->Ebook->Url !== null){ ?> for <i><a href="<?= $artwork->Ebook->Url ?>"><?= Formatter::ToPlainText($artwork->Ebook->Title) ?></a></i><? } ?><? } ?>
|
||||
<? if($artwork->Status === COVER_ARTWORK_STATUS_IN_USE){ ?>In use<? if($artwork->EbookWwwFilesystemPath !== null){ ?> for <? if($artwork->Ebook !== null && $artwork->Ebook->Url !== null){ ?><i><a href="<?= $artwork->Ebook->Url ?>"><?= Formatter::ToPlainText($artwork->Ebook->Title) ?></a></i><? }else{ ?><?= Formatter::ToPlainText($artwork->EbookWwwFilesystemPath) ?><? } ?><? } ?><? } ?>
|
||||
<? } ?>
|
||||
|
|
|
@ -173,6 +173,15 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
value="<?= $artwork->PublicationYear ?>"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="artwork-is-published-in-us"
|
||||
value="true"
|
||||
<? if($artwork->IsPublishedInUs){ ?> checked="checked"<? } ?> />
|
||||
<span>This book was published in the U.S.</span>
|
||||
<span>Yes, if a U.S. city appears anywhere near the publication year or rights statement.</span>
|
||||
</label>
|
||||
<label>
|
||||
<span>URL of page with year of publication</span>
|
||||
<span>Roman numerals on the page scan are OK.</span>
|
||||
|
@ -194,16 +203,8 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
/>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="artwork-is-published-in-us"
|
||||
value="true"
|
||||
<? if($artwork->IsPublishedInUs){ ?> checked="checked"<? } ?> />
|
||||
<span>This book was published in the U.S.</span>
|
||||
<span>Yes, if a U.S. city appears anywhere near the publication year or rights statement.</span>
|
||||
</label>
|
||||
<label>
|
||||
URL of page with artwork
|
||||
<span>URL of page with artwork</span>
|
||||
<span>Review the many <a href="/manual/latest/10-art-and-images#10.3.3.7.1.1">gotchas you may encounter</a> when confirming the reproduction is the exact same painting.</span>
|
||||
<input
|
||||
type="url"
|
||||
name="artwork-artwork-page-url"
|
||||
|
@ -224,13 +225,21 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
<? if($GLOBALS['User']->Benefits->CanReviewArtwork){ ?>
|
||||
<fieldset>
|
||||
<legend>Reviewer options</legend>
|
||||
<label class="select">
|
||||
<span>Artwork approval status</span>
|
||||
<span>
|
||||
<select name="artwork-status">
|
||||
<option value="<?= COVER_ARTWORK_STATUS_UNVERIFIED ?>"<? if($artwork->Status == COVER_ARTWORK_STATUS_UNVERIFIED){ ?> selected="selected"<? } ?>>Unverified</option>
|
||||
<option value="<?= COVER_ARTWORK_STATUS_DECLINED ?>"<? if($artwork->Status == COVER_ARTWORK_STATUS_DECLINED){ ?> selected="selected"<? } ?>>Declined</option>
|
||||
<option value="<?= COVER_ARTWORK_STATUS_APPROVED ?>"<? if($artwork->Status == COVER_ARTWORK_STATUS_APPROVED){ ?> selected="selected"<? } ?>>Approved</option>
|
||||
<option value="<?= COVER_ARTWORK_STATUS_IN_USE ?>"<? if($artwork->Status == COVER_ARTWORK_STATUS_IN_USE){ ?> selected="selected"<? } ?>>In use</option>
|
||||
</select>
|
||||
</span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="artwork-status"
|
||||
value="<?= COVER_ARTWORK_STATUS_APPROVED ?>"
|
||||
<? if($artwork->Status == COVER_ARTWORK_STATUS_APPROVED){ ?> checked="checked"<? } ?> />
|
||||
Approve this artwork immediately
|
||||
<span>In use by</span>
|
||||
<span>Ebook file system slug, like <code>c-s-lewis_poetry</code>. If not in use, leave this blank.</span>
|
||||
<input type="text" name="artwork-ebook-www-filesystem-path" value="<?= Formatter::ToPlainText($artwork->EbookWwwFilesystemPath) ?>"/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<? } ?>
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?
|
||||
use Exceptions\InvalidRequestException;
|
||||
|
||||
use function Safe\ini_get;
|
||||
use function Safe\substr;
|
||||
|
||||
try{
|
||||
session_start();
|
||||
|
||||
if(HttpInput::RequestMethod() != HTTP_POST){
|
||||
throw new InvalidRequestException('Only HTTP POST accepted.');
|
||||
throw new Exceptions\InvalidRequestException('Only HTTP POST accepted.');
|
||||
}
|
||||
|
||||
if(HttpInput::IsRequestTooLarge()){
|
||||
|
@ -33,7 +28,8 @@ try{
|
|||
$artwork->CompletedYear = HttpInput::Int(POST, 'artwork-year');
|
||||
$artwork->CompletedYearIsCirca = HttpInput::Bool(POST, 'artwork-year-is-circa', false);
|
||||
$artwork->Tags = Artwork::ParseTags(HttpInput::Str(POST, 'artwork-tags', false));
|
||||
$artwork->Status = HttpInput::Str(POST, 'artwork-status', false) ?? COVER_ARTWORK_STATUS_UNVERIFIED;
|
||||
$artwork->Status = HttpInput::Str(POST, 'artwork-status', false, COVER_ARTWORK_STATUS_UNVERIFIED);
|
||||
$artwork->EbookWwwFilesystemPath = HttpInput::Str(POST, 'artwork-ebook-www-filesystem-path', false);
|
||||
$artwork->SubmitterUserId = $GLOBALS['User']->UserId ?? null;
|
||||
$artwork->IsPublishedInUs = HttpInput::Bool(POST, 'artwork-is-published-in-us', false);
|
||||
$artwork->PublicationYear = HttpInput::Int(POST, 'artwork-publication-year');
|
||||
|
@ -49,6 +45,11 @@ try{
|
|||
throw new Exceptions\InvalidPermissionsException();
|
||||
}
|
||||
|
||||
// If the artwork is approved, set the reviewer
|
||||
if($artwork->Status != COVER_ARTWORK_STATUS_UNVERIFIED){
|
||||
$artwork->ReviewerUserId = $GLOBALS['User']->UserId;
|
||||
}
|
||||
|
||||
$artwork->Create($_FILES['artwork-image'] ?? []);
|
||||
|
||||
$_SESSION['artwork'] = $artwork;
|
||||
|
@ -63,11 +64,8 @@ catch(Exceptions\LoginRequiredException){
|
|||
catch(Exceptions\InvalidPermissionsException){
|
||||
Template::Emit403();
|
||||
}
|
||||
catch(Exceptions\InvalidRequestException){
|
||||
http_response_code(405);
|
||||
}
|
||||
catch(Exceptions\AppException $exception){
|
||||
$_SESSION['artwork'] = $artwork;
|
||||
$_SESSION['artwork'] = $artwork ?? null;
|
||||
$_SESSION['exception'] = $exception;
|
||||
|
||||
http_response_code(303);
|
||||
|
|
|
@ -1756,6 +1756,10 @@ label span + span{
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
label span + span code{
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
label span + span i{
|
||||
font-style: normal;
|
||||
}
|
||||
|
@ -1798,6 +1802,7 @@ label.select > span + span{
|
|||
|
||||
label.select > span + span::after{
|
||||
display: block;
|
||||
font-style: normal;
|
||||
position: absolute;
|
||||
top: calc((2rem + 1.4rem + 2px) / 2 - 10px);
|
||||
right: calc(1rem - 12px / 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue