Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / includes / pages.inc @ 850092a7

History | View | Annotate | Download (42.9 KB)

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
        $map_render_array = compose_map('specimens', $occurrence_query, $distribution_query, $legend_format_query, array());
103
      }
104
    }
105

    
106
    // -------------------------------------------------------
107
    $render_array['map'] = $map_render_array;
108

    
109
    if(variable_get('cdm_dataportal_compressed_specimen_derivate_table')){
110

    
111
        //COMPRESSED SPECIMEN DERIVATE TABLE
112
        $associatedFieldUnitsQuery_parameters = array();
113
        if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
114
            $associatedFieldUnitsQuery_parameters = array_merge($associatedFieldUnitsQuery_parameters, $_REQUEST['pager']);
115
        }
116

    
117
        $by_associatedtaxon_query = http_build_query($associatedFieldUnitsQuery_parameters);
118
        $pager_field_units = cdm_ws_get(CDM_WS_PORTAL_TAXON,
119
            array($taxon->uuid, 'associatedFieldUnits'),
120
            $by_associatedtaxon_query . '&pageSize=' . variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size')
121
        );
122

    
123
        if (isset($pager_field_units->records[0])) {
124
          $field_unit_uuids = array();
125
          foreach ($pager_field_units->records as $field_unit) {
126
            $field_unit_uuids[] = $field_unit->uuid;
127
          }
128
        }
129

    
130
        $render_array['derivate_hierarchy_table'] = compose_specimen_table($field_unit_uuids);
131

    
132
        $render_array['pager'] = markup_to_render_array(
133
            theme('cdm_pager', array(
134
                'pager' => $pager_field_units,
135
                'path' => $_REQUEST['q'],
136
                'parameters' => $_REQUEST
137
            )),
138
            10 // weight
139
        );
140
    }
141
    else{
142
        //BOTTOM-UP-SPECIMEN-TABLE
143
        // --- generate the specimen list as table
144
        $specimen_table = array(
145
            '#theme' => 'table',
146
            '#weight' => 2,
147
            // prefix attributes and rows with '#' to let it pass toF the theme function,
148
            // otherwise it is handled as child render array
149
            '#attributes' => array('class' => 'specimens'),
150
            '#rows' => array(),
151
        );
152

    
153
        if ($specimensOrObservations) {
154

    
155
            foreach ($specimensOrObservations as $specimenOrObservation) {
156

    
157
                $mediaList = array();
158
                if (is_array($specimenOrObservation->_fieldObjectMedia)) {
159
                    $mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia);
160
                }
161
                if (is_array($specimenOrObservation->_derivedUnitMedia)) {
162
                    $mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia);
163
                }
164

    
165
                // typelabel will contain the typeStatus
166
                $type_label = '';
167
                $typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid);
168
                if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) {
169
                    $type_status = array();
170
                    foreach ($typeDesignationPager->records as $typeDesignation) {
171
                        if (isset($typeDesignation->typeStatus->representation_L10n)){
172
                            $type_status[] = $typeDesignation->typeStatus->representation_L10n;
173
                        }
174
                    }
175
                    $type_label = implode(', ', $type_status);
176
                    if($type_label){
177
                        $type_label .= ': ' ;
178
                    }
179
                }
180

    
181
                // --- Specimen entry as dynamic label:
182
                //     -> Dynabox for the specimenOrObservation
183
                $gallery_name = $specimenOrObservation->uuid;
184

    
185
                $derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array( $specimenOrObservation->uuid));
186
                $label_html = cdm_dynabox(
187
                  $specimenOrObservation->uuid,
188
                  $type_label . $specimenOrObservation->titleCache,
189
                  $derived_unit_ws_request,
190
                  'cdm_specimen_or_observation',
191
                  'Click for details',
192
                  array('div', 'div'),
193
                  array(),
194
                  null, // $content_element_selector
195
                  'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
196
                  'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
197
                );
198

    
199
                // --- Render associated media.
200
                $gallery_html = '';
201
                if (count($mediaList) > 0) {
202
                    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
203
                    $captionElements = array(
204
                        '#uri' => t('open media'),
205
                    );
206

    
207
                    $gallery_html = compose_cdm_media_gallerie(array(
208
                        'mediaList' => $mediaList,
209
                        'galleryName' => $gallery_name,
210
                        'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
211
                        'cols' => $gallery_settings['cdm_dataportal_media_cols'],
212
                        'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
213
                        'captionElements' => $captionElements,
214
                        'mediaLinkType' => 'LIGHTBOX',
215
                        'alternativeMediaUri' => NULL,
216
                        'galleryLinkUri' => NULL,
217
                    ));
218
                }
219

    
220
                $specimen_table['#rows'][] = array(
221
                    // An array of table rows. Every row is an array of cells, or an associative array
222
                    'data' => array(
223
                        // Each cell can be either a string or an associative array
224
                        $label_html . $gallery_html
225
                    ),
226
                    'class' =>  array(
227
                        'descriptionElement',
228
                        'descriptionElement_IndividualsAssociation'
229
                    ),
230
                );
231
            }
232
        }
233

    
234
        $render_array['specimen_list'] = $specimen_table;
235
        $render_array['pager'] = markup_to_render_array(
236
            theme('cdm_pager', array(
237
                'pager' => $pager,
238
                'path' => $_REQUEST['q'],
239
                'parameters' => $_REQUEST,
240
            )),
241
            10 // weight
242
        );
243
    }
244
    RenderHints::popFromRenderStack();
245
    return $render_array;
246
}
247

    
248
/**
249
 * Creates the drupal render array for the table showing all derivated which are
250
 * derive from a common gathering event.
251
 *
252
 * @param $field_unit_uuids array
253
 *  An array of uuids for cdm FieldUnit entities.
254
 *
255
 * @return array
256
 *  A drupal render array for a table
257
 *
258
 * @ingroup compose
259
 */
260
function compose_specimen_table($field_unit_uuids)
261
{
262
// get icon images
263
  $expand_icon = font_awesome_icon_markup(
264
    'fa-plus-square-o',
265
    array(
266
      'alt' => 'Show details',
267
      'class' => array('expand_icon')
268
    )
269
  );
270
  $collapse_icon = font_awesome_icon_markup(
271
    'fa-minus-square-o',
272
    array(
273
      'alt' => 'Show details',
274
      'class' => array('collapse_icon')
275
    )
276
  );
277
  $detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>';
278
  $checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>';
279
  $sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>';
280
  $character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>';
281

    
282
  $rowcount = 0;
283
  $rows = array();
284

    
285
  foreach ($field_unit_uuids as $field_unit_uuid) {
286

    
287
    //get derivate hierarchy for the FieldUnit
288
    $derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy'));
289
    if ($derivateHierarchy) {
290
      //summary row
291
      $rows[] = array(
292
        'data' => array(
293
          array(
294
            'data' => $expand_icon . $collapse_icon,
295
            'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
296
          ),
297
          array(
298
            'data' => $derivateHierarchy->country,
299
            'class' => array('summary_row_cell')
300
          ),
301
          array(
302
            'data' => $derivateHierarchy->date,
303
            'class' => array('summary_row_cell')
304
          ),
305
          array(
306
            'data' => $derivateHierarchy->collection,
307
            'class' => array('summary_row_cell')
308
          ),
309
          array(
310
            'data' => $derivateHierarchy->herbarium,
311
            'class' => array('summary_row_cell')
312
          ),
313
          array(
314
            'data' => $derivateHierarchy->hasType ? $checked_box_icon : "",
315
            'class' => array('summary_row_cell', 'summary_row_icon')
316
          ),
317
          array(
318
            'data' => $derivateHierarchy->hasSpecimenScan ? $checked_box_icon : "",
319
            'class' => array('summary_row_cell', 'summary_row_icon')
320
          ),
321
          array(
322
            'data' => ($derivateHierarchy->hasDna ? $sequence_icon : "") . " "
323
              . ($derivateHierarchy->hasDetailImage ? $detail_image_icon : "") . " "
324
              . ($derivateHierarchy->hasCharacterData ? $character_data_icon : ""),
325
            'class' => array('summary_row_cell', 'summary_row_icon')
326
          )
327
        ),
328
        'id' => ('derivate_summary' . $rowcount), // summary row id
329
        'class' => array('summary_row'),
330
      );
331

    
332
      //assemble field unit details
333
      $detail_html = "";
334
      // - citation
335
      if ($derivateHierarchy->citation) {
336
        $detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>";
337
      }
338
      //assemble specimen details
339
      if ($derivateHierarchy->derivates) {
340
        foreach ($derivateHierarchy->derivates as $preservedSpecimenDTO) {
341
          $detail_html .= "<br>";
342
          $detail_html .= render_cdm_specimen_page($preservedSpecimenDTO);
343
        }
344
      }
345
      $detail_html .= "<br>";
346
      //detail row resp. one BIG detail cell
347
      $rows[] = array(
348
        'data' => array(
349
          array(
350
            'data' => "", //empty first column
351
            'class' => array('expand_column')
352
          ),
353
          array(
354
            'data' => $detail_html,
355
            'colspan' => 7,
356
          ),
357
        ),
358
        'id' => ('derivate_details' . $rowcount),//details row ID
359
        'class' => array('detail_row'),
360
      );
361
      $rowcount++;
362
    }
363
  }
364

    
365
  $tableId = "derivate_hierarchy_table";
366
  $derivateHierarchyTable = array(
367
    "#theme" => "table",
368
    "#weight" => 2,
369
    "#header" => array(
370
      array(
371
        'data' => "",
372
        'class' => array('expand_column')
373
      ),
374
      "Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"),
375
    "#rows" => $rows,
376
    "#attributes" => array(
377
      "id" => $tableId,
378
      "border" => 2
379
    )
380
  );
381

    
382
  //add toggle functionality to derivate hierarchy table
383
  drupal_add_js_rowToggle("#" . $tableId);
384

    
385
  return $derivateHierarchyTable;
386
}
387

    
388
function create_html_link($link, $openInExternalWindow=false){
389
    $html = "";
390
    if($link->uri && $link->uri!=""){
391
        $html .= '<a  href="' . $link->uri . '"';
392
        if($openInExternalWindow){
393
            $html .= ' target="_blank"';
394
        }
395
        $html .= '>' . $link->linkText . '</a>';
396
    }
397
    else{
398
        $html .= $link->linkText;
399
    }
400
    return $html;
401
}
402

    
403
/**
404
 * Creates HTML links from the given link list concatenated by default by a comma.
405
 * @param $linkList the list with Link objects having "uri" and "linkText" as members
406
 * @return string the assembled HTML string containing the links
407
 */
408
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
409
{
410
    $html = "";
411
    if ($linkList) {
412
        foreach ($linkList as $link) {
413
            $html .= create_html_link($link, $openInExternalWindow).$separator;
414
        }
415
        $html = rtrim($html, $separator);
416
    }
417
    return $html;
418
}
419

    
420
/**
421
 * Composes a taxon page which can consist of multiple parts like
422
 * 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed
423
 * as tabs or as sections of a single page.
424
 *
425
 * It is headed by the name of the accepted taxon without author and reference.
426
 *
427
 * @param $taxon
428
 *   The CDM Taxon Instance to compose the page for.
429
 * @param $page_part
430
 *   Name of the part to display, valid values are:
431
 *    - 'description' -  for the general part
432
 *    - 'images'
433
 *    - 'synonymy'
434
 *    - 'keys'
435
 *    - 'all'
436
 *
437
 * @return array
438
 *   A drupal render array
439
 *
440
 * @ingroup compose
441
 */
442
function compose_cdm_taxon_page($taxon, $page_part = 'description') {
443

    
444
  // we better cache here since drupal_get_query_parameters has no internal static cache variable
445
  $http_request_params = drupal_get_query_parameters();
446

    
447
  // add all mandatory js sources
448
  _add_js_footnotes();
449

    
450

    
451
  $render_array = array();
452
  $weight = 0; // the weight for the render array elements
453

    
454
  $tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
455

    
456
  $page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
457

    
458
  $synonymy_as_tab = variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT) === 1;
459
  if(!$synonymy_as_tab){
460
    unset($tabsToDisplay["Synonymy"]);
461
    // the synonymy is located in the general part in this case
462
    if($page_part == 'synonymy'){
463
      $page_part = 'description';
464
    }
465
  }
466

    
467
  $media = _load_media_for_taxon($taxon);
468

    
469

    
470
  if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
471
    taxon_page_tabs_hidden_add('images');
472
  }
473

    
474
  // --- GET specimensOrObservations --- //
475
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
476

    
477
  $specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
478
  if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
479
    taxon_page_tabs_hidden_add('specimens');
480
  }
481

    
482
  // --- GET polytomousKeys --- //
483
  $polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
484
  $identificationKeyCount = 0;
485
  if ($polytomousKeysPager) {
486
    $identificationKeyCount += $polytomousKeysPager->count;
487
  }
488
  if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
489
    taxon_page_tabs_hidden_add('keys');
490
  }
491

    
492
  // --- GET TaxonNodeAgentRelations --- //
493
  $current_classification_uuid = get_current_classification_uuid();
494
  $taxon_node_agent_relations_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
495
      array(
496
          $taxon->uuid,
497
          $current_classification_uuid,
498
      ),
499
      "pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible!
500
  );
501
  if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){
502
      taxon_page_tabs_hidden_add('experts');
503
  }
504

    
505
  if (!isset($tabsToDisplay["Synonymy"]) || $tabsToDisplay["Synonymy"] == '0') {
506
    taxon_page_tabs_hidden_add('synonymy');
507
  }
508

    
509
  // -------------------------------------------- //
510

    
511
  if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
512
    $render_array['accepted_for'] = markup_to_render_array(cdm_accepted_for($_REQUEST['acceptedFor']), $weight++);
513
  }
514

    
515
  // --- PAGE PART: DESCRIPTION --- //
516
  if (!taxon_page_tabs_hidden_check('description') && ($page_part == 'description' || $page_part == 'all')) {
517

    
518
    $merged_tree = merged_taxon_feature_tree($taxon);
519

    
520

    
521
    $render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, !$synonymy_as_tab);
522
    $render_array['general']['#weight'] = $weight++;
523
    $render_array['general']['#prefix'] = '<div id="general" class="page-part">';
524
    $render_array['general']['#suffix'] = '</div>';
525
  }
526

    
527
  // --- PAGE PART: IMAGES --- //
528
  if (!taxon_page_tabs_hidden_check('images') && ($page_part == 'images' || $page_part == 'all')) {
529
    $images_html = '<div id="images" class="page-part">';
530
    if ($page_part == 'all') {
531
      $images_html .= '<h2>' . t(cdm_taxonpage_tab_label('Images')) . '</h2>';
532
    }
533
    // Get the image gallery as configured by the admin.
534
    $default_image_gallery = 'default';
535
    $configured_image_gallery_viewer = variable_get('image_gallery_viewer', 'default');
536
    $taxon_image_gallery = '<div class="error">No image gallery viewer configured</div>';
537
    if($configured_image_gallery_viewer == $default_image_gallery || $configured_image_gallery_viewer == 'fsi'){
538
      // the fsi_gallery requires a flash plugin, in case the client browser is not supporting
539
      // flash we also need to provide an the default gallery as alternative
540
      $taxon_image_gallery = '<div id="default-gallery-viewer">' .
541
        call_user_func_array('taxon_image_gallery_' . $default_image_gallery, array(
542
          $taxon,
543
          $media,
544
        ))
545
        . '</div>';
546
    }
547
    if($configured_image_gallery_viewer == 'fsi'){
548
      $taxon_image_gallery .= '<div id="'. $configured_image_gallery_viewer .'-gallery-viewer">' .
549
        call_user_func_array('taxon_image_gallery_' . $configured_image_gallery_viewer, array(
550
          $taxon,
551
          $media,
552
        ))
553
       . '</div>';
554
    }
555
    $images_html .= $taxon_image_gallery;
556
    $images_html .= '</div>';
557
    $render_array['images'] = markup_to_render_array($images_html, $weight++);
558
  }
559

    
560
  // --- PAGE PART: SYNONYMY --- //
561
  if (!taxon_page_tabs_hidden_check('synonymy') && (($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) {
562
    $synonymy_html = '<div id="synonymy" class="page-part">';
563
    if ($page_part == 'all') {
564
      $synonymy_html .= '<h2>' . t(cdm_taxonpage_tab_label('Synonymy')) . '</h2>';
565
    }
566
    $addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
567

    
568
    $synonymy_html .= theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => $addAcceptedTaxon));
569

    
570
    $synonymy_html .= '</div>';
571
    $render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
572

    
573
  }
574

    
575
  // --- PAGE PART: SPECIMENS --- //
576
  if (!taxon_page_tabs_hidden_check('specimens') && ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all'))) {
577
    $render_array['specimens'] = array(
578
        '#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Specimens')) . '</h2>' : ''),
579
        'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
580
        '#suffix' => '</div>',
581
    );
582
  }
583

    
584
  // --- PAGE PART: KEYS --- //
585
  if(!taxon_page_tabs_hidden_check('keys')){
586
    if ($identificationKeyCount == 1 && $page_part == 'keys'){
587
      drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
588
    }
589
    else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
590
      $keys_html = '<div id="keys" class="page-part">';
591
      if ($page_part == 'all') {
592
        $keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>';
593
      }
594
      $keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
595
      $keys_html .= '</div>';
596
      $render_array['keys'] = markup_to_render_array($keys_html, $weight++);
597
    }
598
  }
599

    
600
  // --- PAGE PART: EXPERTS --- //
601

    
602
  if (!taxon_page_tabs_hidden_check('experts') && ($page_part == 'experts' || $page_part == 'all')) {
603
    $render_array['experts'] = array(
604
        '#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Experts')) . '</h2>' : ''),
605
        'content' => compose_cdm_taxon_page_experts($taxon), // returns render array
606
        '#suffix' => '</div>',
607
    );
608
  }
609

    
610
  // ------------------ END OF PARTS -------------- //
611

    
612
  // adjust weights of page and toc elements according to the settings
613
  $taxontabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
614
  foreach($taxontabs_weights as $tab_key => $weight){
615
    if(isset($render_array[$tab_key])){
616
      $render_array[$tab_key]['#weight'] = $weight;
617
    }
618
  }
619

    
620

    
621
  // set up the TOC for the pages which contain all pageparts
622
  if($page_part == 'all') {
623

    
624
    asort($taxontabs_weights);
625
    foreach(array_keys($taxontabs_weights) as $tab_key){
626
      if(isset($render_array[$tab_key])){
627
        if($tab_key != 'general'){
628
          // add entry for page part
629
          $toc_elements[] = array(
630
              'data' => l(t(cdm_taxonpage_tab_label(ucfirst($tab_key))), $_GET['q'], array('fragment' => $tab_key, 'query' => $http_request_params)),
631
              'class' => array('page-part-toc-item-' . $tab_key)
632
          );
633
        } else {
634
          // add content of profile part instead
635
          if(isset($render_array['general'])) {
636
            // in case all tabs are shown at once the feature tocs
637
            // should be integrated into the tabs toc as sub list
638
            // and the profile image should be on top of the page
639
            if(isset($render_array['general']['taxon_description_feature_toc'])){;
640
            foreach ($render_array['general']['taxon_description_feature_toc']['#items'] as $profile_toc_item){
641
              $toc_elements[] = $profile_toc_item;
642
            }
643
            unset($render_array['general']['taxon_description_feature_toc']);
644
            }
645
          }
646
        }
647
      }
648
    }
649

    
650
    // move profile image in page structure
651
    if(isset($render_array['general']['taxon_profile_image'])){
652
      $render_array['profile_image'] = $render_array['general']['taxon_profile_image'];
653
      $render_array['profile_image']['#weight'] = -100;
654
      unset($render_array['general']['taxon_profile_image']);
655
    }
656

    
657
    // finally add the table of contents to the render array
658
    $render_array['toc'] = array(
659
        '#theme' => 'item_list',
660
        '#items' => $toc_elements,
661
        '#title' => t('Content'),
662
        '#weight' => -101,
663
        '#suffix' => '</div>',
664
        '#prefix'=> '<div id="page-toc">'
665
    );
666
  }
667

    
668

    
669
  return $render_array;
670
}
671

    
672
/**
673
 * TODO should this function really be a compose function?
674
 *     For a compose function must there always be a theme function with the same name? (ak 8.8.2013)
675
 *
676
 * composes and returns an render array containing the components of the taxon profile tab:
677
 *  - 'taxon_profile_image'
678
 *  - 'taxon_description_feature_toc'
679
 *  - 'taxon_description_features'
680
 *
681
 *
682
 * @param object taxon
683
 * @param object $merged_tree
684
 * @param object media
685
 * @param bool $add_synonymy
686
 *
687
 * @return array
688
 *   A Drupal render array with the following elements:
689
 *     - 'taxon_profile_image'
690
 *     - 'taxon_description_feature_toc'
691
 *     - 'taxon_description_features'
692
 *
693
 * @throws Exception
694
 *
695
 * @ingroup compose
696
 */
697
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, $add_synonymy) {
698

    
699
  $render_array = array();
700

    
701
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
702

    
703
  $hide_taxon_profile_image = FALSE;
704
  if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
705
    $rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
706
    $hide_taxon_profile_image = ($rankCompare > -1);
707
  }
708

    
709
  if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
710

    
711
    $representationPart = new stdClass();
712
    $attributes = array();
713
    if (isset($media[0])) {
714
      // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
715
      // which only contains the thumbnail representation even if the height and width filters are not set.
716
      // -->
717
      $preferred_media = cdm_ws_get(CDM_WS_MEDIA, $media[0]->uuid);
718
      $preferred_representations = cdm_preferred_media_representations($preferred_media, array(
719
        'image/jpg',
720
        'image/jpeg',
721
        'image/png',
722
        'image/gif',
723
      ),
724
        $taxon_profile_image_settings['maxextend'],
725
        $taxon_profile_image_settings['maxextend']
726
      );
727
      if(count($preferred_representations) > 0){
728

    
729
        $representation = array_shift($preferred_representations);
730
        $representationPart = $representation->parts[0];
731
        $attributes['alt'] = $representationPart->uri;
732

    
733
        if (!empty($taxon_profile_image_settings['media_uri_query'])) {
734
          $representationPart->uri = $representationPart->uri
735
            . (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
736
            . $taxon_profile_image_settings['media_uri_query'];
737
        }
738
      }
739
    }
740
    else {
741
      if ($taxon_profile_image_settings['custom_placeholder_enabled']) {
742
        // show placeholder image instead
743
        if (!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])) {
744
          // use the user provided image
745
          $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
746
          $url = file_create_url($profile_image_file->uri);
747
          $image_info = image_get_info($profile_image_file->uri);
748
          $representationPart->width = $image_info['width'];
749
          $representationPart->height = $image_info['height'];
750
          $representationPart->uri = $url;
751
        }
752
        else {
753
          // use the hard coded default
754
          $representationPart->width = 184;
755
          $representationPart->height = 144;
756
          $representationPart->uri = base_path() . drupal_get_path('module',
757
              'cdm_dataportal') . '/images/no_picture.png';
758
        }
759
        $attributes['alt'] = "no image available";
760
      }
761
    }
762

    
763
    if (isset($representationPart->uri)) {
764
      $profile_image = cdm_media_gallerie_image($representationPart, $taxon_profile_image_settings['maxextend'], FALSE, $attributes);
765
      // NOTE: style="width:${maxextend}px' is needed for IE8 !!!
766
      $render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image . '</div>',
767
        -101);
768
    }
769
  }
770

    
771
  if($add_synonymy){
772
    $render_array['synonymy'] = markup_to_render_array(
773
      theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => true)),
774
      -102
775
    );
776
  }
777

    
778
  $pseudo_feature_blocks = array();
779
  $pseudo_feature_block_toc_items = array();
780

    
781

    
782
  // Render the sections for each real feature
783
  $feature_block_list = make_feature_block_list($merged_tree->root->childNodes, $taxon);
784

    
785
  // Bibliography
786
  $bibliography_settings = get_bibliography_settings();
787
  if($bibliography_settings['enabled'] == 1){
788
    $bibliography_markup = FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', '');
789
    if($bibliography_markup) {
790
      $feature_bibliography = make_pseudo_feature('Bibliography', 'BIBLIOGRAPHY');
791
      $bibliography_block = feature_block(t('Bibliography'), $feature_bibliography);
792
      $bibliography_item = markup_to_render_array($bibliography_markup);
793
      $bibliography_block->content[] = compose_feature_block_wrap_elements(array($bibliography_item), $feature_bibliography);
794

    
795
      $pseudo_feature_block_toc_items['Bibliography']= 'bibliography';
796
      $pseudo_feature_blocks[] = $bibliography_block;
797
    }
798
  }
799

    
800
  $render_array['taxon_description_features'] = _block_get_renderable_array(
801
    array_merge($feature_block_list, $pseudo_feature_blocks)
802
  );
803

    
804
  if($pseudo_feature_block_toc_items){
805
    foreach ($pseudo_feature_block_toc_items as $label=>$fragment){
806
      cdm_toc_list_add_item($label, $fragment);
807
    }
808
  }
809

    
810
  // create the table of content
811
  $toc = array(
812
      '#theme' => 'item_list',
813
    '#items' => cdm_toc_list(),
814
      '#title' => t('Content'),
815
    '#weight' => -100,                  // move to the top
816
      '#suffix' => '</div>',
817
      '#prefix'=> '<div id="page-toc">'
818
  );
819
  $render_array['taxon_description_feature_toc'] = $toc;
820

    
821
  return $render_array;
822
}
823

    
824
/**
825
 * composes and returns an render array for the experts associated with the given taxon
826
 *
827
 * @param object taxon
828
 *
829
 * @return array
830
 *   A Drupal render array for a table with the experts
831
 *
832
 * @ingroup compose
833
 */
834
function compose_cdm_taxon_page_experts($taxon){
835

    
836
  $render_array = array();
837
  if(!isset($taxon->uuid)){
838
    return $render_array;
839
  }
840

    
841
  $current_classification_uuid = get_current_classification_uuid();
842
  // TODO use cdm_ws_fetchall below but this failes! needs fix!
843
  $taxon_node_agent_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
844
    array(
845
      $taxon->uuid,
846
      $current_classification_uuid
847
    )
848
  );
849

    
850
  $header = array(
851
    array('data' => t('Expert')),
852
    array('data' => t('Role'))
853
  );
854
  $rows = array();
855

    
856

    
857
  foreach($taxon_node_agent_relations->records as $taxon_node_agent_relation){
858

    
859

    
860
    $expert_role_id = $taxon_node_agent_relation->agent->uuid . '-' . $taxon_node_agent_relation->type->uuid;
861
    $expert_details_container_id = 'expert_details_' . $expert_role_id;
862

    
863
    $agent_label_markup = cdm_dynabox(
864
      'expert_' . $expert_role_id,
865
      $taxon_node_agent_relation->agent->titleCache,
866
      // specifying both ends of the relationship will return only one record in the pager
867
      cdm_compose_url(CDM_WS_PORTAL_AGENT,
868
         array($taxon_node_agent_relation->agent->uuid, 'taxonNodeAgentRelations'),
869
        'taxon_uuid=' . $taxon->uuid . '&relType_uuid=' . $taxon_node_agent_relation->type->uuid),
870
      'cdm_taxon_expert',
871
      'Click for details',
872
      array('div', 'div'),
873
      array(), // attributes
874
      '#' . $expert_details_container_id // $content_element_selector
875
    );
876

    
877
    // Expert and Role
878
    $rows[] = array(
879
      'data' => array(
880
        array(
881
          'data' => $agent_label_markup,
882
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->agent))
883
        ),
884
        array(
885
          'data' => $taxon_node_agent_relation->type->representation_L10n,
886
          'class' => array(html_class_attribute_ref($taxon_node_agent_relation->type))
887
        )
888
      )
889
    );
890
    // Agent details
891
    $rows[] = array(
892
      'data' => array(
893
        array(
894
          'data' => '<!-- expert_details_container -->',
895
          'id' => $expert_details_container_id,
896
          'colspan' => 2
897
        )
898
      )
899
    );
900

    
901
  }
902

    
903

    
904
  $render_array['experts_table'] = array(
905
    '#theme' => 'table',
906
    '#header' => $header,
907
    '#rows' => $rows,
908
  );
909

    
910

    
911
  return $render_array;
912
}
913

    
914

    
915
/**
916
 * Manages the tabs to be hidden in the taxon page.
917
 *
918
 * The tabs are identified by their last menu link path element:
919
 *  - description
920
 *  - synonymy
921
 *  - images
922
 *  - specimens
923
 *  - key
924
 *
925
 * Internally the tabs are stored in a static variable which is
926
 * managed by drupal_static().
927
 *
928
 * @param string $add_tab
929
 *   Optional parameter. The given string will be added to the array of tabs
930
 *
931
 * @return
932
 *   The array of tabs
933
 */
934
function taxon_page_tabs_hidden_add($add_tab = NULL) {
935
  $tabs = &drupal_static('taxon_page_tabs_hidden');
936

    
937
  if(!isset($tabs)){
938
    $tabs = array();
939
  }
940

    
941
  if (isset($add_tab) && !array_key_exists($add_tab, $tabs)) {
942
    $tabs[] = $add_tab;
943
  }
944

    
945
  return $tabs;
946
}
947

    
948
/**
949
 * Manages the tabs to be hidden in the taxon page.
950
 *
951
 * The tabs names are identified by their last menu link path element:
952
 *  - description
953
 *  - synonymy
954
 *  - images
955
 *  - specimens
956
 *  - key
957
 *
958
 * Internally the tabs are stored in a static variable which is
959
 * managed by drupal_static().
960
 *
961
 * @param string $tabname
962
 *   The name of the tab to check
963
 *
964
 * @return boolean
965
 *   True if the tab or section is to be hidden
966
 */
967
function taxon_page_tabs_hidden_check($tabname) {
968

    
969
  $tabs = &drupal_static('taxon_page_tabs_hidden');
970

    
971
  if(!isset($tabs)){
972
    $tabs = array();
973
  }
974

    
975
  return array_search($tabname, $tabs) !== FALSE;
976
}
977

    
978
/**
979
 * Implements the hook_preprocess_HOOK() for theme_menu_local_tasks()
980
 *
981
 *  - Removes the tabs to be hidden, @see taxon_page_tabs_hidden_add()
982
 *  - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!)
983
 *
984
 * @param array $variables
985
 *   The variables array
986
 */
987
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) {
988

    
989
  $hidden_tabs = taxon_page_tabs_hidden_add();
990

    
991
  if (is_array($variables['primary'])) {
992
    foreach ($variables['primary'] as $key => &$element) {
993

    
994
      // 1. Remove the tabs to be hidden
995
      foreach ($hidden_tabs as $tab) {
996
        if ($element['#link']['path'] == 'cdm_dataportal/taxon/%/' . $tab) {
997
          // remove the tab
998
          unset($variables['primary'][$key]);
999
        }
1000
      }
1001
    }
1002
  }
1003
}
1004

    
1005

    
1006

    
1007
/**
1008
 * Implements the hook_preprocess_HOOK() for theme_menu_local_task()
1009
 *
1010
 *
1011
 * @param array $variables
1012
 *   An associative array containing:
1013
 *     - element: A render element containing:
1014
 *          #link: A menu link array with 'title', 'href', and 'localized_options' keys.
1015
 *          #active: A boolean indicating whether the local task is active.
1016
 *
1017
 */
1018
function cdm_dataportal_preprocess_menu_local_task(&$variables) {
1019

    
1020
  $link = $variables['element']['#link'];
1021
  if (preg_match('/cdm_dataportal\/.*\/refresh$/', $link['href'])) {
1022
    $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']) . '"/>';
1023
    $link['localized_options']['html'] = TRUE;
1024

    
1025
    $variables['element']['#link'] = $link;
1026
  }
1027
}
1028

    
1029
/* =================== block composition ===================== */
1030

    
1031
/**
1032
 * Composes and returns an render array for the classification breadcrumbs of the given taxon.
1033
 *
1034
 * @param taxon
1035
 *
1036
 * @return array
1037
 *   A Drupal render array for a table with the experts
1038
 *
1039
 * @ingroup compose
1040
 */
1041
function compose_classification_breadcrumbs($taxon_uuid) {
1042

    
1043
  _add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
1044

    
1045
  $render_array = array();
1046

    
1047
  $render_array['#theme'] = 'item_list';
1048
  $render_array['#type'] = 'ul';
1049
  $render_array['#attributes'] = array(
1050
    'id' => 'classification-breadcrumbs',
1051
    'class' => 'breadcrumbs inline',
1052
  );
1053

    
1054
  $items = array();
1055

    
1056
  $parent_taxon_nodes = null;
1057
  if($taxon_uuid){
1058
    $parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
1059
  }
1060

    
1061
  $classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
1062
  // find current classification in list
1063
  $classification = null;
1064
  $current_classification_uuid = get_current_classification_uuid();
1065
  foreach ($classifications as $classification){
1066
    if($classification->uuid == $current_classification_uuid){
1067
      break;
1068
    }
1069
  }
1070

    
1071
  $node_name = '';
1072
  if(count($classifications) > 1 ){
1073
    // need to add the current classification as first label
1074

    
1075
    $label = $classification->titleCache;
1076
    if(strlen($label) > 20){
1077
      $label = substr($label, 0, strpos($label, ' ', 15)) . '...';
1078
    }
1079
    $node_name = font_awesome_icon_markup('fa-th-list')  . ' ' . l($label, '#', array(
1080
      'attributes' => array(
1081
        'class' => 'taxonomic-children-button classification-chooser',
1082
        'data-destination-uri' => drupal_get_destination(),
1083
        'data-cdm-align-with' => array('prev')
1084
      ),
1085
      'html' => true
1086
    ));
1087
  }
1088

    
1089
  $rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
1090

    
1091
  $rank_separator = '<span> '
1092
    . font_awesome_icon_markup('fa-chevron-right')
1093
    . ' </span>';
1094
  $more_children_icon = font_awesome_icon_markup('fa-sitemap fa-rotate-270');
1095
  $more_children_label = '...';
1096

    
1097
  $items[] = $node_name;
1098

    
1099
  $more_children_for = null;
1100
  if($parent_taxon_nodes){
1101
    foreach ($parent_taxon_nodes as $node) {
1102

    
1103
      $is_first_item = count($items) == 0;
1104
      $is_last_item = count($items) == count($parent_taxon_nodes);
1105
      $node_name = cdm_dataportal_shortname_of($node);
1106
      $path = path_to_taxon($node->taxonUuid);
1107

    
1108
      if($node->taxonomicChildrenCount > 0) {
1109
        $more_children_for = $node->taxonUuid;
1110
      } else {
1111
        $more_children_for = null;
1112
      }
1113

    
1114
      // 'fa-sitemap'
1115

    
1116
      $items[] =
1117
        ($is_first_item ? '' : ' ')
1118
        . $rank_separator
1119
        . l(
1120
          '<span class="' . html_class_attribute_ref($node) . '">' . $node_name . '</span>',
1121
          $path,
1122
          array(
1123
            'attributes' => array(
1124
              'class' => array('taxonomic-children-button'),
1125
              'data-cdm-taxon-uuid' => array($node->taxonUuid),
1126
              'data-cdm-classification-mode' => array('siblings'),
1127
              'data-cdm-align-with' => array('prev')
1128
            ),
1129
            'html' => true
1130
          )
1131
        );
1132
      }
1133
    }
1134

    
1135
  // add more button to the end
1136
  if(!$parent_taxon_nodes) {
1137
    // not taxon focused yet, adding button to make  the root nodes available
1138
    $items[] = '<span>'
1139
      . $more_children_icon . '&nbsp;' .
1140
      '<span class="taxonomic-children-button" data-classification-uuid="' . $current_classification_uuid
1141
      . '" data-rank-limit-uuid="' . $rank_limit_uuid . '" data-cdm-align-with="prev"> ' . $more_children_label . '<span>'
1142
      . '</span>';
1143
  } else if($more_children_for){
1144
    // last parent item has child taxon nodes
1145
    $items[] = ' <span>'
1146
      . $more_children_icon . '&nbsp;' .
1147
      '<span class="taxonomic-children-button" data-cdm-taxon-uuid="' .$more_children_for
1148
      . '" data-cdm-classification-mode="children" data-cdm-align-with="prev"> ' . $more_children_label . '</span>'
1149
      . '</span>';
1150

    
1151
  }
1152

    
1153
  $render_array['#items'] = $items;
1154

    
1155
  return $render_array;
1156
}
1157

    
1158

    
1159
/**
1160
 * @param $specimen_uuid
1161
 * @return array
1162
 *    The drupal render array for the page
1163
 *
1164
 * @ingroup compose
1165
 */
1166
function compose_cdm_specimen_page($specimen_uuid)
1167
{
1168
  drupal_set_title("Specimen Details");
1169
  $specimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($specimen_uuid, 'specimenDerivates'));
1170

    
1171
  $render_array = array();
1172
  RenderHints::pushToRenderStack('specimen_page');
1173

    
1174
  $detail_html = render_cdm_specimen_page($specimen, true);
1175
  $render_array['specimen_html'] = array(
1176
    '#markup' => $detail_html
1177
  );
1178

    
1179
  RenderHints::popFromRenderStack();
1180
  return $render_array;
1181
}
1182

    
1183
/**
1184
 * @param $named_area_uuid
1185
 * @return array
1186
 *    The drupal render array for the page
1187
 *
1188
 * @ingroup compose
1189
 */
1190
function compose_cdm_named_area_page($named_area_uuid)
1191
{
1192

    
1193
  $named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, array($named_area_uuid));
1194

    
1195
  $render_array = array();
1196
  RenderHints::pushToRenderStack('named_area_page');
1197

    
1198
  $groups = array();
1199
  @_description_list_group_add($groups, t('Name') . ':', $named_area->representation_L10n);
1200
  @_description_list_group_add($groups, t('IdInVocabulary') . ':', $named_area->idInVocabulary);
1201
  if(isset($named_area->level)) {
1202
    @_description_list_group_add($groups, t('Level') . ':', $named_area->level->representation_L10n);
1203
  }
1204

    
1205
  $name_area_details_elements = array(
1206
   // '#title' => $title,
1207
    '#theme' => 'description_list',
1208
    '#groups' => $groups,
1209
    '#attributes' => array('class' => html_class_attribute_ref($named_area)),
1210
  );
1211

    
1212
  $render_array[] = $name_area_details_elements;
1213

    
1214
  RenderHints::popFromRenderStack();
1215
  return $render_array;
1216
}
1217

    
1218
/**
1219
 * Provides the the label string for taxon page tabs.
1220
 *
1221
 * The $tabname as passed to the method will be returned if no override
1222
 * label is configured in the settings.
1223
 */
1224
function cdm_taxonpage_tab_label($tabname) {
1225
  static $taxon_tabs_labels = null;
1226
  if($taxon_tabs_labels == null){
1227
    $taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
1228
  }
1229
  $tabname_key = strtolower($tabname);
1230
  if(isset($taxon_tabs_labels[$tabname_key]) && $taxon_tabs_labels[$tabname_key]){
1231
    return $taxon_tabs_labels[$tabname_key];
1232
  }
1233
  return $tabname;
1234
}
Add picture from clipboard (Maximum size: 40 MB)