Project

General

Profile

« Previous | Next » 

Revision 4eab6eeb

Added by Andreas Kohlbecker over 3 years ago

moving methods from theme to inc file

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.name.theme
13 13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14 14
 */
15 15

  
16
/**
17
 * Return HTML for the lectotype citation with the correct layout.
18
 *
19
 * This function prints the lectotype citation with the correct layout.
20
 * Lectotypes are renderized in the synonymy tab of a taxon if they exist.
21
 *
22
 * @param mixed $typeDesignation
23
 *   Object containing the lectotype citation to print.
24
 *
25
 * @return string
26
 *   Valid html string.
27
 */
28
function type_designation_citation_layout($typeDesignation, $footnote_separator = ',') {
29
  $res = '';
30
  $citation = $typeDesignation->citation;
31
  $pages = $typeDesignation->citationMicroReference;
32
  if(isset($typeDesignation->typeStatus->uuid) && isset($typeDesignation->typeStatus->representation_L10n)) {
33
    if ( $typeDesignation->typeStatus->uuid == UUID_NTD_ORIGINAL_DESIGNATION || $typeDesignation->typeStatus->uuid == UUID_NTD_MONOTYPY) {
34
      $res = ' (' . $typeDesignation->typeStatus->representation_L10n . ')';
35
      return $res;
36
    }
37
  }
38

  
39
  if ($citation) {
40
    // $type = $typeDesignation_citation->type;
41
    $year = isset($citation->datePublished->start) ? substr($citation->datePublished->start, 0, 4) : '';
42
    $author = isset($citation->authorship->titleCache) ? $citation->authorship->titleCache : '';
43
    $res .= ' (designated by ';
44
    $res .= $author;
45
    $res .= ($year ? ' ' . $year : '');
46
    $res .= ($pages ? ': ' . $pages : '');
47
    // $res .= ')';
48

  
49
    // footnotes should be rendered in the parent element so we
50
    // are relying on the FootnoteListKey set there
51
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $typeDesignation->citation->titleCache);
52
    $res .= theme('cdm_footnote_key', array(
53
      'footnoteKey' => $fkey_typeDesignation,
54
      'separator' => $footnote_separator,
55
      'highlightable' => TRUE,
56
      'separator_off' => TRUE,
57
    )) . ')';
58
  }
59
  return $res;
60
}
61

  
62
/**
63
 * Creates markup for the status of a type designation. In case the status or its representation is missing the label will be set to "Type"
64
 *
65
 * @param $type_designation
66
 * @return string
67
 */
68
function type_designation_status_label_markup($type_designation)
69
{
70
  return '<span class="type-status">'
71
    . ((isset($type_designation->typeStatus->representation_L10n)) ? ucfirst($type_designation->typeStatus->representation_L10n) : t('Type')) . '</span>'
72
    ;
73
}
74

  
75

  
76 16
/**
77 17
 * @todo Please document this function.
78 18
 * @see http://drupal.org/node/1354

Also available in: Unified diff