mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -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 $TextSinglePageUrl
|
||||||
* @property string $TextSinglePageSizeFormatted
|
* @property string $TextSinglePageSizeFormatted
|
||||||
* @property string $IndexableText
|
* @property string $IndexableText
|
||||||
* @property EbookPlaceholder $EbookPlaceholder
|
* @property ?EbookPlaceholder $EbookPlaceholder
|
||||||
*/
|
*/
|
||||||
class Ebook{
|
class Ebook{
|
||||||
use Traits\Accessor;
|
use Traits\Accessor;
|
||||||
|
|
|
@ -12,7 +12,7 @@ $collection = $collection ?? null;
|
||||||
<meta property="schema:name" content="<?= Formatter::EscapeHtml($collection->Name) ?>"/>
|
<meta property="schema:name" content="<?= Formatter::EscapeHtml($collection->Name) ?>"/>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? foreach($ebooks as $ebook){ ?>
|
<? 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){ ?>
|
<? if($collection !== null && $ebook->GetCollectionPosition($collection) !== null){ ?>
|
||||||
<meta property="schema:position" content="<?= $ebook->GetCollectionPosition($collection) ?>"/>
|
<meta property="schema:position" content="<?= $ebook->GetCollectionPosition($collection) ?>"/>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
|
@ -7,6 +7,10 @@ $ebook = null;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$ebook = Ebook::GetByIdentifier($identifier);
|
$ebook = Ebook::GetByIdentifier($identifier);
|
||||||
|
|
||||||
|
if($ebook->EbookPlaceholder === null){
|
||||||
|
throw new Exceptions\EbookNotFoundException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exceptions\EbookNotFoundException){
|
catch(Exceptions\EbookNotFoundException){
|
||||||
Template::Emit404();
|
Template::Emit404();
|
||||||
|
|
|
@ -19,19 +19,23 @@ try{
|
||||||
if($isCreated){
|
if($isCreated){
|
||||||
// We got here because an `Ebook` was successfully created.
|
// We got here because an `Ebook` was successfully created.
|
||||||
http_response_code(Enums\HttpCode::Created->value);
|
http_response_code(Enums\HttpCode::Created->value);
|
||||||
$createdEbook = clone $ebook;
|
if($ebook !== null){
|
||||||
|
$createdEbook = clone $ebook;
|
||||||
|
|
||||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
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.
|
// 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->EbookId);
|
||||||
unset($ebook->Title);
|
unset($ebook->Title);
|
||||||
$ebook->EbookPlaceholder->YearPublished = null;
|
if($ebook->EbookPlaceholder !== null){
|
||||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
$ebook->EbookPlaceholder->YearPublished = null;
|
||||||
$collectionMembership->SequenceNumber++;
|
}
|
||||||
|
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||||
|
$collectionMembership->SequenceNumber++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$ebook = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
$ebook = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session_unset();
|
session_unset();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue