Skip to content

Commit

Permalink
Avoid redundant linked resources captions
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Apr 3, 2024
1 parent 360f62b commit c96c0d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions application/src/Api/Adapter/AbstractResourceEntityAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,14 @@ public function getSubjectValues(Resource $resource, $page = null, $perPage = nu
$offset = (is_numeric($page) && is_numeric($perPage)) ? (($page - 1) * $perPage) : null;
$qb = $this->getSubjectValuesQueryBuilder($resource, $propertyId, $resourceType, $siteId)
->join('value.property', 'property')
->join('property.vocabulary', 'vocabulary')
->select([
'value val',
'property.id property_id',
'resource_template_property.id resource_template_property_id',
'property.label property_label',
'resource_template_property.id resource_template_property_id',
'resource_template_property.alternateLabel property_alternate_label',
"CONCAT(vocabulary.prefix, ':', property.localName) term",
])
->orderBy('property.id, resource_template_property.alternateLabel, resource.title')
->orderBy('resource_template_property.alternateLabel, property.label, property.id, resource.title')
->setMaxResults($perPage)
->setFirstResult($offset);
$event = new Event('api.subject_values.query', $this, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function subjectValues($page = null, $perPage = null, $propertyId = null,
$results = $this->getAdapter()->getSubjectValues($this->resource, $page, $perPage, $propertyId, $resourceType, $siteId);
$subjectValues = [];
foreach ($results as $result) {
$index = sprintf('%s-%s', $result['property_id'], $result['resource_template_property_id']);
$index = $result['property_alternate_label'] ?: $result['property_label'];
$result['val'] = new ValueRepresentation($result['val'], $this->getServiceLocator());
$subjectValues[$index][] = $result;
}
Expand Down
5 changes: 2 additions & 3 deletions application/view/common/linked-resources.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ $resourcePropertiesSelect->setValueOptions($valueOptions);
<?php foreach ($subjectValues as $values): ?>
<?php
$caption = sprintf(
$this->translate('%s with "%s: %s" (%s)'),
$this->translate('%s with "%s: %s"'),
$this->translate($labelMap[$resourceType]),
$values[0]['property_alternate_label'] ?? $this->translate($values[0]['property_label']),
$objectResource->displayTitle(),
$values[0]['term']
$objectResource->displayTitle()
);
?>
<table>
Expand Down

0 comments on commit c96c0d0

Please sign in to comment.