<?php
$this->htmlElement('body')->appendAttribute('class', 'item-sets show');
$escape = $this->plugin('escapeHtml');
$viewItemsLink = $this->url(
    'admin/default', 
    ['controller' => 'item', 'action' => 'browse'], 
    [
        'query' =>  [
            'item_set_id' => $itemSet->id()
        ]
    ]
);
if ($owner = $itemSet->owner()) {
    $ownerText = $escape($itemSet->owner()->name());
} else {
    $ownerText = $this->translate('[no owner]');
}

$sectionNavs = [
    'item-set-metadata' => $this->translate('Metadata'),
    'item-set-linked' => $this->translate('Linked Resources'),
];
?>

<?php echo $this->pageTitle(sprintf($this->translate('Item Set: “%s”'), $itemSet->displayTitle())); ?>

<div id="page-actions">
    <?php if ($itemSet->userIsAllowed('update')): ?>
    <?php echo $itemSet->link($this->translate('Edit item set'), 'edit', ['class' => 'button']); ?>
    <?php endif; ?>
    <a href="<?php echo $viewItemsLink; ?>" class="button"><?php echo $this->translate('View items'); ?></a>
</div>

<?php echo $this->sectionNav($sectionNavs, 'view.show.section_nav', $itemSet); ?>

<div id="item-set-metadata" class="active section">
    <?php if ( $itemSet->resourceClass()): ?>
        <div class="meta-group">
            <h4><?php echo $this->translate('Class'); ?></h4>
            <div class="value"><?php echo $escape($itemSet->resourceClass()->label()); ?></div>
        </div>
    <?php endif; ?>
    <?php echo $itemSet->displayValues(); ?>
</div>

<div id="item-set-linked" class="section">
    <?php echo $itemSet->displayLinkedResources(); ?>
</div>

<div class="active sidebar">
    <div class="meta-group">
        <h4><?php echo $this->translate('Date Created'); ?></h4>
        <div class="value"><?php echo $escape($this->i18n()->dateFormat($itemSet->created())); ?></div>
    </div>
    <div class="meta-group">
        <h4><?php echo $this->translate('Owner'); ?></h4>
        <div class="value"><?php echo $ownerText; ?></div>
    </div>
    <div class="meta-group">
        <h4><?php echo $this->translate('Visibility'); ?></h4>
        <div class="value"><?php echo ($itemSet->isPublic()) ? $escape($this->translate('Public')) : $escape($this->translate('Private')); ?></div>
        <div class="value"><?php echo ($itemSet->isOpen()) ? $escape($this->translate('Open to additions')) : $escape($this->translate('Closed to additions')); ?></div>
    </div>
    <div class="meta-group">
        <h4><?php echo $this->translate('Items'); ?></h4>
        <div class="value"><?php echo $this->hyperlink($itemSet->itemCount(), $this->url('admin/default', ['controller' => 'item', 'action' => 'browse'], ['query' => ['item_set_id' => $itemSet->id()]])); ?></div>
    </div>
</div>

<?php $this->trigger('view.show.after'); ?>
