|
1 |
<?php
|
|
2 |
|
|
3 |
/**
|
|
4 |
* Compose a description as a table of Feature<->State
|
|
5 |
*
|
|
6 |
* @param $description_uuid
|
|
7 |
*
|
|
8 |
* @return array
|
|
9 |
* The drupal render array for the page
|
|
10 |
*
|
|
11 |
* @ingroup compose
|
|
12 |
*/
|
|
13 |
function compose_agent($agent, $enclosing_tag) {
|
|
14 |
|
|
15 |
$name_details = [];
|
|
16 |
if($agent->familyName){
|
|
17 |
$name_details[] = '<span class="label">' . t('Family name') . ': </span>'. $agent->familyName;
|
|
18 |
}
|
|
19 |
if($agent->givenName){
|
|
20 |
$name_details[] = '<span class="label">' . t('Given name') . ': </span>'. $agent->givenName;
|
|
21 |
}
|
|
22 |
$details[] = join(', ', $name_details);
|
|
23 |
if($details[0]) {
|
|
24 |
$details[0] = ' (' . $details[0] . ')';
|
|
25 |
}
|
|
26 |
if($agent->lifespan){
|
|
27 |
// as first element after the titleCache
|
|
28 |
$lifespan_text = timePeriodToString($agent->lifespan);
|
|
29 |
if($lifespan_text){
|
|
30 |
array_unshift($details, ", " . $lifespan_text);
|
|
31 |
}
|
|
32 |
}
|
|
33 |
// FIXME:-------------------------------
|
|
34 |
// 7d1a269b-9bdd-44eb-beba-2f8acee941af is the phycobank specific ext type for "Life span" which will become obsolte!!!!
|
|
35 |
if(isset($visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af'])){
|
|
36 |
// as first element after the titleCache
|
|
37 |
array_unshift($details, ", " . $visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af'][0]->value);
|
|
38 |
unset($visible_extensions_sorted['7d1a269b-9bdd-44eb-beba-2f8acee941af']);
|
|
39 |
}
|
|
40 |
// ------------------------------------
|
|
41 |
// extensions
|
|
42 |
$visible_extensions_sorted = visible_extensions_sorted($agent);
|
|
43 |
$extensions = [];
|
|
44 |
foreach ($visible_extensions_sorted as $type_uuid => $exts){
|
|
45 |
foreach ($exts as $ext){
|
|
46 |
if($ext->value){
|
|
47 |
$extensions[] = '<span class="label">' . $ext->type->representation_L10n . ': </span>'. $ext->value;
|
|
48 |
}
|
|
49 |
}
|
|
50 |
}
|
|
51 |
$extensions_markup = join(', ', $extensions);
|
|
52 |
if($extensions_markup){
|
|
53 |
$details[] = $extensions_markup;
|
|
54 |
}
|
|
55 |
|
|
56 |
// IDs as last
|
|
57 |
if(isset($agent->orcid)){
|
|
58 |
$corcid_id = number_format($agent->orcid->digitsOnly, 0, '.', '-');
|
|
59 |
$details[] = l('https://orcid.org/' . $corcid_id, 'https://orcid.org/' . $corcid_id);
|
|
60 |
}
|
|
61 |
if($agent->identifiers){
|
|
62 |
$identifiers_render_array = compose_identifiers($agent->identifiers);
|
|
63 |
$details[] = drupal_render($identifiers_render_array);
|
|
64 |
}
|
|
65 |
|
|
66 |
$details_markup = join(' ', $details);
|
|
67 |
|
|
68 |
$render_array = markup_to_render_array($agent->titleCache . $details_markup, null, '<' . $enclosing_tag . ' class="' . html_class_attribute_ref($agent) . '">', '</' . $enclosing_tag . '>');
|
|
69 |
|
|
70 |
return $render_array;
|
|
71 |
}
|
ref #9034 simple agent search page with filter function by query parameter