From 11e8975496515a8953f06eacf935534bee58047e Mon Sep 17 00:00:00 2001 From: mshroom <32199029+mshroom@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:35:57 +0200 Subject: [PATCH] LIDO: Display identifier type preferably from label attribute --- module/Finna/src/Finna/RecordDriver/SolrLido.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/module/Finna/src/Finna/RecordDriver/SolrLido.php b/module/Finna/src/Finna/RecordDriver/SolrLido.php index 1919fe44153..8fe8d0458f4 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrLido.php +++ b/module/Finna/src/Finna/RecordDriver/SolrLido.php @@ -2388,8 +2388,8 @@ protected function getDataSourceConfigurationValue($confParam) * Get identifiers by type * * @param bool $includeType Whether to include identifier type in parenthesis - * @param array $include Type attributes to include - * @param array $exclude Type attributes to exclude + * @param array $include Type and label attributes to include + * @param array $exclude Type and label attributes to exclude * * @return array */ @@ -2405,16 +2405,18 @@ protected function getIdentifiersByType( ->repositorySet ?? [] as $repository ) { foreach ($repository->workID ?? [] as $node) { - $type = $node->attributes()->type ?? ''; + $label = trim((string)($node->attributes()->label ?? '')); + $type = trim((string)($node->attributes()->type ?? '')); + $typesLC = [mb_strtolower($label, 'UTF-8'), mb_strtolower($type, 'UTF-8')]; if ( - ($include && !in_array($type, $include)) - || ($exclude && in_array($type, $exclude)) + ($include && !array_intersect($typesLC, $include)) + || ($exclude && array_intersect($typesLC, $exclude)) ) { continue; } if ($identifier = trim((string)$node ?? '')) { - if ($type && $includeType) { - $identifier .= " ($type)"; + if (($label || $type) && $includeType) { + $identifier .= ' (' . ($label ?: $type) . ')'; } $results[] = $identifier; }