Project

General

Profile

Download (21.8 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
<?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 6188d24e Andreas Kohlbecker
        $taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon), TRUE);
76 6657531f Andreas Kohlbecker
      }
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 fea89e38 Andreas Kohlbecker
  // ---- Generate output ---- //
88
89
  $out = '<div class="taxon-relationships">';
90 6657531f Andreas Kohlbecker
  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 6188d24e Andreas Kohlbecker
  if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
110 6657531f Andreas Kohlbecker
    $out .= '<ul class="taxonRelationships">';
111 6188d24e Andreas Kohlbecker
    foreach ($taxon_relationships_lines as $taxon_relationship_line) {
112
      $out .= '<li class="synonym">' . $taxon_relationship_line . '</li>';
113 6657531f Andreas Kohlbecker
    }
114
    $out .= '</ul>';
115
  }
116
117 fea89e38 Andreas Kohlbecker
  $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 6657531f Andreas Kohlbecker
132
  RenderHints::popFromRenderStack();
133
  return $out;
134
}
135
136
/**
137
 * @todo Please document this function.
138
 * @see http://drupal.org/node/1354
139
 */
140 eb6c50ea Andreas Kohlbecker
function theme_cdm_acceptedFor($variables) {
141
  $accepted_for_uuid = $variables['acceptedFor'];
142 6657531f Andreas Kohlbecker
143 eb6c50ea Andreas Kohlbecker
  if(!is_uuid($accepted_for_uuid)){
144
    return '';
145
  }
146 6657531f Andreas Kohlbecker
147 eb6c50ea Andreas Kohlbecker
  RenderHints::pushToRenderStack('acceptedFor');
148
  $out = '';
149 6657531f Andreas Kohlbecker
150 eb6c50ea Andreas Kohlbecker
  $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 6657531f Andreas Kohlbecker
    }
157 eb6c50ea Andreas Kohlbecker
    $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 6657531f Andreas Kohlbecker
  }
165
  RenderHints::popFromRenderStack();
166
  return $out;
167
}
168
169
/**
170
 * @todo document this function.
171
 */
172
function theme_cdm_list_of_taxa($variables) {
173 61b6ee11 Andreas Kohlbecker
174 f56b1626 Andreas Kohlbecker
  $unclassified_snippet = '<span class="unclassified">' . t('unclassified') . '</span>';
175
176 6657531f Andreas Kohlbecker
  $records = $variables['records'];
177
  $freetextSearchResults = $variables['freetextSearchResults'];
178 61b6ee11 Andreas Kohlbecker
  $show_classification = $variables['show_classification'];
179
180 6657531f Andreas Kohlbecker
  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 9c9d11f7 Andreas Kohlbecker
  // $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED,
212 6657531f Andreas Kohlbecker
  // join(',', $synonym_uuids));
213
  // thus ...
214
  $table_of_accepted = array();
215
216
  foreach ($synonym_uuids as $relatedUuid) {
217 9c9d11f7 Andreas Kohlbecker
    $table_of_accepted[$relatedUuid] = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array(
218 6657531f Andreas Kohlbecker
      $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 9c9d11f7 Andreas Kohlbecker
      $taxon_type = $is_synonym ? "Synonym" : "misapplied-name";
242 6657531f Andreas Kohlbecker
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 9c9d11f7 Andreas Kohlbecker
        $out .= '<li class="' . $taxon_type . '">' . theme('cdm_taxonName', array(
254 6657531f Andreas Kohlbecker
          '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 17cab8f4 Patric Plitzner
        if ($show_classification) {
262 61b6ee11 Andreas Kohlbecker
          $classifications = get_classifications_for_taxon($taxon);
263
          $classification_titles = array();
264 17cab8f4 Patric Plitzner
          foreach ($classifications as $classification) {
265
            if (isset($classification->titleCache)) {
266
              $classification_titles[] = $classification->titleCache;
267
            }
268 61b6ee11 Andreas Kohlbecker
          }
269 f56b1626 Andreas Kohlbecker
          if(count($classification_titles) == 0){
270
            $classification_titles[] = $unclassified_snippet;
271
          }
272 61b6ee11 Andreas Kohlbecker
          $out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
273
        }
274 6657531f Andreas Kohlbecker
        $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 c1f5d897 Andreas Kohlbecker
        $out .= cdm_dynabox(
284 9c9d11f7 Andreas Kohlbecker
            $taxon->uuid, // dynabox uuid
285 f0bf24e7 Andreas Kohlbecker
            // taxon name as label:
286 c1f5d897 Andreas Kohlbecker
            theme('cdm_taxonName', array(
287
              'taxonName' => $taxon->name,
288
              'nameLink' => NULL,
289
              'refenceLink' => NULL,
290
              'show_annotations' => FALSE,
291
            )),
292 f0bf24e7 Andreas Kohlbecker
            // content_url:
293 9c9d11f7 Andreas Kohlbecker
            cdm_compose_url(CDM_WS_PORTAL_TAXON_ACCEPTED,
294 f0bf24e7 Andreas Kohlbecker
                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 9c9d11f7 Andreas Kohlbecker
            'show accepted taxa of this ' . $taxon_type,
303
            array('li', 'ul'),
304
            array('class' => array($taxon_type))
305 f0bf24e7 Andreas Kohlbecker
         );
306 6657531f Andreas Kohlbecker
      }
307
    }
308
    else {
309
      // Its a Taxon.
310
      $taxonUri = url(path_to_taxon($taxon->uuid));
311
      $referenceUri = '';
312
      if (isset($taxon->name->nomenclaturalReference)) {
313
        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
314
      }
315
      $out .= '<li class="Taxon">' . theme('cdm_taxonName', array(
316
        'taxonName' => $taxon->name,
317
        'nameLink' => $taxonUri,
318
        'refenceLink' => $referenceUri,
319
        ));
320 17cab8f4 Patric Plitzner
      if ($show_classification) {
321
        $classifications = get_classifications_for_taxon($taxon);
322
        $classification_titles = array();
323
        foreach ($classifications as $classification) {
324
          if (isset($classification->titleCache)) {
325
            $classification_titles[] = $classification->titleCache;
326
          }
327 f56b1626 Andreas Kohlbecker
        }
328
        if(count($classification_titles) == 0){
329
          $classification_titles[] = $unclassified_snippet;
330 17cab8f4 Patric Plitzner
        }
331
        $out .= ' : <span class="classifications">' . implode(', ', $classification_titles) . '</span>';
332 61b6ee11 Andreas Kohlbecker
      }
333 6657531f Andreas Kohlbecker
      $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
334
335
      if ($showMedia_taxa) {
336
        $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
337
      }
338
    }
339
340
    /*
341
     * the score field will be empty in case of MultiTermQueries like
342
     * WildcardQueries, since these are  constant score by default
343
     * since Lucene 2.9
344
     */
345
    if(isset($freetextSearchResults[$itemCnt]) && $freetextSearchResults[$itemCnt]->score && $freetextSearchResults[$itemCnt]->maxScore){
346
      $percentage =  ( $freetextSearchResults[$itemCnt]->score / $freetextSearchResults[$itemCnt]->maxScore ) * 100;
347
      $out .= '<div class="score-bar"><div class="score-bar-indicator" style="width:' . $percentage .'% "></div></div>';
348
      $out .= '<div class="score-bar-value">' . number_format($percentage, 2) .'%</div>';
349
    }
350
351
    // Render highlighted fragments, these are made available by free text
352
    // searches.
353
    if (isset($freetextSearchResults[$itemCnt]->fieldHighlightMap)) {
354
      $field_fragments = (array) $freetextSearchResults[$itemCnt]->fieldHighlightMap;
355
      if (count($field_fragments) > 0) {
356
        $fragments_out = '';
357
        foreach ($field_fragments as $fieldName => $fragments) {
358
          $fragments_out .= '... <span class="' . $fieldName. '">' . filter_xss(join(" ... ", $fragments), array('b') ) . '</span>';
359
        }
360
        $out .= '<div class="fragment_highlight">' . $fragments_out . ' ...</div>';
361
      }
362
    }
363
364
    $out .= '</li>';
365
  }
366
367
  $out .= '</ul>';
368
  RenderHints::popFromRenderStack();
369
370
  return $out;
371
}
372
373
/**
374
 * Renders a representation of the given taxon relationship.
375
 *
376
 * According name relationships are also being rendered.
377 6188d24e Andreas Kohlbecker
 *
378
 * @param unknown_type $taxonRelationship
379
 * @param boolean $doLinkTaxon
380
 *     whether to create a link to the related taxon
381
 * @param boolean $inverse
382
 *     whether the $taxonRelationship should be treaded as invers relation
383
 * @param unknown_type $showSecReference
384
 *     whether the secundum reference for the related taxon should be shown
385
 *
386
 * @return void|string
387 6657531f Andreas Kohlbecker
 */
388 6188d24e Andreas Kohlbecker
function cdm_taxonRelationship($taxonRelationship, $doLinkTaxon = FALSE, $inverse = FALSE, $showSecReference = FALSE) {
389 6657531f Andreas Kohlbecker
390
  // Validate object.
391
  if (!(isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type))) {
392
    return;
393
  }
394
395
  $reltype_uuid = $taxonRelationship->type->uuid;
396
  $taxonRelationType = $taxonRelationship->type;
397
398
  $reltype_representation = '';
399
400
  if ($inverse) {
401
    $toTaxon = $taxonRelationship->fromTaxon;
402
    $fromTaxon = $taxonRelationship->toTaxon;
403
    $relsign = $taxonRelationType->inverseRepresentation_L10n_abbreviatedLabel;
404
    $reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
405
  }
406
  else {
407
    $toTaxon = $taxonRelationship->toTaxon;
408
    $fromTaxon = $taxonRelationship->fromTaxon;
409
    $relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
410
    $reltype_representation = $taxonRelationType->representation_L10n;
411
  }
412
413
  return cdm_related_taxon($toTaxon, NULL, $relsign, $reltype_representation, $doLinkTaxon, $showSecReference);
414
}
415
416
/**
417
 * Renders a representation of the given taxon relationship.
418
 *
419 899922d7 Andreas Kohlbecker
 * According name relationships are also being rendered.
420 6657531f Andreas Kohlbecker
 */
421
function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $reltype_representation = NULL, $doLinkTaxon = FALSE, $showSecReference = FALSE) {
422
  static $relsign_homo = '≡';
423
  static $relsign_hetero = '=';
424
  static $relsign_invalid = '&ndash;';
425
426
  // 'taxonRelationships';
427
  $footnoteListKey = NULL;
428
429
  $name_prefix = '';
430
  $name_postfix = '';
431
432
  $skiptags = array();
433
434
  if (!$relsign) {
435
436
    $relsign = '';
437
    switch ($reltype_uuid) {
438
      case UUID_HETEROTYPIC_SYNONYM_OF:
439
      case UUID_SYNONYM_OF:
440
        $relsign = $relsign_hetero;
441
        break;
442
443
      case UUID_HOMOTYPIC_SYNONYM_OF:
444
        $relsign = $relsign_homo;
445
        break;
446
447
      case UUID_MISAPPLIED_NAME_FOR:
448
      case UUID_INVALID_DESIGNATION_FOR:
449
        $skiptags[] = 'authors';
450
        $relsign = $relsign_invalid;
451
        $name_prefix = '"';
452
        $name_postfix = '"';
453
        break;
454
455
      default:
456
        $relsign = $relsign_invalid;
457
    }
458
  }
459
  /*
460
  Names with status invalid or nudum are to be displayed with the
461
  $relsign_invalid, these names appear at the end of all names in their
462
  homotypic group (ordered correctly by the java cdm_lib).
463
  */
464
  if (isset($taxon->name->status) && is_array($taxon->name->status)) {
465
    foreach ($taxon->name->status as $status) {
466
      if ($status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_INVALID || $status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_NUDUM) {
467
        $relsign = $relsign_invalid;
468
      }
469
    }
470
  }
471
472
  // Now rendering starts ..
473
  RenderHints::pushToRenderStack('related_taxon');
474
475
  if (isset($taxon->name->nomenclaturalReference)) {
476
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
477
  }
478
  $taxonUri = '';
479
  if ($doLinkTaxon) {
480
    $taxonUri = url(path_to_taxon($taxon->uuid, "synonymy"));
481
  }
482
  // Printing the taxonName and the handling the special case of annotations.
483
  if (!isset($referenceUri)) {
484
    $referenceUri = FALSE;
485
  }
486
  $out_taxon_part = theme('cdm_taxonName', array(
487
    'taxonName' => $taxon->name,
488
    'nameLink' => $taxonUri,
489
    'refenceLink' => $referenceUri,
490
    'show_annotations' => TRUE,
491
    'is_type_designation' => FALSE,
492
    'skiptags' => $skiptags,
493
    ));
494 fea89e38 Andreas Kohlbecker
  $out_taxon_part .= theme('cdm_annotations_as_footnotekeys',
495
       array('cdmBase_list' => array(
496
         $taxon->name,
497
         $taxon,
498
       ),
499
       'footnote_list_key' => $footnoteListKey)
500
  );
501 6657531f Andreas Kohlbecker
502
  if ($showSecReference) {
503
    $out_taxon_part .= ' sec. ' . theme('cdm_reference', array('reference' => $taxon->sec));
504
  }
505
506 51b04faf Andreas Kohlbecker
507
  // =========== START OF HOMONYMS ========== //
508
  RenderHints::pushToRenderStack('homonym');
509
  // the render stack element homonyms is being used in the default render templates !!!, see CDM_NAME_RENDER_TEMPLATES_DEFAULT
510
511 6657531f Andreas Kohlbecker
  // Later homonym or treated as later homonym AND bloking names.
512 51b04faf Andreas Kohlbecker
  // TODO apply filter ? $name_rels_to_show = variable_get('name_relationships_to_show', NULL);
513 6657531f Andreas Kohlbecker
  $from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
514
  $to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
515 51b04faf Andreas Kohlbecker
  $name_relations  = array_merge($from_name_relations, $to_name_relations);
516
517
  $homonyms_array = array();
518 6657531f Andreas Kohlbecker
519 51b04faf Andreas Kohlbecker
  if ($name_relations) {
520
    foreach ( $name_relations as $element ) {
521 e513a727 Patric Plitzner
      $taxon_html = null;
522 899922d7 Andreas Kohlbecker
      switch ($element->type->uuid) {
523 17cab8f4 Patric Plitzner
          case UUID_LATER_HOMONYM :
524
              $elementTaxonBasesUuid = isset ($element->toName->taxonBases [0]->uuid) ? $element->toName->taxonBases [0]->uuid : '';
525
526 1ce9afb7 Patric Plitzner
              //from relation ships -> only shown at fromName-synonym
527 17cab8f4 Patric Plitzner
              if ($taxon->name->uuid == $element->fromName->uuid) {
528
                  $taxon_html = theme('cdm_taxonName', array(
529
                      'taxonName' => $element->toName,
530
                      'nameLink' => path_to_name($element->toName->uuid, $taxon->uuid, $elementTaxonBasesUuid)
531
                  ));
532
              }
533
              break;
534
          case UUID_TREATED_AS_LATER_HOMONYM :
535
              $elementTaxonBasesUuid = isset ($element->toName->taxonBases [0]->uuid) ? $element->toName->taxonBases [0]->uuid : '';
536
537 1ce9afb7 Patric Plitzner
              //from relation ships -> only shown at fromName-synonym
538 17cab8f4 Patric Plitzner
              if ($taxon->name->uuid == $element->fromName->uuid) {
539
                  $taxon_html = theme('cdm_taxonName', array(
540
                      'taxonName' => $element->toName,
541
                      'nameLink' => path_to_name($element->toName->uuid)
542
                  ));
543
              }
544
              break;
545
          case UUID_BLOCKING_NAME_FOR :
546
              $elementTaxonBasesUuid = isset ($element->fromName->taxonBases [0]->uuid) ? $element->fromName->taxonBases [0]->uuid : '';
547
548 1ce9afb7 Patric Plitzner
              //to relation ships -> only shown at toName-synonym
549 17cab8f4 Patric Plitzner
              if ($taxon->name->uuid == $element->toName->uuid) {
550
                  $taxon_html = theme('cdm_taxonName', array(
551
                      'taxonName' => $element->fromName,
552
                      'nameLink' => path_to_name($element->fromName->uuid, $taxon->uuid, $elementTaxonBasesUuid)
553
                  ));
554
              }
555
              break;
556
          default:
557
              $taxon_html = null;
558 6657531f Andreas Kohlbecker
      }
559 e513a727 Patric Plitzner
      if (isset($taxon_html) && $taxon_html) {
560 51b04faf Andreas Kohlbecker
        if (count ( $homonyms_array )) {
561
          $homonyms_array [] = 'nec ' . $taxon_html;
562
        } else {
563
          $homonyms_array [] = 'non ' . $taxon_html;
564 6657531f Andreas Kohlbecker
        }
565
      }
566
    }
567
  }
568 51b04faf Andreas Kohlbecker
569
  RenderHints::popFromRenderStack();
570
  // =========== END OF HOMONYMS ========== //
571
572
  $out = '<span class="relation_sign" title="' . $reltype_representation . '">' . $relsign . '</span>'
573
      . $name_prefix . $out_taxon_part . $name_postfix . ' '
574
      . (count($homonyms_array) ?'[' . trim(join(" ", $homonyms_array)) . ']' : '');
575
576 6657531f Andreas Kohlbecker
  $out = uuid_anchor($taxon->uuid, $out);
577
578
  RenderHints::popFromRenderStack();
579
580
  return $out;
581
}
582
583
/**
584
 * @todo document this function.
585
 */
586
function theme_cdm_taxon_list_thumbnails($variables) {
587
588
  $taxon = $variables['taxon'];
589
  $out = '';
590
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
591
  $showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
592
  if ($showCaption) {
593
    $captionElements = array(
594
      'title',
595
      'rights',
596
    );
597 7a2a14b3 Andreas Kohlbecker
  } else {
598
    $captionElements = array();
599 6657531f Andreas Kohlbecker
  }
600
601
  $gallery_name = $taxon->uuid;
602
603 9438ad3a Andreas Kohlbecker
  $mediaList = _load_media_for_taxon($taxon);
604 6657531f Andreas Kohlbecker
605 9438ad3a Andreas Kohlbecker
  $galleryLinkUri = path_to_taxon($taxon->uuid, 'images');
606 6657531f Andreas Kohlbecker
607
  $out .= theme('cdm_media_gallerie', array(
608
    'mediaList' => $mediaList,
609
    'galleryName' => $gallery_name,
610
    'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
611
    'cols' => $gallery_settings['cdm_dataportal_media_cols'],
612
    'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
613
    'captionElements' => $captionElements,
614
    'mediaLinkType' => 'LIGHTBOX',
615
    'alternativeMediaUri' => NULL,
616
    'galleryLinkUri' => $galleryLinkUri,
617
     ));
618
619
  return $out;
620
}