Skip to content

Commit

Permalink
pkp#10792 WIP:update brand guideline
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Jan 17, 2025
1 parent 5b69986 commit 5ea901a
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 9 deletions.
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 '';
}

return $this->hasVerifiedOrcid() ? $this->getOrcid() : $this->getOrcid() . ' (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
7 changes: 7 additions & 0 deletions schemas/author.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@
"orcidVerificationRequested": {
"type": "boolean",
"apiSummary": false
},
"orcidDisplayValue": {
"types": "string",
"apiSummary": true,
"validation": [
"nullable"
]
}
}
}
7 changes: 7 additions & 0 deletions schemas/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@
"description": "The initials that will be displayed for a user.",
"type": "string",
"apiSummary": true
},
"orcidDisplayValue": {
"types": "string",
"apiSummary": true,
"validation": [
"nullable"
]
}
}
}
19 changes: 11 additions & 8 deletions templates/form/orcidProfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
*}

{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}
<div class="orcid_button_container">{$orcidIcon} {translate key='orcid.connect'}</div>
{/if}
</button>

{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}
<div class="orcid_button_container">{$orcidIcon} {translate key='orcid.connect'}</div>
{/if}

<a href="{url router="page" page="orcid" op="about"}">{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
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.

0 comments on commit 5ea901a

Please sign in to comment.