Project

General

Profile

Download (47.3 KB) Statistics
| Branch: | Tag: | Revision:
1 c70b93c3 Andreas Kohlbecker
<?php
2 f19f47fa Andreas Kohlbecker
/**
3
 * @file
4
 * Page 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 c70b93c3 Andreas Kohlbecker
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 *
15
 * @author
16 f19f47fa Andreas Kohlbecker
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
17
 */
18
19
20
/**
21 02e8615c Andreas Kohlbecker
 * Composes a render array representing the ocurrences associetad with the $taxon.
22 f19f47fa Andreas Kohlbecker
 *
23
 * The resulting render array contains two elements:
24
 *  - 'map': A map showing all point locations of the occurences is availabale
25
 *  - 'specimen_list': the list of occurences prepated as table for theme_table()
26
 *
27
 * @param object $taxon
28
 *   A cdm Taxon object
29
 * @return
30
 *   A render array suitable for drupal_render()
31
 *
32 02e8615c Andreas Kohlbecker
 * @ingroup Compose
33
 *
34 c70b93c3 Andreas Kohlbecker
 */
35 02e8615c Andreas Kohlbecker
function compose_cdm_taxon_page_specimens($taxon) {
36 f19f47fa Andreas Kohlbecker
37 1ce9afb7 Patric Plitzner
    $render_array = array();
38
    RenderHints::pushToRenderStack('taxon_page_specimens');
39 30f78c59 Andreas Kohlbecker
40 961319fe Andreas Kohlbecker
    $fieldUnitDTOs = null;
41
    $specimensOrObservations = null;
42 276f39f6 Katja Luther
    if (variable_get('cdm_dataportal_specimen_derivate_tree')){
43 961319fe Andreas Kohlbecker
      // get fieldUnitDTOs
44 a0be8d7e Andreas Kohlbecker
      $fieldUnitDTOs = cdm_ws_get(CDM_WS_TAXON_FIELDUNIT_DTOS, array( $taxon->uuid));
45 961319fe Andreas Kohlbecker
      $fieldUnitDTOs = order_fieldUnitDtos_by_date_and_type($fieldUnitDTOs);
46
    } else {
47
      // $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
48
      // extend by associated taxas occurrences
49
      $relationship_filter_query_parameters = relationship_filter_query_parameters();
50
51
      if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
52
        $relationship_filter_query_parameters = array_merge($relationship_filter_query_parameters, $_REQUEST['pager']);
53
      }
54
      $by_associatedtaxon_query = http_build_query($relationship_filter_query_parameters);
55
      $pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
56
        null,
57
        $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
58
      );
59
      $specimensOrObservations = array();
60
      if (isset($pager->records[0])) {
61
        $specimensOrObservations = $pager->records;
62
      }
63
      // cdm_ws_get(CDM_WS_OCCURRENCE_FIELDUNIT_DTO_BY_ASSOCIATEDTAXON,
64
      // null,
65
      // $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
66
      // );
67
68
      // $specimensOrObservations = array();
69
      // if(isset($pager->records[0])){
70
      //    $specimensOrObservations =  $pager->records;
71
      // }
72
      // Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field
73
      foreach ($specimensOrObservations as &$occurrence) {
74
        $occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
75
          $occurrence->uuid,
76
          'fieldObjectMediaDTO',
77
        ));
78
        $occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
79
          $occurrence->uuid,
80
          'derivedUnitMedia',
81
        ));
82
      }
83
      $specimensOrObservations = order_specimens_or_observations_by_date_and_type($specimensOrObservations);
84 7965ef92 Katja Luther
    }
85 b8afc4bb Patric Plitzner
86 b5c89485 Patric Plitzner
    // --- get map service HTTP query parameters
87 961319fe Andreas Kohlbecker
    if (count($specimensOrObservations) > 0 || $fieldUnitDTOs > 0) {
88
        $render_array['map'] = occurrence_map_query_parameters($taxon);
89 b8afc4bb Patric Plitzner
    }
90 db725031 Andreas Kohlbecker
91
    // -------------------------------------------------------
92 106e1cf9 Katja Luther
93 1ce9afb7 Patric Plitzner
    if(variable_get('cdm_dataportal_compressed_specimen_derivate_table')){
94
95
        //COMPRESSED SPECIMEN DERIVATE TABLE
96 4cb163f8 Patric Plitzner
        $associatedFieldUnitsQuery_parameters = array();
97
        if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
98
            $associatedFieldUnitsQuery_parameters = array_merge($associatedFieldUnitsQuery_parameters, $_REQUEST['pager']);
99
        }
100
101
        $by_associatedtaxon_query = http_build_query($associatedFieldUnitsQuery_parameters);
102 09f028e2 Andreas Kohlbecker
        $pager_field_units = cdm_ws_get(CDM_WS_PORTAL_TAXON,
103 2e82a602 Patrick Plitzner
            array($taxon->uuid, 'associatedFieldUnits'),
104
            $by_associatedtaxon_query . '&pageSize=' . variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size')
105
        );
106 1e87f89f Andreas Kohlbecker
107 09f028e2 Andreas Kohlbecker
        if (isset($pager_field_units->records[0])) {
108
          $field_unit_uuids = array();
109
          foreach ($pager_field_units->records as $field_unit) {
110
            $field_unit_uuids[] = $field_unit->uuid;
111
          }
112
113 961319fe Andreas Kohlbecker
          $render_array['derivate_hierarchy_table'] = compose_compressed_specimen_derivate_table($field_unit_uuids);
114 02f3768c Andreas Kohlbecker
        }
115 f19f47fa Andreas Kohlbecker
116 1e87f89f Andreas Kohlbecker
        $render_array['pager'] = markup_to_render_array(
117
            theme('cdm_pager', array(
118
                'pager' => $pager_field_units,
119
                'path' => $_REQUEST['q'],
120
                'parameters' => $_REQUEST
121
            )),
122
            10 // weight
123
        );
124 f19f47fa Andreas Kohlbecker
    }
125 276f39f6 Katja Luther
    else if(variable_get('cdm_dataportal_specimen_derivate_tree')){
126 961319fe Andreas Kohlbecker
      $render_array['specimen_list'] = compose_specimen_table_top_down($fieldUnitDTOs);
127 ae177dac Andreas Kohlbecker
      $render_array['specimen_list']['#weight'] = 2;
128 961319fe Andreas Kohlbecker
    } else {
129 84849c31 Andreas Kohlbecker
      $specimen_table = compose_specimens_table_bottom_up($specimensOrObservations);
130
131
      $render_array['specimen_list'] = $specimen_table;
132
      $render_array['pager'] = markup_to_render_array(
133
        theme('cdm_pager', array(
134
          'pager' => $pager,
135
          'path' => $_REQUEST['q'],
136
          'parameters' => $_REQUEST,
137
        )),
138
        10 // weight
139
      );
140
    }
141 f19f47fa Andreas Kohlbecker
142 84849c31 Andreas Kohlbecker
    RenderHints::popFromRenderStack();
143
    return $render_array;
144
}
145
146 1e87f89f Andreas Kohlbecker
/**
147
 * @return array
148
 *
149 961319fe Andreas Kohlbecker
 * TODO move to cdm_dataportal.module or api.module?
150 1e87f89f Andreas Kohlbecker
 */
151 961319fe Andreas Kohlbecker
function relationship_filter_query_parameters()
152 1e87f89f Andreas Kohlbecker
{
153 961319fe Andreas Kohlbecker
  $relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
154
  $relationship_choice['direct'] = get_selection($relationship_choice['direct']);
155
  $relationship_choice['invers'] = get_selection($relationship_choice['invers']);
156 1e87f89f Andreas Kohlbecker
157 961319fe Andreas Kohlbecker
  $by_associatedtaxon_query_parameters = array(
158
    'relationshipsInvers' => implode(',', $relationship_choice['invers']),
159
    'relationships' => implode(',', $relationship_choice['direct']),
160 1e87f89f Andreas Kohlbecker
  );
161 961319fe Andreas Kohlbecker
  return $by_associatedtaxon_query_parameters;
162 1e87f89f Andreas Kohlbecker
}
163
164 961319fe Andreas Kohlbecker
165 65a4de51 Patrick Plitzner
function create_html_link($link, $openInExternalWindow=false){
166 7d8ef9fa Patric Plitzner
    $html = "";
167 65a4de51 Patrick Plitzner
    if($link->uri && $link->uri!=""){
168
        $html .= '<a  href="' . $link->uri . '"';
169
        if($openInExternalWindow){
170
            $html .= ' target="_blank"';
171
        }
172
        $html .= '>' . $link->linkText . '</a>';
173 7d8ef9fa Patric Plitzner
    }
174
    else{
175
        $html .= $link->linkText;
176
    }
177
    return $html;
178
}
179
180
/**
181 65a4de51 Patrick Plitzner
 * Creates HTML links from the given link list concatenated by default by a comma.
182 7d8ef9fa Patric Plitzner
 * @param $linkList the list with Link objects having "uri" and "linkText" as members
183
 * @return string the assembled HTML string containing the links
184
 */
185 65a4de51 Patrick Plitzner
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
186 7d8ef9fa Patric Plitzner
{
187
    $html = "";
188
    if ($linkList) {
189
        foreach ($linkList as $link) {
190 65a4de51 Patrick Plitzner
            $html .= create_html_link($link, $openInExternalWindow).$separator;
191 7d8ef9fa Patric Plitzner
        }
192 65a4de51 Patrick Plitzner
        $html = rtrim($html, $separator);
193 7d8ef9fa Patric Plitzner
    }
194
    return $html;
195
}
196
197 00a8e4b6 Andreas Kohlbecker
/**
198
 * Composes a taxon page which can consist of multiple parts like
199
 * 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed
200
 * as tabs or as sections of a single page.
201
 *
202
 * It is headed by the name of the accepted taxon without author and reference.
203
 *
204
 * @param $taxon
205
 *   The CDM Taxon Instance to compose the page for.
206
 * @param $page_part
207
 *   Name of the part to display, valid values are:
208
 *    - 'description' -  for the general part
209
 *    - 'images'
210
 *    - 'synonymy'
211
 *    - 'keys'
212
 *    - 'all'
213
 *
214
 * @return array
215
 *   A drupal render array
216
 *
217
 * @ingroup compose
218
 */
219
function compose_cdm_taxon_page($taxon, $page_part = 'description') {
220
221 0ae57522 Patric Plitzner
  // we better cache here since drupal_get_query_parameters has no internal static cache variable
222
  $http_request_params = drupal_get_query_parameters();
223 00a8e4b6 Andreas Kohlbecker
224 0ae57522 Patric Plitzner
  // add all mandatory js sources
225
  _add_js_footnotes();
226 00a8e4b6 Andreas Kohlbecker
227
228 0ae57522 Patric Plitzner
  $render_array = array();
229
  $weight = 0; // the weight for the render array elements
230 00a8e4b6 Andreas Kohlbecker
231 0ae57522 Patric Plitzner
  $tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
232 00a8e4b6 Andreas Kohlbecker
233 0ae57522 Patric Plitzner
  $page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
234 00a8e4b6 Andreas Kohlbecker
235 22383f95 Andreas Kohlbecker
  $synonymy_as_tab = variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT) === 1;
236
  if(!$synonymy_as_tab){
237
    unset($tabsToDisplay["Synonymy"]);
238 3e6dfbb3 Andreas Kohlbecker
    // the synonymy is located in the general part in this case
239
    if($page_part == 'synonymy'){
240
      $page_part = 'description';
241
    }
242 22383f95 Andreas Kohlbecker
  }
243
244 0ae57522 Patric Plitzner
  $media = _load_media_for_taxon($taxon);
245 00a8e4b6 Andreas Kohlbecker
246
247 0ae57522 Patric Plitzner
  if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
248 48a6d7e8 Andreas Kohlbecker
    taxon_page_tabs_hidden_add('images');
249 0ae57522 Patric Plitzner
  }
250 00a8e4b6 Andreas Kohlbecker
251 0ae57522 Patric Plitzner
  // --- GET specimensOrObservations --- //
252 c10f70e4 Katja Luther
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservationsCount'));
253 00a8e4b6 Andreas Kohlbecker
254 c10f70e4 Katja Luther
  $specimensOrObservationsCount = $specimensOrObservations != null ? $specimensOrObservations->result : 0;
255 0ae57522 Patric Plitzner
  if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
256 48a6d7e8 Andreas Kohlbecker
    taxon_page_tabs_hidden_add('specimens');
257 0ae57522 Patric Plitzner
  }
258 00a8e4b6 Andreas Kohlbecker
259 0ae57522 Patric Plitzner
  // --- GET polytomousKeys --- //
260
  $polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
261
  $identificationKeyCount = 0;
262
  if ($polytomousKeysPager) {
263
    $identificationKeyCount += $polytomousKeysPager->count;
264
  }
265
  if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
266 48a6d7e8 Andreas Kohlbecker
    taxon_page_tabs_hidden_add('keys');
267 0ae57522 Patric Plitzner
  }
268 092744e1 Andreas Kohlbecker
269 22383f95 Andreas Kohlbecker
  // --- GET TaxonNodeAgentRelations --- //
270
  $current_classification_uuid = get_current_classification_uuid();
271
  $taxon_node_agent_relations_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
272
      array(
273
          $taxon->uuid,
274
          $current_classification_uuid,
275
      ),
276
      "pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible!
277
  );
278
  if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){
279 48a6d7e8 Andreas Kohlbecker
      taxon_page_tabs_hidden_add('experts');
280 22383f95 Andreas Kohlbecker
  }
281 7663cd0b Andreas Kohlbecker
282 22383f95 Andreas Kohlbecker
  if (!isset($tabsToDisplay["Synonymy"]) || $tabsToDisplay["Synonymy"] == '0') {
283 48a6d7e8 Andreas Kohlbecker
    taxon_page_tabs_hidden_add('synonymy');
284 0ae57522 Patric Plitzner
  }
285 00a8e4b6 Andreas Kohlbecker
286 0ae57522 Patric Plitzner
  // -------------------------------------------- //
287 00a8e4b6 Andreas Kohlbecker
288 fe169cb6 Andreas Kohlbecker
  if(variable_get(CDM_TAXONPAGE_TAXON_NODE_SHOW_STATES, 1) && ( $page_part == 'description' || $page_part == 'synonymy' || $page_part == 'all')){
289 bd56cbc1 Andreas Kohlbecker
    $taxon_nodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, array($taxon->uuid));
290
    $render_array['taxon_node_status'] = compose_taxon_node_status($taxon_nodes);
291
    $render_array['taxon_node_status']['#weight'] = -100;
292
  }
293
294 0ae57522 Patric Plitzner
  if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
295 7272d19c Andreas Kohlbecker
    $render_array['accepted_for'] = markup_to_render_array(cdm_accepted_for($_REQUEST['acceptedFor']), $weight++);
296 0ae57522 Patric Plitzner
  }
297 00a8e4b6 Andreas Kohlbecker
298 0ae57522 Patric Plitzner
  // --- PAGE PART: DESCRIPTION --- //
299 48a6d7e8 Andreas Kohlbecker
  if (!taxon_page_tabs_hidden_check('description') && ($page_part == 'description' || $page_part == 'all')) {
300 00a8e4b6 Andreas Kohlbecker
301 0ae57522 Patric Plitzner
    $merged_tree = merged_taxon_feature_tree($taxon);
302 00a8e4b6 Andreas Kohlbecker
303 7d8ef9fa Patric Plitzner
304 22383f95 Andreas Kohlbecker
    $render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, !$synonymy_as_tab);
305 0ae57522 Patric Plitzner
    $render_array['general']['#weight'] = $weight++;
306
    $render_array['general']['#prefix'] = '<div id="general" class="page-part">';
307
    $render_array['general']['#suffix'] = '</div>';
308
  }
309 7d8ef9fa Patric Plitzner
310 0ae57522 Patric Plitzner
  // --- PAGE PART: IMAGES --- //
311 48a6d7e8 Andreas Kohlbecker
  if (!taxon_page_tabs_hidden_check('images') && ($page_part == 'images' || $page_part == 'all')) {
312 0ae57522 Patric Plitzner
    $images_html = '<div id="images" class="page-part">';
313
    if ($page_part == 'all') {
314 4feeabc7 Andreas Kohlbecker
      $images_html .= '<h2>' . t(cdm_taxonpage_tab_label('Images')) . '</h2>';
315 7d8ef9fa Patric Plitzner
    }
316 0ae57522 Patric Plitzner
    // Get the image gallery as configured by the admin.
317 a1f7edc0 Andreas Kohlbecker
    $configured_image_gallery_viewer = variable_get(CDM_MEDIA_GALLERY_VIEWER, CDM_MEDIA_GALLERY_VIEWER_DEFAULT);
318
    if($configured_image_gallery_viewer != 'fsi'){
319
      $images_html .= render_taxon_media_gallery($taxon, $configured_image_gallery_viewer, $media);
320
    } else {
321 8f4eb9ce Andreas Kohlbecker
      // the fsi_gallery requires a flash plugin, in case the client browser is not supporting
322
      // flash we also need to provide an the default gallery as alternative
323 a1f7edc0 Andreas Kohlbecker
      $images_html .= render_taxon_media_gallery($taxon, CDM_MEDIA_GALLERY_VIEWER_DEFAULT, $media);
324
      $images_html .= render_taxon_media_gallery($taxon, $configured_image_gallery_viewer, $media);
325 8f4eb9ce Andreas Kohlbecker
    }
326 a1f7edc0 Andreas Kohlbecker
    $images_html .= '</div>'; // END of <div id="images">
327 0ae57522 Patric Plitzner
    $render_array['images'] = markup_to_render_array($images_html, $weight++);
328
  }
329 7d8ef9fa Patric Plitzner
330 0ae57522 Patric Plitzner
  // --- PAGE PART: SYNONYMY --- //
331 48a6d7e8 Andreas Kohlbecker
  if (!taxon_page_tabs_hidden_check('synonymy') && (($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) {
332 0ae57522 Patric Plitzner
    $synonymy_html = '<div id="synonymy" class="page-part">';
333
    if ($page_part == 'all') {
334 4feeabc7 Andreas Kohlbecker
      $synonymy_html .= '<h2>' . t(cdm_taxonpage_tab_label('Synonymy')) . '</h2>';
335 00a8e4b6 Andreas Kohlbecker
    }
336 0ae57522 Patric Plitzner
    $addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
337 41b4bfc9 Andreas Kohlbecker
338 1cda248c Andreas Kohlbecker
    $synonym_a = compose_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon);
339
    $synonymy_html .= drupal_render($synonym_a);
340 00a8e4b6 Andreas Kohlbecker
341 0ae57522 Patric Plitzner
    $synonymy_html .= '</div>';
342
    $render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
343 00a8e4b6 Andreas Kohlbecker
344 0ae57522 Patric Plitzner
  }
345 00a8e4b6 Andreas Kohlbecker
346 0ae57522 Patric Plitzner
  // --- PAGE PART: SPECIMENS --- //
347 48a6d7e8 Andreas Kohlbecker
  if (!taxon_page_tabs_hidden_check('specimens') && ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all'))) {
348 0ae57522 Patric Plitzner
    $render_array['specimens'] = array(
349 4feeabc7 Andreas Kohlbecker
        '#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Specimens')) . '</h2>' : ''),
350 02e8615c Andreas Kohlbecker
        'content' => compose_cdm_taxon_page_specimens($taxon), // returns render array
351 0ae57522 Patric Plitzner
        '#suffix' => '</div>',
352
    );
353
  }
354
355
  // --- PAGE PART: KEYS --- //
356 48a6d7e8 Andreas Kohlbecker
  if(!taxon_page_tabs_hidden_check('keys')){
357
    if ($identificationKeyCount == 1 && $page_part == 'keys'){
358
      drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
359
    }
360
    else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
361
      $keys_html = '<div id="keys" class="page-part">';
362
      if ($page_part == 'all') {
363
        $keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>';
364
      }
365
      $keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
366
      $keys_html .= '</div>';
367
      $render_array['keys'] = markup_to_render_array($keys_html, $weight++);
368 0ae57522 Patric Plitzner
    }
369
  }
370
371 7663cd0b Andreas Kohlbecker
  // --- PAGE PART: EXPERTS --- //
372
373 48a6d7e8 Andreas Kohlbecker
  if (!taxon_page_tabs_hidden_check('experts') && ($page_part == 'experts' || $page_part == 'all')) {
374 7663cd0b Andreas Kohlbecker
    $render_array['experts'] = array(
375 4feeabc7 Andreas Kohlbecker
        '#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Experts')) . '</h2>' : ''),
376 7663cd0b Andreas Kohlbecker
        'content' => compose_cdm_taxon_page_experts($taxon), // returns render array
377
        '#suffix' => '</div>',
378
    );
379
  }
380
381
  // ------------------ END OF PARTS -------------- //
382 0ae57522 Patric Plitzner
383
  // adjust weights of page and toc elements according to the settings
384 4feeabc7 Andreas Kohlbecker
  $taxontabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
385 0ae57522 Patric Plitzner
  foreach($taxontabs_weights as $tab_key => $weight){
386
    if(isset($render_array[$tab_key])){
387
      $render_array[$tab_key]['#weight'] = $weight;
388
    }
389
  }
390
391
392
  // set up the TOC for the pages which contain all pageparts
393
  if($page_part == 'all') {
394
395
    asort($taxontabs_weights);
396
    foreach(array_keys($taxontabs_weights) as $tab_key){
397
      if(isset($render_array[$tab_key])){
398
        if($tab_key != 'general'){
399
          // add entry for page part
400
          $toc_elements[] = array(
401 4feeabc7 Andreas Kohlbecker
              'data' => l(t(cdm_taxonpage_tab_label(ucfirst($tab_key))), $_GET['q'], array('fragment' => $tab_key, 'query' => $http_request_params)),
402 0ae57522 Patric Plitzner
              'class' => array('page-part-toc-item-' . $tab_key)
403
          );
404
        } else {
405
          // add content of profile part instead
406
          if(isset($render_array['general'])) {
407
            // in case all tabs are shown at once the feature tocs
408
            // should be integrated into the tabs toc as sub list
409
            // and the profile image should be on top of the page
410
            if(isset($render_array['general']['taxon_description_feature_toc'])){;
411
            foreach ($render_array['general']['taxon_description_feature_toc']['#items'] as $profile_toc_item){
412
              $toc_elements[] = $profile_toc_item;
413 7d8ef9fa Patric Plitzner
            }
414 0ae57522 Patric Plitzner
            unset($render_array['general']['taxon_description_feature_toc']);
415
            }
416
          }
417 7d8ef9fa Patric Plitzner
        }
418 0ae57522 Patric Plitzner
      }
419
    }
420 7d8ef9fa Patric Plitzner
421 0ae57522 Patric Plitzner
    // move profile image in page structure
422
    if(isset($render_array['general']['taxon_profile_image'])){
423
      $render_array['profile_image'] = $render_array['general']['taxon_profile_image'];
424
      $render_array['profile_image']['#weight'] = -100;
425
      unset($render_array['general']['taxon_profile_image']);
426 7d8ef9fa Patric Plitzner
    }
427
428 0ae57522 Patric Plitzner
    // finally add the table of contents to the render array
429
    $render_array['toc'] = array(
430
        '#theme' => 'item_list',
431
        '#items' => $toc_elements,
432
        '#title' => t('Content'),
433
        '#weight' => -101,
434
        '#suffix' => '</div>',
435
        '#prefix'=> '<div id="page-toc">'
436
    );
437
  }
438
439 7d8ef9fa Patric Plitzner
440 0ae57522 Patric Plitzner
  return $render_array;
441 00a8e4b6 Andreas Kohlbecker
}
442
443 1ce9afb7 Patric Plitzner
/**
444 22f5e82d Andreas Kohlbecker
 * TODO should this function really be a compose function?
445
 *     For a compose function must there always be a theme function with the same name? (ak 8.8.2013)
446 bf97c2e8 Andreas Kohlbecker
 *
447
 * composes and returns an render array containing the components of the taxon profile tab:
448
 *  - 'taxon_profile_image'
449
 *  - 'taxon_description_feature_toc'
450
 *  - 'taxon_description_features'
451
 *
452
 *
453 8a1b451e Andreas Kohlbecker
 * @param object taxon
454
 * @param object $merged_tree
455
 * @param object media
456
 * @param bool $add_synonymy
457 bf97c2e8 Andreas Kohlbecker
 *
458
 * @return array
459 f78fda81 Andreas Kohlbecker
 *   A Drupal render array with the following elements:
460 bf97c2e8 Andreas Kohlbecker
 *     - 'taxon_profile_image'
461
 *     - 'taxon_description_feature_toc'
462
 *     - 'taxon_description_features'
463
 *
464 8a1b451e Andreas Kohlbecker
 * @throws Exception
465
 *
466 bf97c2e8 Andreas Kohlbecker
 * @ingroup compose
467
 */
468 22383f95 Andreas Kohlbecker
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, $add_synonymy) {
469 bf97c2e8 Andreas Kohlbecker
470 0ae57522 Patric Plitzner
  $render_array = array();
471
472
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
473
474
  $hide_taxon_profile_image = FALSE;
475
  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
476
    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
477
    $hide_taxon_profile_image = ($rankCompare > -1);
478
  }
479
480
  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
481
482
    $representationPart = new stdClass();
483
    $attributes = array();
484 02faa087 Andreas Kohlbecker
    if (isset($media[0])) {
485
      // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
486
      // which only contains the thumbnail representation even if the height and width filters are not set.
487 673929dd Andreas Kohlbecker
      // -->
488 02faa087 Andreas Kohlbecker
      $preferred_media = cdm_ws_get(CDM_WS_MEDIA, $media[0]->uuid);
489
      $preferred_representations = cdm_preferred_media_representations($preferred_media, array(
490
        'image/jpg',
491
        'image/jpeg',
492
        'image/png',
493
        'image/gif',
494
      ),
495
        $taxon_profile_image_settings['maxextend'],
496
        $taxon_profile_image_settings['maxextend']
497
      );
498
      if(count($preferred_representations) > 0){
499
500
        $representation = array_shift($preferred_representations);
501
        $representationPart = $representation->parts[0];
502
        $attributes['alt'] = $representationPart->uri;
503
504
        if (!empty($taxon_profile_image_settings['media_uri_query'])) {
505
          $representationPart->uri = $representationPart->uri
506
            . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
507
            . $taxon_profile_image_settings['media_uri_query'];
508
        }
509 0ae57522 Patric Plitzner
      }
510
    }
511
    else {
512 9506fd1f Andreas Kohlbecker
      if ($taxon_profile_image_settings['custom_placeholder_enabled']) {
513 ca47ea76 Andreas Kohlbecker
        // show placeholder image instead
514
        if (!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])) {
515
          // use the user provided image
516
          $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
517
          $url = file_create_url($profile_image_file->uri);
518
          $image_info = image_get_info($profile_image_file->uri);
519
          $representationPart->width = $image_info['width'];
520
          $representationPart->height = $image_info['height'];
521
          $representationPart->uri = $url;
522
        }
523
        else {
524
          // use the hard coded default
525
          $representationPart->width = 184;
526
          $representationPart->height = 144;
527
          $representationPart->uri = base_path() . drupal_get_path('module',
528
              'cdm_dataportal') . '/images/no_picture.png';
529
        }
530
        $attributes['alt'] = "no image available";
531 0ae57522 Patric Plitzner
      }
532
    }
533
534 ca47ea76 Andreas Kohlbecker
    if (isset($representationPart->uri)) {
535 a9815578 Andreas Kohlbecker
      $profile_image = cdm_media_gallerie_image($representationPart, $taxon_profile_image_settings['maxextend'], FALSE, $attributes);
536 ca47ea76 Andreas Kohlbecker
      // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
537 84849c31 Andreas Kohlbecker
      $max_extend_with = $taxon_profile_image_settings['maxextend'] . 'px';
538 062686a1 Andreas Kohlbecker
      $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $max_extend_with . '">' . $profile_image . '</div>',
539 ca47ea76 Andreas Kohlbecker
        -101);
540
    }
541 0ae57522 Patric Plitzner
  }
542
543 22383f95 Andreas Kohlbecker
  if($add_synonymy){
544 1cda248c Andreas Kohlbecker
    $synonymy_a = compose_cdm_taxon_page_synonymy($taxon, true);
545
    $synonymy_a['#weight'] = -102;
546
    $render_array['synonymy'] = $synonymy_a;
547 22383f95 Andreas Kohlbecker
  }
548
549 c3a41ddb Andreas Kohlbecker
//  $pseudo_feature_block_toc_items = array();
550 0ae57522 Patric Plitzner
551
552 1b756c5f Andreas Kohlbecker
  // Render the sections for each real feature
553
  $feature_block_list = make_feature_block_list($merged_tree->root->childNodes, $taxon);
554
555 bf8aea21 Andreas Kohlbecker
  // >>>>>>>>>>>>>>>>>>> PSEUDO FEATURES >>>>>>>>>>>>>>>>>>>
556 c3a41ddb Andreas Kohlbecker
  $pseudo_feature_weights = get_array_variable_merged(CDM_PSEUDO_FEATURE_BLOCK_WEIGHTS, CDM_PSEUDO_FEATURE_BLOCK_WEIGHTS_DEFAULT);
557 1b756c5f Andreas Kohlbecker
  // Bibliography
558 0ae57522 Patric Plitzner
  $bibliography_settings = get_bibliography_settings();
559
  if($bibliography_settings['enabled'] == 1){
560 bf8aea21 Andreas Kohlbecker
    $bibliography_markup = FootnoteManager::renderFootnoteList(PSEUDO_FEATURE_BIBLIOGRAPHY, '');
561 850092a7 Andreas Kohlbecker
    if($bibliography_markup) {
562 bf8aea21 Andreas Kohlbecker
      $feature_bibliography = make_pseudo_feature('Bibliography', PSEUDO_FEATURE_BIBLIOGRAPHY);
563 850092a7 Andreas Kohlbecker
      $bibliography_item = markup_to_render_array($bibliography_markup);
564 667f16d4 Andreas Kohlbecker
      $bibliography_block = feature_block(t('Bibliography'), $feature_bibliography);
565
      $bibliography_block->content = array();
566 850092a7 Andreas Kohlbecker
      $bibliography_block->content[] = compose_feature_block_wrap_elements(array($bibliography_item), $feature_bibliography);
567 0ae57522 Patric Plitzner
568 c3a41ddb Andreas Kohlbecker
      $feature_block_list[$pseudo_feature_weights[PSEUDO_FEATURE_BIBLIOGRAPHY]] = $bibliography_block;
569 089fb6ea Andreas Kohlbecker
      cdm_toc_list_add_item('Bibliography', 'bibliography', null, false, $pseudo_feature_weights[PSEUDO_FEATURE_BIBLIOGRAPHY]);
570 0ae57522 Patric Plitzner
    }
571 1b756c5f Andreas Kohlbecker
  }
572
573 bf8aea21 Andreas Kohlbecker
  // Descriptions (aggregated)
574
  $descriptionTypes = array();
575
  $descriptionTypes['descriptionTypes'] = ("AGGREGATED_STRUC_DESC");
576
  $aggregatedDescriptions = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXON . '/' . $taxon->uuid . '/descriptions', $descriptionTypes);
577
  if (isset($aggregatedDescriptions) and !empty($aggregatedDescriptions)) {
578
      // if($feature_block_list) ....TODO
579
      $feature_description = make_pseudo_feature('Descriptions (aggregated)', PSEUDO_FEATURE_AGGREGATION_DESCRIPTIONS);
580
      $description_item = '';
581
      foreach ($aggregatedDescriptions as $description) {
582 92e522db Andreas Kohlbecker
        $description_item = '<div class="' . html_class_attribute_ref($description) . '">';
583 2527a83c Andreas Kohlbecker
        $description_item .= render_description_string(get_root_nodes_for_dataset($description));
584 92e522db Andreas Kohlbecker
        $description_item .= ' ' . icon_link(path_to_description($description->uuid));
585 cd3ea2e8 Andreas Kohlbecker
        $description_item .= '<div class="content-caption">'. statistical_values_explanation() . '</div>';
586 92e522db Andreas Kohlbecker
        $description_item .= '</div>';
587 bf8aea21 Andreas Kohlbecker
      }
588
      $description_block = feature_block(t('Descriptions (aggregated)'), $feature_description);
589
      $description_block->content = [];
590
      $description_block->content[] = compose_feature_block_wrap_elements([$description_item], $feature_description);
591 e170a53e Patrick Plitzner
592 c3a41ddb Andreas Kohlbecker
      $feature_block_list[$pseudo_feature_weights[PSEUDO_FEATURE_AGGREGATION_DESCRIPTIONS]] = $description_block;
593 089fb6ea Andreas Kohlbecker
      cdm_toc_list_add_item('Descriptions (aggregated)', 'aggregation_descriptions', null, false, $pseudo_feature_weights[PSEUDO_FEATURE_AGGREGATION_DESCRIPTIONS]);
594 c3a41ddb Andreas Kohlbecker
595 0ae57522 Patric Plitzner
596 bf8aea21 Andreas Kohlbecker
  }
597 9d88232c Patrick Plitzner
598 c3a41ddb Andreas Kohlbecker
  // sort by weight
599
  ksort($feature_block_list);
600
  $render_array['taxon_description_features'] = _block_get_renderable_array($feature_block_list);
601
602
/*  // update TOC
603 bf8aea21 Andreas Kohlbecker
  if ($pseudo_feature_block_toc_items){
604 1b756c5f Andreas Kohlbecker
    foreach ($pseudo_feature_block_toc_items as $label=>$fragment){
605
      cdm_toc_list_add_item($label, $fragment);
606
    }
607 0ae57522 Patric Plitzner
  }
608 c3a41ddb Andreas Kohlbecker
*/
609 bf8aea21 Andreas Kohlbecker
  // <<<<<<<<<<<<<<<<<<< PSEUDO FEATURES <<<<<<<<<<<<<<<<<<<
610
611 0ae57522 Patric Plitzner
  // create the table of content
612
  $toc = array(
613
      '#theme' => 'item_list',
614
    '#items' => cdm_toc_list(),
615
      '#title' => t('Content'),
616
    '#weight' => -100,                  // move to the top
617
      '#suffix' => '</div>',
618
      '#prefix'=> '<div id="page-toc">'
619
  );
620
  $render_array['taxon_description_feature_toc'] = $toc;
621
622
  return $render_array;
623 bf97c2e8 Andreas Kohlbecker
}
624
625 a38c0718 Patrick Plitzner
626 67ce7111 Patrick Plitzner
/**
627
 * Renders the link which will lead to the specimen detail page
628 55236f7f Andreas Kohlbecker
 * @param object $specimen
629
 *    the cdm specimen entity which will be linked to
630 67ce7111 Patrick Plitzner
 *
631 55236f7f Andreas Kohlbecker
 * @return string
632
 *     the markup for the link
633 67ce7111 Patrick Plitzner
 */
634
function render_cdm_specimen_link($specimen) {
635
  $path = path_to_specimen($specimen->uuid);
636
  $attributes['class'][] = html_class_attribute_ref($specimen);
637 ab025781 Andreas Kohlbecker
  return $specimen->titleCache.icon_link($path);
638 67ce7111 Patrick Plitzner
}
639
640 57dabcba Andreas Kohlbecker
/**
641
 * Returns HTML containing the synonymy for the accepted taxon.
642
 *
643
 * Shows the whole synonymy for the accepted taxon.
644
 * The synonymy list is headed by the complete scientific name
645
 * of the accepted taxon with nomenclatural reference.
646
 *
647
 * @param object $taxon
648
 * @param boolean $add_accepted_taxon
649
 *
650
 * @return array
651
 *  Drupal render array for the synonymy
652
 *
653
 * @throws Exception
654
 *
655
 * @ingroup compose
656
 */
657
function compose_cdm_taxon_page_synonymy($taxon, $add_accepted_taxon) {
658
659
  RenderHints::pushToRenderStack('taxon_page_synonymy');
660
661
  // footnote key for the homotypic group and accepted taxon,
662
  // both should have the same footnote key
663
  RenderHints::setFootnoteListKey(RenderHints::getRenderPath());
664
665
  $synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, array($taxon->uuid));
666
667
  $out = '';
668
669
  // Render accepted taxon.
670
  //
671
  // foonotes of the accepted taxon will be rendered in the homotypic group section
672
  // even if there are not synonyms in the homotypic group
673
  // homotypic group and accepted taxon should have the same footnote key
674
  $referenceUri = '';
675
  if ($add_accepted_taxon) {
676
    // remember the last part of the render path
677
    $synonymy_render_path = RenderHints::getRenderPath();
678
    // set new render path for the accepted taxon so
679
    // it can be styled differently via the name render part definitions
680
    RenderHints::pushToRenderStack('accepted_taxon');
681
    $accepted_name = '';
682
    if (variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE, 0)) {
683
      $label = variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL, CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL_DEFAULT);
684
      $accepted_name .= '<div class="secReference"><span class="label">' . t($label) . ':</span> ' . $taxon->sec->titleCache . '</div>';
685
    }
686
    if (isset($taxon->name->nomenclaturalReference)) {
687
      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
688
    }
689
690
    $accepted_name .= '<div class="accepted-name">';
691
    $accepted_name .= render_taxon_or_name($taxon, NULL, $referenceUri);
692
693
    $name_relations = cdm_name_relationships_for_taxon($taxon);
694
    $name_relationships = compose_name_relationships_inline($name_relations, $taxon->name->uuid, $taxon->uuid);
695
    // Render relationships of accepted name.
696
    if(isset($name_relationships['list']['items'][0])){
697
      $accepted_name .= ' ' . drupal_render($name_relationships);
698
    }
699
700
    // handle annotations of the name and taxon
701
    $special_annotations_array = array();
702
    $special_annotations_array[] = $taxon->name;
703
    $special_annotations_array[] = $taxon;
704
    $accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
705
        'cdmBase_list' => $special_annotations_array,
706
        'footnote_list_key' => $synonymy_render_path . '-annotations')
707
    );
708
    $accepted_name .= '</div>';
709
    RenderHints::popFromRenderStack();
710
  }
711
712
  // --- Render homotypic synonymy group
713
  if (!empty($accepted_name)) {
714
    $out .= $accepted_name;
715
  }
716
717
  // Render the homotypicSynonymyGroup including the type information.
718
  $out .= theme(
719
    'cdm_homotypicSynonymyGroup',
720
    array(
721
      'synonymList' => $synomymie->homotypicSynonymsByHomotypicGroup,
722
      'accepted_taxon_name_uuid' => $taxon->name->uuid
723
    )
724
  );
725
726
727
  // Render accepted taxon heterotypic synonymy groups.
728
  if ($synomymie->heterotypicSynonymyGroups) {
729
    foreach ($synomymie->heterotypicSynonymyGroups as $homotypicalGroup) {
730
      $out .= theme('cdm_heterotypicSynonymyGroup', array('homotypicalGroup' => $homotypicalGroup));
731
    }
732
  }
733
  // Render taxon relationships.
734
  if (variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)) {
735
    $taxonRelationshipsDTO = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS_DTO, $taxon->uuid);
736
    $out .= cdm_taxonRelationships($taxonRelationshipsDTO, $taxon);
737
  }
738
739
  RenderHints::popFromRenderStack();
740
741
  return markup_to_render_array($out);
742
}
743
744
745 f9a3d0f6 Andreas Kohlbecker
/**
746
 * composes and returns an render array for the experts associated with the given taxon
747
 *
748 8a1b451e Andreas Kohlbecker
 * @param object taxon
749 f9a3d0f6 Andreas Kohlbecker
 *
750
 * @return array
751
 *   A Drupal render array for a table with the experts
752
 *
753
 * @ingroup compose
754
 */
755 7663cd0b Andreas Kohlbecker
function compose_cdm_taxon_page_experts($taxon){
756
757
  $render_array = array();
758
  if(!isset($taxon->uuid)){
759
    return $render_array;
760
  }
761
762
  $current_classification_uuid = get_current_classification_uuid();
763
  // TODO use cdm_ws_fetchall below but this failes! needs fix!
764
  $taxon_node_agent_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
765
    array(
766
      $taxon->uuid,
767
      $current_classification_uuid
768
    )
769
  );
770
771
  $header = array(
772
    array('data' => t('Expert')),
773
    array('data' => t('Role'))
774
  );
775
  $rows = array();
776
777
778
  foreach($taxon_node_agent_relations->records as $taxon_node_agent_relation){
779
780 d9763fd3 Andreas Kohlbecker
781
    $expert_role_id = $taxon_node_agent_relation->agent->uuid . '-' . $taxon_node_agent_relation->type->uuid;
782
    $expert_details_container_id = 'expert_details_' . $expert_role_id;
783
784
    $agent_label_markup = cdm_dynabox(
785
      'expert_' . $expert_role_id,
786
      $taxon_node_agent_relation->agent->titleCache,
787
      // specifying both ends of the relationship will return only one record in the pager
788
      cdm_compose_url(CDM_WS_PORTAL_AGENT,
789
         array($taxon_node_agent_relation->agent->uuid, 'taxonNodeAgentRelations'),
790
        'taxon_uuid=' . $taxon->uuid . '&relType_uuid=' . $taxon_node_agent_relation->type->uuid),
791
      'cdm_taxon_expert',
792
      'Click for details',
793
      array('div', 'div'),
794
      array(), // attributes
795 cea412e7 Andreas Kohlbecker
      '#' . $expert_details_container_id // $content_element_selector
796 d9763fd3 Andreas Kohlbecker
    );
797
798
    // Expert and Role
799
    $rows[] = array(
800
      'data' => array(
801
        array(
802
          'data' => $agent_label_markup,
803
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->agent))
804 7663cd0b Andreas Kohlbecker
        ),
805 d9763fd3 Andreas Kohlbecker
        array(
806
          'data' => $taxon_node_agent_relation->type->representation_L10n,
807
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->type))
808
        )
809
      )
810
    );
811
    // Agent details
812
    $rows[] = array(
813
      'data' => array(
814
        array(
815
          'data' => '<!-- expert_details_container -->',
816
          'id' => $expert_details_container_id,
817
          'colspan' => 2
818
        )
819
      )
820 7663cd0b Andreas Kohlbecker
    );
821 d9763fd3 Andreas Kohlbecker
822 7663cd0b Andreas Kohlbecker
  }
823
824
825
  $render_array['experts_table'] = array(
826
    '#theme' => 'table',
827
    '#header' => $header,
828
    '#rows' => $rows,
829
  );
830
831
832
  return $render_array;
833
}
834
835 bf97c2e8 Andreas Kohlbecker
836 3f259ca3 Andreas Kohlbecker
/**
837 7663cd0b Andreas Kohlbecker
 * Manages the tabs to be hidden in the taxon page.
838 3f259ca3 Andreas Kohlbecker
 *
839
 * The tabs are identified by their last menu link path element:
840
 *  - description
841
 *  - synonymy
842
 *  - images
843
 *  - specimens
844
 *  - key
845
 *
846
 * Internally the tabs are stored in a static variable which is
847
 * managed by drupal_static().
848
 *
849
 * @param string $add_tab
850 7663cd0b Andreas Kohlbecker
 *   Optional parameter. The given string will be added to the array of tabs
851 3f259ca3 Andreas Kohlbecker
 *
852
 * @return
853
 *   The array of tabs
854
 */
855 48a6d7e8 Andreas Kohlbecker
function taxon_page_tabs_hidden_add($add_tab = NULL) {
856
  $tabs = &drupal_static('taxon_page_tabs_hidden');
857 3f259ca3 Andreas Kohlbecker
858 0ae57522 Patric Plitzner
  if(!isset($tabs)){
859
    $tabs = array();
860
  }
861 3f259ca3 Andreas Kohlbecker
862 0ae57522 Patric Plitzner
  if (isset($add_tab) && !array_key_exists($add_tab, $tabs)) {
863
    $tabs[] = $add_tab;
864
  }
865 3f259ca3 Andreas Kohlbecker
866 0ae57522 Patric Plitzner
  return $tabs;
867 3f259ca3 Andreas Kohlbecker
}
868
869 48a6d7e8 Andreas Kohlbecker
/**
870
 * Manages the tabs to be hidden in the taxon page.
871
 *
872
 * The tabs names are identified by their last menu link path element:
873
 *  - description
874
 *  - synonymy
875
 *  - images
876
 *  - specimens
877
 *  - key
878
 *
879
 * Internally the tabs are stored in a static variable which is
880
 * managed by drupal_static().
881
 *
882
 * @param string $tabname
883
 *   The name of the tab to check
884
 *
885
 * @return boolean
886
 *   True if the tab or section is to be hidden
887
 */
888
function taxon_page_tabs_hidden_check($tabname) {
889
890
  $tabs = &drupal_static('taxon_page_tabs_hidden');
891
892
  if(!isset($tabs)){
893
    $tabs = array();
894
  }
895
896
  return array_search($tabname, $tabs) !== FALSE;
897
}
898
899 3f259ca3 Andreas Kohlbecker
/**
900
 * Implements the hook_preprocess_HOOK() for theme_menu_local_tasks()
901
 *
902 48a6d7e8 Andreas Kohlbecker
 *  - Removes the tabs to be hidden, @see taxon_page_tabs_hidden_add()
903 9438ad3a Andreas Kohlbecker
 *  - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!)
904 3f259ca3 Andreas Kohlbecker
 *
905
 * @param array $variables
906
 *   The variables array
907
 */
908
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) {
909
910 48a6d7e8 Andreas Kohlbecker
  $hidden_tabs = taxon_page_tabs_hidden_add();
911 3f259ca3 Andreas Kohlbecker
912 868be375 Katja Luther
  if (!variable_get(CDM_SEARCH_BLAST_ENABLED)) {
913 6f6f79f6 Katja Luther
      if (is_array($variables['primary'])) {
914
          foreach ($variables['primary'] as $key => &$element) {
915
              if ($element['#link']['path'] == 'cdm_dataportal/search/blast') {
916
                  // remove the tab
917
                  unset($variables['primary'][$key]);
918
              }
919 868be375 Katja Luther
920 6f6f79f6 Katja Luther
          }
921 868be375 Katja Luther
      }
922
  }
923 0ae57522 Patric Plitzner
  if (is_array($variables['primary'])) {
924
    foreach ($variables['primary'] as $key => &$element) {
925 6f1a217c Andreas Kohlbecker
926 0ae57522 Patric Plitzner
      // 1. Remove the tabs to be hidden
927
      foreach ($hidden_tabs as $tab) {
928
        if ($element['#link']['path'] == 'cdm_dataportal/taxon/%/' . $tab) {
929
          // remove the tab
930
          unset($variables['primary'][$key]);
931 9438ad3a Andreas Kohlbecker
        }
932 0ae57522 Patric Plitzner
      }
933 3f259ca3 Andreas Kohlbecker
    }
934 0ae57522 Patric Plitzner
  }
935 6f1a217c Andreas Kohlbecker
}
936
937
938
939
/**
940
 * Implements the hook_preprocess_HOOK() for theme_menu_local_task()
941
 *
942
 *
943
 * @param array $variables
944
 *   An associative array containing:
945
 *     - element: A render element containing:
946
 *          #link: A menu link array with 'title', 'href', and 'localized_options' keys.
947
 *          #active: A boolean indicating whether the local task is active.
948
 *
949
 */
950
function cdm_dataportal_preprocess_menu_local_task(&$variables) {
951
952 0ae57522 Patric Plitzner
  $link = $variables['element']['#link'];
953
  if (preg_match('/cdm_dataportal\/.*\/refresh$/', $link['href'])) {
954
    $link['title'] = '<img class="refresh" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/view-refresh.png' . '" alt="' . check_plain($link['title']) . '" title="' . check_plain($link['title']) . '"/>';
955
    $link['localized_options']['html'] = TRUE;
956 6f1a217c Andreas Kohlbecker
957 0ae57522 Patric Plitzner
    $variables['element']['#link'] = $link;
958
  }
959 f19f47fa Andreas Kohlbecker
}
960 f9a3d0f6 Andreas Kohlbecker
961
/* =================== block composition ===================== */
962
963
/**
964 23ad16a1 Andreas Kohlbecker
 * Composes and returns an render array for the classification breadcrumbs of the given taxon.
965 f9a3d0f6 Andreas Kohlbecker
 *
966
 * @param taxon
967
 *
968
 * @return array
969
 *   A Drupal render array for a table with the experts
970
 *
971
 * @ingroup compose
972
 */
973
function compose_classification_breadcrumbs($taxon_uuid) {
974
975 b0adfd32 Andreas Kohlbecker
  _add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
976 d0d23caa Andreas Kohlbecker
977 f9a3d0f6 Andreas Kohlbecker
  $render_array = array();
978
979
  $render_array['#theme'] = 'item_list';
980
  $render_array['#type'] = 'ul';
981
  $render_array['#attributes'] = array(
982
    'id' => 'classification-breadcrumbs',
983
    'class' => 'breadcrumbs inline',
984
  );
985
986
  $items = array();
987
988 38da4e54 Andreas Kohlbecker
  $parent_taxon_nodes = null;
989
  if($taxon_uuid){
990
    $parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
991
  }
992 f9a3d0f6 Andreas Kohlbecker
993 38da4e54 Andreas Kohlbecker
  $classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
994
  // find current classification in list
995
  $classification = null;
996
  $current_classification_uuid = get_current_classification_uuid();
997
  foreach ($classifications as $classification){
998
    if($classification->uuid == $current_classification_uuid){
999
      break;
1000 b0adfd32 Andreas Kohlbecker
    }
1001 38da4e54 Andreas Kohlbecker
  }
1002 b0adfd32 Andreas Kohlbecker
1003 38da4e54 Andreas Kohlbecker
  $node_name = '';
1004
  if(count($classifications) > 1 ){
1005
    // need to add the current classification as first label
1006 0af3ce28 Andreas Kohlbecker
1007
    $label = $classification->titleCache;
1008
    if(strlen($label) > 20){
1009
      $label = substr($label, 0, strpos($label, ' ', 15)) . '...';
1010
    }
1011
    $node_name = font_awesome_icon_markup('fa-th-list')  . ' ' . l($label, '#', array(
1012
      'attributes' => array(
1013
        'class' => 'taxonomic-children-button classification-chooser',
1014
        'data-destination-uri' => drupal_get_destination(),
1015
        'data-cdm-align-with' => array('prev')
1016
      ),
1017
      'html' => true
1018
    ));
1019 f9a3d0f6 Andreas Kohlbecker
  }
1020 b0adfd32 Andreas Kohlbecker
1021 38da4e54 Andreas Kohlbecker
  $rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
1022 0af3ce28 Andreas Kohlbecker
1023
  $rank_separator = '<span> '
1024 38da4e54 Andreas Kohlbecker
    . font_awesome_icon_markup('fa-chevron-right')
1025
    . ' </span>';
1026 0af3ce28 Andreas Kohlbecker
  $more_children_icon = font_awesome_icon_markup('fa-sitemap fa-rotate-270');
1027 69fb3dbb Andreas Kohlbecker
  $more_children_label = '...';
1028 38da4e54 Andreas Kohlbecker
1029 0af3ce28 Andreas Kohlbecker
  $items[] = $node_name;
1030 38da4e54 Andreas Kohlbecker
1031 0af3ce28 Andreas Kohlbecker
  $more_children_for = null;
1032 e3235962 Andreas Kohlbecker
  if($parent_taxon_nodes){
1033 0af3ce28 Andreas Kohlbecker
    foreach ($parent_taxon_nodes as $node) {
1034 38da4e54 Andreas Kohlbecker
1035
      $is_first_item = count($items) == 0;
1036 0af3ce28 Andreas Kohlbecker
      $is_last_item = count($items) == count($parent_taxon_nodes);
1037 38da4e54 Andreas Kohlbecker
      $node_name = cdm_dataportal_shortname_of($node);
1038
      $path = path_to_taxon($node->taxonUuid);
1039
1040 0af3ce28 Andreas Kohlbecker
      if($node->taxonomicChildrenCount > 0) {
1041
        $more_children_for = $node->taxonUuid;
1042
      } else {
1043
        $more_children_for = null;
1044 38da4e54 Andreas Kohlbecker
      }
1045
1046 0af3ce28 Andreas Kohlbecker
      // 'fa-sitemap'
1047
1048 38da4e54 Andreas Kohlbecker
      $items[] =
1049 0af3ce28 Andreas Kohlbecker
        ($is_first_item ? '' : ' ')
1050
        . $rank_separator
1051
        . l(
1052 4b3be949 Andreas Kohlbecker
          '<span class="' . html_class_attribute_ref($node) . '">' . $node_name . '</span>',
1053 0af3ce28 Andreas Kohlbecker
          $path,
1054
          array(
1055
            'attributes' => array(
1056
              'class' => array('taxonomic-children-button'),
1057
              'data-cdm-taxon-uuid' => array($node->taxonUuid),
1058
              'data-cdm-classification-mode' => array('siblings'),
1059
              'data-cdm-align-with' => array('prev')
1060 4b3be949 Andreas Kohlbecker
            ),
1061
            'html' => true
1062 0af3ce28 Andreas Kohlbecker
          )
1063
        );
1064
      }
1065 38da4e54 Andreas Kohlbecker
    }
1066 0af3ce28 Andreas Kohlbecker
1067
  // add more button to the end
1068
  if(!$parent_taxon_nodes) {
1069
    // not taxon focused yet, adding button to make  the root nodes available
1070 69fb3dbb Andreas Kohlbecker
    $items[] = '<span>'
1071
      . $more_children_icon . '&nbsp;' .
1072
      '<span class="taxonomic-children-button" data-classification-uuid="' . $current_classification_uuid
1073 53c705d4 Andreas Kohlbecker
      . '" data-rank-limit-uuid="' . $rank_limit_uuid . '" data-cdm-align-with="prev"> ' . $more_children_label . '<span>'
1074 69fb3dbb Andreas Kohlbecker
      . '</span>';
1075 0af3ce28 Andreas Kohlbecker
  } else if($more_children_for){
1076
    // last parent item has child taxon nodes
1077 69fb3dbb Andreas Kohlbecker
    $items[] = ' <span>'
1078
      . $more_children_icon . '&nbsp;' .
1079
      '<span class="taxonomic-children-button" data-cdm-taxon-uuid="' .$more_children_for
1080 53c705d4 Andreas Kohlbecker
      . '" data-cdm-classification-mode="children" data-cdm-align-with="prev"> ' . $more_children_label . '</span>'
1081 69fb3dbb Andreas Kohlbecker
      . '</span>';
1082 0af3ce28 Andreas Kohlbecker
1083 e3235962 Andreas Kohlbecker
  }
1084 b0adfd32 Andreas Kohlbecker
1085 30845bda Andreas Kohlbecker
  $render_array['#items'] = $items;
1086 0af3ce28 Andreas Kohlbecker
1087 30845bda Andreas Kohlbecker
  return $render_array;
1088
}
1089 0af3ce28 Andreas Kohlbecker
1090 69fb3dbb Andreas Kohlbecker
1091 30845bda Andreas Kohlbecker
/**
1092
 * @param $specimen_uuid
1093
 * @return array
1094
 *    The drupal render array for the page
1095
 *
1096
 * @ingroup compose
1097
 */
1098 e89c1115 Katja Luther
function compose_cdm_specimen_page($specimen_uuid)
1099 30845bda Andreas Kohlbecker
{
1100
  drupal_set_title("Specimen Details");
1101
  RenderHints::pushToRenderStack('specimen_page');
1102 f9a3d0f6 Andreas Kohlbecker
1103 78a42a9b Katja Luther
  $specimen_table = array(
1104
      '#theme' => 'table',
1105
      '#weight' => 2,
1106 2527a83c Andreas Kohlbecker
      // prefix attributes and rows with '#' to let it pass to the theme function,
1107 78a42a9b Katja Luther
      // otherwise it is handled as child render array
1108 489f7610 Katja Luther
1109
    '#attributes' => array('class' => 'specimens'),
1110 78a42a9b Katja Luther
      '#rows' => array(),
1111 93fb962c Katja Luther
      '#prefix' => '<div id="specimens">',
1112
      '#suffix' => '</div>',
1113
1114 489f7610 Katja Luther
1115 78a42a9b Katja Luther
  );
1116
  $specimen = compose_cdm_specimen_or_observation($specimen_uuid, true);
1117 44f44469 Andreas Kohlbecker
  /*
1118 961319fe Andreas Kohlbecker
  $render_array = array(
1119 78a42a9b Katja Luther
          '#theme' => 'item_list',
1120
          '#items' => array($specimen),
1121
          '#type' => 'ul');
1122 961319fe Andreas Kohlbecker
  $output = drupal_render($render_array);
1123 44f44469 Andreas Kohlbecker
 */
1124 78a42a9b Katja Luther
  $specimen_table['#rows'][] = array(
1125
          // An array of table rows. Every row is an array of cells, or an associative array
1126 961319fe Andreas Kohlbecker
          'data' => $specimen,
1127 78a42a9b Katja Luther
          'class' =>  array(
1128
              'descriptionElement',
1129
              'descriptionElement_IndividualsAssociation'
1130
          ),
1131
  );
1132 e89c1115 Katja Luther
1133
1134 78a42a9b Katja Luther
 // $detail_html = compose_cdm_specimen_or_observation($specimen_uuid, true);
1135 93fb962c Katja Luther
//    $render_array['markup'] = array(
1136
//        '#prefix' => '<div id="specimens" class="page">',
1137
//        'content' => $specimen_table,
1138
//        '#suffix' => '</div>',
1139
//    );
1140 2527a83c Andreas Kohlbecker
  $render_array['specimen_table'] =  $specimen_table;
1141 e89c1115 Katja Luther
1142 30845bda Andreas Kohlbecker
  RenderHints::popFromRenderStack();
1143 961319fe Andreas Kohlbecker
  return $specimen; // $render_array;
1144 30845bda Andreas Kohlbecker
}
1145 f9a3d0f6 Andreas Kohlbecker
1146 30845bda Andreas Kohlbecker
/**
1147
 * @param $named_area_uuid
1148
 * @return array
1149
 *    The drupal render array for the page
1150
 *
1151
 * @ingroup compose
1152
 */
1153
function compose_cdm_named_area_page($named_area_uuid)
1154
{
1155
1156
  $named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, array($named_area_uuid));
1157
1158
  $render_array = array();
1159
  RenderHints::pushToRenderStack('named_area_page');
1160
1161
  $groups = array();
1162
  @_description_list_group_add($groups, t('Name') . ':', $named_area->representation_L10n);
1163
  @_description_list_group_add($groups, t('IdInVocabulary') . ':', $named_area->idInVocabulary);
1164
  if(isset($named_area->level)) {
1165
    @_description_list_group_add($groups, t('Level') . ':', $named_area->level->representation_L10n);
1166
  }
1167
1168
  $name_area_details_elements = array(
1169
   // '#title' => $title,
1170
    '#theme' => 'description_list',
1171
    '#groups' => $groups,
1172
    '#attributes' => array('class' => html_class_attribute_ref($named_area)),
1173
  );
1174
1175
  $render_array[] = $name_area_details_elements;
1176
1177
  RenderHints::popFromRenderStack();
1178
  return $render_array;
1179 f9a3d0f6 Andreas Kohlbecker
}
1180 4feeabc7 Andreas Kohlbecker
1181 57dabcba Andreas Kohlbecker
1182
/**
1183
 * Returns a drupal render array for a single reference page.
1184
 *
1185
 * Composes a page with all data on a single reference.
1186
 *
1187
 * @param string $uuid
1188
 *   An uuid for a cdm reference.
1189
 *
1190
 * @return array
1191
 *  A drupal render array
1192
 *
1193
 * @throws Exception
1194
 *
1195
 * @ingroup compose
1196
 */
1197
function compose_cdm_reference_page($uuid) {
1198
1199
  $pathelement = "reference_page";
1200
  RenderHints::pushToRenderStack($pathelement);
1201
  $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
1202 4d9660ef Andreas Kohlbecker
  if (!$reference) {
1203
    drupal_set_title(t('Reference does not exist'), PASS_THROUGH);
1204 de017852 Andreas Kohlbecker
    return "";
1205 4d9660ef Andreas Kohlbecker
  }
1206 57dabcba Andreas Kohlbecker
  if (isset($reference->titleCache)) {
1207
    drupal_set_title($reference->titleCache, PASS_THROUGH);
1208
  }
1209
1210
  $field_order = array(
1211
    "title",
1212
    "abbrevTitle",
1213
    // "titleCache" abbrevTitleCache
1214
    // "citation",
1215
    "authorship",
1216
    "editor",
1217
    "publisher",
1218
    "placePublished",
1219
    "datePublished",
1220
    "year",
1221
    "edition",// Class Book.
1222
    "volume",// Class Article.
1223
    "seriesPart",
1224
    "inReference",
1225
    "nomRefBase", // Class BookSection, Book, Article.
1226
    "pages",// Class Article.
1227
    "series",// Class Article, PrintSeries.
1228
    "school",// Class Thesis.
1229
    "institution",// Class Report.
1230
    "organization",// Class Proceedings.
1231
    "nextVersion",
1232
    "previousVersion",
1233
    "isbn",// Class Book.
1234
    "issn",// Class Journal.
1235
    "doi",
1236
    "uri"
1237
  );
1238
1239
  $table_rows = array();
1240
1241
  if (!isset($reference->authorship)) {
1242
    $authorship = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
1243
    $reference->authorship = isset($authorship->titleCache) ? $authorship->titleCache : '';
1244
  }
1245
1246
  if (!isset($reference->inReference)) {
1247
    $reference->inReference = cdm_ws_get(CDM_WS_REFERENCE, array(
1248
      $reference->uuid,
1249
      "inReference",
1250
    ));
1251
  }
1252
1253
  foreach ($field_order as $fieldname) {
1254
1255
    if (isset($reference->$fieldname)) {
1256
1257
      if ($fieldname == "datePublished") {
1258
        $period = $reference->$fieldname;
1259
        $datePublished = timePeriodToString($period);
1260
        if (isset($datePublished) && $datePublished != '') {
1261
          $table_rows[] = array(
1262
            t("Date published"),
1263
            $datePublished,
1264
          );
1265
        }
1266
      }
1267
      elseif ($fieldname == "doi" && is_object($reference->doi)) {
1268
        $table_rows[] = array(
1269
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
1270
          cdm_doi($reference->doi, false)
1271
        );
1272
      }
1273
      elseif ($fieldname == "uri" && isset($reference->uri) && $reference->uri) {
1274
        $table_rows[] = array(
1275
          t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
1276
          cdm_external_uri($reference->uri, false)
1277
        );
1278
      }
1279
      elseif (is_object($reference->$fieldname)) {
1280
        if ($fieldname == "authorship") {
1281
          $dump = $reference->$fieldname;
1282
          $teammembers = "teamMembers";
1283
          $team = $dump->$teammembers;
1284
          $nameArray = array();
1285
1286
          foreach ($team as $member) {
1287
            if (strlen($member->lastname) > 0) {
1288
              $nname = $member->lastname;
1289
              $name = $nname;
1290
              if (strlen($member->firstname) > 0) {
1291
                $vname = $member->firstname;
1292
                $name = $vname . " " . $nname;
1293
              }
1294
              $nameArray[] = $name;
1295
            }
1296
            else {
1297
              if (strlen($member->titleCache) > 0) {
1298
                $nameArray[] = $member->titleCache;
1299
              }
1300
            }
1301
          }
1302
          $value = join($nameArray, ", ");
1303
        }
1304
        elseif ($fieldname == "inReference") {
1305
          $type = $reference->$fieldname->type;
1306
          $value = l($reference->$fieldname->titleCache, path_to_reference($reference->$fieldname->uuid));
1307
          switch ($type) {
1308
            case "Book":
1309
              $fieldname = "in book";
1310
              break;
1311
            case "Journal":
1312
              $fieldname = "in journal";
1313
              break;
1314
            case "Proceedings":
1315
              $fieldname = "in proceedings";
1316
              break;
1317
          }
1318
        }
1319
        else {
1320
          $value = $reference->$fieldname->titleCache;
1321
        }
1322
1323
1324
        if (isset($value) && $value != '') {
1325
          $table_rows[] = array(
1326
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
1327
            $value,
1328
          );
1329
        }
1330
1331
      }
1332
      else {
1333
        if (isset($reference->$fieldname) && $reference->$fieldname != '') {
1334
          $table_rows[] = array(
1335
            t('@fieldname', array('@fieldname' => ucfirst(strtolower($fieldname)))),
1336
            $reference->$fieldname,
1337
          );
1338
        }
1339
      }
1340
    }
1341
  }
1342
1343
  $out = theme_table(array(
1344
    'header' => array(),
1345
    'rows' => $table_rows,
1346
    'attributes' => array(
1347
      'class' => html_class_attribute_ref($reference)
1348
    ),
1349
    'caption' => NULL,
1350
    'colgroups' => NULL,
1351
    'sticky' => NULL,
1352
    'empty' => NULL,
1353
  ));
1354
1355
  if(isset($reference->referenceAbstract)){
1356
    $out .= '<h2 class="block-title">Abstract</h2><div class="abstract">' . $reference->referenceAbstract . '</div>';
1357
  }
1358
1359
1360
  // Annotations below the table
1361
  $annotations = cdm_fetch_visible_annotations($reference);
1362
  $out .= theme("cdm_annotations", array('annotations' => $annotations));
1363
1364
  $registration_working_set = cdm_ws_get("registrationWorkingSetDTO", array($uuid));
1365
  if($registration_working_set && count($registration_working_set->registrationDTOs) > 0){
1366
    $out .= "<h3>Nomenclatural acts:</h3><div class=\"cdm-item-list registration-item-list\">";
1367
    foreach($registration_working_set->registrationDTOs as $registration_dto){
1368
      if($registration_dto->status == "PUBLISHED"){
1369
        $registration_render_a = compose_registration_dto_compact($registration_dto, 'citation');
1370
        $registration_render_a["#prefix"] = "<div class=\"item item-registration\">";
1371
        $registration_render_a["#suffix"] = "</div>";
1372
        $out .= drupal_render($registration_render_a);
1373
      }
1374
    }
1375
    $out .= "</div>";
1376
  }
1377
1378
  RenderHints::popFromRenderStack();
1379
1380
  return markup_to_render_array($out);
1381
}
1382
1383 4feeabc7 Andreas Kohlbecker
/**
1384
 * Provides the the label string for taxon page tabs.
1385
 *
1386
 * The $tabname as passed to the method will be returned if no override
1387
 * label is configured in the settings.
1388
 */
1389
function cdm_taxonpage_tab_label($tabname) {
1390
  static $taxon_tabs_labels = null;
1391
  if($taxon_tabs_labels == null){
1392
    $taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
1393
  }
1394
  $tabname_key = strtolower($tabname);
1395
  if(isset($taxon_tabs_labels[$tabname_key]) && $taxon_tabs_labels[$tabname_key]){
1396
    return $taxon_tabs_labels[$tabname_key];
1397
  }
1398
  return $tabname;
1399
}