Project

General

Profile

Download (6.62 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Name theming functions.
5
 *
6
 * @copyright
7
 *   (C) 2007-2012 EDIT
8
 *   European Distributed Institute of Taxonomy
9
 *   http://www.e-taxonomy.eu
10
 *
11
 *   The contents of this module are subject to the Mozilla
12
 *   Public License Version 1.1.
13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 */
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
/**
77
 * @todo Please document this function.
78
 * @see http://drupal.org/node/1354
79
 */
80
function theme_cdm_homotypicSynonymLine($variables) {
81
  $taxon = $variables['taxon'];
82
  $out = '';
83
  $out .= '<li class="synonym">' . cdm_related_taxon($taxon, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
84

    
85
  return $out;
86
}
87

    
88
/**
89
 * @todo Please document this function.
90
 * @see http://drupal.org/node/1354
91
 */
92
function theme_cdm_heterotypicSynonymyGroup($variables) {
93
  $homotypical_group = $variables['homotypicalGroup'];
94
  RenderHints::pushToRenderStack('heterotypicSynonymyGroup');
95

    
96
  $out = '';
97
  $out = '<div class="heterotypic-synonymy-group"><ul class="heterotypicSynonymyGroup">';
98
  $footnoteListKey = (isset($homotypical_group[0]) ? $homotypical_group[0]->uuid : 'NULL');
99
  RenderHints::setFootnoteListKey($footnoteListKey);
100

    
101
  $type_designations= type_designations_for_synonymy_group($homotypical_group);
102

    
103
  $is_first_entry = TRUE;
104
  foreach ($homotypical_group as $synonym) {
105
    if ($is_first_entry) {
106
      $is_first_entry = FALSE;
107
      // Is first list entry.
108
      $out .= '<li class="firstentry synonym">' . cdm_related_taxon($synonym, UUID_HETEROTYPIC_SYNONYM_OF) . '</li>';
109
    }
110
    else {
111
      $out .= '<li class="synonym">' . cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
112
    }
113
  }
114

    
115
  if (count($type_designations) > 0) {
116
    $out .= render_type_designations($type_designations);
117
  }
118
  $out .= '</ul>';
119

    
120
  // ------- footnotes ------- //
121
  $out .= '<ul class="footnotes">';
122
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
123
  $out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
124
  $out .= '</ul>';
125

    
126
  $out .= '</div>';
127

    
128
  RenderHints::popFromRenderStack();
129
  return $out;
130
}
131

    
132
/**
133
 * Renders the homotypic synonymy group for the accepted taxon in the synonymy.
134
 *
135
 * Foonotes of the accepted taxon will also be rendered here in the
136
 * homotypic synonymy group even if the synonymList or prependedSynonyms are
137
 * empty. Therefore  the homotypic group and accepted taxon share the  same
138
 * footnote key.
139
 *
140
 * @param $variables
141
 *   an associative array:
142
 *   - synonymList: the list of cdm Synonym entities
143
 *   - accepted_taxon_uuid: the uuid of the accepted taxon
144
 *   - prependedSynonyms: further synonyms which should be prepended
145
 *      before the actual list of synonyms
146
 */
147
function theme_cdm_homotypicSynonymyGroup($variables) {
148
  $synonymList = $variables['synonymList'];
149
  $accepted_taxon_name_uuid = $variables['accepted_taxon_name_uuid'];
150
  $prependedSynonyms = $variables['prependedSynonyms'];
151

    
152
  RenderHints::pushToRenderStack('homotypicSynonymyGroup');
153

    
154
  $type_designations_in_group = NULL;
155

    
156
  $out = '<div class="homotypic-synonymy-group">';
157

    
158
  $type_designations = type_designations_for_synonymy_group($synonymList, $accepted_taxon_name_uuid);
159

    
160
  if (count($type_designations) > 0 || is_array($prependedSynonyms) || is_array($synonymList)) {
161
    $out .= '<ul class="homotypicSynonyms">';
162
  if (!empty($prependedSynonyms)) {
163
    foreach ($prependedSynonyms as $taxon) {
164
      $out .= '<li class="synonym">' . cdm_related_taxon($taxon, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
165
    }
166
  }
167

    
168

    
169
  if (isset($synonymList[0])) {
170
    foreach ($synonymList as $synonym) {
171
      $out .= '<li class="synonym">' . cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
172
    }
173
  }
174

    
175
  if (count($type_designations) > 0) {
176
    $out .= theme('cdm_typedesignations', array('typeDesignations' => $type_designations));
177
  }
178

    
179
  }
180

    
181
  $out .= '</ul>';
182

    
183
  // ------- footnotes ------- //
184

    
185
  // all foonotes of the homotypic group and also of the accepted taxon are
186
  // rendered here, both should have the same footnote key
187
  $out .= '<ul class="footnotes">';
188
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
189
  $out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
190
  $out .= '</ul>';
191

    
192
  $out .= '</div>';
193

    
194

    
195
  RenderHints::popFromRenderStack();
196
  return $out;
197
}
(4-4/9)