|
{ |
|
package EPrints::Script::Compiled; |
|
use strict; |
|
|
|
sub run_people_with_orcids |
|
{ |
|
my( $self, $state, $value ) = @_; |
|
|
|
my $session = $state->{session}; |
|
my $r = $state->{session}->make_doc_fragment; |
|
|
|
my $contributors = $value->[0]; |
|
my $field = $value->[1]; |
|
|
|
my $f = $field->get_property( "fields_cache" ); |
|
my $browse_links = {}; |
|
my $views = $session->config( "browse_views" ); |
|
|
|
foreach my $sub_field ( @{$f} ) |
|
{ |
|
if( defined $sub_field->{browse_link} ) |
|
{ |
|
my $linkview; |
|
foreach my $view ( @{$views} ) |
|
{ |
|
$linkview = $view if( $view->{id} eq $sub_field->{browse_link} ); |
|
} |
|
$browse_links->{$sub_field->property("sub_name")}->{view} = $linkview; |
|
$browse_links->{$sub_field->property("sub_name")}->{field} = $sub_field; |
|
} |
|
} |
|
|
|
foreach my $i ( 0..$#$contributors ) |
|
{ |
|
my $contributor = @$contributors[$i]; |
|
my $url = $session->config( "rel_path" ); |
|
|
|
my $contributors = $value->[0]; |
|
|
|
if( $i > 0 ) |
|
{ |
|
# not first item (or only one item) |
|
if( $i == $#$contributors ) |
|
{ |
|
# last item |
|
$r->appendChild( $session->make_text( " and " ) ); |
|
} |
|
else |
|
{ |
|
$r->appendChild( $session->make_text( ", " ) ); |
|
} |
|
} |
|
|
|
my $person_span = $session->make_element( "span", "class" => "person" ); |
|
|
|
# only looking for browse_link in the name sub field for now... |
|
if( defined( $browse_links->{name} ) ) |
|
{ |
|
my $linkview = $browse_links->{name}->{view}; |
|
my $sub_field = $browse_links->{name}->{field}; |
|
my $link_id = $sub_field->get_id_from_value( $session, $contributor->{name} ); |
|
|
|
if( |
|
( defined $linkview->{fields} && $linkview->{fields} =~ m/,/ ) || |
|
( defined $linkview->{menus} && scalar(@{$linkview->{menus}}) > 1 ) |
|
) |
|
{ |
|
# has sub pages |
|
$url .= "/view/".$sub_field->{browse_link}."/". |
|
EPrints::Utils::escape_filename( $link_id )."/"; |
|
} |
|
else |
|
{ |
|
# no sub pages |
|
$url .= "/view/".$sub_field->{browse_link}."/". |
|
EPrints::Utils::escape_filename( $link_id ). |
|
".html"; |
|
} |
|
my $a = $session->render_link( $url ); |
|
$a->appendChild( $session->render_name( $contributor->{name} ) ); |
|
$person_span->appendChild( $a ); |
|
} |
|
else |
|
{ |
|
$person_span->appendChild( $session->render_name( $contributor->{name} ) ); |
|
} |
|
|
|
|
|
my $orcid = $contributor->{orcid}; |
|
my $uri = ""; |
|
$uri = $session->get_request->uri if defined $session->get_request; |
|
if( $uri !~ m/exportview/ && $uri !~ m!/export_! && $uri !~ m!/cgi/export/! && defined $orcid && $orcid =~ m/^(?:orcid.org\/)?(\d{4}\-\d{4}\-\d{4}\-\d{3}(?:\d|X))$/ ) |
|
{ |
|
my $orcid_link = $session->make_element( "a", |
|
"class" => "orcid", |
|
"href" => "https://orcid.org/$1", |
|
"target" => "_blank", |
|
); |
|
$orcid_link->appendChild( $session->make_element( "img", "src" => "/images/orcid_id.svg", "class" => "orcid-icon", "alt" => "ORCID logo" ) ); |
|
|
|
my $orcid_span = $session->make_element( "span", "class" => "orcid-tooltip" ); |
|
|
|
$orcid_span->appendChild( $session->make_text( "ORCID: " ) ); |
|
$orcid_span->appendChild( $session->make_text( "https://orcid.org/$1" ) ); |
|
$orcid_link->appendChild( $orcid_span ); |
|
|
|
$person_span->appendChild( $session->make_text( " " ) ); |
|
$person_span->appendChild( $orcid_link ); |
|
|
|
$person_span->setAttribute( "class", "person orcid-person" ); |
|
} |
|
$r->appendChild( $person_span ); |
|
} |
|
return [ $r, "XHTML" ]; |
|
} |
|
|
|
} |
This block:
orcid_support/cfg/cfg.d/z_orcid_support.pl
Lines 125 to 241 in 84c916b
when used in a multiple-archive configuration results in:
Subroutine run_people_with_orcids redefined at (eval 2408) line 171.Possibly move this method to a site_lib or lib file.