|
| 1 | +<?php |
| 2 | +$translate = $this->plugin('translate'); |
| 3 | +$escape = $this->plugin('escapeHtml'); |
| 4 | + |
| 5 | +if ($this->status()->isSiteRequest()) { |
| 6 | + $labelInfo = $this->siteSetting('property_label_information'); |
| 7 | + $showLocale = (bool) $this->siteSetting('show_locale_label', true); |
| 8 | + $filterLocale = $this->siteSetting('filter_locale_values'); |
| 9 | + $lang = $this->lang(); |
| 10 | + $showValueAnnotations = (bool) $this->siteSetting('show_value_annotations', false); |
| 11 | +} else { |
| 12 | + $labelInfo = $this->setting('property_label_information'); |
| 13 | + $showLocale = true; |
| 14 | + $filterLocale = false; |
| 15 | + $lang = null; |
| 16 | + $showValueAnnotations = true; |
| 17 | +} |
| 18 | +$filterLocaleCallback = function ($value) use ($lang) { |
| 19 | + $valueLang = $value->lang(); |
| 20 | + return $valueLang == '' || strcasecmp($valueLang, $lang) === 0; |
| 21 | +}; |
| 22 | +?> |
| 23 | + |
| 24 | +<table class="metadata"> |
| 25 | + <caption class="sr">Item metadata</caption> |
| 26 | +<?php |
| 27 | +foreach ($values as $term => $propertyData) : |
| 28 | + $propertyValues = $propertyData['values']; |
| 29 | + if ($filterLocale) { |
| 30 | + $propertyValues = array_filter($propertyValues, $filterLocaleCallback); |
| 31 | + } |
| 32 | + if (!$propertyValues) { |
| 33 | + continue; |
| 34 | + } |
| 35 | + $property = $propertyData['property']; |
| 36 | + $propertyLabel = $propertyData['alternate_label'] ?: $translate($property->label()); |
| 37 | + if ('term' === $labelInfo) { |
| 38 | + $propertyTerm = $property->term(); |
| 39 | + } elseif ('vocab' === $labelInfo) { |
| 40 | + $propertyTerm = $property->vocabulary()->label(); |
| 41 | + } else { |
| 42 | + $propertyTerm = null; |
| 43 | + } |
| 44 | + $propertyRows = count($propertyValues); |
| 45 | + ?> |
| 46 | + <tr class="property"> |
| 47 | + <th scope="row" rowspan="<?php echo $propertyRows; ?>"> |
| 48 | + <?php echo $escape($propertyLabel); ?> |
| 49 | + <?php if ($propertyTerm !== null) : ?> |
| 50 | + <span class="field-term">(<?php echo $escape($propertyTerm); ?>)</span> |
| 51 | + <?php endif; ?> |
| 52 | + </th> |
| 53 | + <?php foreach ($propertyValues as $key => $value) : ?> |
| 54 | + <?php if (0!=$key) {?> |
| 55 | + </tr><tr> |
| 56 | + <?php } ?> |
| 57 | + <?php |
| 58 | + $valueType = $value->type(); |
| 59 | + $valueLang = $value->lang(); |
| 60 | + $valueAnnotation = $value->valueAnnotation(); |
| 61 | + $class = ['value']; |
| 62 | + if ('resource' == $valueType || strpos($valueType, 'resource') !== false) { |
| 63 | + $class[] = 'resource'; |
| 64 | + $class[] = $escape($value->valueResource()->resourceName()); |
| 65 | + } elseif ('uri' == $valueType) { |
| 66 | + $class[] = 'uri'; |
| 67 | + } |
| 68 | + ?> |
| 69 | + <td class="<?php echo implode(' ', $class); ?>" <?php echo ($valueLang) ? "lang='{$escape($valueLang)}'" : ''; ?>> |
| 70 | + <?php if ($showLocale && $valueLang) : ?> |
| 71 | + <span class="language"><?php echo $valueLang; ?></span> |
| 72 | + <?php endif; ?> |
| 73 | + <span class="value-content"><?php echo $filterLocale ? $value->asHtml($lang) : $value->asHtml(); ?></span> |
| 74 | + <?php if (!$value->isPublic()) : ?> |
| 75 | + <span class="o-icon-private" aria-role="tooltip" title="<?php echo $this->escapeHtml($translate('Private')); ?>" aria-label="<?php echo $this->escapeHtml($translate('Private')); ?>"></span> |
| 76 | + <?php endif; ?> |
| 77 | + <?php if ($valueAnnotation && $showValueAnnotations) : ?> |
| 78 | + <a href="#" class="expand" aria-label="<?php echo $this->escapeHtml($translate('Expand')); ?>"> |
| 79 | + <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> |
| 80 | + </a> |
| 81 | + <div class="collapsible annotation"> |
| 82 | + <?php echo $valueAnnotation->displayValues(); ?> |
| 83 | + </div> |
| 84 | + <?php endif; ?> |
| 85 | + <?php $this->trigger('view.show.value', ['value' => $value]); ?> |
| 86 | + </td> |
| 87 | + <?php endforeach; ?> |
| 88 | + </tr> |
| 89 | +<?php endforeach; ?> |
| 90 | +</table> |
0 commit comments