Skip to content

Commit

Permalink
multiple author affiliations
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel committed Jan 20, 2025
1 parent fa7f1f9 commit f5baf3e
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 68 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 @@ -159,6 +159,8 @@
<migration class="PKP\migration\upgrade\v3_5_0\FilterClassNames"/>
<migration class="APP\migration\upgrade\v3_5_0\I10620_EditorialBoardMemberRole"/>
<migration class="APP\migration\upgrade\v3_5_0\I9707_WeblateUILocales"/>
<migration class="PKP\migration\upgrade\v3_5_0\I7135_CreateAuthorAffiliationsTables"/>
<migration class="PKP\migration\upgrade\v3_5_0\I7135_CreateNewRorRegistryCacheTables"/>
<note file="docs/release-notes/README-3.5.0" />
</upgrade>

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 @@ -360,6 +360,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 @@ -297,8 +297,7 @@ public function createCreatorsNode(DOMDocument $doc, Issue $issue, Publication $
$creators[] = [
'name' => $creator,
'orcid' => null,
'affiliation' => null,
'ror' => null
'affiliations' => null
];
break;
}
Expand All @@ -312,17 +311,15 @@ public function createCreatorsNode(DOMDocument $doc, Issue $issue, Publication $
$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 @@ -338,15 +335,17 @@ public function createCreatorsNode(DOMDocument $doc, Issue $issue, Publication $
$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 @@ -158,9 +158,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 @@ -248,8 +248,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 @@ -269,8 +276,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
13 changes: 10 additions & 3 deletions plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* @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 @@ -102,7 +102,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('[email protected]');

// Publication
Expand Down
6 changes: 4 additions & 2 deletions plugins/oaiMetadataFormats/marc/templates/record.tpl
Original file line number Diff line number Diff line change
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
6 changes: 4 additions & 2 deletions plugins/oaiMetadataFormats/marcxml/templates/record.tpl
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,8 @@ public function toXml($record, $format = null)

// Format creators
$creators = [];
foreach ($publication->getData('authors') as $author) {
$authorName = $author->getFullName(false, true);
$affiliation = $author->getLocalizedAffiliation();
if (!empty($affiliation)) {
$authorName .= '; ' . $affiliation;
}
$creators[] = $authorName;
foreach ($publication->getAuthors() as $author) {
$creators[] = $author->getFullName(false, true);
}

$subjects = array_merge_recursive(
Expand Down
6 changes: 3 additions & 3 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 @@ -186,7 +186,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 Down
30 changes: 15 additions & 15 deletions templates/frontend/objects/article_details.tpl
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -113,13 +113,13 @@
<span class="name">
{$author->getFullName()|escape}
</span>
{if $author->getLocalizedData('affiliation')}
{if $author->getLocalizedAffiliations()}
{foreach $author->getLocalizedAffiliations() as $affiliation}
<span class="affiliation">
{$author->getLocalizedData('affiliation')|escape}
{if $author->getData('rorId')}
<a href="{$author->getData('rorId')|escape}">{$rorIdIcon}</a>
{/if}
</span>
{$affiliation['name']|escape}
{if $affiliation['ror']}<a href="{$affiliation['ror']|escape}">{$rorIdIcon}</a>{/if}
</span><br/>
{/foreach}
{/if}
{assign var=authorUserGroup value=$userGroupsById[$author->getData('userGroupId')]}
{if $authorUserGroup->showTitle}
Expand Down Expand Up @@ -223,13 +223,13 @@
{if $author->getLocalizedData('biography')}
<li class="sub_item">
<div class="label">
{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}
</div>
<div class="value">
{$author->getLocalizedData('biography')|strip_unsafe_html}
Expand Down
Loading

0 comments on commit f5baf3e

Please sign in to comment.