diff --git a/templates/CollectionFormatted.php b/templates/CollectionFormatted.php new file mode 100644 index 00000000..5ba87132 --- /dev/null +++ b/templates/CollectionFormatted.php @@ -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 } ?> = Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?> + 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 } ?> diff --git a/www/ebook-placeholders/get.php b/www/ebook-placeholders/get.php index ae66f66c..24b42f15 100644 --- a/www/ebook-placeholders/get.php +++ b/www/ebook-placeholders/get.php @@ -77,17 +77,8 @@ catch(Exceptions\EbookNotFoundException){ } ?> if(sizeof($ebook->CollectionMemberships) > 0){ ?> foreach($ebook->CollectionMemberships as $collectionMembership){ ?> - $collection = $collectionMembership->Collection; ?> - $sequenceNumber = $collectionMembership->SequenceNumber; ?>
- if($sequenceNumber !== null){ ?>№ = number_format($sequenceNumber) ?> in the }else{ ?>Part of the } ?> = Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?> - 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. - } ?> + = Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
} ?> } ?> diff --git a/www/ebooks/get.php b/www/ebooks/get.php index ab3351ef..6f9689fc 100644 --- a/www/ebooks/get.php +++ b/www/ebooks/get.php @@ -131,17 +131,8 @@ catch(Exceptions\EbookNotFoundException){ } ?> if(sizeof($ebook->CollectionMemberships) > 0){ ?> foreach($ebook->CollectionMemberships as $collectionMembership){ ?> - $collection = $collectionMembership->Collection; ?> - $sequenceNumber = $collectionMembership->SequenceNumber; ?>- if($sequenceNumber !== null){ ?>№ = number_format($sequenceNumber) ?> in the }else{ ?>Part of the } ?> = Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?> - 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. - } ?> + = Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
} ?> } ?> diff --git a/www/ebooks/public-domain-day-placeholder.php b/www/ebooks/public-domain-day-placeholder.php index a8974ce3..be43aae7 100644 --- a/www/ebooks/public-domain-day-placeholder.php +++ b/www/ebooks/public-domain-day-placeholder.php @@ -68,17 +68,8 @@ catch(Exceptions\EbookNotFoundException){ } ?> if(sizeof($ebook->CollectionMemberships) > 0){ ?> foreach($ebook->CollectionMemberships as $collectionMembership){ ?> - $collection = $collectionMembership->Collection; ?> - $sequenceNumber = $collectionMembership->SequenceNumber; ?>- if($sequenceNumber !== null){ ?>№ = number_format($sequenceNumber) ?> in the }else{ ?>Part of the } ?> = Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?> - 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. - } ?> + = Template::CollectionFormatted(['collectionMembership' => $collectionMembership]) ?>.
} ?> } ?>