mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 02:21:55 -04:00
Add endpoint to get collections for an ebook or placeholder
This commit is contained in:
parent
ed5540c177
commit
bdeebc8291
3 changed files with 32 additions and 1 deletions
|
@ -1,5 +1,4 @@
|
|||
<?
|
||||
use function Safe\preg_replace;
|
||||
use function Safe\session_unset;
|
||||
|
||||
session_start();
|
||||
|
|
29
www/ebooks/collections.php
Normal file
29
www/ebooks/collections.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?
|
||||
$identifier = EBOOKS_IDENTIFIER_PREFIX . trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after `https://standardebooks.org/ebooks/`.
|
||||
|
||||
$ebook = null;
|
||||
|
||||
try{
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
Template::ExitWithCode(Enums\HttpCode::NotFound);
|
||||
}
|
||||
|
||||
header('content-type: application/xml; charset=utf-8');
|
||||
print('<?xml version="1.0" encoding="utf-8"?>');
|
||||
print("\n");
|
||||
?>
|
||||
<collections>
|
||||
<? foreach($ebook->CollectionMemberships as $collectionMembership){ ?>
|
||||
<collection>
|
||||
<meta id="collection-<?= $collectionMembership->SortOrder + 1 ?>" property="belongs-to-collection"><?= Formatter::EscapeXml($collectionMembership->Collection->Name) ?></meta>
|
||||
<? if($collectionMembership->Collection->Type !== null){ ?>
|
||||
<meta property="collection-type" refines="#collection-<?= $collectionMembership->SortOrder + 1 ?>"><?= $collectionMembership->Collection->Type->value ?></meta>
|
||||
<? } ?>
|
||||
<? if($collectionMembership->SequenceNumber !== null){ ?>
|
||||
<meta property="group-position" refines="#collection-<?= $collectionMembership->SortOrder + 1 ?>"><?= $collectionMembership->SequenceNumber ?></meta>
|
||||
<? } ?>
|
||||
</collection>
|
||||
<? } ?>
|
||||
</collections>
|
Loading…
Add table
Add a link
Reference in a new issue