<?php
  // Set up standard record scripts:
  $this->headScript()->appendFile("record.js");
  $this->headScript()->appendFile("check_save_statuses.js");
  $this->headScript()->appendFile("accordion.js");
  // Activate Syndetics Plus if necessary:
  if ($this->syndeticsPlus()->isActive()) {
    $this->headScript()->appendFile($this->syndeticsPlus()->getScript());
  }

  // Add RDF header link if applicable:
  if ($this->export()->recordSupportsFormat($this->driver, 'RDF')) {
    $this->headLink()->appendAlternate($this->recordLinker($this->results)->getActionUrl($this->driver, 'RDF'), 'application/rdf+xml', 'RDF Representation');
  }

  // Set up breadcrumbs:
  $this->layout()->breadcrumbs = '<li>' . $this->searchMemory()->getLastSearchLink($this->transEsc('Resultlist'), '', '</li> ') .
    '<li class="active">' . $this->recordLinker($this->results)->getBreadcrumb($this->driver) . '</li> ';
  $this->layout()->title = $this->driver->getShortTitle();
?>

<div class="record source<?=$this->escapeHtmlAttr($this->driver->getSourceIdentifier())?>">
  <div class="<?=$this->layoutClass('mainbody')?>">


      <?php if (isset($this->scrollData) && ($this->scrollData['previousRecord'] || $this->scrollData['nextRecord'])): ?>
          <ul class="pager hidden-print">
              <?php if ($this->scrollData['previousRecord']): ?>
                  <?php if ($this->scrollData['firstRecord']): ?>
                      <li>
                          <a href="<?=$this->recordLinker($this->results)->getUrl($this->scrollData['firstRecord'])?>" title="<?=$this->transEsc('First Search Result')?>" rel="nofollow">&laquo; <?=$this->transEsc('First')?></a>
                      </li>
                  <?php endif; ?>
                  <li>
                      <a href="<?=$this->recordLinker($this->results)->getUrl($this->scrollData['previousRecord'])?>" title="<?=$this->transEsc('Previous Search Result')?>" rel="nofollow">&laquo; <?=$this->transEsc('Prev')?></a>
                  </li>
              <?php else: ?>
                  <?php if ($this->scrollData['firstRecord']): ?>
                      <li class="disabled"><a href="#">&laquo; <?=$this->transEsc('First')?></a></li>
                  <?php endif; ?>
                  <li class="disabled"><a href="#">&laquo; <?=$this->transEsc('Prev')?></a></li>
              <?php endif; ?>
              <?=$this->transEsc('of_num_results', [
                  '%%position%%' => $this->localizedNumber($this->scrollData['currentPosition']),
                  '%%total%%' => $this->localizedNumber($this->scrollData['resultTotal'])
              ]) ?>
              <?php if ($this->scrollData['nextRecord']): ?>
                  <li>
                      <a href="<?=$this->recordLinker($this->results)->getUrl($this->scrollData['nextRecord'])?>" title="<?=$this->transEsc('Next Search Result')?>" rel="nofollow"><?=$this->transEsc('Next')?> &raquo;</a>
                  </li>
                  <?php if ($this->scrollData['lastRecord']): ?>
                      <li>
                          <a href="<?=$this->recordLinker($this->results)->getUrl($this->scrollData['lastRecord'])?>" title="<?=$this->transEsc('Last Search Result')?>" rel="nofollow"><?=$this->transEsc('Last')?> &raquo;</a>
                      </li>
                  <?php endif; ?>
              <?php else: ?>
                  <li class="disabled"><a href="#"><?=$this->transEsc('Next')?> &raquo;</a></li>
                  <?php if ($this->scrollData['lastRecord']): ?>
                      <li class="disabled"><a href="#"><?=$this->transEsc('Last')?> &raquo;</a></li>
                  <?php endif; ?>
              <?php endif; ?>
          </ul>
      <?php endif; ?>
      <div class="clear"></div>

      <?=$this->record($this->driver)->getToolbar()?>

    <input type="hidden" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" class="hiddenId" />
    <input type="hidden" value="<?=$this->escapeHtmlAttr($this->driver->getSourceIdentifier()) ?>" class="hiddenSource" />
    <?=$this->flashmessages()?>
    <?=$this->record($this->driver)->getCoreMetadata()?>

    <?php if (count($this->tabs) > 0): ?>
      <a name="tabnav"></a>
      <div class="record-tabs">
        <ul class="nav nav-tabs">
          <?php foreach ($this->tabs as $tab => $obj): ?>
            <?php // add current tab to breadcrumbs if applicable:
              $desc = $obj->getDescription();
              $tab_classes = [];
              if (0 === strcasecmp($this->activeTab, $tab)) {
                if (!$this->loadInitialTabWithAjax || !$obj->supportsAjax()) {
                  $tab_classes[] = 'active';
                }
                $tab_classes[] = 'initiallyActive';
                $this->layout()->breadcrumbs .= '<li class="active">' . $this->transEsc($desc) . '</li>';
                $activeTabObj = $obj;
              }
              if (!$obj->isVisible()) { $tab_classes[] = 'hidden'; }
              if (!$obj->supportsAjax()) { $tab_classes[] = 'noajax'; }
            ?>
            <li<?=count($tab_classes) > 0 ? ' class="' . implode(' ', $tab_classes) . '"' : ''?>>
              <a class="<?=strtolower($tab) ?>" href="<?=$this->recordLinker($this->results)->getTabUrl($this->driver, $tab)?>#tabnav"<?php if ($obj->supportsAjax() && in_array($tab, $this->backgroundTabs)):?> data-background<?php endif ?>><?=$this->transEsc($desc)?></a>
            </li>
          <?php endforeach; ?>
        </ul>

        <div class="tab-content">
          <?php if (!$this->loadInitialTabWithAjax || !isset($activeTabObj) || !$activeTabObj->supportsAjax()): ?>
            <div class="tab-pane active <?=$this->activeTab ?>-tab">
              <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?>
            </div>
          <?php endif; ?>
        </div>
      </div>
    <?php endif; ?>

    <?=$this->driver->supportsCoinsOpenURL()?'<span class="Z3988" title="'.$this->escapeHtmlAttr($this->driver->getCoinsOpenURL()).'"></span>':''?>
  </div>

  <div class="<?=$this->layoutClass('sidebar')?>">
    <?php foreach ($this->related()->getList($this->driver) as $current): ?>
      <?=$this->related()->render($current)?>
    <?php endforeach; ?>
  </div>
</div>
<?=$this->inlineScript(\Laminas\View\Helper\HeadScript::SCRIPT, '$(document).ready(recordDocReady);', 'SET'); ?>
