Add series number to collection headline

This commit is contained in:
Alex Cabal 2020-05-22 15:59:00 -05:00
parent 2b07471252
commit c8cacc4ace
3 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@ class Collection{
public $Name; public $Name;
public $Url; public $Url;
public $SequenceNumber = null; public $SequenceNumber = null;
public $Type = null;
public function __construct(string $name){ public function __construct(string $name){
$this->Name = $name; $this->Name = $name;

View file

@ -170,6 +170,9 @@ class Ebook{
foreach($xml->xpath('/package/metadata/meta[@refines="#' . $collection->attributes()->id . '"][@property="group-position"]') ?: [] as $s){ foreach($xml->xpath('/package/metadata/meta[@refines="#' . $collection->attributes()->id . '"][@property="group-position"]') ?: [] as $s){
$c->SequenceNumber = (int)$s; $c->SequenceNumber = (int)$s;
} }
foreach($xml->xpath('/package/metadata/meta[@refines="#' . $collection->attributes()->id . '"][@property="collection-type"]') ?: [] as $s){
$c->Type = (string)$s;
}
$this->Collections[] = $c; $this->Collections[] = $c;
} }

View file

@ -79,11 +79,11 @@ catch(\Exception $ex){
<p><?= $ebook->ContributorsHtml ?></p> <p><?= $ebook->ContributorsHtml ?></p>
<? } ?> <? } ?>
<? if(sizeof($ebook->Collections) > 0){ ?> <? if(sizeof($ebook->Collections) > 0){ ?>
<p>Part of the <p><? if(sizeof($ebook->Collections) == 1 && $ebook->Collections[0]->SequenceNumber !== null){ ?>№ <?= number_format($ebook->Collections[0]->SequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?>
<? for($i = 0; $i < sizeof($ebook->Collections); $i++){ ?> <? for($i = 0; $i < sizeof($ebook->Collections); $i++){ ?>
<a href="<?= $ebook->Collections[$i]->Url ?>"><?= Formatter::ToPlainText(preg_replace('/^The /ius', '', (string)$ebook->Collections[$i]->Name) ?? '') ?></a><? if(sizeof($ebook->Collections) > 2){ ?><? if($i == sizeof($ebook->Collections) - 2){ ?>, and <? }elseif($i != sizeof($ebook->Collections) - 1){ ?>, <? } ?><? }elseif($i == sizeof($ebook->Collections) - 2){ ?> and <? } ?> <a href="<?= $ebook->Collections[$i]->Url ?>"><?= Formatter::ToPlainText(preg_replace('/^The /ius', '', (string)$ebook->Collections[$i]->Name) ?? '') ?></a><? if(sizeof($ebook->Collections) > 2){ ?><? if($i == sizeof($ebook->Collections) - 2){ ?>, and <? }elseif($i != sizeof($ebook->Collections) - 1){ ?>, <? } ?><? }elseif($i == sizeof($ebook->Collections) - 2){ ?> and <? } ?>
<? } ?> <? } ?>
collection<? if(sizeof($ebook->Collections) > 1){ ?>s<? } ?>.</p> <? if(sizeof($ebook->Collections) == 1 && $ebook->Collections[0]->Type !== null){ ?><? if(substr_compare(mb_strtolower($ebook->Collections[0]->Name), mb_strtolower($ebook->Collections[0]->Type), -strlen(mb_strtolower($ebook->Collections[0]->Type))) !== 0){ ?><?= $ebook->Collections[0]->Type ?><? } ?><? }else{ ?>collection<? if(sizeof($ebook->Collections) > 1){ ?>s<? } ?><? } ?>.</p>
<? } ?> <? } ?>
<ul class="tags"><? foreach($ebook->Tags as $tag){ ?><li><a href="<?= $tag->Url ?>"><?= Formatter::ToPlainText($tag->Name) ?></a></li><? } ?></ul> <ul class="tags"><? foreach($ebook->Tags as $tag){ ?><li><a href="<?= $tag->Url ?>"><?= Formatter::ToPlainText($tag->Name) ?></a></li><? } ?></ul>
</aside> </aside>