mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Add Template::CollectionFormatted for common formatting
This commit is contained in:
parent
617d27ec92
commit
9652d63b12
4 changed files with 13 additions and 30 deletions
10
templates/CollectionFormatted.php
Normal file
10
templates/CollectionFormatted.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?
|
||||||
|
use function Safe\preg_replace;
|
||||||
|
|
||||||
|
$collectionMembership = $collectionMembership ?? null;
|
||||||
|
$collection = $collectionMembership?->Collection;
|
||||||
|
$sequenceNumber = $collectionMembership?->SequenceNumber;
|
||||||
|
?>
|
||||||
|
<? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
||||||
|
<? if($collection->Type !== null){ ?>
|
||||||
|
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?><?= $collection->Type->value ?><? } ?><? }else{ ?>collection<? } ?>
|
|
@ -77,17 +77,8 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
||||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||||
<? $collection = $collectionMembership->Collection; ?>
|
|
||||||
<? $sequenceNumber = $collectionMembership->SequenceNumber; ?>
|
|
||||||
<p>
|
<p>
|
||||||
<? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
<?= Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
|
||||||
<? if($collection->Type !== null){ ?>
|
|
||||||
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?>
|
|
||||||
<?= $collection->Type->value ?>.
|
|
||||||
<? } ?>
|
|
||||||
<? }else{ ?>
|
|
||||||
collection.
|
|
||||||
<? } ?>
|
|
||||||
</p>
|
</p>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
|
@ -131,17 +131,8 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
||||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||||
<? $collection = $collectionMembership->Collection; ?>
|
|
||||||
<? $sequenceNumber = $collectionMembership->SequenceNumber; ?>
|
|
||||||
<p>
|
<p>
|
||||||
<? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
<?= Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
|
||||||
<? if($collection->Type !== null){ ?>
|
|
||||||
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?>
|
|
||||||
<?= $collection->Type->value ?>.
|
|
||||||
<? } ?>
|
|
||||||
<? }else{ ?>
|
|
||||||
collection.
|
|
||||||
<? } ?>
|
|
||||||
</p>
|
</p>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
|
@ -68,17 +68,8 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
<? if(sizeof($ebook->CollectionMemberships) > 0){ ?>
|
||||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||||
<? $collection = $collectionMembership->Collection; ?>
|
|
||||||
<? $sequenceNumber = $collectionMembership->SequenceNumber; ?>
|
|
||||||
<p>
|
<p>
|
||||||
<? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
<?= Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
|
||||||
<? if($collection->Type !== null){ ?>
|
|
||||||
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?>
|
|
||||||
<?= $collection->Type->value ?>.
|
|
||||||
<? } ?>
|
|
||||||
<? }else{ ?>
|
|
||||||
collection.
|
|
||||||
<? } ?>
|
|
||||||
</p>
|
</p>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue