Skip to content

Commit

Permalink
View all linked resources that are items by default (fix #2102))
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Oct 6, 2023
1 parent d9dc3d3 commit 01d3455
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ public function subjectValuesForReverse($propertyId = null, $resourceType = null
return $subjectValues;
}

public function subjectValueTotalCount($propertyId = null, $resourceType = null, $siteId = null)
{
return $this->getAdapter()->getSubjectValueTotalCount($this->resource, $propertyId, $resourceType, $siteId);
}

/**
* Get value representations where this resource is the RDF subject.
*
Expand Down Expand Up @@ -533,7 +538,7 @@ public function displaySubjectValues(array $options = [])
$viewName = $options['viewName'] ?? 'common/linked-resources';
$page = $options['page'] ?? null;
$perPage = $options['perPage'] ?? null;
$resourceProperty = $options['resourceProperty'] ?? null;
$resourceProperty = $options['resourceProperty'] ?? 'items:';
$siteId = $options['siteId'] ?? null;

$resourceType = $adapter->getResourceName();
Expand All @@ -544,13 +549,7 @@ public function displaySubjectValues(array $options = [])
}

$totalCount = $adapter->getSubjectValueTotalCount($this->resource, $propertyId, $resourceType, $siteId);
if (!$totalCount) {
return;
}
$subjectValues = $this->subjectValues($page, $perPage, $propertyId, $resourceType, $siteId);
if (!$subjectValues) {
return;
}
$resourcePropertiesAll = [
'items' => $adapter->getSubjectValueProperties($this->resource, 'items', $siteId),
'item_sets' => $adapter->getSubjectValueProperties($this->resource, 'item_sets', $siteId),
Expand Down
15 changes: 6 additions & 9 deletions application/view/omeka/admin/item-set/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,13 @@ $sectionNavs = [
</div>

<div id="resources-linked" class="section">
<?php
$subjectValues = $itemSet->displaySubjectValues([
'page' => $this->params()->fromQuery('page', 1),
'perPage' => 25,
'resourceProperty' => $this->params()->fromQuery('resource_property'),
]);
?>
<?php if ($subjectValues): ?>
<?php if ($itemSet->subjectValueTotalCount()): ?>
<p><?php echo $translate('The following resources link to this item set:'); ?></p>
<?php echo $subjectValues; ?>
<?php echo $itemSet->displaySubjectValues([
'page' => $this->params()->fromQuery('page', 1),
'perPage' => 25,
'resourceProperty' => $this->params()->fromQuery('resource_property'),
]); ?>
<?php else: ?>
<div class="no-resources">
<p><?php echo $translate('No resources link to this item set.'); ?></p>
Expand Down
15 changes: 6 additions & 9 deletions application/view/omeka/admin/item/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ $itemMedia = $item->media();
</div>

<div id="resources-linked" class="section">
<?php
$subjectValues = $item->displaySubjectValues([
'page' => $this->params()->fromQuery('page', 1),
'perPage' => 25,
'resourceProperty' => $this->params()->fromQuery('resource_property'),
]);
?>
<?php if ($subjectValues): ?>
<?php echo $subjectValues; ?>
<?php if ($item->subjectValueTotalCount()): ?>
<?php echo $item->displaySubjectValues([
'page' => $this->params()->fromQuery('page', 1),
'perPage' => 25,
'resourceProperty' => $this->params()->fromQuery('resource_property'),
]); ?>
<?php else: ?>
<div class="no-resources">
<p><?php echo $translate('No resources link to this item.'); ?></p>
Expand Down

0 comments on commit 01d3455

Please sign in to comment.