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/includes/name.inc
1855 1855
    'Paratype'
1856 1856
  );
1857 1857
  return $type_status_order;
1858
}
1858
}
1859

  
1860
/**
1861
 * Return HTML for the lectotype citation with the correct layout.
1862
 *
1863
 * This function prints the lectotype citation with the correct layout.
1864
 * Lectotypes are renderized in the synonymy tab of a taxon if they exist.
1865
 *
1866
 * @param mixed $typeDesignation
1867
 *   Object containing the lectotype citation to print.
1868
 *
1869
 * @return string
1870
 *   Valid html string.
1871
 */
1872
function type_designation_citation_layout($typeDesignation, $footnote_separator = ',') {
1873
  $res = '';
1874
  $citation = $typeDesignation->citation;
1875
  $pages = $typeDesignation->citationMicroReference;
1876
  if(isset($typeDesignation->typeStatus->uuid) && isset($typeDesignation->typeStatus->representation_L10n)) {
1877
    if ( $typeDesignation->typeStatus->uuid == UUID_NTD_ORIGINAL_DESIGNATION || $typeDesignation->typeStatus->uuid == UUID_NTD_MONOTYPY) {
1878
      $res = ' (' . $typeDesignation->typeStatus->representation_L10n . ')';
1879
      return $res;
1880
    }
1881
  }
1882

  
1883
  if ($citation) {
1884
    // $type = $typeDesignation_citation->type;
1885
    $year = isset($citation->datePublished->start) ? substr($citation->datePublished->start, 0, 4) : '';
1886
    $author = isset($citation->authorship->titleCache) ? $citation->authorship->titleCache : '';
1887
    $res .= ' (designated by ';
1888
    $res .= $author;
1889
    $res .= ($year ? ' ' . $year : '');
1890
    $res .= ($pages ? ': ' . $pages : '');
1891
    // $res .= ')';
1892

  
1893
    // footnotes should be rendered in the parent element so we
1894
    // are relying on the FootnoteListKey set there
1895
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $typeDesignation->citation->titleCache);
1896
    $res .= theme('cdm_footnote_key', array(
1897
        'footnoteKey' => $fkey_typeDesignation,
1898
        'separator' => $footnote_separator,
1899
        'highlightable' => TRUE,
1900
        'separator_off' => TRUE,
1901
      )) . ')';
1902
  }
1903
  return $res;
1904
}
1905

  
1906
/**
1907
 * 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"
1908
 *
1909
 * @param $type_designation
1910
 * @return string
1911
 */
1912
function type_designation_status_label_markup($type_designation)
1913
{
1914
  return '<span class="type-status">'
1915
    . ((isset($type_designation->typeStatus->representation_L10n)) ? ucfirst($type_designation->typeStatus->representation_L10n) : t('Type')) . '</span>'
1916
    ;
1917
}
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