Project

General

Profile

Download (21.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Taxon Theming 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

    
16
/**
17
 * Returns HTML for misapplied names and invalid designations.
18
 *
19
 * Both relation types are currently treated the same!
20
 *
21
 * @param array $variables
22
 *   An associative array containing:
23
 *   - taxonRelationships
24
 *   - focusedTaxon
25
 *
26
 * @ingroup themeable
27
 */
28
function theme_cdm_taxonRelationships($variables) {
29
  $taxonRelationships = $variables['taxonRelationships'];
30
  $focusedTaxon = $variables['focusedTaxon'];
31
  if (!$taxonRelationships) {
32
    return;
33
  }
34

    
35
  RenderHints::pushToRenderStack('taxonRelationships');
36
  $footnoteListKey = 'taxonRelationships';
37
  RenderHints::setFootnoteListKey($footnoteListKey);
38

    
39
  $misapplied = array();
40
  $joinedAuthorTeams = array();
41

    
42
  $taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
43

    
44
  // Aggregate misapplied names having the same fullname:
45
  foreach ($taxonRelationships as $taxonRelation) {
46

    
47
    if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
48

    
49
      if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
50

    
51
        $name = $taxonRelation->fromTaxon->name->titleCache;
52

    
53
        $authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
54
        $authorteam = $authorteam->titleCache;
55

    
56
        if (!isset($misapplied[$name])) {
57
          // Render the first name found as representative for all others.
58
          $misapplied[$name]['out'] = cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
59
        }
60
        else {
61
          // We need to add the anchors for all of the other mispplied names not
62
          // being rendered explicitly.
63
          $misapplied[$name]['out'] = uuid_anchor($taxonRelation->fromTaxon->uuid, $misapplied[$name]['out']);
64
        }
65

    
66
        // Collect all authors for this fullname.
67
        if (isset($authorteam)) {
68
          $misapplied[$name]['authorteam'][$authorteam] = '';
69
          $joinedAuthorTeams[$authorteam] = 'sensu ' . theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
70
        }
71
      }
72
      else {
73
        // All relationsship types but misapplied_name_for
74
        // invalid_designation_for.
75
        $taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon), TRUE);
76
      }
77
    }
78
  }
79

    
80
  // Sort the joinedAuthorTeams and create footnotes and footnotekeys.
81
  ksort($joinedAuthorTeams);
82
  foreach ($joinedAuthorTeams as $authorteam => $sensuCitation) {
83
    $footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
84
    $joinedAuthorTeams[$authorteam] = '<span class="sensu">sensu ' . $authorteam . theme('cdm_footnote_key', array('footnoteKey' => $footnoteKey)) . '</span>';
85
  }
86

    
87
  // ---- Generate output ---- //
88

    
89
  $out = '<div class="taxon-relationships">';
90
  if (is_array($misapplied) && count($misapplied) > 0) {
91
    $out .= '<ul class="misapplied">';
92
    foreach ($misapplied as $misapplied_name) {
93

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

    
96
      if (isset($misapplied_name['authorteam'])) {
97
        // Fill authors with the renderedFootnoteKey and sorting 'em.
98
        foreach ($misapplied_name['authorteam'] as $authorteam => &$renderedFootnoteKey) {
99
          $renderedFootnoteKey = $joinedAuthorTeams[$authorteam];
100
        }
101
        ksort($misapplied_name['authorteam']);
102
        $out .= join('; ', $misapplied_name['authorteam']);
103
      }
104
      $out .= '</li>';
105
    }
106
    $out .= '</ul>';
107
  }
108

    
109
  if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
110
    $out .= '<ul class="taxonRelationships">';
111
    foreach ($taxon_relationships_lines as $taxon_relationship_line) {
112
      $out .= '<li class="synonym">' . $taxon_relationship_line . '</li>';
113
    }
114
    $out .= '</ul>';
115
  }
116

    
117
  $footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
118
  $footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
119

    
120
// AK: why splitting footnotes at the sennsu string ??? this is weired and hacky
121
//     TODO remove below dead code
122
//   $tr_footnotes_exploded = explode('sensu', $tr_footnotes);
123
//   $tr_footnotes_aux = '';
124
//   foreach ($tr_footnotes_exploded as $element) {
125
//     $tr_footnotes_aux .= $element;
126
//   }
127

    
128
  $out .= '<ul class="footnotes">' . $footnotes . '</ul>';
129

    
130
  $out .= '</div>';
131

    
132
  RenderHints::popFromRenderStack();
133
  return $out;
134
}
135

    
136
/**
137
 * @todo Please document this function.
138
 * @see http://drupal.org/node/1354
139
 */
140
function theme_cdm_acceptedFor($variables) {
141
  $accepted_for_uuid = $variables['acceptedFor'];
142

    
143
  if(!is_uuid($accepted_for_uuid)){
144
    return '';
145
  }
146

    
147
  RenderHints::pushToRenderStack('acceptedFor');
148
  $out = '';
149

    
150
  $synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $accepted_for_uuid);
151
  if ($synonym) {
152
    $out .= '<span class="acceptedFor">';
153
    $out .= t('is accepted for ');
154
    if (isset($synonym->name->nomenclaturalReference)) {
155
      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
156
    }
157
    $out .= theme('cdm_taxonName', array(
158
      'taxonName' => $synonym->name,
159
      'nameLink' => NULL,
160
      'refenceLink' => $referenceUri,
161
      ));
162
    $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
163
    $out .= '</span>';
164
  }
165
  RenderHints::popFromRenderStack();
166
  return $out;
167
}
168

    
169
/**
170
 * @todo document this function.
171
 */
172
function theme_cdm_list_of_taxa($variables) {
173

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

    
176
  $records = $variables['records'];
177
  $freetextSearchResults = $variables['freetextSearchResults'];
178
  $show_classification = $variables['show_classification'];
179

    
180
  RenderHints::pushToRenderStack('list_of_taxa');
181

    
182
  $form_name = 'search_gallery';
183
  // $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
184
  // $gallery_settings = variable_get($form_name, $default_values);
185
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
186

    
187
  $showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
188
  $showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
189
  // $showMedia_taxa =
190
  // variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
191
  // $showMedia_synonyms =
192
  // variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
193
  $classification_uuid = get_taxonomictree_uuid_selected();
194

    
195
  // .. Well, for sure not as performant as before, but better than nothing.
196
  $synonym_uuids = array();
197
  $misappied_uuids = array();
198
  foreach ($records as $taxon) {
199
    if ($taxon->class == "Synonym") {
200
      if (!array_key_exists($taxon->uuid, $synonym_uuids)) {
201
        $synonym_uuids[$taxon->uuid] = $taxon->uuid;
202
      }
203
    }
204
    elseif (!_cdm_dataportal_acceptedByCurrentView($taxon)) {
205
      // Assuming that it is a misappied name, will be further examined below.
206
      $misappied_uuids[$taxon->uuid] = $taxon->uuid;
207
    }
208
  }
209

    
210
  // Batch service not jet implemented:
211
  // $table_of_accepted = cdm_ws_property(CDM_WS_TAXON_ACCEPTED,
212
  // join(',', $synonym_uuids));
213
  // thus ...
214
  $table_of_accepted = array();
215

    
216
  foreach ($synonym_uuids as $relatedUuid) {
217
    $table_of_accepted[$relatedUuid] = cdm_ws_get(CDM_WS_TAXON_ACCEPTED, array(
218
      $relatedUuid,
219
      $classification_uuid,
220
    ));
221
  }
222

    
223
  foreach ($misappied_uuids as $relatedUuid) {
224
    $taxonRelations = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, array(
225
      $relatedUuid,
226
    ));
227
    foreach ($taxonRelations as $relation) {
228
      if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_acceptedByCurrentView($relation->toTaxon)) {
229
        $table_of_accepted[$relatedUuid][] = $relation->toTaxon;
230
      }
231
    }
232
  }
233

    
234
  $out = '<ul class="cdm_names" style="background-image: none;">';
235
  $itemCnt = -1;
236
  foreach ($records as $taxon) {
237
    $itemCnt++;
238
    if (isset($table_of_accepted[$taxon->uuid])) {
239
      // Its a synonym or misapplied name.
240
      $is_synonym = isset($synonym_uuids[$taxon->uuid]);
241
      $class_name = $is_synonym ? "Synonym" : "misapplied-name";
242

    
243
      $acceptedTaxa = $table_of_accepted[$taxon->uuid];
244

    
245
      if (count($acceptedTaxa) == 1) {
246

    
247
        $acceptedTaxon = $acceptedTaxa[0];
248
        $taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
249
        $referenceUri = '';
250
        if (isset($acceptedTaxon->name->nomenclaturalReference)) {
251
          $referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
252
        }
253
        $out .= '<li class="' . $class_name . '">' . theme('cdm_taxonName', array(
254
          'taxonName' => $taxon->name,
255
          'nameLink' => $taxonUri,
256
          'refenceLink' => $referenceUri,
257
          ));
258
        if (!$is_synonym) {
259
          $out .= '<span class="sensu"> sensu ' . theme('cdm_reference', array('reference' => $taxon->sec)) . '</span>';
260
        }
261
        if ($show_classification) {
262
          $classifications = get_classifications_for_taxon($taxon);
263
          $classification_titles = array();
264
          foreach ($classifications as $classification) {
265
            if (isset($classification->titleCache)) {
266
              $classification_titles[] = $classification->titleCache;
267
            }
268
          }
269
          if(count($classification_titles) == 0){
270
            $classification_titles[] = $unclassified_snippet;
271
          }
272
          $out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
273
        }
274
        $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
275
        if ($showMedia_synonyms) {
276
          $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
277
        }
278
      }
279
      else {
280

    
281
        // TODO avoid using Ajax in the cdm_dynabox .... why?
282
        // TODO add media.
283
        $out .= cdm_dynabox(
284
            $taxon->uuid,// dynabox uuid
285
            // taxon name as label:
286
            theme('cdm_taxonName', array(
287
              'taxonName' => $taxon->name,
288
              'nameLink' => NULL,
289
              'refenceLink' => NULL,
290
              'show_annotations' => FALSE,
291
            )),
292
            // content_url:
293
            cdm_compose_url(CDM_WS_TAXON_ACCEPTED,
294
                array(
295
                    $taxon->uuid,
296
                    $classification_uuid
297
                )
298
            ),
299
            // theme to use for rendering:
300
            'cdm_list_of_taxa',
301
            // label to toggle open:
302
            'Click for accepted taxon'
303
         );
304
      }
305
    }
306
    else {
307
      // Its a Taxon.
308
      $taxonUri = url(path_to_taxon($taxon->uuid));
309
      $referenceUri = '';
310
      if (isset($taxon->name->nomenclaturalReference)) {
311
        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
312
      }
313
      $out .= '<li class="Taxon">' . theme('cdm_taxonName', array(
314
        'taxonName' => $taxon->name,
315
        'nameLink' => $taxonUri,
316
        'refenceLink' => $referenceUri,
317
        ));
318
      if ($show_classification) {
319
        $classifications = get_classifications_for_taxon($taxon);
320
        $classification_titles = array();
321
        foreach ($classifications as $classification) {
322
          if (isset($classification->titleCache)) {
323
            $classification_titles[] = $classification->titleCache;
324
          }
325
        }
326
        if(count($classification_titles) == 0){
327
          $classification_titles[] = $unclassified_snippet;
328
        }
329
        $out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
330
      }
331
      $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
332

    
333
      if ($showMedia_taxa) {
334
        $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
335
      }
336
    }
337

    
338
    /*
339
     * the score field will be empty in case of MultiTermQueries like
340
     * WildcardQueries, since these are  constant score by default
341
     * since Lucene 2.9
342
     */
343
    if(isset($freetextSearchResults[$itemCnt]) && $freetextSearchResults[$itemCnt]->score && $freetextSearchResults[$itemCnt]->maxScore){
344
      $percentage =  ( $freetextSearchResults[$itemCnt]->score / $freetextSearchResults[$itemCnt]->maxScore ) * 100;
345
      $out .= '<div class="score-bar"><div class="score-bar-indicator" style="width:' . $percentage .'% "></div></div>';
346
      $out .= '<div class="score-bar-value">' . number_format($percentage, 2) .'%</div>';
347
    }
348

    
349
    // Render highlighted fragments, these are made available by free text
350
    // searches.
351
    if (isset($freetextSearchResults[$itemCnt]->fieldHighlightMap)) {
352
      $field_fragments = (array) $freetextSearchResults[$itemCnt]->fieldHighlightMap;
353
      if (count($field_fragments) > 0) {
354
        $fragments_out = '';
355
        foreach ($field_fragments as $fieldName => $fragments) {
356
          $fragments_out .= '... <span class="' . $fieldName. '">' . filter_xss(join(" ... ", $fragments), array('b') ) . '</span>';
357
        }
358
        $out .= '<div class="fragment_highlight">' . $fragments_out . ' ...</div>';
359
      }
360
    }
361

    
362
    $out .= '</li>';
363
  }
364

    
365
  $out .= '</ul>';
366
  RenderHints::popFromRenderStack();
367

    
368
  return $out;
369
}
370

    
371
/**
372
 * Renders a representation of the given taxon relationship.
373
 *
374
 * According name relationships are also being rendered.
375
 *
376
 * @param unknown_type $taxonRelationship
377
 * @param boolean $doLinkTaxon
378
 *     whether to create a link to the related taxon
379
 * @param boolean $inverse
380
 *     whether the $taxonRelationship should be treaded as invers relation
381
 * @param unknown_type $showSecReference
382
 *     whether the secundum reference for the related taxon should be shown
383
 *
384
 * @return void|string
385
 */
386
function cdm_taxonRelationship($taxonRelationship, $doLinkTaxon = FALSE, $inverse = FALSE, $showSecReference = FALSE) {
387

    
388
  // Validate object.
389
  if (!(isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type))) {
390
    return;
391
  }
392

    
393
  $reltype_uuid = $taxonRelationship->type->uuid;
394
  $taxonRelationType = $taxonRelationship->type;
395

    
396
  $reltype_representation = '';
397

    
398
  if ($inverse) {
399
    $toTaxon = $taxonRelationship->fromTaxon;
400
    $fromTaxon = $taxonRelationship->toTaxon;
401
    $relsign = $taxonRelationType->inverseRepresentation_L10n_abbreviatedLabel;
402
    $reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
403
  }
404
  else {
405
    $toTaxon = $taxonRelationship->toTaxon;
406
    $fromTaxon = $taxonRelationship->fromTaxon;
407
    $relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
408
    $reltype_representation = $taxonRelationType->representation_L10n;
409
  }
410

    
411
  return cdm_related_taxon($toTaxon, NULL, $relsign, $reltype_representation, $doLinkTaxon, $showSecReference);
412
}
413

    
414
/**
415
 * Renders a representation of the given taxon relationship.
416
 *
417
 * According name relationships are also being rendered.
418
 */
419
function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $reltype_representation = NULL, $doLinkTaxon = FALSE, $showSecReference = FALSE) {
420
  static $relsign_homo = '≡';
421
  static $relsign_hetero = '=';
422
  static $relsign_invalid = '&ndash;';
423

    
424
  // 'taxonRelationships';
425
  $footnoteListKey = NULL;
426

    
427
  $name_prefix = '';
428
  $name_postfix = '';
429

    
430
  $skiptags = array();
431

    
432
  if (!$relsign) {
433

    
434
    $relsign = '';
435
    switch ($reltype_uuid) {
436
      case UUID_HETEROTYPIC_SYNONYM_OF:
437
      case UUID_SYNONYM_OF:
438
        $relsign = $relsign_hetero;
439
        break;
440

    
441
      case UUID_HOMOTYPIC_SYNONYM_OF:
442
        $relsign = $relsign_homo;
443
        break;
444

    
445
      case UUID_MISAPPLIED_NAME_FOR:
446
      case UUID_INVALID_DESIGNATION_FOR:
447
        $skiptags[] = 'authors';
448
        $relsign = $relsign_invalid;
449
        $name_prefix = '"';
450
        $name_postfix = '"';
451
        break;
452

    
453
      default:
454
        $relsign = $relsign_invalid;
455
    }
456
  }
457
  /*
458
  Names with status invalid or nudum are to be displayed with the
459
  $relsign_invalid, these names appear at the end of all names in their
460
  homotypic group (ordered correctly by the java cdm_lib).
461
  */
462
  if (isset($taxon->name->status) && is_array($taxon->name->status)) {
463
    foreach ($taxon->name->status as $status) {
464
      if ($status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_INVALID || $status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_NUDUM) {
465
        $relsign = $relsign_invalid;
466
      }
467
    }
468
  }
469

    
470
  // Now rendering starts ..
471
  RenderHints::pushToRenderStack('related_taxon');
472

    
473
  if (isset($taxon->name->nomenclaturalReference)) {
474
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
475
  }
476
  $taxonUri = '';
477
  if ($doLinkTaxon) {
478
    $taxonUri = url(path_to_taxon($taxon->uuid, "synonymy"));
479
  }
480
  // Printing the taxonName and the handling the special case of annotations.
481
  if (!isset($referenceUri)) {
482
    $referenceUri = FALSE;
483
  }
484
  $out_taxon_part = theme('cdm_taxonName', array(
485
    'taxonName' => $taxon->name,
486
    'nameLink' => $taxonUri,
487
    'refenceLink' => $referenceUri,
488
    'show_annotations' => TRUE,
489
    'is_type_designation' => FALSE,
490
    'skiptags' => $skiptags,
491
    ));
492
  $out_taxon_part .= theme('cdm_annotations_as_footnotekeys',
493
       array('cdmBase_list' => array(
494
         $taxon->name,
495
         $taxon,
496
       ),
497
       'footnote_list_key' => $footnoteListKey)
498
  );
499

    
500
  if ($showSecReference) {
501
    $out_taxon_part .= ' sec. ' . theme('cdm_reference', array('reference' => $taxon->sec));
502
  }
503

    
504

    
505
  // =========== START OF HOMONYMS ========== //
506
  RenderHints::pushToRenderStack('homonym');
507
  // the render stack element homonyms is being used in the default render templates !!!, see CDM_NAME_RENDER_TEMPLATES_DEFAULT
508

    
509
  // Later homonym or treated as later homonym AND bloking names.
510
  // TODO apply filter ? $name_rels_to_show = variable_get('name_relationships_to_show', NULL);
511
  $from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
512
  $to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
513
  $name_relations  = array_merge($from_name_relations, $to_name_relations);
514

    
515
  $homonyms_array = array();
516

    
517
  if ($name_relations) {
518
    foreach ( $name_relations as $element ) {
519
      switch ($element->type->uuid) {
520
          case UUID_LATER_HOMONYM :
521
              $elementTaxonBasesUuid = isset ($element->toName->taxonBases [0]->uuid) ? $element->toName->taxonBases [0]->uuid : '';
522

    
523
              //from relation ships -> only shown at after fromName-synonym
524
              if ($taxon->name->uuid == $element->fromName->uuid) {
525
                  $taxon_html = theme('cdm_taxonName', array(
526
                      'taxonName' => $element->toName,
527
                      'nameLink' => path_to_name($element->toName->uuid, $taxon->uuid, $elementTaxonBasesUuid)
528
                  ));
529
              }
530
              break;
531
          case UUID_TREATED_AS_LATER_HOMONYM :
532
              $elementTaxonBasesUuid = isset ($element->toName->taxonBases [0]->uuid) ? $element->toName->taxonBases [0]->uuid : '';
533

    
534
              //from relation ships -> only shown at after fromName-synonym
535
              if ($taxon->name->uuid == $element->fromName->uuid) {
536
                  $taxon_html = theme('cdm_taxonName', array(
537
                      'taxonName' => $element->toName,
538
                      'nameLink' => path_to_name($element->toName->uuid)
539
                  ));
540
              }
541
              break;
542
          case UUID_BLOCKING_NAME_FOR :
543
              $elementTaxonBasesUuid = isset ($element->fromName->taxonBases [0]->uuid) ? $element->fromName->taxonBases [0]->uuid : '';
544

    
545
              //to relation ships -> only shown at after toName-synonym
546
              if ($taxon->name->uuid == $element->toName->uuid) {
547
                  $taxon_html = theme('cdm_taxonName', array(
548
                      'taxonName' => $element->fromName,
549
                      'nameLink' => path_to_name($element->fromName->uuid, $taxon->uuid, $elementTaxonBasesUuid)
550
                  ));
551
              }
552
              break;
553
          default:
554
              $taxon_html = null;
555
      }
556
      if ($taxon_html) {
557
        if (count ( $homonyms_array )) {
558
          $homonyms_array [] = 'nec ' . $taxon_html;
559
        } else {
560
          $homonyms_array [] = 'non ' . $taxon_html;
561
        }
562
      }
563
    }
564
  }
565

    
566
  RenderHints::popFromRenderStack();
567
  // =========== END OF HOMONYMS ========== //
568

    
569
  $out = '<span class="relation_sign" title="' . $reltype_representation . '">' . $relsign . '</span>'
570
      . $name_prefix . $out_taxon_part . $name_postfix . ' '
571
      . (count($homonyms_array) ?'[' . trim(join(" ", $homonyms_array)) . ']' : '');
572

    
573
  $out = uuid_anchor($taxon->uuid, $out);
574

    
575
  RenderHints::popFromRenderStack();
576

    
577
  return $out;
578
}
579

    
580
/**
581
 * @todo document this function.
582
 */
583
function theme_cdm_taxon_list_thumbnails($variables) {
584

    
585
  $taxon = $variables['taxon'];
586
  $out = '';
587
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
588
  $showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
589
  if ($showCaption) {
590
    $captionElements = array(
591
      'title',
592
      'rights',
593
    );
594
  } else {
595
    $captionElements = array();
596
  }
597

    
598
  $gallery_name = $taxon->uuid;
599

    
600
  $mediaList = _load_media_for_taxon($taxon);
601

    
602
  $galleryLinkUri = path_to_taxon($taxon->uuid, 'images');
603

    
604
  $out .= theme('cdm_media_gallerie', array(
605
    'mediaList' => $mediaList,
606
    'galleryName' => $gallery_name,
607
    'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
608
    'cols' => $gallery_settings['cdm_dataportal_media_cols'],
609
    'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
610
    'captionElements' => $captionElements,
611
    'mediaLinkType' => 'LIGHTBOX',
612
    'alternativeMediaUri' => NULL,
613
    'galleryLinkUri' => $galleryLinkUri,
614
     ));
615

    
616
  return $out;
617
}
(9-9/10)