From 639dca7d09b4587b73aa5916da31b19aca060db8 Mon Sep 17 00:00:00 2001 From: GaziYucel Date: Sun, 17 Nov 2024 17:03:28 +0100 Subject: [PATCH] multiple author affiliations --- api/v1/rors/index.php | 19 ++++ dbscripts/xml/install.xml | 6 +- dbscripts/xml/upgrade.xml | 6 +- pages/article/ArticleHandler.php | 10 +- .../datacite/filter/DataciteXmlFilter.php | 31 +++---- .../doaj/filter/DOAJJsonFilter.php | 10 +- .../doaj/filter/DOAJXmlFilter.php | 22 +++-- .../pubmed/filter/ArticlePubMedXmlFilter.php | 17 +++- .../dc/tests/OAIMetadataFormat_DCTest.php | 14 ++- .../marc/templates/record.tpl | 10 +- .../marcxml/templates/record.tpl | 10 +- .../rfc1807/OAIMetadataFormat_RFC1807.php | 11 +-- .../reports/articles/ArticleReportPlugin.php | 8 +- .../frontend/objects/article_details.tpl | 30 +++--- templates/images/ror-org-logo-icon.svg | 92 +++++++++++++++++++ 15 files changed, 222 insertions(+), 74 deletions(-) create mode 100644 api/v1/rors/index.php create mode 100644 templates/images/ror-org-logo-icon.svg diff --git a/api/v1/rors/index.php b/api/v1/rors/index.php new file mode 100644 index 00000000000..4da33b61f85 --- /dev/null +++ b/api/v1/rors/index.php @@ -0,0 +1,19 @@ + + + diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index 2f8d11c0096..1d10d494933 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -3,8 +3,8 @@ diff --git a/pages/article/ArticleHandler.php b/pages/article/ArticleHandler.php index a40ad52ec32..f1ade856de4 100644 --- a/pages/article/ArticleHandler.php +++ b/pages/article/ArticleHandler.php @@ -3,8 +3,8 @@ /** * @file pages/article/ArticleHandler.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class ArticleHandler @@ -357,6 +357,12 @@ public function view($args, $request) $templateMgr->assign('purchaseArticleEnabled', true); } + // ror icon + $rorIdIcon = 'ROR'; + if (file_exists('templates/images/ror-org-logo-icon.svg')) + $rorIdIcon = file_get_contents('templates/images/ror-org-logo-icon.svg'); + $templateMgr->assign('rorIdIcon', $rorIdIcon); + if (!Hook::call('ArticleHandler::view', [&$request, &$issue, &$article, $publication])) { $templateMgr->display('frontend/pages/article.tpl'); event(new UsageEvent(Application::ASSOC_TYPE_SUBMISSION, $context, $article, null, null, $this->issue)); diff --git a/plugins/generic/datacite/filter/DataciteXmlFilter.php b/plugins/generic/datacite/filter/DataciteXmlFilter.php index 976a5b51c5e..fb974c02e96 100644 --- a/plugins/generic/datacite/filter/DataciteXmlFilter.php +++ b/plugins/generic/datacite/filter/DataciteXmlFilter.php @@ -3,8 +3,8 @@ /** * @file plugins/generic/datacite/filter/DataciteXmlFilter.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2000-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2000-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class DataciteXmlFilter @@ -307,8 +307,7 @@ public function createCreatorsNode($doc, $issue, $publication, $galley, $galleyF $creators[] = [ 'name' => $creator, 'orcid' => null, - 'affiliation' => null, - 'ror' => null + 'affiliations' => null ]; break; } @@ -323,8 +322,7 @@ public function createCreatorsNode($doc, $issue, $publication, $galley, $galleyF $creators[] = [ 'name' => $author->getFullName(false, true, $publication->getData('locale')), 'orcid' => $author->getOrcid(), - 'affiliation' => $author->getLocalizedData('affiliation', $publication->getData('locale')), - 'ror' => $author->getData('rorId') ?? null + 'affiliations' => $author->getLocalizedAffiliations($publication->getData('locale')) ]; } break; @@ -332,8 +330,7 @@ public function createCreatorsNode($doc, $issue, $publication, $galley, $galleyF $creators[] = [ 'name' => $publisher, 'orcid' => null, - 'affiliation' => null, - 'ror' => null + 'affiliations' => null ]; break; } @@ -349,15 +346,17 @@ public function createCreatorsNode($doc, $issue, $publication, $galley, $galleyF $node->setAttribute('nameIdentifierScheme', 'ORCID'); $creatorNode->appendChild($node); } - if ($creator['affiliation']) { - $node = $doc->createElementNS($deployment->getNamespace(), 'affiliation'); - if ($creator['ror']) { - $node->setAttribute('affiliationIdentifier', $creator['ror']); - $node->setAttribute('affiliationIdentifierScheme', 'ROR'); - $node->setAttribute('schemeURI', 'https://ror.org'); + if ($creator['affiliations']) { + foreach($creator['affiliations'] as $affiliation) { + $node = $doc->createElementNS($deployment->getNamespace(), 'affiliation'); + if ($affiliation['ror']) { + $node->setAttribute('affiliationIdentifier', $affiliation['ror']); + $node->setAttribute('affiliationIdentifierScheme', 'ROR'); + $node->setAttribute('schemeURI', 'https://ror.org'); + } + $node->appendChild($doc->createTextNode($affiliation['name'])); + $creatorNode->appendChild($node); } - $node->appendChild($doc->createTextNode($creator['affiliation'])); - $creatorNode->appendChild($node); } $creatorsNode->appendChild($creatorNode); } diff --git a/plugins/importexport/doaj/filter/DOAJJsonFilter.php b/plugins/importexport/doaj/filter/DOAJJsonFilter.php index e78518132af..14b44d91b8f 100644 --- a/plugins/importexport/doaj/filter/DOAJJsonFilter.php +++ b/plugins/importexport/doaj/filter/DOAJJsonFilter.php @@ -3,8 +3,8 @@ /** * @file plugins/importexport/doaj/filter/DOAJJsonFilter.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2000-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2000-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class DOAJJsonFilter @@ -159,9 +159,9 @@ public function &process(&$pubObject) foreach ($articleAuthors as $articleAuthor) { $author = ['name' => $articleAuthor->getFullName(false, false, $publicationLocale)]; - $affiliation = $articleAuthor->getAffiliation($publicationLocale); - if (!empty($affiliation)) { - $author['affiliation'] = $affiliation; + $affiliations = $articleAuthor->getLocalizedAffiliationNamesAsString($publicationLocale); + if (!empty($affiliations)) { + $author['affiliations'] = $affiliations; } if ($orcid = $articleAuthor->getData('orcid')) { $author['orcid_id'] = $orcid; diff --git a/plugins/importexport/doaj/filter/DOAJXmlFilter.php b/plugins/importexport/doaj/filter/DOAJXmlFilter.php index d5817b9f28f..8e7f7d34e82 100644 --- a/plugins/importexport/doaj/filter/DOAJXmlFilter.php +++ b/plugins/importexport/doaj/filter/DOAJXmlFilter.php @@ -3,8 +3,8 @@ /** * @file plugins/importexport/doaj/filter/DOAJXmlFilter.php * - * Copyright (c) 2014-2022 Simon Fraser University - * Copyright (c) 2000-2022 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2000-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class DOAJXmlFilter @@ -245,8 +245,15 @@ public function createAuthorNode($doc, $publication, $author, $affilList) $deployment = $this->getDeployment(); $authorNode = $doc->createElement('author'); $authorNode->appendChild($node = $doc->createElement('name', htmlspecialchars($author->getFullName(false, false, $publication->getData('locale')), ENT_COMPAT, 'UTF-8'))); - if (in_array($author->getAffiliation($publication->getData('locale')), $affilList) && !empty($affilList[0])) { - $authorNode->appendChild($node = $doc->createElement('affiliationId', htmlspecialchars(current(array_keys($affilList, $author->getAffiliation($publication->getData('locale')))), ENT_COMPAT, 'UTF-8'))); + $affiliations = $author->getLocalizedAffiliationNames($publication->getData('locale')); + foreach ($affiliations as $affiliation) { + if (in_array($affiliation, $affilList) && !empty($affilList[0])) { + $authorNode->appendChild( + $node = $doc->createElement('affiliationId', + htmlspecialchars(current(array_keys($affilList, $affiliation)), ENT_COMPAT, 'UTF-8') + ) + ); + } } if ($orcid = $author->getData('orcid')) { $authorNode->appendChild($doc->createElement('orcid_id'))->appendChild($doc->createTextNode($orcid)); @@ -266,8 +273,11 @@ public function createAffiliationsList($authors, $publication) { $affilList = []; foreach ($authors as $author) { - if (!in_array($author->getAffiliation($publication->getData('locale')), $affilList)) { - $affilList[] = $author->getAffiliation($publication->getData('locale')) ; + $affiliations = $author->getLocalizedAffiliationNames($publication->getData('locale')); + foreach ($affiliations as $affiliation) { + if (!in_array($affiliation, $affilList)) { + $affilList[] = $affiliation;; + } } } return $affilList; diff --git a/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php b/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php index ecea2032dab..7cbc9bc8c2a 100644 --- a/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php +++ b/plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php @@ -3,8 +3,8 @@ /** * @file plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2000-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2000-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class ArticlePubMedXmlFilter @@ -215,7 +215,18 @@ public function generateAuthorNode($doc, $journal, $issue, $submission, $author) $authorElement->appendChild($doc->createElement('FirstName'))->appendChild($doc->createTextNode(ucfirst($author->getLocalizedGivenName()))); $authorElement->appendChild($doc->createElement('LastName'))->appendChild($doc->createTextNode(ucfirst($author->getLocalizedFamilyName()))); } - $authorElement->appendChild($doc->createElement('Affiliation'))->appendChild($doc->createTextNode($author->getLocalizedAffiliation())); + foreach($author->getLocalizedAffiliations() as $affiliation) { + if(!empty($affiliation['name']) || !empty($affiliation['ror'])) { + $affiliationInfoElement = $doc->createElement('AffiliationInfo'); + if(!empty($affiliation['name'])) { + $affiliationInfoElement->appendChild($doc->createElement('Affiliation'))->appendChild($doc->createTextNode($affiliation['name'])); + } + if(!empty($affiliation['ror'])) { + $affiliationInfoElement->appendChild($doc->createElement('Identifier'))->appendChild($doc->createTextNode($affiliation['ror'])); + } + $authorElement->appendChild($affiliationInfoElement); + } + } // We're storing the ORCID with a URL (http://orcid.org/{$ID}), but the XML expects just the ID $orcidId = explode('/', trim($author->getData('orcid') ?? '', '/')); $orcidId = array_pop($orcidId); diff --git a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php index 71449fcd7cf..2fe3663d250 100755 --- a/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php +++ b/plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php @@ -1,4 +1,5 @@ setGivenName('author-firstname', 'en'); $author->setFamilyName('author-lastname', 'en'); - $author->setAffiliation('author-affiliation', 'en'); + $author->setAffiliations([ + Repo::affiliation()->newDataObject([ + "id" => 1, + "authorId" => 1, + "ror" => 'https://ror.org/05ek4tb53', + "name" => ['en' => 'author-affiliation'] + ]) + ]); $author->setEmail('someone@example.com'); // Publication diff --git a/plugins/oaiMetadataFormats/marc/templates/record.tpl b/plugins/oaiMetadataFormats/marc/templates/record.tpl index 16477409587..cd8e9ecb429 100644 --- a/plugins/oaiMetadataFormats/marc/templates/record.tpl +++ b/plugins/oaiMetadataFormats/marc/templates/record.tpl @@ -1,8 +1,8 @@ {** * plugins/oaiMetadataFormats/marc/record.tpl * - * Copyright (c) 2013-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2013-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * MARC-formatted metadata record for an article @@ -34,8 +34,10 @@ {foreach from=$authors item=author} {$author->getFullName(false, true, $journal->getPrimaryLocale())|escape} - {assign var=affiliation value=$author->getAffiliation($journal->getPrimaryLocale())} - {if $affiliation}{$affiliation|escape}{/if} + {foreach from=$author->getLocalizedAffiliations() item=$affiliation} + {if $affiliation['ror']}{$affiliation['ror']|escape} + {elseif $affiliation['name']}{$affiliation['name']|escape}{/if} + {/foreach} {if $author->getUrl()}{$author->getUrl()|escape}{/if} {if $author->getData('orcid')}{$author->getData('orcid')|escape}{/if} diff --git a/plugins/oaiMetadataFormats/marcxml/templates/record.tpl b/plugins/oaiMetadataFormats/marcxml/templates/record.tpl index 5f326b7b9fb..c0c3c1300f8 100644 --- a/plugins/oaiMetadataFormats/marcxml/templates/record.tpl +++ b/plugins/oaiMetadataFormats/marcxml/templates/record.tpl @@ -1,8 +1,8 @@ {** * plugins/oaiMetadataFormats/marcxml/record.tpl * - * Copyright (c) 2013-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2013-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * MARCXML-formatted metadata record for an article @@ -43,8 +43,10 @@ {foreach from=$authors item=author} {$author->getFullName(false, true, $journal->getPrimaryLocale())|escape} - {assign var=affiliation value=$author->getAffiliation($journal->getPrimaryLocale())} - {if $affiliation}{$affiliation|escape}{/if} + {foreach from=$author->getLocalizedAffiliations() item=$affiliation} + {if $affiliation['ror']}{$affiliation['ror']|escape} + {elseif $affiliation['name']}{$affiliation['name']|escape}{/if} + {/foreach} {if $author->getUrl()}{$author->getUrl()|escape}{/if} {if $author->getData('orcid')}{$author->getData('orcid')|escape}{/if} diff --git a/plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php b/plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php index e474187493b..16b9b7f54aa 100644 --- a/plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php +++ b/plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php @@ -3,8 +3,8 @@ /** * @file plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class OAIMetadataFormat_RFC1807 @@ -58,12 +58,7 @@ public function toXml($record, $format = null) // Format creators $creators = []; foreach ($publication->getAuthors() as $author) { - $authorName = $author->getFullName(false, true); - $affiliation = $author->getLocalizedAffiliation(); - if (!empty($affiliation)) { - $authorName .= '; ' . $affiliation; - } - $creators[] = $authorName; + $creators[] = $author->getFullName(false, true); } // Subject diff --git a/plugins/reports/articles/ArticleReportPlugin.php b/plugins/reports/articles/ArticleReportPlugin.php index e3a419a496e..137ef694174 100644 --- a/plugins/reports/articles/ArticleReportPlugin.php +++ b/plugins/reports/articles/ArticleReportPlugin.php @@ -3,8 +3,8 @@ /** * @file plugins/reports/articles/ArticleReportPlugin.php * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class ArticleReportPlugin @@ -175,7 +175,7 @@ public function display($args, $request) $author->getLocalizedFamilyName(), $author->getData('orcid'), $author->getData('country'), - $author->getLocalizedData('affiliation'), + $author->getLocalizedAffiliationNamesAsString(), $author->getData('email'), $author->getData('url'), html_entity_decode(strip_tags($author->getLocalizedData('biography'))), @@ -195,7 +195,7 @@ public function display($args, $request) 'url' => $request->url(null, 'workflow', 'access', $submission->getId()), 'doi' => $submission->getStoredPubId('doi'), 'dateSubmitted' => $submission->getData('dateSubmitted'), - 'lastModified' => $submission->getLastModified(), + 'lastModified' => $submission->getData['lastModified'], 'firstPublished' => $submission->getOriginalPublication()?->getData('datePublished') ?? '', 'editors' => $editors, 'decisions' => $editDecisions->toArray(), diff --git a/templates/frontend/objects/article_details.tpl b/templates/frontend/objects/article_details.tpl index 0c5b51e4b0a..3933fa76805 100755 --- a/templates/frontend/objects/article_details.tpl +++ b/templates/frontend/objects/article_details.tpl @@ -1,8 +1,8 @@ {** * templates/frontend/objects/article_details.tpl * - * Copyright (c) 2014-2021 Simon Fraser University - * Copyright (c) 2003-2021 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @brief View of an Article which displays all details about the article. @@ -113,13 +113,13 @@ {$author->getFullName()|escape} - {if $author->getLocalizedData('affiliation')} + {if $author->getLocalizedAffiliations()} + {foreach $author->getLocalizedAffiliations() as $affiliation} - {$author->getLocalizedData('affiliation')|escape} - {if $author->getData('rorId')} - {$rorIdIcon} - {/if} - + {$affiliation['name']|escape} + {if $affiliation['ror']}{$rorIdIcon}{/if} +
+ {/foreach} {/if} {assign var=authorUserGroup value=$userGroupsById[$author->getData('userGroupId')]} {if $authorUserGroup->getShowTitle()} @@ -223,13 +223,13 @@ {if $author->getLocalizedData('biography')}
  • - {if $author->getLocalizedData('affiliation')} - {capture assign="authorName"}{$author->getFullName()|escape}{/capture} - {capture assign="authorAffiliation"} {$author->getLocalizedData('affiliation')|escape} {/capture} - {translate key="submission.authorWithAffiliation" name=$authorName affiliation=$authorAffiliation} - {else} - {$author->getFullName()|escape} - {/if} + {if $author->getLocalizedAffiliationNamesAsString()} + {capture assign="authorName"}{$author->getFullName()|escape}{/capture} + {capture assign="authorAffiliations"} {$author->getLocalizedAffiliationNamesAsString()|escape} {/capture} + {translate key="submission.authorWithAffiliation" name=$authorName affiliation=$authorAffiliations} + {else} + {$author->getFullName()|escape} + {/if}
    {$author->getLocalizedData('biography')|strip_unsafe_html} diff --git a/templates/images/ror-org-logo-icon.svg b/templates/images/ror-org-logo-icon.svg new file mode 100644 index 00000000000..7b27e1e3d2c --- /dev/null +++ b/templates/images/ror-org-logo-icon.svg @@ -0,0 +1,92 @@ + + + +image/svg+xml + + + + + + + + + + + + + + +