From c8cacc4ace03e7bc7e411c5567ac701c127004a1 Mon Sep 17 00:00:00 2001
From: Alex Cabal
Date: Fri, 22 May 2020 15:59:00 -0500
Subject: [PATCH] Add series number to collection headline
---
lib/Collection.php | 1 +
lib/Ebook.php | 3 +++
www/ebooks/ebook.php | 4 ++--
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/Collection.php b/lib/Collection.php
index 857b3d05..7247cc8f 100644
--- a/lib/Collection.php
+++ b/lib/Collection.php
@@ -3,6 +3,7 @@ class Collection{
public $Name;
public $Url;
public $SequenceNumber = null;
+ public $Type = null;
public function __construct(string $name){
$this->Name = $name;
diff --git a/lib/Ebook.php b/lib/Ebook.php
index 4d1559e5..03a4ba0f 100644
--- a/lib/Ebook.php
+++ b/lib/Ebook.php
@@ -170,6 +170,9 @@ class Ebook{
foreach($xml->xpath('/package/metadata/meta[@refines="#' . $collection->attributes()->id . '"][@property="group-position"]') ?: [] as $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;
}
diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php
index 76332635..3575ea1a 100644
--- a/www/ebooks/ebook.php
+++ b/www/ebooks/ebook.php
@@ -79,11 +79,11 @@ catch(\Exception $ex){
= $ebook->ContributorsHtml ?>
} ?>
if(sizeof($ebook->Collections) > 0){ ?>
- Part of the
+
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++){ ?>
= Formatter::ToPlainText(preg_replace('/^The /ius', '', (string)$ebook->Collections[$i]->Name) ?? '') ?> 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 } ?>.
+ 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 } ?> } ?>.
} ?>