<?php
$this->htmlElement('body')->appendAttribute('class', 'browse');
$escape = $this->plugin('escapeHtml');
$sortHeadings = [
    [
        'label' => $this->translate('Label'),
        'value' => 'label'
    ],
    [
        'label' => $this->translate('Term'),
        'value' => 'local_name'
    ],
    [
        'label' => $this->translate('Items'),
        'value' => 'item_count'
    ]
];
?>

<?php echo $this->pageTitle(sprintf($this->translate('Classes in “%s”'), $vocabulary->label())); ?>

<p><?php echo $escape($this->translate($vocabulary->comment())); ?></p>
<p><strong><?php echo $this->translate('Prefix:'); ?></strong> <?php echo $escape($vocabulary->prefix()); ?><br>
<strong><?php echo $this->translate('Namespace URI:'); ?></strong> <?php echo $escape($vocabulary->namespaceUri()); ?></p>

<?php if (count($resourceClasses)): ?>

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

<?php echo $this->sortSelector($sortHeadings); ?>

<table class="tablesaw tablesaw-stack" data-tablesaw-mode="stack">
    <thead>
        <tr>
            <th><?php echo $this->translate('Label'); ?></th>
            <th><?php echo $this->translate('Term'); ?></th>
            <th><?php echo $this->translate('Items'); ?></th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($resourceClasses as $resourceClass): ?>
        <tr>
            <td>
                <span class="resource-name">
                    <?php echo $escape($this->translate($resourceClass->label())); ?>
                </span>
                <ul class="actions">
                    <li><a href="#"
                        data-sidebar-content-url="<?php echo $escape($resourceClass->url('show-details')); ?>"
                        class="o-icon-more sidebar-content"
                        aria-label="<?php echo $escape($this->translate('Details')); ?>"
                        title="<?php echo $escape($this->translate('Details')); ?>"></a>
                    </li>
                </ul>
            </td>
            <td><?php echo $escape($this->translate($resourceClass->term())); ?></td>
            <td><?php echo $this->hyperlink($resourceClass->itemCount(), $this->url('admin/default', ['controller' => 'item', 'action' => 'browse'], ['query' => ['resource_class_id' => $resourceClass->id()]])); ?></td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

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

<div class="sidebar">
    <a href="#"
        class="sidebar-close o-icon-close"
        aria-label="<?php echo $escape($this->translate('Close')); ?>"
        title="<?php echo $escape($this->translate('Close')); ?>"></a>
    <div class="sidebar-content"></div>
</div>

<?php else: ?>

<div class="no-resources">
    <p><?php echo $this->translate('This vocabulary has no classes.'); ?></p>
</div>

<?php endif; ?>
