Project

General

Profile

Download (42.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
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
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 *
15
 * @author
16
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
17
 */
18

    
19

    
20
/**
21
 * Creates a render array representing the ocurrences associetad with the $taxon.
22
 *
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
 */
33
function cdm_dataportal_taxon_page_specimens($taxon) {
34

    
35
    $render_array = array();
36
    RenderHints::pushToRenderStack('taxon_page_specimens');
37

    
38
    $relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
39
    $relationship_choice['direct'] = get_selection($relationship_choice['direct']);
40
    $relationship_choice['invers'] = get_selection($relationship_choice['invers']);
41

    
42
    $by_associatedtaxon_query_parameters = array(
43
        'relationshipsInvers' => implode(',', $relationship_choice['invers']),
44
        'relationships' => implode(',', $relationship_choice['direct']),
45
    );
46

    
47
    if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
48
        $by_associatedtaxon_query_parameters = array_merge($by_associatedtaxon_query_parameters, $_REQUEST['pager']);
49
    }
50

    
51
    $by_associatedtaxon_query = http_build_query($by_associatedtaxon_query_parameters);
52

    
53
    $pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
54
        null,
55
        $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
56
    );
57

    
58
    $specimensOrObservations = array();
59
    if(isset($pager->records[0])){
60
        $specimensOrObservations =  $pager->records;
61
    }
62

    
63
    // order occurrences by date but types should be on top of the list
64
    $type_specimens = array();
65
    $other_occurrences = array();
66
    foreach ($specimensOrObservations as &$occurrence) {
67
        $typeDesignationsPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $occurrence->uuid);
68
        if (isset($typeDesignationsPager->count) && $typeDesignationsPager->count > 0) {
69
            $type_specimens[] = $occurrence;
70
        } else {
71
            $other_occurrences[] = $occurrence;
72
        }
73
    }
74
    $specimensOrObservations = array_merge($type_specimens, $other_occurrences);
75

    
76
    // Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field
77
    // $occurrence->_fieldObjectMedia
78
    foreach ($specimensOrObservations as &$occurrence) {
79
        $occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
80
            $occurrence->uuid,
81
            'fieldObjectMedia',
82
        ));
83
        $occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
84
            $occurrence->uuid,
85
            'derivedUnitMedia',
86
        ));
87
    }
88

    
89
    // --- get map service HTTP query parameters
90
    if (count($specimensOrObservations) > 0) {
91
        $occurrence_queryDto = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid,  $by_associatedtaxon_query);
92

    
93
      $map_visibility = variable_get(SPECIMEN_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY_DEFAULT);
94
      if($map_visibility == 'always' ||
95
        variable_get(SPECIMEN_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY_DEFAULT) == 'automatic' &&
96
          (isset($occurrence_queryDto->fieldUnitPoints[0]) || isset($occurrence_queryDto->derivedUnitPoints[0]))
97
        )
98
      {
99
        $occurrence_query = $occurrence_queryDto->occurrenceQuery;
100
        $legend_format_query = null;
101
        $distribution_query = NULL;
102
        $render_array['map'] = compose_map('specimens', $occurrence_query, $distribution_query, $legend_format_query, array());
103
      }
104
    }
105
    if(variable_get('cdm_dataportal_compressed_specimen_derivate_table')){
106

    
107
        //COMPRESSED SPECIMEN DERIVATE TABLE
108
        $associatedFieldUnitsQuery_parameters = array();
109
        if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
110
            $associatedFieldUnitsQuery_parameters = array_merge($associatedFieldUnitsQuery_parameters, $_REQUEST['pager']);
111
        }
112

    
113
        $by_associatedtaxon_query = http_build_query($associatedFieldUnitsQuery_parameters);
114
        $pager_field_units = cdm_ws_get(CDM_WS_PORTAL_TAXON,
115
            array($taxon->uuid, 'associatedFieldUnits'),
116
            $by_associatedtaxon_query . '&pageSize=' . variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size')
117
        );
118
        if (isset($pager_field_units->records[0])) {
119
          $field_unit_uuids = array();
120
          foreach ($pager_field_units->records as $field_unit) {
121
            $field_unit_uuids[] = $field_unit->uuid;
122
          }
123
        }
124
        // get icon images
125
        $expand_icon = font_awesome_icon_markup(
126
            'fa-plus-square-o',
127
            array(
128
                'alt'=>'Show details',
129
                'class' => array('expand_icon')
130
            )
131
        );
132
        $collapse_icon = font_awesome_icon_markup(
133
            'fa-minus-square-o',
134
            array(
135
                'alt'=>'Show details',
136
                'class' => array('collapse_icon')
137
            )
138
        );
139
        $detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>';
140
        $checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>';
141
        $sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>';
142
        $character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>';
143
        if (isset($pagerFieldUnits->records[0])) {
144
        $rowcount = 0;
145
        foreach ($field_unit_uuids as $field_unit_uuid) {
146
            //get derivate hierarchy for the FieldUnit
147
            $derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy'));
148
            if($derivateHierarchy){
149
                //summary row
150
                $rows[] = array(
151
                    'data' => array(
152
                        array(
153
                            'data' => $expand_icon . $collapse_icon,
154
                            'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
155
                        ),
156
                        array(
157
                            'data' => $derivateHierarchy->country,
158
                            'class' => array('summary_row_cell')
159
                        ),
160
                        array(
161
                            'data' => $derivateHierarchy->date,
162
                            'class' => array('summary_row_cell')
163
                        ),
164
                        array(
165
                            'data' => $derivateHierarchy->collection,
166
                            'class' => array('summary_row_cell')
167
                        ),
168
                        array(
169
                            'data' => $derivateHierarchy->herbarium,
170
                            'class' => array('summary_row_cell')
171
                        ),
172
                        array(
173
                            'data' => $derivateHierarchy->hasType? $checked_box_icon:"",
174
                            'class' => array('summary_row_cell', 'summary_row_icon')
175
                        ),
176
                        array(
177
                            'data' => $derivateHierarchy->hasSpecimenScan? $checked_box_icon:"",
178
                            'class' => array('summary_row_cell', 'summary_row_icon')
179
                        ),
180
                        array(
181
                            'data' => ($derivateHierarchy->hasDna? $sequence_icon :"")." "
182
                                .($derivateHierarchy->hasDetailImage?$detail_image_icon:"")." "
183
                                .($derivateHierarchy->hasCharacterData?$character_data_icon:""),
184
                            'class' => array('summary_row_cell', 'summary_row_icon')
185
                        )
186
                    ),
187
                    'id' => ('derivate_summary' . $rowcount), // summary row id
188
                    'class' => array('summary_row'),
189
                );
190

    
191
                //assemble field unit details
192
                $detail_html = "";
193
                // - citation
194
                if ($derivateHierarchy->citation) {
195
                    $detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>";
196
                }
197
                //assemble specimen details
198
                if($derivateHierarchy->preservedSpecimenDTOs){
199
                    foreach($derivateHierarchy->preservedSpecimenDTOs as $preservedSpecimenDTO) {
200
                        $detail_html .= "<br>";
201
                        $detail_html .= render_cdm_specimen_page($preservedSpecimenDTO);
202
                    }
203
                }
204
                $detail_html .= "<br>";
205
                //detail row resp. one BIG detail cell
206
                $rows[] = array(
207
                    'data' => array(
208
                        array(
209
                            'data' => "", //empty first column
210
                            'class' => array('expand_column')
211
                        ),
212
                        array(
213
                            'data' => $detail_html,
214
                            'colspan' => 7,
215
                        ),
216
                    ),
217
                    'id' => ('derivate_details' . $rowcount),//details row ID
218
                    'class' => array('detail_row'),
219
                );
220
                $rowcount++;
221
                }
222
            }
223

    
224
            $tableId = "derivate_hierarchy_table";
225
            $derivateHierarchyTable = array(
226
                "#theme" => "table",
227
                "#weight" => 2,
228
                "#header" => array(
229
                    array(
230
                        'data' => "",
231
                        'class' => array('expand_column')
232
                    ),
233
                    "Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"),
234
                "#rows" => $rows,
235
                "#attributes" => array(
236
                    "id" => $tableId,
237
                    "border" => 2
238
                )
239
            );
240

    
241
            //add toggle functionality to derivate hierarchy table
242
            drupal_add_js_rowToggle("#".$tableId);
243

    
244
            $render_array['derivate_hierarchy_table'] = $derivateHierarchyTable;
245
            $render_array['pager'] = markup_to_render_array(
246
                theme('cdm_pager', array(
247
                    'pager' => $pager_field_units,
248
                    'path' => $_REQUEST['q'],
249
                    'parameters' => $_REQUEST
250
                )),
251
                10 // weight
252
            );
253
        }
254
    }
255
    else{
256
        //BOTTOM-UP-SPECIMEN-TABLE
257
        // --- generate the specimen list as table
258
        $specimen_table = array(
259
            '#theme' => 'table',
260
            '#weight' => 2,
261
            // prefix attributes and rows with '#' to let it pass to the theme function,
262
            // otherwise it is handled as child render array
263
            '#attributes' => array('class' => 'specimens'),
264
            '#rows' => array(),
265
        );
266

    
267
        if ($specimensOrObservations) {
268

    
269
            foreach ($specimensOrObservations as $specimenOrObservation) {
270

    
271
                $mediaList = array();
272
                if (is_array($specimenOrObservation->_fieldObjectMedia)) {
273
                    $mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia);
274
                }
275
                if (is_array($specimenOrObservation->_derivedUnitMedia)) {
276
                    $mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia);
277
                }
278

    
279
                // typelabel will contain the typeStatus
280
                $type_label = '';
281
                $typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid);
282
                if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) {
283
                    $type_status = array();
284
                    foreach ($typeDesignationPager->records as $typeDesignation) {
285
                        if (isset($typeDesignation->typeStatus->representation_L10n)){
286
                            $type_status[] = $typeDesignation->typeStatus->representation_L10n;
287
                        }
288
                    }
289
                    $type_label = implode(', ', $type_status);
290
                    if($type_label){
291
                        $type_label .= ': ' ;
292
                    }
293
                }
294

    
295
                // --- Specimen entry as dynamic label:
296
                //     -> Dynabox for the specimenOrObservation
297
                $gallery_name = $specimenOrObservation->uuid;
298

    
299
                $derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array( $specimenOrObservation->uuid));
300
                $label_html = cdm_dynabox(
301
                  $specimenOrObservation->uuid,
302
                  $type_label . $specimenOrObservation->titleCache,
303
                  $derived_unit_ws_request,
304
                  'cdm_specimenOrObservation',
305
                  'Click for details',
306
                  array('div', 'div'),
307
                  array(),
308
                  null, // $content_element_selector
309
                  'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
310
                  'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
311
                );
312

    
313
                // --- Render associated media.
314
                $gallery_html = '';
315
                if (count($mediaList) > 0) {
316
                    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
317
                    $captionElements = array(
318
                        '#uri' => t('open media'),
319
                    );
320

    
321
                    $gallery_html = compose_cdm_media_gallerie(array(
322
                        'mediaList' => $mediaList,
323
                        'galleryName' => $gallery_name,
324
                        'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
325
                        'cols' => $gallery_settings['cdm_dataportal_media_cols'],
326
                        'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
327
                        'captionElements' => $captionElements,
328
                        'mediaLinkType' => 'LIGHTBOX',
329
                        'alternativeMediaUri' => NULL,
330
                        'galleryLinkUri' => NULL,
331
                    ));
332
                }
333

    
334
                $specimen_table['#rows'][] = array(
335
                    // An array of table rows. Every row is an array of cells, or an associative array
336
                    'data' => array(
337
                        // Each cell can be either a string or an associative array
338
                        $label_html . $gallery_html
339
                    ),
340
                    'class' =>  array(
341
                        'descriptionElement',
342
                        'descriptionElement_IndividualsAssociation'
343
                    ),
344
                );
345
            }
346
        }
347

    
348
        $render_array['specimen_list'] = $specimen_table;
349
        $render_array['pager'] = markup_to_render_array(
350
            theme('cdm_pager', array(
351
                'pager' => $pager,
352
                'path' => $_REQUEST['q'],
353
                'parameters' => $_REQUEST,
354
            )),
355
            10 // weight
356
        );
357
    }
358
    RenderHints::popFromRenderStack();
359
    return $render_array;
360
}
361
 
362
function create_html_link($link, $openInExternalWindow=false){
363
    $html = "";
364
    if($link->uri && $link->uri!=""){
365
        $html .= '<a  href="' . $link->uri . '"';
366
        if($openInExternalWindow){
367
            $html .= ' target="_blank"';
368
        }
369
        $html .= '>' . $link->linkText . '</a>';
370
    }
371
    else{
372
        $html .= $link->linkText;
373
    }
374
    return $html;
375
}
376

    
377
/**
378
 * Creates HTML links from the given link list concatenated by default by a comma.
379
 * @param $linkList the list with Link objects having "uri" and "linkText" as members
380
 * @return string the assembled HTML string containing the links
381
 */
382
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
383
{
384
    $html = "";
385
    if ($linkList) {
386
        foreach ($linkList as $link) {
387
            $html .= create_html_link($link, $openInExternalWindow).$separator;
388
        }
389
        $html = rtrim($html, $separator);
390
    }
391
    return $html;
392
}
393

    
394
/**
395
 * Composes a taxon page which can consist of multiple parts like
396
 * 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed
397
 * as tabs or as sections of a single page.
398
 *
399
 * It is headed by the name of the accepted taxon without author and reference.
400
 *
401
 * @param $taxon
402
 *   The CDM Taxon Instance to compose the page for.
403
 * @param $page_part
404
 *   Name of the part to display, valid values are:
405
 *    - 'description' -  for the general part
406
 *    - 'images'
407
 *    - 'synonymy'
408
 *    - 'keys'
409
 *    - 'all'
410
 *
411
 * @return array
412
 *   A drupal render array
413
 *
414
 * @ingroup compose
415
 */
416
function compose_cdm_taxon_page($taxon, $page_part = 'description') {
417

    
418
  // we better cache here since drupal_get_query_parameters has no internal static cache variable
419
  $http_request_params = drupal_get_query_parameters();
420

    
421
  // add all mandatory js sources
422
  _add_js_footnotes();
423

    
424

    
425
  $render_array = array();
426
  $weight = 0; // the weight for the render array elements
427

    
428
  $tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
429

    
430
  $page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
431

    
432
  $synonymy_as_tab = variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT) === 1;
433
  if(!$synonymy_as_tab){
434
    unset($tabsToDisplay["Synonymy"]);
435
    // the synonymy is located in the general part in this case
436
    if($page_part == 'synonymy'){
437
      $page_part = 'description';
438
    }
439
  }
440

    
441
  $media = _load_media_for_taxon($taxon);
442

    
443

    
444
  if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
445
    taxon_page_tabs_hidden('images');
446
  }
447

    
448
  // --- GET specimensOrObservations --- //
449
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
450

    
451
  $specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
452
  if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
453
    taxon_page_tabs_hidden('specimens');
454
  }
455

    
456
  // --- GET polytomousKeys --- //
457
  $polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
458
  $identificationKeyCount = 0;
459
  if ($polytomousKeysPager) {
460
    $identificationKeyCount += $polytomousKeysPager->count;
461
  }
462
  if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
463
    taxon_page_tabs_hidden('keys');
464
  }
465

    
466
  // --- GET TaxonNodeAgentRelations --- //
467
  $current_classification_uuid = get_current_classification_uuid();
468
  $taxon_node_agent_relations_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
469
      array(
470
          $taxon->uuid,
471
          $current_classification_uuid,
472
      ),
473
      "pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible!
474
  );
475
  if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){
476
      taxon_page_tabs_hidden('experts');
477
  }
478

    
479
  if (!isset($tabsToDisplay["Synonymy"]) || $tabsToDisplay["Synonymy"] == '0') {
480
    taxon_page_tabs_hidden('synonymy');
481
  }
482

    
483
  // -------------------------------------------- //
484

    
485
  if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
486
    $render_array['accepted_for'] = markup_to_render_array(cdm_accepted_for($_REQUEST['acceptedFor']), $weight++);
487
  }
488

    
489
  // --- PAGE PART: DESCRIPTION --- //
490
  if ($page_part == 'description' || $page_part == 'all') {
491

    
492
    $merged_tree = merged_taxon_feature_tree($taxon);
493

    
494

    
495
    $render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, !$synonymy_as_tab);
496
    $render_array['general']['#weight'] = $weight++;
497
    $render_array['general']['#prefix'] = '<div id="general" class="page-part">';
498
    $render_array['general']['#suffix'] = '</div>';
499
  }
500

    
501
  // --- PAGE PART: IMAGES --- //
502
  if (array_search('images', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'images' || $page_part == 'all')) {
503
    $images_html = '<div id="images" class="page-part">';
504
    if ($page_part == 'all') {
505
      $images_html .= '<h2>' . t(cdm_taxonpage_tab_label('Images')) . '</h2>';
506
    }
507
    // Get the image gallery as configured by the admin.
508
    $default_image_gallery = 'default';
509
    $configured_image_gallery_viewer = variable_get('image_gallery_viewer', 'default');
510
    $taxon_image_gallery = '<div class="error">No image gallery viewer configured</div>';
511
    if($configured_image_gallery_viewer == $default_image_gallery || $configured_image_gallery_viewer == 'fsi'){
512
      // the fsi_gallery requires a flash plugin, in case the client browser is not supporting
513
      // flash we also need to provide an the default gallery as alternative
514
      $taxon_image_gallery = '<div id="default-gallery-viewer">' .
515
        call_user_func_array('taxon_image_gallery_' . $default_image_gallery, array(
516
          $taxon,
517
          $media,
518
        ))
519
        . '</div>';
520
    }
521
    if($configured_image_gallery_viewer == 'fsi'){
522
      $taxon_image_gallery .= '<div id="'. $configured_image_gallery_viewer .'-gallery-viewer">' .
523
        call_user_func_array('taxon_image_gallery_' . $configured_image_gallery_viewer, array(
524
          $taxon,
525
          $media,
526
        ))
527
       . '</div>';
528
    }
529
    $images_html .= $taxon_image_gallery;
530
    $images_html .= '</div>';
531
    $render_array['images'] = markup_to_render_array($images_html, $weight++);
532
  }
533

    
534
  // --- PAGE PART: SYNONYMY --- //
535
  if ((($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) {
536
    $synonymy_html = '<div id="synonymy" class="page-part">';
537
    if ($page_part == 'all') {
538
      $synonymy_html .= '<h2>' . t(cdm_taxonpage_tab_label('Synonymy')) . '</h2>';
539
    }
540
    $addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
541

    
542
    $synonymy_html .= theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => $addAcceptedTaxon));
543

    
544
    $synonymy_html .= '</div>';
545
    $render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
546

    
547
  }
548

    
549
  // --- PAGE PART: SPECIMENS --- //
550
  if ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all')) {
551
    $render_array['specimens'] = array(
552
        '#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Specimens')) . '</h2>' : ''),
553
        'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
554
        '#suffix' => '</div>',
555
    );
556
  }
557

    
558
  // --- PAGE PART: KEYS --- //
559
  if ($identificationKeyCount == 1 && $page_part == 'keys'){
560
    drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
561
  }
562
  else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
563
    $keys_html = '<div id="keys" class="page-part">';
564
    if ($page_part == 'all') {
565
      $keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>';
566
    }
567
    $keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
568
    $keys_html .= '</div>';
569
    $render_array['keys'] = markup_to_render_array($keys_html, $weight++);
570
  }
571

    
572
  // --- PAGE PART: EXPERTS --- //
573

    
574
  if (array_search('experts', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'experts' || $page_part == 'all')) {
575
    $render_array['experts'] = array(
576
        '#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Experts')) . '</h2>' : ''),
577
        'content' => compose_cdm_taxon_page_experts($taxon), // returns render array
578
        '#suffix' => '</div>',
579
    );
580
  }
581

    
582
  // ------------------ END OF PARTS -------------- //
583

    
584
  // adjust weights of page and toc elements according to the settings
585
  $taxontabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
586
  foreach($taxontabs_weights as $tab_key => $weight){
587
    if(isset($render_array[$tab_key])){
588
      $render_array[$tab_key]['#weight'] = $weight;
589
    }
590
  }
591

    
592

    
593
  // set up the TOC for the pages which contain all pageparts
594
  if($page_part == 'all') {
595

    
596
    asort($taxontabs_weights);
597
    foreach(array_keys($taxontabs_weights) as $tab_key){
598
      if(isset($render_array[$tab_key])){
599
        if($tab_key != 'general'){
600
          // add entry for page part
601
          $toc_elements[] = array(
602
              'data' => l(t(cdm_taxonpage_tab_label(ucfirst($tab_key))), $_GET['q'], array('fragment' => $tab_key, 'query' => $http_request_params)),
603
              'class' => array('page-part-toc-item-' . $tab_key)
604
          );
605
        } else {
606
          // add content of profile part instead
607
          if(isset($render_array['general'])) {
608
            // in case all tabs are shown at once the feature tocs
609
            // should be integrated into the tabs toc as sub list
610
            // and the profile image should be on top of the page
611
            if(isset($render_array['general']['taxon_description_feature_toc'])){;
612
            foreach ($render_array['general']['taxon_description_feature_toc']['#items'] as $profile_toc_item){
613
              $toc_elements[] = $profile_toc_item;
614
            }
615
            unset($render_array['general']['taxon_description_feature_toc']);
616
            }
617
          }
618
        }
619
      }
620
    }
621

    
622
    // move profile image in page structure
623
    if(isset($render_array['general']['taxon_profile_image'])){
624
      $render_array['profile_image'] = $render_array['general']['taxon_profile_image'];
625
      $render_array['profile_image']['#weight'] = -100;
626
      unset($render_array['general']['taxon_profile_image']);
627
    }
628

    
629
    // finally add the table of contents to the render array
630
    $render_array['toc'] = array(
631
        '#theme' => 'item_list',
632
        '#items' => $toc_elements,
633
        '#title' => t('Content'),
634
        '#weight' => -101,
635
        '#suffix' => '</div>',
636
        '#prefix'=> '<div id="page-toc">'
637
    );
638
  }
639

    
640

    
641
  return $render_array;
642
}
643

    
644
/**
645
 * TODO should this function really be a compose function?
646
 *     For a compose function must there always be a theme function with the same name? (ak 8.8.2013)
647
 *
648
 * composes and returns an render array containing the components of the taxon profile tab:
649
 *  - 'taxon_profile_image'
650
 *  - 'taxon_description_feature_toc'
651
 *  - 'taxon_description_features'
652
 *
653
 *
654
 * @param taxon
655
 * @param mergedTrees
656
 * @param media
657
 *
658
 * @return array
659
 *   A Drupal render array with the following elements:
660
 *     - 'taxon_profile_image'
661
 *     - 'taxon_description_feature_toc'
662
 *     - 'taxon_description_features'
663
 *
664
 * @ingroup compose
665
 */
666
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, $add_synonymy) {
667

    
668
  $render_array = array();
669

    
670
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
671

    
672
  $hide_taxon_profile_image = FALSE;
673
  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
674
    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
675
    $hide_taxon_profile_image = ($rankCompare > -1);
676
  }
677

    
678
  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
679

    
680
    $representationPart = new stdClass();
681
    $attributes = array();
682
    if (isset($media[0])) {
683
      // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
684
      // which only contains the thumbnail representation even if the height and width filters are not set.
685
      // -->
686
      $preferred_media = cdm_ws_get(CDM_WS_MEDIA, $media[0]->uuid);
687
      $preferred_representations = cdm_preferred_media_representations($preferred_media, array(
688
        'image/jpg',
689
        'image/jpeg',
690
        'image/png',
691
        'image/gif',
692
      ),
693
        $taxon_profile_image_settings['maxextend'],
694
        $taxon_profile_image_settings['maxextend']
695
      );
696
      if(count($preferred_representations) > 0){
697

    
698
        $representation = array_shift($preferred_representations);
699
        $representationPart = $representation->parts[0];
700
        $attributes['alt'] = $representationPart->uri;
701

    
702
        if (!empty($taxon_profile_image_settings['media_uri_query'])) {
703
          $representationPart->uri = $representationPart->uri
704
            . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
705
            . $taxon_profile_image_settings['media_uri_query'];
706
        }
707
      }
708
    }
709
    else {
710
      if ($taxon_profile_image_settings['custom_placeholder_enabled']) {
711
        // show placeholder image instead
712
        if (!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])) {
713
          // use the user provided image
714
          $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
715
          $url = file_create_url($profile_image_file->uri);
716
          $image_info = image_get_info($profile_image_file->uri);
717
          $representationPart->width = $image_info['width'];
718
          $representationPart->height = $image_info['height'];
719
          $representationPart->uri = $url;
720
        }
721
        else {
722
          // use the hard coded default
723
          $representationPart->width = 184;
724
          $representationPart->height = 144;
725
          $representationPart->uri = base_path() . drupal_get_path('module',
726
              'cdm_dataportal') . '/images/no_picture.png';
727
        }
728
        $attributes['alt'] = "no image available";
729
      }
730
    }
731

    
732
    if (isset($representationPart->uri)) {
733
      $profile_image = cdm_media_gallerie_image($representationPart, $taxon_profile_image_settings['maxextend'], FALSE, $attributes);
734
      // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
735
      $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image . '</div>',
736
        -101);
737
    }
738
  }
739

    
740
  if($add_synonymy){
741
    $render_array['synonymy'] = markup_to_render_array(
742
      theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => true)),
743
      -102
744
    );
745
  }
746

    
747
  $pseudo_feature_blocks = array();
748
  $pseudo_feature_block_toc_items = array();
749

    
750

    
751
  // Render the sections for each real feature
752
  $feature_block_list = make_feature_block_list($merged_tree->root->childNodes, $taxon);
753

    
754
  // Bibliography
755
  $bibliography_settings = get_bibliography_settings();
756
  if($bibliography_settings['enabled'] == 1){
757
    $feature_bibliography = make_pseudo_feature('Bibliography', 'BIBLIOGRAPHY');
758
    $bibliography_block = feature_block(t('Bibliography'), $feature_bibliography);
759
    $bibliography_item = markup_to_render_array(FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', ''));
760
    $bibliography_block->content[] = compose_feature_block_wrap_elements(array($bibliography_item), $feature_bibliography);
761

    
762
    if(!empty($bibliography_block->content)){
763
      $pseudo_feature_block_toc_items['Bibliography']= 'bibliography';
764
      $pseudo_feature_blocks[] = $bibliography_block;
765
    }
766
  }
767

    
768
  $render_array['taxon_description_features'] = _block_get_renderable_array(
769
    array_merge($feature_block_list, $pseudo_feature_blocks)
770
  );
771

    
772
  if($pseudo_feature_block_toc_items){
773
    foreach ($pseudo_feature_block_toc_items as $label=>$fragment){
774
      cdm_toc_list_add_item($label, $fragment);
775
    }
776
  }
777

    
778
  // create the table of content
779
  $toc = array(
780
      '#theme' => 'item_list',
781
    '#items' => cdm_toc_list(),
782
      '#title' => t('Content'),
783
    '#weight' => -100,                  // move to the top
784
      '#suffix' => '</div>',
785
      '#prefix'=> '<div id="page-toc">'
786
  );
787
  $render_array['taxon_description_feature_toc'] = $toc;
788

    
789
  return $render_array;
790
}
791

    
792
/**
793
 * composes and returns an render array for the experts associated with the given taxon
794
 *
795
 * @param taxon
796
 *
797
 * @return array
798
 *   A Drupal render array for a table with the experts
799
 *
800
 * @ingroup compose
801
 */
802
function compose_cdm_taxon_page_experts($taxon){
803

    
804
  $render_array = array();
805
  if(!isset($taxon->uuid)){
806
    return $render_array;
807
  }
808

    
809
  $current_classification_uuid = get_current_classification_uuid();
810
  // TODO use cdm_ws_fetchall below but this failes! needs fix!
811
  $taxon_node_agent_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
812
    array(
813
      $taxon->uuid,
814
      $current_classification_uuid
815
    )
816
  );
817

    
818
  $header = array(
819
    array('data' => t('Expert')),
820
    array('data' => t('Role'))
821
  );
822
  $rows = array();
823

    
824

    
825
  foreach($taxon_node_agent_relations->records as $taxon_node_agent_relation){
826

    
827

    
828
    $expert_role_id = $taxon_node_agent_relation->agent->uuid . '-' . $taxon_node_agent_relation->type->uuid;
829
    $expert_details_container_id = 'expert_details_' . $expert_role_id;
830

    
831
    $agent_label_markup = cdm_dynabox(
832
      'expert_' . $expert_role_id,
833
      $taxon_node_agent_relation->agent->titleCache,
834
      // specifying both ends of the relationship will return only one record in the pager
835
      cdm_compose_url(CDM_WS_PORTAL_AGENT,
836
         array($taxon_node_agent_relation->agent->uuid, 'taxonNodeAgentRelations'),
837
        'taxon_uuid=' . $taxon->uuid . '&relType_uuid=' . $taxon_node_agent_relation->type->uuid),
838
      'cdm_taxon_expert',
839
      'Click for details',
840
      array('div', 'div'),
841
      array(), // attributes
842
      '#' . $expert_details_container_id // $content_element_selector
843
    );
844

    
845
    // Expert and Role
846
    $rows[] = array(
847
      'data' => array(
848
        array(
849
          'data' => $agent_label_markup,
850
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->agent))
851
        ),
852
        array(
853
          'data' => $taxon_node_agent_relation->type->representation_L10n,
854
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->type))
855
        )
856
      )
857
    );
858
    // Agent details
859
    $rows[] = array(
860
      'data' => array(
861
        array(
862
          'data' => '<!-- expert_details_container -->',
863
          'id' => $expert_details_container_id,
864
          'colspan' => 2
865
        )
866
      )
867
    );
868

    
869
  }
870

    
871

    
872
  $render_array['experts_table'] = array(
873
    '#theme' => 'table',
874
    '#header' => $header,
875
    '#rows' => $rows,
876
  );
877

    
878

    
879
  return $render_array;
880
}
881

    
882

    
883
/**
884
 * Manages the tabs to be hidden in the taxon page.
885
 *
886
 * The tabs are identified by their last menu link path element:
887
 *  - description
888
 *  - synonymy
889
 *  - images
890
 *  - specimens
891
 *  - key
892
 *
893
 * Internally the tabs are stored in a static variable which is
894
 * managed by drupal_static().
895
 *
896
 * @param string $add_tab
897
 *   Optional parameter. The given string will be added to the array of tabs
898
 *
899
 * @return
900
 *   The array of tabs
901
 */
902
function taxon_page_tabs_hidden($add_tab = NULL) {
903
  $tabs = &drupal_static(__FUNCTION__);
904

    
905
  if(!isset($tabs)){
906
    $tabs = array();
907
  }
908

    
909
  if (isset($add_tab) && !array_key_exists($add_tab, $tabs)) {
910
    $tabs[] = $add_tab;
911
  }
912

    
913
  return $tabs;
914
}
915

    
916
/**
917
 * Implements the hook_preprocess_HOOK() for theme_menu_local_tasks()
918
 *
919
 *  - Removes the tabs to be hidden, @see taxon_page_tabs_hidden()
920
 *  - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!)
921
 *
922
 * @param array $variables
923
 *   The variables array
924
 */
925
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) {
926

    
927
  $hidden_tabs = taxon_page_tabs_hidden();
928

    
929
  if (is_array($variables['primary'])) {
930
    foreach ($variables['primary'] as $key => &$element) {
931

    
932
      // 1. Remove the tabs to be hidden
933
      foreach ($hidden_tabs as $tab) {
934
        if ($element['#link']['path'] == 'cdm_dataportal/taxon/%/' . $tab) {
935
          // remove the tab
936
          unset($variables['primary'][$key]);
937
        }
938
      }
939
    }
940
  }
941
}
942

    
943

    
944

    
945
/**
946
 * Implements the hook_preprocess_HOOK() for theme_menu_local_task()
947
 *
948
 *
949
 * @param array $variables
950
 *   An associative array containing:
951
 *     - element: A render element containing:
952
 *          #link: A menu link array with 'title', 'href', and 'localized_options' keys.
953
 *          #active: A boolean indicating whether the local task is active.
954
 *
955
 */
956
function cdm_dataportal_preprocess_menu_local_task(&$variables) {
957

    
958
  $link = $variables['element']['#link'];
959
  if (preg_match('/cdm_dataportal\/.*\/refresh$/', $link['href'])) {
960
    $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']) . '"/>';
961
    $link['localized_options']['html'] = TRUE;
962

    
963
    $variables['element']['#link'] = $link;
964
  }
965
}
966

    
967
/* =================== block composition ===================== */
968

    
969
/**
970
 * Composes and returns an render array for the classification breadcrumbs of the given taxon.
971
 *
972
 * @param taxon
973
 *
974
 * @return array
975
 *   A Drupal render array for a table with the experts
976
 *
977
 * @ingroup compose
978
 */
979
function compose_classification_breadcrumbs($taxon_uuid) {
980

    
981
  _add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
982

    
983
  $render_array = array();
984

    
985
  $render_array['#theme'] = 'item_list';
986
  $render_array['#type'] = 'ul';
987
  $render_array['#attributes'] = array(
988
    'id' => 'classification-breadcrumbs',
989
    'class' => 'breadcrumbs inline',
990
  );
991

    
992
  $items = array();
993

    
994
  $parent_taxon_nodes = null;
995
  if($taxon_uuid){
996
    $parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
997
  }
998

    
999
  $classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
1000
  // find current classification in list
1001
  $classification = null;
1002
  $current_classification_uuid = get_current_classification_uuid();
1003
  foreach ($classifications as $classification){
1004
    if($classification->uuid == $current_classification_uuid){
1005
      break;
1006
    }
1007
  }
1008

    
1009
  $node_name = '';
1010
  if(count($classifications) > 1 ){
1011
    // need to add the current classification as first label
1012

    
1013
    $label = $classification->titleCache;
1014
    if(strlen($label) > 20){
1015
      $label = substr($label, 0, strpos($label, ' ', 15)) . '...';
1016
    }
1017
    $node_name = font_awesome_icon_markup('fa-th-list')  . ' ' . l($label, '#', array(
1018
      'attributes' => array(
1019
        'class' => 'taxonomic-children-button classification-chooser',
1020
        'data-destination-uri' => drupal_get_destination(),
1021
        'data-cdm-align-with' => array('prev')
1022
      ),
1023
      'html' => true
1024
    ));
1025
  }
1026

    
1027
  $rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
1028

    
1029
  $rank_separator = '<span> '
1030
    . font_awesome_icon_markup('fa-chevron-right')
1031
    . ' </span>';
1032
  $more_children_icon = font_awesome_icon_markup('fa-sitemap fa-rotate-270');
1033
  $more_children_label = '...';
1034

    
1035
  $items[] = $node_name;
1036

    
1037
  $more_children_for = null;
1038
  if($parent_taxon_nodes){
1039
    foreach ($parent_taxon_nodes as $node) {
1040

    
1041
      $is_first_item = count($items) == 0;
1042
      $is_last_item = count($items) == count($parent_taxon_nodes);
1043
      $node_name = cdm_dataportal_shortname_of($node);
1044
      $path = path_to_taxon($node->taxonUuid);
1045

    
1046
      if($node->taxonomicChildrenCount > 0) {
1047
        $more_children_for = $node->taxonUuid;
1048
      } else {
1049
        $more_children_for = null;
1050
      }
1051

    
1052
      // 'fa-sitemap'
1053

    
1054
      $items[] =
1055
        ($is_first_item ? '' : ' ')
1056
        . $rank_separator
1057
        . l(
1058
          '<span class="' . html_class_attribute_ref($node) . '">' . $node_name . '</span>',
1059
          $path,
1060
          array(
1061
            'attributes' => array(
1062
              'class' => array('taxonomic-children-button'),
1063
              'data-cdm-taxon-uuid' => array($node->taxonUuid),
1064
              'data-cdm-classification-mode' => array('siblings'),
1065
              'data-cdm-align-with' => array('prev')
1066
            ),
1067
            'html' => true
1068
          )
1069
        );
1070
      }
1071
    }
1072

    
1073
  // add more button to the end
1074
  if(!$parent_taxon_nodes) {
1075
    // not taxon focused yet, adding button to make  the root nodes available
1076
    $items[] = '<span>'
1077
      . $more_children_icon . '&nbsp;' .
1078
      '<span class="taxonomic-children-button" data-classification-uuid="' . $current_classification_uuid
1079
      . '" data-rank-limit-uuid="' . $rank_limit_uuid . '" data-cdm-align-with="prev"> ' . $more_children_label . '<span>'
1080
      . '</span>';
1081
  } else if($more_children_for){
1082
    // last parent item has child taxon nodes
1083
    $items[] = ' <span>'
1084
      . $more_children_icon . '&nbsp;' .
1085
      '<span class="taxonomic-children-button" data-cdm-taxon-uuid="' .$more_children_for
1086
      . '" data-cdm-classification-mode="children" data-cdm-align-with="prev"> ' . $more_children_label . '</span>'
1087
      . '</span>';
1088

    
1089
  }
1090

    
1091
  $render_array['#items'] = $items;
1092

    
1093
  return $render_array;
1094
}
1095

    
1096

    
1097
/**
1098
 * @param $specimen_uuid
1099
 * @return array
1100
 *    The drupal render array for the page
1101
 *
1102
 * @ingroup compose
1103
 */
1104
function compose_cdm_specimen_page($specimen_uuid)
1105
{
1106
  drupal_set_title("Specimen Details");
1107
  $specimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($specimen_uuid, 'specimenDerivates'));
1108

    
1109
  $render_array = array();
1110
  RenderHints::pushToRenderStack('specimen_page');
1111

    
1112
  $detail_html = render_cdm_specimen_page($specimen, true);
1113
  $render_array['specimen_html'] = array(
1114
    '#markup' => $detail_html
1115
  );
1116

    
1117
  RenderHints::popFromRenderStack();
1118
  return $render_array;
1119
}
1120

    
1121
/**
1122
 * @param $named_area_uuid
1123
 * @return array
1124
 *    The drupal render array for the page
1125
 *
1126
 * @ingroup compose
1127
 */
1128
function compose_cdm_named_area_page($named_area_uuid)
1129
{
1130

    
1131
  $named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, array($named_area_uuid));
1132

    
1133
  $render_array = array();
1134
  RenderHints::pushToRenderStack('named_area_page');
1135

    
1136
  $groups = array();
1137
  @_description_list_group_add($groups, t('Name') . ':', $named_area->representation_L10n);
1138
  @_description_list_group_add($groups, t('IdInVocabulary') . ':', $named_area->idInVocabulary);
1139
  if(isset($named_area->level)) {
1140
    @_description_list_group_add($groups, t('Level') . ':', $named_area->level->representation_L10n);
1141
  }
1142

    
1143
  $name_area_details_elements = array(
1144
   // '#title' => $title,
1145
    '#theme' => 'description_list',
1146
    '#groups' => $groups,
1147
    '#attributes' => array('class' => html_class_attribute_ref($named_area)),
1148
  );
1149

    
1150
  $render_array[] = $name_area_details_elements;
1151

    
1152
  RenderHints::popFromRenderStack();
1153
  return $render_array;
1154
}
1155

    
1156
/**
1157
 * Provides the the label string for taxon page tabs.
1158
 *
1159
 * The $tabname as passed to the method will be returned if no override
1160
 * label is configured in the settings.
1161
 */
1162
function cdm_taxonpage_tab_label($tabname) {
1163
  static $taxon_tabs_labels = null;
1164
  if($taxon_tabs_labels == null){
1165
    $taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
1166
  }
1167
  $tabname_key = strtolower($tabname);
1168
  if(isset($taxon_tabs_labels[$tabname_key]) && $taxon_tabs_labels[$tabname_key]){
1169
    return $taxon_tabs_labels[$tabname_key];
1170
  }
1171
  return $tabname;
1172
}
(7-7/10)