Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / includes / agent.inc @ 93f3d033

History | View | Annotate | Download (2.53 KB)

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

    
16
  $names_and_lifespan = $agent->titleCache;
17

    
18
  if(isset($agent->nomenclaturalTitle) && $agent->nomenclaturalTitle != $agent->titleCache){
19
    $names_and_lifespan .=  ' [' . $agent->nomenclaturalTitle . ']';
20
  }
21

    
22
  $visible_extensions_sorted = visible_extensions_sorted($agent);
23
  // ------------------------------------
24
  if(isset($agent->lifespan)){
25
    $names_and_lifespan .= ', ' . timePeriodToString($agent->lifespan);
26
  }
27
  $names_and_lifespan_markup = '<div class="names-and-lifespan">' . $names_and_lifespan . '</div> ';
28

    
29
  $name_details = [];
30
  $name_details_markup = '';
31
  if(isset($agent->familyName) || isset($agent->givenName)){
32
    if(isset($agent->familyName)){
33
      $name_details[] = '<span class="label">' . t('Family name') . ': </span>'. $agent->familyName;
34
    }
35
    if(isset($agent->givenName)){
36
      $name_details[] = '<span class="label">' . t('Given name') . ': </span>'. $agent->givenName;
37
    }
38
    $name_details_markup = ' <div class="name-details">(' .  join(', ', $name_details) .')</div> ';
39
  }
40

    
41
  // extensions
42
  $extensions = [];
43
  foreach ($visible_extensions_sorted as $type_uuid => $exts){
44
    foreach ($exts as $ext){
45
      if($ext->value){
46
        $extensions[] = '<span class="label">' . $ext->type->representation_L10n . ': </span>'. $ext->value;
47
      }
48
    }
49
  }
50
  $extensions_markup = '';
51
  if(count($extensions) > 0 ){
52
    $extensions_markup = '<div class="extensions">' . join(', ', $extensions) . '</div>';
53
  }
54

    
55
  // IDs
56
  $identifiers_markup = '';
57
  $identifiers_render_array = [];
58
  if(isset($agent->orcid)){
59
    $orcid_id = number_format($agent->orcid->digitsOnly, 0, '.', '-');
60
    $identifiers_render_array[] = markup_to_render_array(l('https://orcid.org/' . $orcid_id, 'https://orcid.org/' . $orcid_id) . ' ');
61
  }
62
  if(isset($agent->identifiers)){
63
    $identifiers_render_array = array_merge($identifiers_render_array, compose_identifiers($agent->identifiers));
64
  }
65
  if(count($identifiers_render_array) > 0){
66
    $identifiers_markup = '<div class="identifier">' . drupal_render($identifiers_render_array) . '</div>';
67
  }
68

    
69

    
70
  $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 . '>');
71

    
72
  return $render_array;
73
}
Add picture from clipboard (Maximum size: 40 MB)