12 |
12 |
*/
|
13 |
13 |
function compose_agent($agent, $enclosing_tag) {
|
14 |
14 |
|
15 |
|
$render_array = [];
|
16 |
|
$name_caches = $agent->titleCache;
|
17 |
15 |
|
|
16 |
$names_and_lifespan = $agent->titleCache;
|
18 |
17 |
|
19 |
|
$name_details = [];
|
20 |
|
if($agent->familyName){
|
21 |
|
$name_details[] = '<span class="label">' . t('Family name') . ': </span>'. $agent->familyName;
|
22 |
|
}
|
23 |
|
if($agent->givenName){
|
24 |
|
$name_details[] = '<span class="label">' . t('Given name') . ': </span>'. $agent->givenName;
|
25 |
|
}
|
26 |
|
$name_details_markup = ' (' . join(', ', $name_details) .')';
|
27 |
18 |
if($agent->nomenclaturalTitle != $agent->titleCache){
|
28 |
|
$name_details_markup .= ' ' . $agent->nomenclaturalTitle;
|
|
19 |
$names_and_lifespan .= ' [' . $agent->nomenclaturalTitle . ']';
|
29 |
20 |
}
|
30 |
21 |
|
31 |
|
$details[] = $name_details_markup;
|
32 |
|
if($agent->lifespan){
|
33 |
|
// as first element after the titleCache
|
34 |
|
$lifespan_text = timePeriodToString($agent->lifespan);
|
35 |
|
if($lifespan_text){
|
36 |
|
array_unshift($details, ", " . $lifespan_text);
|
37 |
|
}
|
38 |
|
}
|
39 |
22 |
$visible_extensions_sorted = visible_extensions_sorted($agent);
|
40 |
|
// FIXME:-------------------------------
|
41 |
|
// 7d1a269b-9bdd-44eb-beba-2f8acee941af is the phycobank specific ext type for "Life span" which will become obsolte!!!!
|
|
23 |
// FIXME:-------------- "Life span" as Extension -------------
|
|
24 |
// 7d1a269b-9bdd-44eb-beba-2f8acee941af is the phycobank specific ext type for "Life span" which will become obsolete!!!!
|
42 |
25 |
if(isset($visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af'])){
|
43 |
26 |
// as first element after the titleCache
|
44 |
|
array_unshift($details, ", " . $visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af'][0]->value);
|
|
27 |
$lifespan_extension = $visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af'][0]->value;
|
45 |
28 |
unset($visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af']);
|
46 |
29 |
}
|
47 |
30 |
// ------------------------------------
|
|
31 |
if(!$names_and_lifespan && $agent->lifespan){
|
|
32 |
$names_and_lifespan .= ', ' . timePeriodToString($agent->lifespan);
|
|
33 |
} else {
|
|
34 |
$names_and_lifespan .= ", " . $lifespan_extension;
|
|
35 |
}
|
|
36 |
|
|
37 |
$names_and_lifespan_markup = '<div class="names-and-lifespan">' . $names_and_lifespan . '</div> ';
|
|
38 |
|
|
39 |
$name_details = [];
|
|
40 |
if($agent->familyName){
|
|
41 |
$name_details[] = '<span class="label">' . t('Family name') . ': </span>'. $agent->familyName;
|
|
42 |
}
|
|
43 |
if($agent->givenName){
|
|
44 |
$name_details[] = '<span class="label">' . t('Given name') . ': </span>'. $agent->givenName;
|
|
45 |
}
|
|
46 |
$name_details_markup = ' <div class="name-details">(' . join(', ', $name_details) .')</div> ';
|
|
47 |
|
48 |
48 |
// extensions
|
49 |
49 |
$extensions = [];
|
50 |
50 |
foreach ($visible_extensions_sorted as $type_uuid => $exts){
|
... | ... | |
54 |
54 |
}
|
55 |
55 |
}
|
56 |
56 |
}
|
57 |
|
$extensions_markup = join(', ', $extensions);
|
58 |
|
if($extensions_markup){
|
59 |
|
$details[] = $extensions_markup;
|
|
57 |
if(count($extensions) > 0 ){
|
|
58 |
$extensions_markup = '<div class="extensions">' . join(', ', $extensions) . '</div>';
|
60 |
59 |
}
|
61 |
60 |
|
62 |
|
// IDs as last
|
|
61 |
// IDs
|
|
62 |
$identifiers_markup = '';
|
|
63 |
$identifiers_render_array = [];
|
63 |
64 |
if(isset($agent->orcid)){
|
64 |
|
$corcid_id = number_format($agent->orcid->digitsOnly, 0, '.', '-');
|
65 |
|
$details[] = l('https://orcid.org/' . $corcid_id, 'https://orcid.org/' . $corcid_id);
|
|
65 |
$orcid_id = number_format($agent->orcid->digitsOnly, 0, '.', '-');
|
|
66 |
$identifiers_render_array[] = markup_to_render_array(l('https://orcid.org/' . $orcid_id, 'https://orcid.org/' . $orcid_id) . ' ');
|
66 |
67 |
}
|
67 |
68 |
if($agent->identifiers){
|
68 |
|
$identifiers_render_array = compose_identifiers($agent->identifiers);
|
69 |
|
$details[] = drupal_render($identifiers_render_array);
|
|
69 |
$identifiers_render_array = array_merge($identifiers_render_array, compose_identifiers($agent->identifiers));
|
|
70 |
}
|
|
71 |
if(count($identifiers_render_array) > 0){
|
|
72 |
$identifiers_markup = '<div class="identifier">' . drupal_render($identifiers_render_array) . '</div>';
|
70 |
73 |
}
|
71 |
74 |
|
72 |
|
$details_markup = join(' ', $details);
|
73 |
75 |
|
74 |
|
$render_array = markup_to_render_array($name_caches . $details_markup, null, '<' . $enclosing_tag . ' class="' . html_class_attribute_ref($agent) . '">', '</' . $enclosing_tag . '>');
|
|
76 |
$render_array = markup_to_render_array($names_and_lifespan_markup . $name_details_markup . $extensions_markup . $identifiers_markup, null, '<' . $enclosing_tag . ' class="' . html_class_attribute_ref($agent) . '">', '</' . $enclosing_tag . '>');
|
75 |
77 |
|
76 |
78 |
return $render_array;
|
77 |
79 |
}
|
ref #9034 new agent item layout