Skip to content

Commit

Permalink
multiple author affiliations
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel committed Dec 6, 2024
1 parent 1f1bb3f commit 639dca7
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 74 deletions.
19 changes: 19 additions & 0 deletions api/v1/rors/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @defgroup api_v1_rors Ror API requests
*/

/**
* @file api/v1/rors/index.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @ingroup api_v1_rors
*
* @brief Handle API requests for rors.
*/

return new \PKP\handler\APIHandler(new \PKP\API\v1\rors\PKPRorController());
6 changes: 4 additions & 2 deletions dbscripts/xml/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!--
* dbscripts/xml/install.xml
*
* 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.
*
* Installation descriptor file.
Expand Down Expand Up @@ -39,6 +39,8 @@
<migration class="PKP\migration\install\TombstoneMigration" />
<migration class="PKP\migration\install\DoiMigration" />
<migration class="PKP\migration\install\InstitutionsMigration" />
<migration class="PKP\migration\install\AffiliationsMigration" />
<migration class="PKP\migration\install\RorsMigration" />

<migration class="APP\migration\install\OJSMigration" />

Expand Down
6 changes: 4 additions & 2 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!--
* dbscripts/xml/upgrade.xml
*
* 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.
*
* Upgrade descriptor file.
Expand Down Expand Up @@ -151,6 +151,8 @@
<migration class="PKP\migration\upgrade\v3_5_0\I9771_OrcidMigration"/>
<migration class="APP\migration\upgrade\v3_5_0\I5885_RenameReviewReminderSettingsName"/>
<migration class="PKP\migration\upgrade\v3_5_0\COA75_AddUserRoleEndEmail"/>
<migration class="PKP\migration\upgrade\v3_5_0\I7135_CreateAuthorAffiliationsTables"/>
<migration class="PKP\migration\upgrade\v3_5_0\I7135_CreateNewRorRegistryCacheTables"/>
</upgrade>

<!-- update plugin configuration - should be done as the final upgrade task -->
Expand Down
10 changes: 8 additions & 2 deletions pages/article/ArticleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
31 changes: 15 additions & 16 deletions plugins/generic/datacite/filter/DataciteXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -307,8 +307,7 @@ public function createCreatorsNode($doc, $issue, $publication, $galley, $galleyF
$creators[] = [
'name' => $creator,
'orcid' => null,
'affiliation' => null,
'ror' => null
'affiliations' => null
];
break;
}
Expand All @@ -323,17 +322,15 @@ 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;
case isset($issue):
$creators[] = [
'name' => $publisher,
'orcid' => null,
'affiliation' => null,
'ror' => null
'affiliations' => null
];
break;
}
Expand All @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions plugins/importexport/doaj/filter/DOAJJsonFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 16 additions & 6 deletions plugins/importexport/doaj/filter/DOAJXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

/**
* @defgroup plugins_oaiMetadataFormats_dc_tests Dublin Core OAI Plugin
*/

/**
* @file plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.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 OAIMetadataFormat_DCTest
Expand Down Expand Up @@ -88,7 +89,14 @@ public function testToXml()
$author = new Author();
$author->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
Expand Down
10 changes: 6 additions & 4 deletions plugins/oaiMetadataFormats/marc/templates/record.tpl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,8 +34,10 @@
{foreach from=$authors item=author}
<varfield id="{if $authors|@count==1}100{else}720{/if}" i1="1" i2=" ">
<subfield label="a">{$author->getFullName(false, true, $journal->getPrimaryLocale())|escape}</subfield>
{assign var=affiliation value=$author->getAffiliation($journal->getPrimaryLocale())}
{if $affiliation}<subfield label="u">{$affiliation|escape}</subfield>{/if}
{foreach from=$author->getLocalizedAffiliations() item=$affiliation}
{if $affiliation['ror']}<subfield code="u">{$affiliation['ror']|escape}</subfield>
{elseif $affiliation['name']}<subfield code="u">{$affiliation['name']|escape}</subfield>{/if}
{/foreach}
{if $author->getUrl()}<subfield label="0">{$author->getUrl()|escape}</subfield>{/if}
{if $author->getData('orcid')}<subfield label="0">{$author->getData('orcid')|escape}</subfield>{/if}
</varfield>
Expand Down
10 changes: 6 additions & 4 deletions plugins/oaiMetadataFormats/marcxml/templates/record.tpl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,8 +43,10 @@
{foreach from=$authors item=author}
<datafield tag="{if $authors|@count==1}100{else}720{/if}" ind1="1" ind2=" ">
<subfield code="a">{$author->getFullName(false, true, $journal->getPrimaryLocale())|escape}</subfield>
{assign var=affiliation value=$author->getAffiliation($journal->getPrimaryLocale())}
{if $affiliation}<subfield code="u">{$affiliation|escape}</subfield>{/if}
{foreach from=$author->getLocalizedAffiliations() item=$affiliation}
{if $affiliation['ror']}<subfield code="u">{$affiliation['ror']|escape}</subfield>
{elseif $affiliation['name']}<subfield code="u">{$affiliation['name']|escape}</subfield>{/if}
{/foreach}
{if $author->getUrl()}<subfield code="0">{$author->getUrl()|escape}</subfield>{/if}
{if $author->getData('orcid')}<subfield code="0">{$author->getData('orcid')|escape}</subfield>{/if}
</datafield>
Expand Down
11 changes: 3 additions & 8 deletions plugins/oaiMetadataFormats/rfc1807/OAIMetadataFormat_RFC1807.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions plugins/reports/articles/ArticleReportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))),
Expand All @@ -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(),
Expand Down
Loading

0 comments on commit 639dca7

Please sign in to comment.