Project

General

Profile

Download (21.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
/**
4
 * @file
5
 * Functions for dealing with CDM entities from the package model.taxon
6
 *
7
 * @copyright
8
 *   (C) 2007-2016 EDIT
9
 *   European Distributed Institute of Taxonomy
10
 *   http://www.e-taxonomy.eu
11
 *
12
 *   The contents of this module are subject to the Mozilla
13
 *   Public License Version 1.1.
14
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
15
 *
16
 * @author
17
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
18
 */
19

    
20
/**
21
 * @defgroup compose Compose functions
22
 * @{
23
 * Functions which are composing Drupal render arrays
24
 *
25
 * The cdm_dataportal module needs to compose rather complex render arrays from
26
 * the data returned by the CDM REST service. The compose functions are
27
 * responsible for creating the render arrays.
28
 *
29
 * All these functions are also implementations of the compose_hook()
30
 * which is used in the proxy_content() function.
31
 * @}
32
 */
33

    
34
define('TAXON_TYPE_SYNONYM', 'Synonym');
35
define('TAXON_TYPE_MISAPPLIEDNAME', 'misapplied-name');
36

    
37
/**
38
 * Returns HTML for misapplied names and invalid designations.
39
 *
40
 * Both relation types are currently treated the same!
41
 *
42
 * @param object taxonRelationships
43
 *   A TaxonRelationshipsDTO, see taxon/{uuid}/taxonRelationshipsDTO
44
 *
45
 * @param object focusedTaxon
46
 *  The taxon being in the focus of the application
47
 *
48
 * @return string
49
 *    the rendered html
50
 */
51
function cdm_taxonRelationships($taxonRelationshipsDTO, $focusedTaxon){
52

    
53
  static $NULL_AUTHORTEAM = 'NULL_AUTHORTEAM';
54

    
55
  if (!$taxonRelationshipsDTO || $taxonRelationshipsDTO->size < 1) {
56
    return null;
57
  }
58

    
59
  RenderHints::pushToRenderStack('taxon_relationships');
60
  $footnoteListKey = 'taxon_relationships';
61
  RenderHints::setFootnoteListKey($footnoteListKey);
62

    
63
  $misapplied = array();
64
  $joinedAuthorTeams = array();
65

    
66
  $taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
67

    
68
  // Aggregate misapplied names having the same fullname:
69
  //  - deduplicate misapplied names, so that the same name it not shown multiple times in case it
70
  //    the duplicates only have different sensu references/author teams (see #5647)
71
  //  - show the author team as sec reference
72
  //  - show the according reference as footnote to this author team
73
  //  - if the sec reference has no author team it should show instead the title cache
74
  //
75
  // Example:
76
  // "Xenoxylum foobar" sensu Grumbach¹; sensu Lem²
77
  //    1. Novel marsian species, Grumbach, 2022
78
  //    2. Flora solaris, Lem, 2019
79
  if (isset($taxonRelationshipsDTO->relations[0])) {
80
    foreach($taxonRelationshipsDTO->relations as $taxon_relation){
81

    
82
      if (in_array($taxon_relation->type->uuid, $taxon_relationship_types)) {
83

    
84
        if ($taxon_relation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxon_relation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
85

    
86
          RenderHints::pushToRenderStack('misapplied_name_for'); // TODO the render path string should in future come from $taxonRelation->type->...
87

    
88
          $name = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('name')));
89

    
90
          $sensu_citation_footnote_str = null;
91

    
92
          if (!isset($misapplied[$name])) {
93
            // Render the first name found as representative for all others.
94

    
95
            //###OLD: $misapplied[$name]['out'] = cdm_related_taxon($taxon_relation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
96
            $name_tagged_text = array();
97
            $secref_tagged_text = null;
98
            foreach($taxon_relation->taggedText as $tt){
99
              if($tt->type !== 'secReference' && !$secref_tagged_text){
100
                $name_tagged_text[] = $tt;
101
              } else {
102
                if(!$secref_tagged_text){
103
                  // initialize $secref_tagged_text
104
                  $secref_tagged_text = array();
105
                  $secref_tagged_text[] = array_pop($name_tagged_text); // remmove last elemetn wich is a separator in this case
106
                }
107
                $secref_tagged_text[] = $tt;
108
              }
109
            }
110
            $misapplied[$name]['out'] = cdm_tagged_text_to_markup($name_tagged_text);
111
          } else {
112
            // We need to add the anchors for all of the other misapplied names not
113
            // being rendered explicitly.
114
            $misapplied[$name]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$name]['out']);
115
          }
116

    
117
          // Collect all authors for this fullname.
118
          if (isset($authorteam_str) && $authorteam_str != $NULL_AUTHORTEAM) {
119
            // prepare entry for the footnote key of the sensu citation footnote
120
            $misapplied[$name]['authorteam'][$authorteam_str] = '';
121
            // map sensu citation footnote to the authorteam string
122
            $joinedAuthorTeams[$authorteam_str] = $sensu_citation_footnote_str;
123
          }
124

    
125
        } else {
126
          RenderHints::pushToRenderStack('other_taxon_relationship');
127
          // All relationship types except misapplied_name_for and invalid_designation_for.
128
          $taxon_relationships_lines[] = cdm_taxonRelationship($taxon_relation, TRUE, _is_invers_taxonRelationship($taxon_relation, $focusedTaxon));
129
        }
130

    
131
        RenderHints::popFromRenderStack();
132
      }
133
    }
134
  }
135

    
136
  // Sort the joinedAuthorTeams and create footnotes and footnotekeys.
137
  ksort($joinedAuthorTeams);
138
  $author_team_cnt = 0;
139
  foreach ($joinedAuthorTeams as $authorteam_str => $sensu_citation) {
140
    $footnoteKey = '';
141
    if(!empty($sensu_citation)) {
142
      $footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensu_citation);
143
      $footnoteKey = theme('cdm_footnote_key', array('footnoteKey' => $footnoteKey));
144
    }
145
    $sensu = '';
146
    if($authorteam_str != $NULL_AUTHORTEAM){
147
      $sensu = ++$author_team_cnt == 0 ? '' : 'sensu ' . $authorteam_str;
148
    }
149
    $joinedAuthorTeams[$authorteam_str] = '<span class="sensu">' . $sensu . $footnoteKey .'</span>';
150
  }
151

    
152
  // ---- Generate output ---- //
153

    
154
  $out = '<div class="taxon-relationships">';
155
  if (is_array($misapplied) && count($misapplied) > 0) {
156
    $out .= '<ul class="misapplied">';
157
    foreach ($misapplied as $misapplied_name) {
158

    
159
      $out .= '<li class="synonym"><span class="misapplied">' . $misapplied_name['out'] . ' </span>';
160

    
161
      if (isset($misapplied_name['authorteam'])) {
162
        // Fill authors with the renderedFootnoteKey and sorting 'em.
163
        foreach ($misapplied_name['authorteam'] as $authorteam_str => &$renderedFootnoteKey) {
164
          $renderedFootnoteKey = $joinedAuthorTeams[$authorteam_str];
165
        }
166
        ksort($misapplied_name['authorteam']);
167
        $out .= join('; ', $misapplied_name['authorteam']);
168
      }
169
      $out .= '</li>';
170
    }
171
    $out .= '</ul>';
172
  }
173

    
174
  if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
175
    $out .= '<ul class="taxonRelationships">';
176
    foreach ($taxon_relationships_lines as $taxon_relationship_line) {
177
      $out .= '<li class="synonym">' . $taxon_relationship_line . '</li>';
178
    }
179
    $out .= '</ul>';
180
  }
181

    
182
  $footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
183
  $footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
184

    
185
// AK: why splitting footnotes at the sensu string ??? this is weired and hacky
186
//     TODO remove below dead code
187
//   $tr_footnotes_exploded = explode('sensu', $tr_footnotes);
188
//   $tr_footnotes_aux = '';
189
//   foreach ($tr_footnotes_exploded as $element) {
190
//     $tr_footnotes_aux .= $element;
191
//   }
192

    
193
  $out .= '<ul class="footnotes">' . $footnotes . '</ul>';
194

    
195
  $out .= '</div>';
196

    
197
  RenderHints::popFromRenderStack();
198
  return $out;
199
}
200

    
201

    
202
/**
203
 * Renders a representation of the given taxon relationship.
204
 *
205
 * According name relationships are also being rendered.
206
 *
207
 * @param $taxonRelationship
208
 * @param boolean $doLinkTaxon
209
 *     whether to create a link to the related taxon
210
 * @param boolean $inverse
211
 *     whether the $taxonRelationship should be treaded as invers relation
212
 *
213
 * @return string
214
 *
215
 */
216
function cdm_taxonRelationship($taxonRelationship, $doLinkTaxon = FALSE, $inverse = FALSE) {
217

    
218
  // Validate object.
219
  if (!(isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type))) {
220
    return null;
221
  }
222

    
223
  $taxonRelationType = $taxonRelationship->type;
224

    
225
  if ($inverse) {
226
    $toTaxon = $taxonRelationship->fromTaxon;
227
    $relsign = $taxonRelationType->inverseSymbol;
228
    $reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
229
  }
230
  else {
231
    $toTaxon = $taxonRelationship->toTaxon;
232
    $relsign = $taxonRelationType->symbol;
233
    $reltype_representation = $taxonRelationType->representation_L10n;
234
  }
235

    
236
  return cdm_related_taxon($toTaxon, NULL, $relsign, $reltype_representation, $taxonRelationship->doubtful, $doLinkTaxon);
237
}
238

    
239
/**
240
 * Renders a representation of the given taxon relationship.
241
 *
242
 * According name relationships are also being rendered.
243
 *
244
 * @param $taxon
245
 *  The CDM TaxonBase entity
246
 * @param $reltype_uuid
247
 *  The UUID of the TaxonRelationshipType
248
 * @param $relsign
249
 *  Optional. Can be  used to override the internal decision strategy on finding a suitable icon for the relationship
250
 * @param $reltype_representation
251
 *   Optional: Defines the value for the title attribute of the html element enclosing the relsign
252
 * @param $doubtful
253
 *   TODO
254
 * @param $doLinkTaxon
255
 *   The taxon will be rendered as clickable link when true.
256
 *
257
 * @return string
258
 *   Markup for the taxon relationship.
259
 *
260
 * @throws Exception
261
 */
262
function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $reltype_representation = NULL, $doubtful=false, $doLinkTaxon = FALSE) {
263
  static $relsign_homo = '≡';
264
  static $relsign_hetero = '=';
265
  static $relsign_invalid = '&ndash;';
266
  static $nom_status_invalid_type_uuids =  array(
267
    UUID_NOMENCLATURALSTATUS_TYPE_INVALID,
268
    UUID_NOMENCLATURALSTATUS_TYPE_NUDUM,
269
    UUID_NOMENCLATURALSTATUS_TYPE_COMBINATIONINVALID,
270
    UUID_NOMENCLATURALSTATUS_TYPE_PROVISIONAL
271
  );
272

    
273
  // 'taxonRelationships';
274
  $footnoteListKey = NULL;
275

    
276
  $skip_tags = array();
277

    
278
  $is_invalid = false;
279

    
280
  if (!$relsign) {
281

    
282
    switch ($reltype_uuid) {
283
      case UUID_HETEROTYPIC_SYNONYM_OF:
284
      case UUID_SYNONYM_OF:
285
        $relsign = $relsign_hetero;
286
        break;
287

    
288
      case UUID_HOMOTYPIC_SYNONYM_OF:
289
        $relsign = $relsign_homo;
290
        break;
291

    
292
      case UUID_MISAPPLIED_NAME_FOR:
293
      case UUID_INVALID_DESIGNATION_FOR:
294
        $skip_tags[] = 'authors';
295
        $is_invalid = true;
296
        $relsign = $relsign_invalid;
297

    
298
        break;
299

    
300
      default:
301
        $relsign = $relsign_invalid;
302
    }
303

    
304
  }
305

    
306
  if($doubtful) {
307
    $relsign = '?' . $relsign;
308
  }
309

    
310
  /*
311
  Names with status invalid or nudum are to be displayed with the
312
  $relsign_invalid, these names appear at the end of all names in their
313
  homotypic group (ordered correctly by the java cdm_lib).
314
  */
315
  if (isset($taxon->name->status) && is_array($taxon->name->status)) {
316
    foreach ($taxon->name->status as $status) {
317
      if (in_array($status->type->uuid , $nom_status_invalid_type_uuids)) {
318
        $relsign = $relsign_invalid;
319
        break;
320
      }
321
    }
322
  }
323

    
324
  // Now rendering starts ..
325
  RenderHints::pushToRenderStack('related_taxon');
326

    
327
  if (isset($taxon->name->nomenclaturalReference)) {
328
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
329
  }
330
  $taxonUri = '';
331
  if ($doLinkTaxon) {
332
    $taxonUri = url(path_to_taxon($taxon->uuid, "synonymy"));
333
  }
334
  // Printing the taxonName and the handling the special case of annotations.
335
  if (!isset($referenceUri)) {
336
    $referenceUri = FALSE;
337
  }
338
  $out_taxon_part = render_taxon_or_name($taxon, $taxonUri, $referenceUri, TRUE, FALSE, $skip_tags, $is_invalid);
339
  $taxon_footnotes = theme('cdm_annotations_as_footnotekeys',
340
    array('cdmBase_list' => array(
341
      $taxon->name,
342
      $taxon,
343
    ),
344
      'footnote_list_key' => $footnoteListKey)
345
  );
346

    
347
  $homonyms = cdm_name_relationships_of($taxon);
348

    
349
  $out = '<span class="relation_sign" title="' . $reltype_representation . '">' . $relsign . '</span>'
350
    . $out_taxon_part . $taxon_footnotes . ' '  . $homonyms;
351

    
352
  $out = uuid_anchor($taxon->uuid, $out);
353

    
354
  RenderHints::popFromRenderStack();
355

    
356
  return $out;
357
}
358

    
359

    
360
/**
361
 * Creates markup for a taxon which is the accepted of another one
362
 *
363
 * @param $accepted_for_uuid
364
 *   The uuid of the accepted taxon
365
 */
366
function cdm_accepted_for($accepted_for_uuid) {
367

    
368
  if(!is_uuid($accepted_for_uuid)){
369
    return '';
370
  }
371

    
372
  RenderHints::pushToRenderStack('acceptedFor');
373
  $out = '';
374

    
375
  $synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $accepted_for_uuid);
376
  if ($synonym) {
377
    $out .= '<span class="acceptedFor">';
378
    $out .= t('is accepted for ');
379
    if (isset($synonym->name->nomenclaturalReference)) {
380
      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
381
    }
382
    $out .= render_taxon_or_name($synonym->name, NULL, $referenceUri);
383
    $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
384
    $out .= '</span>';
385
  }
386
  RenderHints::popFromRenderStack();
387
  return $out;
388
}
389

    
390
/**
391
 * Compose function for a list of taxa.
392
 *
393
 * This function is for used to:
394
 *
395
 * 1. Display search results
396
 * 2. List the taxa for a taxon name in the name page.
397
 *
398
 * @param $taxon_list array
399
 *   The list of CDM Taxon entities. e.g. The records array as contained in a pager object.
400
 * @param $freetext_search_results array
401
 * @param $show_classification boolean
402
 *
403
 * @ingroup compose
404
 *
405
 */
406
function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $show_classification = false) {
407

    
408
  $unclassified_snippet = '<span class="unclassified">' . t('unclassified') . '</span>';
409

    
410
  RenderHints::pushToRenderStack('list_of_taxa');
411

    
412
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
413

    
414
  $showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
415
  $showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
416
  $searched_in_classification = cdm_dataportal_searched_in_classification();
417
  $searched_in_classification_uuid = null;
418
  if(isset($searched_in_classification->uuid)){
419
    $searched_in_classification_uuid = $searched_in_classification->uuid;
420
  }
421

    
422
  // .. Well, for sure not as performant as before, but better than nothing.
423
  $synonym_uuids = array();
424
  $misappied_uuids = array();
425
  foreach ($taxon_list as $taxon) {
426
    if ($taxon->class == "Synonym") {
427
      if (!array_key_exists($taxon->uuid, $synonym_uuids)) {
428
        $synonym_uuids[$taxon->uuid] = $taxon->uuid;
429
      }
430
    }
431
    elseif (!_cdm_dataportal_acceptedByCurrentView($taxon)) {
432
      // Assuming that it is a misappied name, will be further examined below.
433
      $misappied_uuids[$taxon->uuid] = $taxon->uuid;
434
    }
435
  }
436

    
437
  // Batch service not jet implemented:
438
  // $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED,
439
  // join(',', $synonym_uuids));
440
  // thus ...
441
  $table_of_accepted = array();
442

    
443
  foreach ($synonym_uuids as $relatedUuid) {
444
    $classification_filter = '';
445
    if($searched_in_classification_uuid){
446
      $classification_filter = 'classificationFilter=' . $searched_in_classification_uuid;
447
    }
448
    $table_of_accepted[$relatedUuid] = cdm_ws_get(
449
      CDM_WS_PORTAL_TAXON_ACCEPTED,
450
      array($relatedUuid),
451
      $classification_filter
452
    );
453
  }
454

    
455
  foreach ($misappied_uuids as $relatedUuid) {
456
    $taxonRelations = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, array(
457
      $relatedUuid,
458
    ));
459
    foreach ($taxonRelations as $relation) {
460
      if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_acceptedByCurrentView($relation->toTaxon)) {
461
        $table_of_accepted[$relatedUuid][] = $relation->toTaxon;
462
      }
463
    }
464
  }
465

    
466
  $out = '<div class="cdm-item-list" style="background-image: none;">';
467
  $itemCnt = -1;
468
  foreach ($taxon_list as $taxon) {
469
    $itemCnt++;
470
    if (isset($table_of_accepted[$taxon->uuid])) {
471
      // Its a synonym or misapplied name.
472
      $is_synonym = isset($synonym_uuids[$taxon->uuid]); //TODO better use the $taxon->class attribute?
473
      $taxon_type = $is_synonym ? TAXON_TYPE_SYNONYM :TAXON_TYPE_MISAPPLIEDNAME;
474

    
475
      $acceptedTaxa = $table_of_accepted[$taxon->uuid];
476

    
477
      if (!is_array($acceptedTaxa)) {
478
        $acceptedTaxa = array($acceptedTaxa);
479
      }
480

    
481
      foreach ($acceptedTaxa as $acceptedTaxon) {
482
        if (is_object($acceptedTaxon)) {
483

    
484
          $taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid);
485
          $referenceUri = '';
486
          if (isset($acceptedTaxon->name->nomenclaturalReference)) {
487
            $referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
488
          }
489
          $taxon_or_name = $is_synonym ? $taxon->name : $taxon;
490
          // $taxon_or_name this is a trick to suppress the sec reference for synonyms
491
          // supplying the name will cause render_taxon_or_name() to not show the sec reference
492
          $out .= "<div class=\"item " . $taxon_type . "\">" . render_taxon_or_name($taxon_or_name, $taxonUri, $referenceUri);
493
          if($taxon_type == TAXON_TYPE_MISAPPLIEDNAME && is_object($taxon->sec)){
494
            if(isset($taxon->sec->authorship)){
495
              $authorship = $taxon->sec->authorship->titleCache;
496
            } else {
497
              $authorship = $taxon->sec->titleCache;
498
            }
499
            $out .=  ' sensu ' . $authorship;
500
          }
501
          if ($show_classification) {
502
            $classifications = get_classifications_for_taxon($taxon);
503
            $classification_titles = array();
504
            foreach ($classifications as $classification) {
505
              if (isset($classification->titleCache)) {
506
                $classification_titles[] = $classification->titleCache;
507
              }
508
            }
509
            if (count($classification_titles) == 0) {
510
              $classification_titles[] = $unclassified_snippet;
511
            }
512
            $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
513
          }
514
          $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
515
          if ($showMedia_synonyms) {
516
            $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
517
          }
518
        }
519
      }
520
    }
521
    else {
522
      // Its a Taxon.
523
      $taxonUri = url(path_to_taxon($taxon->uuid));
524
      $referenceUri = '';
525
      if (isset($taxon->name->nomenclaturalReference)) {
526
        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
527
      }
528
      $out .= '<div class="item Taxon">' . render_taxon_or_name($taxon, $taxonUri, $referenceUri);
529
      if ($show_classification) {
530
        $classifications = get_classifications_for_taxon($taxon);
531
        $classification_titles = array();
532
        foreach ($classifications as $classification) {
533
          if (isset($classification->titleCache)) {
534
            $classification_titles[] = $classification->titleCache;
535
          }
536
        }
537
        if(count($classification_titles) == 0){
538
          $classification_titles[] = $unclassified_snippet;
539
        }
540
        $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
541
      }
542
      $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
543

    
544
      if ($showMedia_taxa) {
545
        $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
546
      }
547
    }
548

    
549
    /*
550
     * the score field will be empty in case of MultiTermQueries like
551
     * WildcardQueries, since these are  constant score by default
552
     * since Lucene 2.9
553
     */
554
    if(isset($freetext_search_results[$itemCnt]) && $freetext_search_results[$itemCnt]->score && $freetext_search_results[$itemCnt]->maxScore){
555
      $percentage =  ( $freetext_search_results[$itemCnt]->score / $freetext_search_results[$itemCnt]->maxScore ) * 100;
556
      $out .= '<div class="score-bar"><div class="score-bar-indicator" style="width:' . $percentage .'% "></div></div>';
557
      $out .= '<div class="score-bar-value">' . number_format($percentage, 2) .'%</div>';
558
    }
559

    
560
    // Render highlighted fragments, these are made available by free text
561
    // searches.
562
    if (isset($freetext_search_results[$itemCnt]->fieldHighlightMap)) {
563
      $field_fragments = (array) $freetext_search_results[$itemCnt]->fieldHighlightMap;
564
      if (count($field_fragments) > 0) {
565
        $fragments_out = '';
566
        foreach ($field_fragments as $fieldName => $fragments) {
567
          $fragments_out .= '... <span class="' . $fieldName. '">' . filter_xss(join(" ... ", $fragments), array('b') ) . '</span>';
568
        }
569
        $out .= '<div class="fragment_highlight">' . $fragments_out . ' ...</div>';
570
      }
571
    }
572

    
573
    $out .= '</div>';
574
  }
575

    
576
  $out .= '</div>';
577
  RenderHints::popFromRenderStack();
578

    
579
  return markup_to_render_array($out); // TODO create render array of all list items in function
580
}
581

    
582

    
583
/**
584
 * Compose function for the taxonomic children
585
 *
586
 * @param $taxon_uuid
587
 *    The uuuid of the taxon to compose the list of taxonomic children for
588
 * @return
589
 *   A drupal render array.
590
 *
591
 * @ingroup compose
592
 */
593
function compose_taxonomic_children($taxon_uuid){
594

    
595
  $render_array = array();
596
  
597
  if($taxon_uuid) {
598
    $children = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array(
599
      get_current_classification_uuid(),
600
      $taxon_uuid
601
      ));
602
    if($children){
603
      $taxonomic_children = theme('cdm_taxontree', array('tree' => $children));
604
      $render_array = markup_to_render_array($taxonomic_children);
605
    }
606
  }
607
  return $render_array;
608
}
609

    
(10-10/10)