<?php
use Omeka\Api\Representation\ItemRepresentation;

$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');

// Users can select media resources as values only when editing an item, and can
// only assign media that's assigned ot the current item and ingested.
$mediaContentUrlOptions = ['query' => []];
if ($resource instanceof ItemRepresentation) {
    $mediaContentUrlOptions['query']['item_id'] = $resource->id();
}
?>
<div class="resource-inputs">
<span class="default"><?php echo $translate('No resource selected'); ?></span>
<p class="selected-resource">
    <span class="o-title"></span>
    <input type="hidden" class="value to-require" data-value-key="value_resource_id">
</p>

<?php
if (in_array($dataType, ['resource', 'resource:item'])):
    echo $this->hyperlink($translate('Items'), '#item-resource-select', [
        'class' => 'o-icon-items button resource-select',
        'data-sidebar-content-url' => $this->url('admin/default', ['controller' => 'item', 'action' => 'sidebar-select'], false),
    ]);
endif;

if (in_array($dataType, ['resource', 'resource:itemset'])):
    echo $this->hyperlink($translate('Item sets'), '#itemset-resource-select', [
        'class' => 'o-icon-item-sets button resource-select',
        'data-sidebar-content-url' => $this->url('admin/default', ['controller' => 'item-set', 'action' => 'sidebar-select'], false),
    ]);
endif;

if (in_array($dataType, ['resource', 'resource:media']) && $resource instanceof ItemRepresentation):
    echo $this->hyperlink($translate('Media'), '#media-resource-select', [
        'class' => 'o-icon-media button resource-select',
        'data-sidebar-content-url' => $this->url('admin/default', ['controller' => 'media', 'action' => 'sidebar-select'], $mediaContentUrlOptions, false),
    ]);
endif;
?>
</div>
