<?php
$this->headScript()->appendFile($this->assetUrl('js/item-manage-item-sets.js', 'Omeka'));
$escape = $this->plugin('escapeHtml');
?>
<table id="item-item-sets" data-tablesaw-mode="stack" class="tablesaw tablesaw-stack <?php echo ($item && $item->itemSets()) ? '' : 'empty'; ?>">
    <thead>
    <tr>
        <th><?php echo $this->translate('Title'); ?></th>
        <th><?php echo $this->translate('Owner'); ?></th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <?php if ($item && $item->itemSets()): ?>
    <?php foreach ($item->itemSets() as $itemSet): ?>
    <?php
    if ($owner = $itemSet->owner()) {
        $ownerText = $escape($itemSet->owner()->name());
    } else {
        $ownerText = $this->translate('[no owner]');
    }
    ?>
    <tr>
        <td><?php echo $escape($itemSet->displayTitle()); ?></td>
        <td><?php echo $ownerText; ?></td>
        <td><ul class="actions">
            <li><a
                class="o-icon-delete"
                href="#"
                title=" <?php echo $escape($this->translate('Remove item set')); ?>"
                aria-label=" <?php echo $escape($this->translate('Remove item set')); ?>">
            </a></li>
        </ul><input type="hidden" name="o:item_set[]" value="<?php echo $escape($itemSet->id()) ?>"></td>
    </tr>
    <?php endforeach; ?>
    <?php endif; ?>
    </tbody>
</table>

<div class="no-resources">
    <p><?php echo $this->translate('This item is part of no item sets. Add it to an item set using the interface to the right.'); ?></p>
</div>

<button id="item-set-selector-button" class="mobile-only"><?php echo $this->translate('Add to item set'); ?></button>

<?php
$itemSetTemplate = '
<tr>
    <td class="item-set-title"></td>
    <td class="owner-email">__owner-email__</td>
    <td><ul class="actions">
        <li><a href="#"
        class="o-icon-delete"
        title="' . $escape($this->translate('Remove item set')) . '"
        aria-label="' . $escape($this->translate('Remove item set')) . '">
        </a></li>
    </ul><input type="hidden" name="o:item_set[]"></td>
</tr>';
?>
<span id="item-set-template" data-template="<?php echo $escape($itemSetTemplate); ?>"></span>

<?php echo $this->itemSetSelector(); ?>
