Project

General

Profile

Download (21.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Functions for dealing with CDM entities from the package model.common
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
 * @defgroup compose Compose functions
21
 * @{
22
 * Functions which are composing Drupal render arays
23
 *
24
 * The cdm_dataportal module needs to compose rather complex render arrays from
25
 * the data returned by the CDM REST service. The compose functions are
26
 * responsible for creating the render arrays.
27
 *
28
 * All these functions are also implementations of the compose_hook()
29
 * which is used in the proxy_content() function.
30
 * @}
31
 */
32

    
33
/**
34
 * Compose an render array from a CDM Marker object.
35
 *
36
 * compose_hook() implementation
37
 *
38
 * @param object $marker
39
 *   CDM instance of type Marker
40
 * @return array
41
 *   A drupal render array
42
 *
43
 * @ingroup compose
44
 */
45
function compose_cdm_marker($marker) {
46

    
47
  $render_array = array(
48
      // ---- generic
49
      //  these entries should be common to all cdm enitiy render arrays
50
      '#theme' => 'cdm_marker', // TODO   add alternative theme funcitons: 'cdm_marker_' . marker.type.label
51
      '#attributes' => array('class' => html_class_attribute_ref($marker)),
52

    
53
      // ---- individual
54
      '#label' => $marker->markerType->representation_L10n . ': ' . (($marker->flag !== TRUE ? t('yes') : t('no'))),
55
  );
56

    
57
  return $render_array;
58
}
59

    
60
/**
61
 * Checks if the given $cdm_entitiy has a marker the type references by the
62
 * $marker_type_uuid and returns TRUE if a matching marker has been found.
63
 *
64
 * @param object $cdm_entitiy A CDM Entity
65
 * @param string $marker_type_uuid
66
 */
67
function cdm_entity_has_marker($cdm_entitiy, $marker_type_uuid) {
68
  if(isset($cdm_entitiy->markers[0]) && !is_uuid($marker_type_uuid)){
69
    foreach ($cdm_entitiy->markers as $marker) {
70
      if(isset($marker->markerType) && $marker->markerType->uuid == $marker_type_uuid){
71
        return TRUE;
72
      }
73
    }
74
  }
75
  return FALSE;
76
}
77

    
78
/**
79
 * Sorts an array of CDM IdentifiableSource instances by 1. by the
80
 * author teams family names and 2. by the publication date.
81
 *
82
 * @param array $sources
83
 *    The array of CDM IdentifiableSource instances
84
 * @return array
85
 *  An array of drupal render arrays
86
 */
87
function oder_and_render_original_sources($sources){
88
    $sort_array = array();
89
    foreach ($sources as $source) {
90

    
91
      $order_key = '';
92

    
93
      // find the familynames
94
      if(isset($source->citation->uuid) && !isset($source->citation->authorship)){
95
        $authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $source->citation->uuid);
96

    
97
        $persons = array();
98
        if($authorteam->class == 'Team'){
99
          if(isset($authorteam->teamMembers)){
100
            $persons = $authorteam->teamMembers;
101
          }
102
        } else {
103
          $persons[] = $authorteam;
104
        }
105

    
106
        foreach($persons as $person){
107
          if(!empty($person->lastname)){
108
            $order_key .= $person->lastname;
109
          } else {
110
            $order_key .= $person->titleCache;
111
          }
112
        }
113
        if(empty($order_key)){
114
          $order_key = $authorteam->titleCache;
115
        }
116

    
117
      }
118
      $order_key = str_pad($order_key, 50);
119

    
120
      // add publication date to the key
121
      if(isset($source->citation->datePublished)){
122
        $order_key .= '_' . timePeriodAsOrderKey($source->citation->datePublished);
123
      } else {
124
        $order_key .= '_' . "0000";
125
      }
126

    
127
      // padd key until unique
128
      while(array_key_exists($order_key, $sort_array)){
129
        $order_key .= "_";
130
      }
131

    
132
      $sort_array[$order_key] = render_original_source($source);
133
    }
134
    ksort($sort_array);
135
    return array_values ($sort_array);
136
}
137

    
138
/**
139
 * Compare callback to be used in usort to sort image sources of CDM OriginalSource instances.
140
 *
141
 * TODO the compare strategy implemented in oder_and_render_original_sources() is probably better but is not taking the
142
 * originalName into account.
143
 *
144
 * @param $a
145
 * @param $b
146
 */
147
function compare_original_sources($a, $b){
148

    
149
  $a_string = '';
150
  if(isset($a->citation->titleCache)) {
151
    $a_string = $a->citation->titleCache;
152
  }
153
  if((isset($a->nameUsedInSource))){
154
    $a_string .= $a->nameUsedInSource->titleCache;
155
  } elseif (isset($a->originalNameString)){
156
    $a_string .= $a->originalNameString;
157
  }
158

    
159
  $b_string = '';
160
  if(isset($b->citation->titleCache)) {
161
    $b_string = $b->citation->titleCache;
162
  };
163
  if((isset($b->nameUsedInSource))){
164
    $b_string .= $b->nameUsedInSource->titleCache;
165
  } elseif (isset($b->originalNameString)){
166
    $b_string .= $b->originalNameString;
167
  }
168

    
169
  if ($a_string == $b_string) {
170
    return 0;
171
  }
172
  return ($a_string < $b_string) ? -1 : 1;
173
}
174

    
175
/**
176
 * Compare callback to be used in usort to sort image sources of CDM Media instances.
177
 *
178
 * @param $a
179
 * @param $b
180
 */
181
function compare_text_data($a, $b) {
182

    
183
  if ($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text) {
184
    return 0;
185
  }
186
  return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
187
}
188

    
189
  /**
190
   * Compare two different footnotes objects.
191
   *
192
   * The comparison is based on the footnote key. The one which is
193
   * displayed as footnote number.
194
   *
195
   * @param mixed $a
196
   *   Footnote object $a.
197
   * @param mixed $b
198
   *   Footnote object $b.
199
   */
200
  function footnotes_key_compare($a, $b) {
201
    $res = 0;
202
    if (empty($a) || empty($b)) {
203
      return $res;
204
    }
205
    if ($a->keyStr < $b->keyStr) {
206
      $res = -1;
207
    }
208
    elseif ($a->keyStr > $b->keyStr) {
209
      $res = 1;
210
    }
211
    return $res;
212
  }
213

    
214

    
215
/**
216
 * Creates an array suitable to be used in min_max_markup()
217
 * The min max structure is suitable for being used in the context
218
 * of GatheringEvents and StatisticalMeasures (see render_quantitative_statistics()).
219
 *
220
 * The order of the items is important for the display and must not be changed.
221
 *
222
 * @return array
223
 */
224
function min_max_array() {
225

    
226
  $min_max = [
227
    'Min' => NULL,
228
    'TypicalLowerBoundary' => NULL,
229
    'TypicalUpperBoundary' => NULL,
230
    'Max' => NULL,
231
    'SampleSize' => NULL,
232
    'Average' => NULL,
233
    'Variance' => NULL,
234
    'StandardDeviation' => NULL,
235
  ];
236
  return $min_max;
237
}
238

    
239
/**
240
 * Creates markup from a min max array.
241
 *
242
 * NOTE: use  min_max_array() to create an appropriate array
243
 *
244
 * Internally Min will be translated to TypicalLowerBoundary if no such value is present.
245
 * The same also accounts for Max and TypicalUpperBoundary.
246
 *
247
 * For further details see #3742, #8766
248
 *
249
 * @param $min_max
250
 *  the min-max array
251
 * @param $unit
252
 *  Defaults to no unit
253
 * @return string
254
 */
255
function min_max_markup($min_max, $unit = '') {
256

    
257
  static $xbar_equals = 'x&#x304='; // x&#x304 is x-bar
258

    
259
  $min_max_markup = '';
260
  $other_vals_array = [];
261

    
262
  // --- sanitize values
263
  if(min_max_equals($min_max, 'Min', 'TypicalLowerBoundary')){
264
    $min_max['Min'] = NULL;
265
  }
266

    
267
  if(min_max_equals($min_max, 'Max', 'TypicalUpperBoundary')){
268
    $min_max['Max'] = NULL;
269
  }
270

    
271
  if($min_max['TypicalLowerBoundary'] === null && $min_max['Min'] !== null){
272
    $min_max['TypicalLowerBoundary'] = $min_max['Min'];
273
    $min_max['Min'] = NULL;
274
  }
275

    
276
  if($min_max['TypicalUpperBoundary'] === null && $min_max['Max']  !== null){
277
    $min_max['TypicalUpperBoundary'] = $min_max['Max'];
278
    $min_max['Max'] = NULL;
279
  }
280

    
281
  if (min_max_equals($min_max, 'TypicalUpperBoundary', 'TypicalLowerBoundary')) {
282
    $min_max['Average'] = $min_max['TypicalUpperBoundary'];
283
    $min_max['TypicalLowerBoundary'] = NULL;
284
    $min_max['TypicalUpperBoundary'] = NULL;
285
  }
286

    
287
  // --- check for inconsistent cases, eg. only Max and average given
288
  if ($min_max['TypicalLowerBoundary'] === NULL && $min_max['TypicalUpperBoundary']  !== null) {
289
    // min missing
290
    $min_max['TypicalLowerBoundary'] = '?';
291
  }
292
  if ($min_max['TypicalLowerBoundary'] !== null && $min_max['TypicalUpperBoundary'] === NULL) {
293
    // max missing
294
    $min_max['TypicalUpperBoundary'] = '?';
295
  }
296

    
297
  foreach ($min_max as $key => $statistical_val) {
298

    
299
    if ($statistical_val !== NULL) {
300
      if ($statistical_val == '?') {
301
        $val_markup = $statistical_val;
302
      } else {
303
        $val_markup = '<span class="'
304
            . html_class_attribute_ref($statistical_val) . ' '
305
            . (isset($statistical_val->type) ? $statistical_val->type->termType : '') . ' ' . $key .'" title="'. $key. '">'
306
            . $statistical_val->_value . '</span>';
307
      }
308

    
309
      switch ($key) {
310
        // ---- min_max_element
311
        case 'Min':
312
          $min_max_markup .= "($val_markup&ndash;)";
313
          break;
314
        case 'Max':
315
          $min_max_markup .= "(&ndash;$val_markup)";
316
          break;
317
        case 'TypicalLowerBoundary':
318
          $min_max_markup .= "$val_markup";
319
          break;
320
        case 'TypicalUpperBoundary':
321
          $min_max_markup .= "&ndash;$val_markup";
322
          break;
323
          // ---- other values
324
        case 'SampleSize':
325
          $other_vals_array[$key] = $val_markup;
326
          break;
327
        case 'Average':
328
          $other_vals_array[$key] = $xbar_equals . $val_markup;
329
          break;
330
        case 'Variance':
331
          $other_vals_array[$key] = 'σ²=' . $val_markup;
332
          break;
333
        case 'StandardDeviation':
334
          $other_vals_array[$key] = 'σ=' . $val_markup;
335
          break;
336
      }
337
    }
338
  }
339

    
340
  if(!$min_max_markup && $other_vals_array['Average']){
341
    // this could be the case in which we only have one value for Average
342
    // this trivial case needs to be displayed a simpler way
343
    $min_max_markup = str_replace($xbar_equals, '' ,$other_vals_array['Average']);
344
    if($other_vals_array['SampleSize']){
345
      $min_max_markup .= '['. $other_vals_array['SampleSize'] .']';
346
    }
347
  } else {
348
    if(count($other_vals_array)){
349
      $min_max_markup .= '[' . join(';', $other_vals_array) . ']';
350
    }
351
  }
352

    
353
  return $min_max_markup . ($unit ? ' ' . $unit : '');
354
}
355

    
356
/**
357
 * Used internally in min_max_markup() do determine equality of min_max values
358
 *
359
 * @param $min_max
360
 * @param $key1
361
 * @param $key2
362
 *
363
 * @return bool
364
 */
365
function min_max_equals($min_max,  $key1, $key2){
366

    
367
  return $min_max[$key1] !== NULL && $min_max[$key2] !== NULL && $min_max[$key1]->_value ==  $min_max[$key2]->_value;
368
}
369

    
370
/**
371
 * Creates min max markup to represent a min-average-max measure optionally with an error value.
372
 *
373
 * The fields that are taken into account are:
374
 * - field_base_name = min
375
 * - field_base_nameMax = max
376
 * - field_base_nameText = free text
377
 * - field_base_nameError = error value
378
 *
379
 * @param $object
380
 *    The object having min max measurement fields e.g.: GatheringEvent
381
 * @param string $field_base_name
382
 *    The base name for all measurement fields. This name is at the same time the full name of the
383
 *    min value.
384
 * @return string
385
 *   The markup for the min max
386
 */
387
function min_max_measure($object, $field_base_name)
388
{
389
  static $default_unit = 'm';
390

    
391
  $field_name = $field_base_name . 'Text';
392
  if (@is_string($object->$field_name)) {
393
    // Freetext overrides all other data
394
    $min_max_markup = ' ' . $object->$field_name;
395
  } else {
396
    // create markup for the atomized min max data
397
    $min_max_array = min_max_array();
398
    if (@is_numeric($object->$field_base_name)) {
399
      $min_max_array['Min'] = new stdClass();
400
      $min_max_array['Min']->_value = $object->$field_base_name;
401
    }
402
    $field_name = $field_base_name . 'Max';
403
    if (@is_numeric($object->$field_name)) {
404
      $min_max_array['Max'] = new stdClass();
405
      $min_max_array['Max']->_value = $object->$field_name;
406
    }
407
    $min_max_markup = min_max_markup($min_max_array, $default_unit);
408
  }
409

    
410
  return $min_max_markup;
411
}
412

    
413
// TODO  move below code into new file: agent.inc
414

    
415
/*
416
 * Compose an render array from a CDM TaxonNodeAgentRelation object as Taxon Expert.
417
 *
418
 * compose_hook() implementation
419
 *
420
 * @param object $taxon_node_agent_relation
421
 *   CDM instance of type TaxonNodeAgentRelation
422
 * @return array
423
 *   A drupal render array
424
 *
425
 * @ingroup compose
426
 */
427
function compose_cdm_taxon_expert($taxon_node_agent_relation) {
428

    
429
  $label_suffix = ':';
430

    
431
  if($taxon_node_agent_relation->class == 'DefaultPagerImpl'){
432
    // oops this is a pager
433
    // this situation will occur when this compose is executed
434
    // through the proxy_content() method
435
    $taxon_node_agent_relation = $taxon_node_agent_relation->records[0];
436

    
437
  }
438

    
439
  if(is_object($taxon_node_agent_relation->agent)) {
440
    $agent_details = compose_cdm_team_or_person_base($taxon_node_agent_relation->agent);
441
    // all data will be added to the groups of the agent_details render array
442
    $groups = &$agent_details[0]['#groups'];
443

    
444
    @_description_list_group_add($groups, t('Role'). $label_suffix, $taxon_node_agent_relation->type->representation_L10n);
445

    
446
    $family_tnars = cdm_ws_fetch_all(CDM_WS_PORTAL_AGENT . '/' . $taxon_node_agent_relation->agent->uuid . '/taxonNodeAgentRelations', array("rank"=>"Familia"));
447

    
448
    $taxa_markup = array(
449
      '#theme_wrappers' => array('container'),
450
      '#attributes' => array('class' => array('managed_taxa')),
451
      '#wrapper_attributes' => array('class' => 'sublist-container')
452
      );
453
    foreach($family_tnars as $tnar){
454
      if(is_object($tnar->taxonNode->taxon)){
455
        $taxa_markup[$tnar->taxonNode->taxon->titleCache] = markup_to_render_array(render_taxon_or_name($tnar->taxonNode->taxon, url(path_to_taxon($tnar->taxonNode->taxon->uuid))));
456
      }
457
    }
458
    ksort($taxa_markup);
459

    
460
    @_description_list_group_add($groups, t('Families'). $label_suffix, array($taxa_markup));
461

    
462
  }
463

    
464
  return $agent_details;
465
}
466

    
467

    
468
/*
469
 * Compose an render array from a CDM TeamOrPersonBase object.
470
 *
471
 * compose_hook() implementation
472
 *
473
 * TODO: currently mainly implemented for Agent, add Team details
474
 *
475
 * @param object $team_or_person
476
 *   CDM instance of type TeamOrPersonBase
477
 * @return array
478
 *   A drupal render array
479
 *
480
 * @ingroup compose
481
 */
482
function compose_cdm_team_or_person_base($team_or_person, $data = array()) {
483

    
484
  $groups = array();
485

    
486
  $label_suffix = ':';
487

    
488
  // $weight = 0;
489
  if($team_or_person){
490

    
491
    if(is_object($team_or_person->lifespan)){
492
      // ToDo render as date* - date† ?
493
      @_description_list_group_add($groups, t('Lifespan'). $label_suffix, timePeriodToString($team_or_person->lifespan) /*, '' , $weight++ */);
494
    }
495

    
496
    // nomenclaturalTitle
497
    @_description_list_group_add($groups, "Nomenclatural Title". $label_suffix, $team_or_person->nomenclaturalTitle);
498
    // collectorTitle
499
    @_description_list_group_add($groups, "Collector Title". $label_suffix, $team_or_person->collectorTitle);
500

    
501
    // institutionalMemberships
502
    if(is_array($team_or_person->institutionalMemberships)){
503

    
504
      $institutes_ra =  array();
505
      foreach($team_or_person->institutionalMemberships as $membership) {
506
        $membership_groups = array();
507
        @_description_list_group_add($membership_groups, t('Department'). $label_suffix, $membership->department);
508
        @_description_list_group_add($membership_groups, t('Role'). $label_suffix, $membership->role);
509
        if(is_object($membership->period)){
510
          @_description_list_group_add($membership_groups, t('Period'). $label_suffix, timePeriodToString($membership->period));
511
        }
512
        if(is_object($membership->institute->contact)){
513
          $institute_contact_details = compose_cdm_contact($membership->institute->contact, $membership->institute->titleCache);
514
          if(is_array($institute_contact_details[0]['#groups'])){
515
            $membership_groups = array_merge($membership_groups, $institute_contact_details[0]['#groups']);
516
          }
517
        }
518
        if(count($membership_groups) > 0){
519
          $institutes_ra[]  = array(
520
            '#title' => $membership->institute->titleCache,
521
            '#theme' => 'description_list',
522
            '#groups' => $membership_groups,
523
            '#attributes' => array('class' => html_class_attribute_ref($membership)),
524
            '#wrapper_attributes' => array('class' => 'sublist-container')
525
          );
526
        } else {
527
          // no further details for the membership, display the title
528
          $institutes_ra[] = markup_to_render_array('<h3>' . $membership->institute->titleCache . '</h3>');
529
        }
530

    
531
      }
532

    
533
      $label = count($institutes_ra) > 1 ? t('Institutes'):  t('Institute');
534
      @_description_list_group_add($groups, $label. $label_suffix, $institutes_ra /*, '' , $weight++ */);
535
    }
536

    
537

    
538
    // Contact
539
    $agent_contact_details = compose_cdm_contact($team_or_person->contact, $team_or_person->titleCache);
540
    if(is_array($agent_contact_details[0]['#groups'])){
541
      $groups = array_merge($groups, $agent_contact_details[0]['#groups']);
542
    }
543

    
544
    // additional data
545
    foreach($data as $key=>$value){
546
      @_description_list_group_add($sub_dl_groups, t('@key', array('@key' => $key)), $value /*, '' , $weight++ */);
547
    }
548

    
549
  }
550

    
551
  $team_or_person_details = array(
552
    '#title' => $team_or_person->titleCache,
553
    '#theme' => 'description_list',
554
    '#groups' => $groups,
555
    '#attributes' => array('class' => html_class_attribute_ref($team_or_person)),
556
  );
557
  return array($team_or_person_details);
558
}
559

    
560

    
561
/*
562
 * Compose an render array from a CDM Contact object.
563
 *
564
 * compose_hook() implementation
565
 *
566
 * TODO: currently mainly implemented for Agent, add Team details
567
 *
568
 * @param object $contact
569
 *   CDM instance of type Contact
570
 * @param $title
571
 *   The title for the description list header
572
 * @param $weight
573
 *   Optional weight for the description list entries
574
 * @return array
575
 *   A drupal render array
576
 *
577
 * @ingroup compose
578
 */
579
function compose_cdm_contact($contact, $title, $weight = 0)
580
{
581

    
582
  $groups = array();
583

    
584
  $contact_details = null;
585

    
586
  $label_suffix = ':';
587

    
588
  $contact_field_names_map = array(
589
    'emailAddresses' => t('Email'),
590
    'urls' => t('Urls'),
591
    'phoneNumbers' => t('Phone'),
592
    'faxNumbers' => t('Fax'),
593
  );
594

    
595
  // Contact
596
  if(is_object($contact)){
597
    if(isset($contact->addresses)){
598
      // TODO ....
599
      // $sub_groups = array();
600
      // foreach($contact->addresses as $address){
601
      //   @_description_list_group_add($sub_groups, $label, $contact->$fieldName, '', $weight++);
602
      // }
603
    }
604
    foreach($contact_field_names_map as $fieldName => $label){
605
      if(is_array($contact->$fieldName)){
606
        @_description_list_group_add($groups, $label . $label_suffix, $contact->$fieldName, '', $weight++);
607
      }
608
    }
609
    $contact_details = array(
610
      '#title' => $title,
611
      '#theme' => 'description_list',
612
      '#groups' => $groups
613
    );
614

    
615

    
616
  } else if(is_string($title)) {
617
    // if the contact entity is empty but the title is given anyway
618
    // we are only adding the title, using the description_list
619
    // structure is not possible since it would be empty due to
620
    // missing group data
621
    $contact_details = array('#markup' => '<h3>' . $title . '</h3>');
622
  }
623

    
624
  return array($contact_details);
625

    
626
}
627

    
628
/**
629
 * Compose an render array from a CDM Extension objects.
630
 *
631
 * @param $extensions
632
 *    An array of CDM Extension objects
633
 * @return array
634
 *   A render array containing the fields of the supplied $sequence
635
 *
636
 * @ingroup compose
637
 */
638
function compose_extensions($extensions)
639
{
640
  $extensions_render_array= null;
641
  $extensions_by_type = array();
642
  foreach ($extensions as $extension) {
643
    if (@is_string($extension->value)) {
644
      if (!isset($extensions_by_type[$extension->type->representation_L10n])) {
645
        $extensions_by_type[$extension->type->representation_L10n] = array();
646
      }
647
      $extensions_by_type[$extension->type->representation_L10n][] = markup_to_render_array($extension->value);
648
    }
649
  }
650

    
651
  if (count($extensions_by_type)) {
652
    $sub_dl_groups = array();
653
    foreach ($extensions_by_type as $type_label => $text_list) {
654
      @_description_list_group_add($sub_dl_groups, $type_label . ':', $text_list);
655
    }
656
    $extensions_render_array = array(
657
      array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
658
    );
659
    return $extensions_render_array;
660
  }
661
  return $extensions_render_array;
662
}
663

    
664
function formatParams($params) {
665
    if (is_array($params)){
666
        $keys =array_keys($params);
667
        $paramString = '';
668
        foreach ($keys as $k ){
669
            if ($k != 'pageNumber' && $k != 'pageSize'){
670
                $paramString .= ' -'.$k.'='.urlencode($params[$k]);
671
            }
672
        }
673
    }
674
    return $paramString;
675
}
676

    
677
function formatWSParams($params) {
678
    if (is_array($params)){
679
        $keys =array_keys($params);
680
        $paramString = '';
681
        foreach ($keys as $k ){
682
            if ($k != 'pageNumber' && $k != 'pageSize'){
683
                $paramString .= '&'.$k.'='.urlencode($params[$k]);
684
            }
685
        }
686
    }
687
    return $paramString;
688
}
689

    
690
/**
691
 *
692
 * @param $cdm_entity
693
 *
694
 * @return string the markup
695
 */
696
function render_cdm_entity_link($cdm_entity) {
697

    
698
  switch ($cdm_entity->class) {
699
    case 'TaxonDescription':
700
    case 'NameDescription':
701
    case 'SpecimenDescription':
702
      $link =  '<span class="' . html_class_attribute_ref($cdm_entity) . '">' . $cdm_entity->titleCache . '</span> ' . icon_link(path_to_description($cdm_entity->uuid));
703
      break;
704
    default:
705
      $link = '<span class="error">UNSUPPORTED CDM ENTITY TYPE</span>';
706
  }
707
  return $link;
708
}
709

    
710
/**
711
 * Creates an icon which links to the given path
712
 * @param $path
713
 *
714
 * @return string
715
 */
716
function icon_link($path, $fragment = '') {
717
  $iconlink = l(custom_icon_font_markup('icon-interal-link-alt-solid', ['class' => ['superscript']]), $path, ['html' => TRUE, 'fragment' => $fragment] );
718
  return $iconlink;
719
}
(1-1/10)