<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$labelInfo = $this->setting('property_label_information');
?>
<dl>
<?php foreach ($values as $term => $propertyData): ?>
    <div class="property">
        <dt>
        <?php if ($propertyData['alternate_label']): ?>
        <?php echo $escape($propertyData['alternate_label']); ?>
        <?php else: ?>
        <?php echo $escape($translate($propertyData['property']->label())); ?>
        <?php endif; ?>
        <?php if ('term' === $labelInfo): ?>
        <span class="field-term">(<?php echo $escape($propertyData['property']->term()); ?>)</span>
        <?php elseif ('vocab' === $labelInfo): ?>
        <span class="field-term">(<?php echo $escape($propertyData['property']->vocabulary()->label()); ?>)</span>
        <?php endif; ?>
        </dt>
        <div class="values">
        <?php foreach ($propertyData['values'] as $value): ?>
            <?php
            $valueType = $value->type();
            $class = ['value'];
            if ('resource' == $valueType || strpos($valueType, 'resource') !== false) {
                $class[] = 'resource';
                $class[] = $escape($value->valueResource()->resourceName());
            } elseif ('uri' == $valueType) {
                $class[] = 'uri';
            }
            if (!$value->isPublic()) {
                $class[] = 'private';
            }
            ?>
            <dl class="<?php echo implode(' ', $class); ?>" lang="<?php echo $escape($value->lang()); ?>">
                <?php if ($language = $value->lang()): ?>
                <span class="language"><?php echo $language; ?></span>
                <?php endif; ?>
                <?php echo $value->asHtml(); ?>
            </dl>
        <?php endforeach; ?>
        </div>
    </div>
<?php endforeach; ?>
</dl>