Use the se:is-a-collection metadata element to decide if we search the ToC

This commit is contained in:
Alex Cabal 2022-06-25 14:55:31 -05:00
parent 86ae801f84
commit 70fbce410c

View file

@ -57,7 +57,7 @@ class Ebook{
public $ModifiedTimestamp; public $ModifiedTimestamp;
public $TextUrl; public $TextUrl;
public $TextSinglePageUrl; public $TextSinglePageUrl;
public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'shorts' or 'poetry' tag, null otherwise public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise
public function __construct(string $wwwFilesystemPath){ public function __construct(string $wwwFilesystemPath){
// First, construct a source repo path from our WWW filesystem path. // First, construct a source repo path from our WWW filesystem path.
@ -198,11 +198,9 @@ class Ebook{
$includeToc = false; $includeToc = false;
foreach($xml->xpath('/package/metadata/meta[@property="se:subject"]') ?: [] as $tag){ foreach($xml->xpath('/package/metadata/meta[@property="se:subject"]') ?: [] as $tag){
$this->Tags[] = new Tag($tag); $this->Tags[] = new Tag($tag);
}
if($tag == 'Shorts' || $tag == 'Poetry'){ $includeToc = sizeof($xml->xpath('/package/metadata/meta[@property="se:is-a-collection"]') ?: []) > 0;
$includeToc = true;
}
}
// Fill the ToC if necessary // Fill the ToC if necessary
if($includeToc){ if($includeToc){