From 3d5be5323cd26c74e4a522ab28fe72e46e2992cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Mon, 10 May 2021 13:01:11 +0200 Subject: [PATCH 1/4] Encode URIs for OAI-PMH --- .../OAIMetadataFormat_FgsMetsMods.inc.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php index 3350fcd..8bd1749 100644 --- a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php +++ b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php @@ -29,7 +29,7 @@ function toXml($record, $format = null) { $galleys = $article->getGalleys(); $submissionFileService = Services::get('submissionFile'); $articleUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'article', 'view', $article->getId()); - + $temporaryFileManager = new PrivateFileManager(); $basePath = $temporaryFileManager->getBasePath(); @@ -68,6 +68,19 @@ function toXml($record, $format = null) { } } + // Keyword URI's are decoded (%C3%A4 -> 'ä' etc) when saved in OJS. + // This code turns them back to valid URIs. + $kwUris = []; + foreach ($keywords[$article->getLocale()] as $kw) { + if (str_contains($kw, 'https://id.kb.se/term')) { + $kwFragments = explode('/', $kw); + $label = end($kwFragments); + array_pop($kwFragments); + array_push($kwFragments, rawurlencode($label)); + $kwUris[] = implode('/', $kwFragments); + } + } + $templateMgr = TemplateManager::getManager(); $templateMgr->assign(array( 'journal' => $journal, @@ -75,7 +88,7 @@ function toXml($record, $format = null) { 'articleUrl' => $articleUrl, 'issue' => $record->getData('issue'), 'section' => $record->getData('section'), - 'keywords' => $keywords[$article->getLocale()], + 'keywords' => $kwUris, 'galleyProps' => $galleyProps, 'fileGroups' => $fileGroups, 'pluginName' => $plugin->getDisplayName(), From 07c1dd7d73cae718b9fb8b821860ea85df6ef3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Mon, 10 May 2021 13:01:25 +0200 Subject: [PATCH 2/4] Revert "Encode URIs for OAI-PMH" This reverts commit 3d5be5323cd26c74e4a522ab28fe72e46e2992cc. --- .../OAIMetadataFormat_FgsMetsMods.inc.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php index 8bd1749..3350fcd 100644 --- a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php +++ b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php @@ -29,7 +29,7 @@ function toXml($record, $format = null) { $galleys = $article->getGalleys(); $submissionFileService = Services::get('submissionFile'); $articleUrl = $request->getDispatcher()->url($request, ROUTE_PAGE, null, 'article', 'view', $article->getId()); - + $temporaryFileManager = new PrivateFileManager(); $basePath = $temporaryFileManager->getBasePath(); @@ -68,19 +68,6 @@ function toXml($record, $format = null) { } } - // Keyword URI's are decoded (%C3%A4 -> 'ä' etc) when saved in OJS. - // This code turns them back to valid URIs. - $kwUris = []; - foreach ($keywords[$article->getLocale()] as $kw) { - if (str_contains($kw, 'https://id.kb.se/term')) { - $kwFragments = explode('/', $kw); - $label = end($kwFragments); - array_pop($kwFragments); - array_push($kwFragments, rawurlencode($label)); - $kwUris[] = implode('/', $kwFragments); - } - } - $templateMgr = TemplateManager::getManager(); $templateMgr->assign(array( 'journal' => $journal, @@ -88,7 +75,7 @@ function toXml($record, $format = null) { 'articleUrl' => $articleUrl, 'issue' => $record->getData('issue'), 'section' => $record->getData('section'), - 'keywords' => $kwUris, + 'keywords' => $keywords[$article->getLocale()], 'galleyProps' => $galleyProps, 'fileGroups' => $fileGroups, 'pluginName' => $plugin->getDisplayName(), From c38ecd323f95be5b8126febe41432297b96c6830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Mon, 10 May 2021 14:34:32 +0200 Subject: [PATCH 3/4] Handle id.kb.se keywords. Added code following the current FGS-PUBL spec and code to be activated when Mimer can handle the valueUri attribute. --- .../OAIMetadataFormat_FgsMetsMods.inc.php | 31 ++++++++++++++++++- fgsMetsMods/templates/record.tpl | 17 ++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php index 3350fcd..b66bf37 100644 --- a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php +++ b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php @@ -68,6 +68,34 @@ 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')) { + $kwFragments = explode('/', $kw); + $label = end($kwFragments); + array_pop($kwFragments); + $authority = end($kwFragments); + array_push($kwFragments, rawurlencode($label)); + $linkedKeywords[] = + [ + 'lang' => $lang, + 'label' => $label, + 'uri' => implode('/', $kwFragments), + 'authority' => $authority + ]; + } else { + $simpleKeywords[] = + [ + 'lang' => $lang, + 'keyword' => $kw + ]; + } + } + } + $templateMgr = TemplateManager::getManager(); $templateMgr->assign(array( 'journal' => $journal, @@ -75,7 +103,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} From 1c265296c39c116d9da4c2e8a183c769bcc15c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Tue, 11 May 2021 09:11:35 +0200 Subject: [PATCH 4/4] Don't parse preflabel from URI --- .../OAIMetadataFormat_FgsMetsMods.inc.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php index b66bf37..5559258 100644 --- a/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php +++ b/fgsMetsMods/OAIMetadataFormat_FgsMetsMods.inc.php @@ -74,16 +74,20 @@ function toXml($record, $format = null) { $lang = AppLocale::get3LetterIsoFromLocale($locale); foreach ($kws as $kw) { if (str_contains($kw, 'https://id.kb.se/term')) { - $kwFragments = explode('/', $kw); - $label = end($kwFragments); - array_pop($kwFragments); - $authority = end($kwFragments); - array_push($kwFragments, rawurlencode($label)); + $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' => $label, - 'uri' => implode('/', $kwFragments), + 'label' => $prefLabel, + 'uri' => implode('/', $uriFragments), 'authority' => $authority ]; } else {