mirror of
https://github.com/standardebooks/web.git
synced 2025-07-09 16:20:27 -04:00
Some type check fixes
This commit is contained in:
parent
1979b27432
commit
79fdc8c20f
4 changed files with 21 additions and 13 deletions
|
@ -41,7 +41,7 @@ use function Safe\shell_exec;
|
|||
* @property string $TextSinglePageUrl
|
||||
* @property string $TextSinglePageSizeFormatted
|
||||
* @property string $IndexableText
|
||||
* @property EbookPlaceholder $EbookPlaceholder
|
||||
* @property ?EbookPlaceholder $EbookPlaceholder
|
||||
*/
|
||||
class Ebook{
|
||||
use Traits\Accessor;
|
||||
|
|
|
@ -12,7 +12,7 @@ $collection = $collection ?? null;
|
|||
<meta property="schema:name" content="<?= Formatter::EscapeHtml($collection->Name) ?>"/>
|
||||
<? } ?>
|
||||
<? foreach($ebooks as $ebook){ ?>
|
||||
<li typeof="schema:Book"<? if($collection !== null){ ?> resource="<?= $ebook->Url ?>" property="schema:hasPart"<? if($ebook->GetCollectionPosition($collection) !== null){ ?> value="<?= $ebook->GetCollectionPosition($collection) ?>"<? } ?><? }else{ ?> about="<?= $ebook->Url ?>"<? } ?><? if($ebook->EbookPlaceholder?->IsWanted){ ?> class="ribbon <? if($ebook->EbookPlaceholder?->Status == \Enums\EbookPlaceholderStatus::InProgress){ ?>in-progress<? }else{ ?>wanted<? } ?>"<? }elseif($ebook->EbookPlaceholder !== null && !$ebook->EbookPlaceholder->IsPublicDomain){ ?> class="ribbon not-pd"<? } ?>>
|
||||
<li typeof="schema:Book"<? if($collection !== null){ ?> resource="<?= $ebook->Url ?>" property="schema:hasPart"<? if($ebook->GetCollectionPosition($collection) !== null){ ?> value="<?= $ebook->GetCollectionPosition($collection) ?>"<? } ?><? }else{ ?> about="<?= $ebook->Url ?>"<? } ?><? if($ebook->EbookPlaceholder?->IsWanted){ ?> class="ribbon <? if($ebook->EbookPlaceholder->Status == \Enums\EbookPlaceholderStatus::InProgress){ ?>in-progress<? }else{ ?>wanted<? } ?>"<? }elseif($ebook->EbookPlaceholder !== null && !$ebook->EbookPlaceholder->IsPublicDomain){ ?> class="ribbon not-pd"<? } ?>>
|
||||
<? if($collection !== null && $ebook->GetCollectionPosition($collection) !== null){ ?>
|
||||
<meta property="schema:position" content="<?= $ebook->GetCollectionPosition($collection) ?>"/>
|
||||
<? } ?>
|
||||
|
|
|
@ -7,6 +7,10 @@ $ebook = null;
|
|||
|
||||
try{
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
|
||||
if($ebook->EbookPlaceholder === null){
|
||||
throw new Exceptions\EbookNotFoundException();
|
||||
}
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
Template::Emit404();
|
||||
|
|
|
@ -19,19 +19,23 @@ try{
|
|||
if($isCreated){
|
||||
// We got here because an `Ebook` was successfully created.
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
$createdEbook = clone $ebook;
|
||||
if($ebook !== null){
|
||||
$createdEbook = clone $ebook;
|
||||
|
||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
||||
// If the `EbookPlaceholder` we just added is part of a collection, prefill the form with the same data to make it easier to submit series.
|
||||
unset($ebook->EbookId);
|
||||
unset($ebook->Title);
|
||||
$ebook->EbookPlaceholder->YearPublished = null;
|
||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||
$collectionMembership->SequenceNumber++;
|
||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
||||
// If the `EbookPlaceholder` we just added is part of a collection, prefill the form with the same data to make it easier to submit series.
|
||||
unset($ebook->EbookId);
|
||||
unset($ebook->Title);
|
||||
if($ebook->EbookPlaceholder !== null){
|
||||
$ebook->EbookPlaceholder->YearPublished = null;
|
||||
}
|
||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||
$collectionMembership->SequenceNumber++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ebook = null;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ebook = null;
|
||||
}
|
||||
|
||||
session_unset();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue