Project

General

Profile

Download (21 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 taxonRelationships
43
 * @param focusedTaxon
44
 *
45
 * @return string
46
 *    the rendered html
47
 */
48
function cdm_taxonRelationships($taxonRelationships, $focusedTaxon){
49

    
50
  static $NULL_AUTHORTEAM = 'NULL_AUTHORTEAM';
51

    
52
  if (!$taxonRelationships) {
53
    return null;
54
  }
55

    
56
  RenderHints::pushToRenderStack('taxon_relationships');
57
  $footnoteListKey = 'taxon_relationships';
58
  RenderHints::setFootnoteListKey($footnoteListKey);
59

    
60
  $misapplied = array();
61
  $joinedAuthorTeams = array();
62

    
63
  $taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
64

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

    
78
    if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
79

    
80
      if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
81

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

    
84
        $name = $taxonRelation->fromTaxon->name->titleCache;
85

    
86
        $sensu_citation_footnote_str = null;
87

    
88
        if(isset($taxonRelation->fromTaxon->sec)) {
89

    
90
          $sensu_citation_footnote_str = theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
91
          $authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
92

    
93
          if(isset($authorteam->titleCache)){
94
            $authorteam_str = $authorteam->titleCache;
95
            if($taxonRelation->fromTaxon->sec->titleCache == $authorteam->titleCache){
96
              // no need for a footnote in case the reference only consists of the author team
97
              $sensu_citation_footnote_str = '';
98
            }
99
          } else {
100
            $authorteam_str = $sensu_citation_footnote_str;
101
            // no need for a footnote in case in case it is used as replacement for missing author teams
102
            $sensu_citation_footnote_str = '';
103
          }
104
        } else {
105
          // taxa not always are have a sec reference (e.g. doubtful taxa)
106
          // use the NULL_AUTHORTEAM in this case
107
          $authorteam_str = $NULL_AUTHORTEAM;
108
        }
109

    
110
        if (!isset($misapplied[$name])) {
111
          // Render the first name found as representative for all others.
112
          $misapplied[$name]['out'] = cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
113
        }
114
        else {
115
          // We need to add the anchors for all of the other misapplied names not
116
          // being rendered explicitly.
117
          $misapplied[$name]['out'] = uuid_anchor($taxonRelation->fromTaxon->uuid, $misapplied[$name]['out']);
118
        }
119

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

    
127
        }
128

    
129
      }
130
      else {
131
        RenderHints::pushToRenderStack('other_taxon_relationship');
132
        // All relationsship types but misapplied_name_for
133
        // invalid_designation_for.
134
        $taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon));
135
      }
136

    
137
      RenderHints::popFromRenderStack();
138
    }
139
  }
140

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

    
157
  // ---- Generate output ---- //
158

    
159
  $out = '<div class="taxon-relationships">';
160
  if (is_array($misapplied) && count($misapplied) > 0) {
161
    $out .= '<ul class="misapplied">';
162
    foreach ($misapplied as $misapplied_name) {
163

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

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

    
179
  if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
180
    $out .= '<ul class="taxonRelationships">';
181
    foreach ($taxon_relationships_lines as $taxon_relationship_line) {
182
      $out .= '<li class="synonym">' . $taxon_relationship_line . '</li>';
183
    }
184
    $out .= '</ul>';
185
  }
186

    
187
  $footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
188
  $footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
189

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

    
198
  $out .= '<ul class="footnotes">' . $footnotes . '</ul>';
199

    
200
  $out .= '</div>';
201

    
202
  RenderHints::popFromRenderStack();
203
  return $out;
204
}
205

    
206

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

    
222
  // Validate object.
223
  if (!(isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type))) {
224
    return null;
225
  }
226

    
227
  $taxonRelationType = $taxonRelationship->type;
228

    
229
  if ($inverse) {
230
    $toTaxon = $taxonRelationship->fromTaxon;
231
    $relsign = $taxonRelationType->inverseRepresentation_L10n_abbreviatedLabel;
232
    $reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
233
  }
234
  else {
235
    $toTaxon = $taxonRelationship->toTaxon;
236
    $relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
237
    $reltype_representation = $taxonRelationType->representation_L10n;
238
  }
239

    
240
  return cdm_related_taxon($toTaxon, NULL, $relsign, $reltype_representation, $taxonRelationship->doubtful, $doLinkTaxon);
241
}
242

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

    
275
  // 'taxonRelationships';
276
  $footnoteListKey = NULL;
277

    
278
  $skip_tags = array();
279

    
280
  $is_invalid = false;
281

    
282
  if (!$relsign) {
283

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

    
290
      case UUID_HOMOTYPIC_SYNONYM_OF:
291
        $relsign = $relsign_homo;
292
        break;
293

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

    
300
        break;
301

    
302
      default:
303
        $relsign = $relsign_invalid;
304
    }
305

    
306
  }
307

    
308
  if($doubtful) {
309
    $relsign = '?' . $relsign;
310
  }
311

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

    
326
  // Now rendering starts ..
327
  RenderHints::pushToRenderStack('related_taxon');
328

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

    
349
  $homonyms = cdm_name_relationships_of($taxon);
350

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

    
354
  $out = uuid_anchor($taxon->uuid, $out);
355

    
356
  RenderHints::popFromRenderStack();
357

    
358
  return $out;
359
}
360

    
361

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

    
370
  if(!is_uuid($accepted_for_uuid)){
371
    return '';
372
  }
373

    
374
  RenderHints::pushToRenderStack('acceptedFor');
375
  $out = '';
376

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

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

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

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

    
411
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
412

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

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

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

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

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

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

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

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

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

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

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

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

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

    
572
    $out .= '</li>';
573
  }
574

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

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

    
581

    
582
function compose_taxonomic_children($taxon_uuid){
583

    
584
  $render_array = array();
585
  
586
  if($taxon_uuid) {
587
    $children = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array(
588
      get_current_classification_uuid(),
589
      $taxon_uuid
590
      ));
591
    if($children){
592
      $taxonomic_children = theme('cdm_taxontree', array('tree' => $children));
593
      $render_array = markup_to_render_array($taxonomic_children);
594
    }
595
  }
596
  return $render_array;
597
}
598

    
(10-10/10)