Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10792 update ORCiD branding #10829

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions classes/author/maps/Schema.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/author/maps/Schema.php
*
Expand Down Expand Up @@ -102,6 +103,9 @@ protected function mapByProperties(array $props, Author $item): array
case 'hasVerifiedOrcid':
$output[$prop] = $item->hasVerifiedOrcid();
break;
case 'orcidDisplayValue':
$output[$prop] = $item->getOrcidDisplayValue();
break;
default:
$output[$prop] = $item->getData($prop);
break;
Expand Down
13 changes: 13 additions & 0 deletions classes/identity/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ public function getOrcid()
return $this->getData('orcid');
}

/**
* Return the string that should be displayed when showing a user's ORCiD
*
*/
public function getOrcidDisplayValue(): ?string
{
if (!$this->getOrcid()) {
return null;
}

return $this->hasVerifiedOrcid() ? $this->getOrcid() : $this->getOrcid() . ' (' . __('orcid.unauthenticated') . ')';
}

/**
* Set ORCID identifier.
*
Expand Down
11 changes: 11 additions & 0 deletions classes/orcid/OrcidManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ public static function getIcon(): string
return file_exists($path) ? file_get_contents($path) : '';
}

/**
* Return a string of the ORCiD unauthenticated SVG icon
*
*/
public static function getUnauthenticatedIcon(): string
{
$path = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/templates/images/orcid_unauthenticated.svg';
return file_exists($path) ? file_get_contents($path) : '';
}


/**
* Checks if ORCID functionality is enabled. Works at the context-level.
*/
Expand Down
2 changes: 2 additions & 0 deletions classes/user/form/IdentityForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function fetch($request, $template = null, $display = false)
'orcidOAuthUrl' => OrcidManager::buildOAuthUrl('authorizeOrcid', ['targetOp' => $targetOp]),
'orcidClientId' => OrcidManager::getClientId(),
'orcidIcon' => OrcidManager::getIcon(),
'orcidUnauthenticatedIcon' => OrcidManager::getUnauthenticatedIcon(),
'orcidAuthenticated' => $user !== null && $user->hasVerifiedOrcid(),
'orcidDisplayValue' => $user->getOrcidDisplayValue(),
]);
} else {
$templateMgr->assign([
Expand Down
6 changes: 5 additions & 1 deletion classes/user/maps/Schema.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/user/maps/Schema.php
*
Expand Down Expand Up @@ -187,7 +188,7 @@ protected function mapByProperties(array $props, User $user, array $auxiliaryDat
$output[$prop] = [];
if ($this->context) {
$interests = collect(Repo::userInterest()->getInterestsForUser($user))
->map(fn($value, $index) => ['id' => $index, 'interest' => $value])
->map(fn ($value, $index) => ['id' => $index, 'interest' => $value])
->values()
->toArray();

Expand Down Expand Up @@ -255,6 +256,9 @@ protected function mapByProperties(array $props, User $user, array $auxiliaryDat
case 'displayInitials':
$output['displayInitials'] = $user->getDisplayInitials();
break;
case 'orcidDisplayValue':
$output[$prop] = $user->getOrcidDisplayValue();
break;
default:
$output[$prop] = $user->getData($prop);
break;
Expand Down
3 changes: 3 additions & 0 deletions locale/en/user.po
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ msgstr "See below to request authenticated ORCID iD"
msgid "orcid.author.unauthenticated"
msgstr "ORCID iD not authenticated! Please request authentication from the contributor."

msgid "orcid.unauthenticated"
msgstr "unauthenticated"

msgid "orcid.verify.title"
msgstr "ORCID Authorization"

Expand Down
8 changes: 8 additions & 0 deletions schemas/author.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@
"orcidVerificationRequested": {
"type": "boolean",
"apiSummary": false
},
"orcidDisplayValue": {
"type": "string",
"apiSummary": true,
"readOnly": true,
"validation": [
"nullable"
]
}
}
}
8 changes: 8 additions & 0 deletions schemas/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@
"description": "The initials that will be displayed for a user.",
"type": "string",
"apiSummary": true
},
"orcidDisplayValue": {
"type": "string",
"apiSummary": true,
"readOnly": true,
"validation": [
"nullable"
]
}
}
}
21 changes: 13 additions & 8 deletions templates/form/orcidProfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
*}

{capture name=orcidButton assign=orcidButton}
<button id="connect-orcid-button" class="pkp_button" onclick="return openORCID();">
{if $orcid && !$orcidAuthenticated }
<div class="orcid_button_container">{$orcidIcon}{translate key='orcid.authorise'}</div>
{else}

{if $orcid && !$orcidAuthenticated }
<a href="{$orcid}" target="_blank" class='flex gap-2 mb-4'>{$orcidUnauthenticatedIcon}{$orcidDisplayValue}</a>
<button id="connect-orcid-button" class="pkp_button" onclick="return openORCID();">
{$orcidIcon}{translate key='orcid.authorise'}
</button>
{else}
<button id="connect-orcid-button" class="pkp_button" onclick="return openORCID();">
<div class="orcid_button_container">{$orcidIcon} {translate key='orcid.connect'}</div>
{/if}
</button>
<a href="{url router="page" page="orcid" op="about"}">{translate key='orcid.about.title'}</a>
</button>
{/if}

<a href="{url router="page" page="orcid" op="about"}" onclick="return openORCID();">{translate key='orcid.about.title'}</a>
{/capture}


{capture name=orcidLink assign=orcidLink}
{if $orcidAuthenticated}
<a href="{$orcid}" target="_blank" id='orcid-link'>{$orcidIcon}{$orcid}</a>
<a href="{$orcid}" target="_blank" id='orcid-link'>{$orcidIcon}{$orcidDisplayValue}</a>
{else}
{$orcidButton}
{/if}
Expand Down
2 changes: 1 addition & 1 deletion templates/frontend/pages/editorialHistory.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</span>
<span class="name">
{$mastheadUser['user']->getFullName()|escape}
{if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken')}
{if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken') && $mastheadUser['user']->hasVerifiedOrcid()}
<span class="orcid">
<a href="{$mastheadUser['user']->getData('orcid')|escape}" target="_blank" aria-label="{translate key="common.editorialHistory.page.orcidLink" name=$mastheadUser['user']->getFullName()|escape}">
{$orcidIcon}
Expand Down
4 changes: 2 additions & 2 deletions templates/frontend/pages/editorialMasthead.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<span class="date_start">{translate key="common.fromUntil" from=$mastheadUser['dateStart'] until=""}</span>
<span class="name">
{$mastheadUser['user']->getFullName()|escape}
{if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken')}
<span class="orcid">
{if $mastheadUser['user']->getData('orcid') && $mastheadUser['user']->getData('orcidAccessToken') && $mastheadUser['user']->hasVerifiedOrcid()}
<span class="orcid">
<a href="{$mastheadUser['user']->getData('orcid')|escape}" target="_blank" aria-label="{translate key="common.editorialHistory.page.orcidLink" name=$mastheadUser['user']->getFullName()|escape}">
{$orcidIcon}
</a>
Expand Down
5 changes: 5 additions & 0 deletions templates/images/orcid_unauthenticated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.