<?php
$fulltextSearch = $this->params()->fromQuery('fulltext_search');
$archiveSiteHelper = $this->getHelperPluginManager()->get('archiveSiteMeta');
$archive_collections = $archiveSiteHelper->getCollections();
?>

<!-- <h2><?php echo sprintf($this->translate('Item results for "%s"'), $fulltextSearch); ?></h2> -->
<!-- <?php echo $this->pagination(); ?> -->

<table>
  <thead>
    <tr>
      <th>Item</th>
      <th>Site</th>
      <th>Curator</th>
      <th>Collection</th>
      <th>Date</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($items as $item): ?>
        <?php $sites = $item->sites(); ?>
          <?php foreach ($sites as $site): ?>
          <?php $site_meta_values = $archiveSiteHelper->getSiteMetaValues($site); ?>
          <tr>
            <td>
              <?php echo $this->hyperlink($item->displayTitle(), $item->siteUrl($site->slug())); ?>
            </td>
            <td>
              <?php echo $this->hyperlink($site->title(), $site->siteUrl(), ['class' => 'site-link']); ?>
            </td>
            <td>
              <?php if ($site_meta_values != null): ?>
                <?= $site_meta_values['currator']; ?><br />
              <?php endif; ?>
            </td>
            <td>
              <?php if ($site_meta_values != null): ?>
                <?= $archive_collections[$site_meta_values['collection']]; ?>
              <?php endif; ?>
            </td>
            <td>
              <?php if ($site_meta_values != null): ?>
                <?= $site_meta_values['project_date']; ?>
              <?php endif; ?>
            </td>
          </tr>
          <?php endforeach; ?>

    <?php endforeach; ?>
  </tbody>
</table>

<!-- <?php echo $this->pagination(); ?> -->
