/
resource-values.phtml
93 lines (90 loc) · 4.09 KB
/
resource-values.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$decoration = $this->themeSetting('image_decoration');
if ($this->status()->isSiteRequest()) {
$labelInfo = $this->siteSetting('property_label_information');
$showLocale = (bool) $this->siteSetting('show_locale_label', true);
$filterLocale = $this->siteSetting('filter_locale_values');
$lang = $this->lang();
$showValueAnnotations = (bool) $this->siteSetting('show_value_annotations', false);
} else {
$labelInfo = $this->setting('property_label_information');
$showLocale = true;
$filterLocale = false;
$lang = null;
$showValueAnnotations = true;
}
$filterLocaleCallback = function ($value) use ($lang) {
$valueLang = $value->lang();
return $valueLang == '' || strcasecmp($valueLang, $lang) === 0;
};
?>
<dl>
<?php
foreach ($values as $term => $propertyData):
$propertyValues = $propertyData['values'];
if ($filterLocale) {
$propertyValues = array_filter($propertyValues, $filterLocaleCallback);
}
if (!$propertyValues) {
continue;
}
$property = $propertyData['property'];
$propertyLabel = $propertyData['alternate_label'] ?: $translate($property->label());
if ('term' === $labelInfo) {
$propertyTerm = $property->term();
} elseif ('vocab' === $labelInfo) {
$propertyTerm = $property->vocabulary()->label();
} else {
$propertyTerm = null;
}
?>
<div class="property">
<dt>
<?php echo $escape($propertyLabel); ?>
<?php if ($propertyTerm !== null) : ?>
<span class="field-term">(<?php echo $escape($propertyTerm); ?>)</span>
<?php endif; ?>
</dt>
<?php foreach ($propertyValues as $value): ?>
<?php
$valueType = $value->type();
$valueLang = $value->lang();
$valueAnnotation = $value->valueAnnotation();
$class = ['value'];
if ('resource' == $valueType || strpos($valueType, 'resource') !== false) {
$class[] = 'resource';
$class[] = $escape($value->valueResource()->resourceName());
if ('media' == $value->valueResource()->resourceName() && is_array($decoration) && in_array('media', $decoration)) {
$class[] = 'decoration decoration--thumbnail';
}
} elseif ('uri' == $valueType) {
$class[] = 'uri';
}
?>
<dd class="<?php echo implode(' ', $class); ?>" lang="<?php echo $escape($valueLang); ?>">
<?php if ($showLocale && $valueLang) : ?>
<span class="language"><?php echo $valueLang; ?></span>
<?php endif; ?>
<span class="value-content"><?php echo $filterLocale ? $value->asHtml($lang) : $value->asHtml(); ?></span>
<?php if(!$value->isPublic()) : ?>
<span class="o-icon-private" aria-role="tooltip" title="<?php echo $this->escapeHtml($translate('Private')); ?>" aria-label="<?php echo $this->escapeHtml($translate('Private')); ?>"></span>
<?php endif; ?>
<?php if ($valueAnnotation && $showValueAnnotations) : ?>
<div class="annotation-btn">
<span class="has-annotation o-icon-annotation" aria-role="tooltip" title="<?php echo $this->escapeHtml($translate('Has annotation')); ?>" aria-label="<?php echo $this->escapeHtml($translate('Has annotation')); ?>"></span>
<div class="annotation-tooltip">
<div class="annotation-tooltip__wrapper">
<h6 class="annotation-tooltip__heading"><?php echo $this->escapeHtml($translate('Value Annotations')); ?></h6>
<?php echo $valueAnnotation->displayValues(); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php $this->trigger('view.show.value', ['value' => $value]); ?>
</dd>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</dl>