diff --git a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php index 3350fcd..5559258 100644 --- a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php +++ b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php @@ -68,6 +68,38 @@ function toXml($record, $format = null) { } } + $linkedKeywords = []; + $simpleKeywords = []; + foreach ($keywords as $locale => $kws) { + $lang = AppLocale::get3LetterIsoFromLocale($locale); + foreach ($kws as $kw) { + if (str_contains($kw, 'https://id.kb.se/term')) { + $prefLabelAndUri = explode('|', $kw); + $prefLabel = $prefLabelAndUri[0]; + $uriDecoded = end($prefLabelAndUri); + + $uriFragments = explode('/', $uriDecoded); + $label = end($uriFragments); + array_pop($uriFragments); + $authority = end($uriFragments); + array_push($uriFragments, rawurlencode($label)); + $linkedKeywords[] = + [ + 'lang' => $lang, + 'label' => $prefLabel, + 'uri' => implode('/', $uriFragments), + 'authority' => $authority + ]; + } else { + $simpleKeywords[] = + [ + 'lang' => $lang, + 'keyword' => $kw + ]; + } + } + } + $templateMgr = TemplateManager::getManager(); $templateMgr->assign(array( 'journal' => $journal, @@ -75,7 +107,8 @@ function toXml($record, $format = null) { 'articleUrl' => $articleUrl, 'issue' => $record->getData('issue'), 'section' => $record->getData('section'), - 'keywords' => $keywords[$article->getLocale()], + 'keywords' => $simpleKeywords, + 'linkedKeywords' => $linkedKeywords, 'galleyProps' => $galleyProps, 'fileGroups' => $fileGroups, 'pluginName' => $plugin->getDisplayName(), diff --git a/fgsMetsMods/templates/record.tpl b/fgsMetsMods/templates/record.tpl index 63c37fe..2ce53ca 100644 --- a/fgsMetsMods/templates/record.tpl +++ b/fgsMetsMods/templates/record.tpl @@ -128,10 +128,23 @@ {/if} {foreach $keywords as $keyword} - - {$keyword|escape} + + {$keyword.keyword|escape} {/foreach} + {* Remove when Mimer accepts the valueUri attribute *} + {foreach $linkedKeywords as $keyword} + + {$keyword.label|escape} + + {/foreach} + {* Activate when Mimer accepts the valueUri attribute! + {foreach $linkedKeywords as $keyword} + + {$keyword.label} + + {/foreach} + *} {if $abstract} {$abstract|escape} {/if}