From c96c0d0c56e2a62c2997131d9e0ea21245d6ff74 Mon Sep 17 00:00:00 2001 From: Jim Safley Date: Wed, 3 Apr 2024 18:11:23 -0400 Subject: [PATCH] Avoid redundant linked resources captions --- .../src/Api/Adapter/AbstractResourceEntityAdapter.php | 6 ++---- .../Representation/AbstractResourceEntityRepresentation.php | 2 +- application/view/common/linked-resources.phtml | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/application/src/Api/Adapter/AbstractResourceEntityAdapter.php b/application/src/Api/Adapter/AbstractResourceEntityAdapter.php index 3d2be7920..f773ff2df 100644 --- a/application/src/Api/Adapter/AbstractResourceEntityAdapter.php +++ b/application/src/Api/Adapter/AbstractResourceEntityAdapter.php @@ -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, [ diff --git a/application/src/Api/Representation/AbstractResourceEntityRepresentation.php b/application/src/Api/Representation/AbstractResourceEntityRepresentation.php index ec2bc60d3..ed6367c29 100644 --- a/application/src/Api/Representation/AbstractResourceEntityRepresentation.php +++ b/application/src/Api/Representation/AbstractResourceEntityRepresentation.php @@ -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; } diff --git a/application/view/common/linked-resources.phtml b/application/view/common/linked-resources.phtml index 79e9d02f6..27b82a525 100644 --- a/application/view/common/linked-resources.phtml +++ b/application/view/common/linked-resources.phtml @@ -63,11 +63,10 @@ $resourcePropertiesSelect->setValueOptions($valueOptions); 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() ); ?>