<?php declare(strict_types=1); ?>

<!-- Display a single audio soundtrack object -->
<?php if ($content): ?>
<!-- Title and meta information -->
<div>
  <h2 class="title">
    <?php if ($content->isValidMedia()): ?>
    <a href="<?php echo TFISH_URL . 'enclosure.php?id=' . $content->escapeForXss('id'); ?>"><?php echo $content->icon; ?> <?php echo $content->escapeForXss('title'); ?></a>
    <?php else: ?>
    <?php echo $content->icon . ' ' . $content->escapeForXss('title'); ?>
    <?php endif; ?>
    </h2>
    <?php if ($contentInfo): ?>
    <p class="content-info">
      <span class="small">
      <?php if (TfSession::isAdmin()): ?>
      <a href="<?php echo TFISH_ADMIN_URL . 'admin.php?op=edit&amp;id=' . $content->escapeForXss('id'); ?>"><i title="<?php echo TFISH_EDIT_CONTENT; ?>" class="fas fa-edit"></i></a>
      <?php endif; ?>
      <?php echo $contentInfo; ?>
      </span>
    </p>
  <?php endif; ?>
</div>

<?php if ($content->isValidMedia()): ?>
<div class="audio-player text-left">
  <audio controls>
    <source src="<?php echo TFISH_MEDIA_URL . $content->escapeForXss('media'); ?>" type="<?php echo $tfValidator->escapeForXss($content->format); ?>">
    <?php echo TFISH_BROWSER_DOES_NOT_SUPPORT_AUDIO; ?>
  </audio>
</div>
<?php endif; ?>

<!-- Image with link to download media attachment -->
<?php if ($content->image): ?>
<div class="float-right figure-right">
  <figure>
    <?php if ($content->media): ?>
    <a href="<?php echo TFISH_URL . 'enclosure.php?id=' . $content->escapeForXss('id'); ?>">
      <img class="image img-fluid" src="<?php echo $content->getCachedImage(400); ?>" 
      <?php if ($content->caption): ?>
        title="<?php echo $content->escapeForXss('caption'); ?>" alt="<?php echo $content->escapeForXss('caption'); ?>"/>
      <?php else: ?>
        alt="" />
      <?php endif; ?>
    </a>
    <?php if ($content->caption): ?>
    <figcaption class="text-left"><em><?php echo $content->escapeForXss('caption'); ?></em></figcaption>
      <?php endif; ?>
    <?php else: ?>
      <img class="image img-fluid" src="<?php echo $content->getCachedImage(400); ?>" 
      <?php if ($content->caption): ?>
        title="<?php echo $content->escapeForXss('caption'); ?>" alt="<?php echo $content->escapeForXss('caption'); ?>"/>
        <figcaption><em><?php echo $content->escapeForXss('caption'); ?></em></figcaption>
      <?php else: ?>
        alt="" />
      <?php endif; ?>
    <?php endif; ?>                
    </figure>
</div>
<?php endif; ?>

<!-- Description -->
<div class="description">
  <?php if ($content->description) echo $content->escapeForXss('description'); ?>
</div>

<!-- Rights -->
<?php if ($content->rights): ?>
<div>
  <p class="rights"><?php echo $content->escapeForXss('rights'); ?></p>
</div>
<?php endif; ?>

<!-- Display parent work -->
<?php if (!empty($parent)): ?>
<div>
  <h3><?php echo TFISH_RELATED; ?></h3>
  <h4 class="parent"><a href="<?php echo $parent->getUrl($targetFileName); ?>"><?php echo $parent->icon; ?> <?php echo $parent->escapeForXss('title'); ?></a></h4>
  <?php if ($parent->image): ?>
  <div class="float-left">
    <figure class="figure-left">
    <a href="<?php echo $parent->getUrl($targetFileName); ?>">
    <img class="image img-fluid" src="<?php echo $parent->getCachedImage(150); ?>" 
    <?php if ($parent->caption): ?>
      title="<?php echo $parent->escapeForXss('caption'); ?>" alt="<?php echo $parent->escapeForXss('caption'); ?>"
    <?php else: ?>
      alt=""
    <?php endif; ?>
    /></a>
    </figure>
  </div>
  <?php endif; ?>
  <div class="teaser">
    <?php echo $parent->escapeForXss('teaser'); ?>
  </div>
</div>
<?php endif; ?>
<?php endif; ?>