Project

General

Profile

Download (25.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Description 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
/**
18
 * Theme function to alter the feature representation.
19
 *
20
 * It is highly qeutionalbe if this function should be completely removed.
21
 * If a feature needs a different representation this should be edited directly
22
 * in the cdm data but it shoud not be tweeked like this in the portal.
23
 *
24
 * Used in:
25
 *  - theme_cdm_feature_nodesTOC()
26
 *  - theme_cdm_feature_nodes()
27
 *  - theme_cdm_media_mime_application()
28
 *  - theme_cdm_media_mime_text()
29
 *
30
 * TODO delete this function? (a.kohlbecker feb 2013)
31
 *
32
 */
33
function theme_cdm_feature_name($variables) {
34
  $feature_name = $variables['feature_name'];
35
  return t($feature_name);
36
}
37

    
38

    
39
/**
40
 * @todo Please document this function.
41
 * @see http://drupal.org/node/1354
42
 */
43
function theme_FeatureTree_hierarchy($variables) {
44

    
45
  $feature_tree_uuid = $variables['FeatureTreeUuid'];
46
  if (!is_uuid($feature_tree_uuid)) {
47
    return NULL;
48
  }
49

    
50
  $out = '';
51
  $feature_tree = cdm_ws_get(CDM_WS_FEATURETREE,
52
    array(
53
      $feature_tree_uuid,
54
    )
55
  );
56

    
57
  if (isset($feature_tree) && isset($feature_tree->root)) {
58
    $out = '<ul class="' . $feature_tree->class . '">';
59
    $out .= theme('FeatureTree_hierarchy_children', array('node' => $feature_tree->root));
60
    $out .= '</ul>';
61
  }
62
  return $out;
63
}
64

    
65
/**
66
 * @todo Please document this function.
67
 * @see http://drupal.org/node/1354
68
 */
69
function theme_FeatureTree_hierarchy_children($variables) {
70

    
71
  $node = $variables['node'];
72
  $out = '';
73
  if (isset($node->childNodes)) {
74

    
75
    foreach ($node->childNodes as $child_node) {
76
      $out .= '<li>' . check_plain($child_node->feature->representation_L10n);
77
      if (isset($child_node->childNodes) && count($child_node->childNodes) > 0) {
78
        $out .= '<ul>' . theme('FeatureTree_hierarchy_children', array('node' => $child_node)) . '</ul>';
79
      }
80
      $out .= '</li>';
81
    }
82
  }
83
  return $out;
84
}
85

    
86

    
87
/**
88
 * Theme function to render CDM DescriptionElements of the type CategoricalData.
89
 *
90
 * @param array $variables
91
 *   An associative array containing:
92
 *  - element: the CategoricalData element
93
 *
94
 * @return string
95
 *   a html representation of the given CategoricalData element
96
 *
97
 * @ingroup themeable
98
 */
99
function theme_cdm_descriptionElement_CategoricalData($variables) {
100
  $element = $variables['element'];
101

    
102
  $state_data_strings = array();
103
  if (isset($element->stateData)) {
104
    foreach ($element->stateData as $state_data) {
105

    
106
      $state  = NULL;
107

    
108
      if (isset($state_data->state)) {
109
        $state = cdm_term_representation($state_data->state);
110
      }
111

    
112
      if (isset($state_data->modifyingText_L10n)) {
113
        $state = ' ' . $state_data->modifyingText_L10n;
114
      }
115

    
116
      $modifiers_strings = cdm_modifers_representations($state_data);
117

    
118
      $state_data_strings[] = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
119

    
120
    }
121
  }
122

    
123

    
124
  $out = '<span class="' . html_class_attribute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
125

    
126
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
127
  $annotations_and_sources = handle_annotations_and_sources(
128
    $element,
129
    $feature_block_settings,
130
    $out, // The description element text.
131
    $element->feature->uuid
132
  );
133

    
134
  if (!empty($annotations_and_sources['source_references'])) {
135
    $out .= ' ' . implode(' ', $annotations_and_sources['source_references']);
136
  }
137
  return $out . $annotations_and_sources['foot_note_keys'];
138
}
139

    
140
/**
141
 * Theme function to render CDM DescriptionElements of the type QuantitativeData.
142
 *
143
 * The function renders the statisticalValues contained in the QuantitativeData
144
 * entity according to the following scheme:
145
 *
146
 * (ExtremeMin)-Min-Average-Max-(ExtremeMax)
147
 *
148
 * All modifiers of these values are appended.
149
 *
150
 * If the QuantitativeData is containing more statisticalValues with further
151
 * statisticalValue types, these additional measures will be appended to the
152
 * above string separated by whitespace.
153
 *
154
 * Special cases;
155
 * 1. Min==Max: this will be interpreted as Average
156
 *
157
 * @param array $variables
158
 *   An associative array containing:
159
 *    - element: the QuantitativeData element
160
 *
161
 * @return string
162
 *   a html representation of the given QuantitativeData element
163
 *
164
 * @ingroup themeable
165
 */
166
function theme_cdm_descriptionElement_QuantitativeData($variables) {
167
  /*
168
   * - statisticalValues
169
   *   - value
170
   *   - modifiers
171
   *   - type
172
   * - unit->representation_L10n
173
   * - modifyingText
174
   * - modifiers
175
   * - sources
176
   */
177
  $element = $variables['element'];
178

    
179
  $out = '';
180
  $type_representation = NULL;
181
  $min_max = min_max_array();
182

    
183

    
184
  $other_values = array();
185

    
186
  if (isset($element->statisticalValues)) {
187
    $other_values_markup = array();
188
    foreach ($element->statisticalValues as $statistical_val) {
189

    
190
      // compile the full value string which also may contain modifiers
191
      if (isset($statistical_val->value)) {
192
        $statistical_val->_value = $statistical_val->value;
193
      }
194
      $val_modifiers_strings = cdm_modifers_representations($statistical_val);
195
      if ($val_modifiers_strings) {
196
        $statistical_val->_value = ' ' . $val_modifiers_strings . ' ' . $statistical_val->_value;
197
      }
198

    
199
      // either put into min max array or into $other_values
200
      // for generic output to be appended to 'min-max' string
201
      if (array_key_exists($statistical_val->type->titleCache, $min_max)) {
202
        $min_max[$statistical_val->type->titleCache] = $statistical_val;
203
      }
204
      else {
205
        $other_values[] = $statistical_val;
206
      }
207
    } // end of loop over statisticalValues
208

    
209
    // create markup
210

    
211
    $min_max_markup = min_max_markup($min_max);
212

    
213

    
214
    foreach ($other_values as $statistical_val) {
215
      $statistical_val_type_representation = NULL;
216
      if (isset($statistical_val->type)) {
217
        $statistical_val_type_representation = cdm_term_representation($statistical_val->type);
218
        // $statistical_val->type->termType;
219
        // $statistical_val->type->userFriendlyTypeName;
220
      }
221
      $value_markup = '<span class="' . html_class_attribute_ref($statistical_val) . ' ' . $statistical_val->type->termType . ' ">'
222
        . $statistical_val->_value . '</span>';
223
      $value_markup = $value_markup .
224
        ($statistical_val_type_representation ? ' <span class="type">' . $statistical_val_type_representation . '</span>' : '');
225
      $other_values_markup[] = $value_markup;
226
    }
227

    
228

    
229
    $out .= $min_max_markup . ' ' . implode($other_values_markup, ', ');
230
  }
231

    
232
  if (isset($element->unit)) {
233
    $out .= ' <span class="unit" title="'
234
      . cdm_term_representation($element->unit) . '">'
235
      . cdm_term_representation_abbreviated($element->unit)
236
      . '</span>';
237
  }
238

    
239
  // modifiers of the description element itself
240
  $modifier_string = cdm_modifers_representations($element);
241
  $out .= ($modifier_string ? ' ' . $modifier_string : '');
242
  if (isset($element->modifyingText_L10n)) {
243
    $out = $element->modifyingText_L10n . ' ' . $out;
244
  }
245

    
246
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
247
  $annotations_and_sources = handle_annotations_and_sources(
248
    $element,
249
    $feature_block_settings,
250
    $out, // the description element text
251
    $element->feature->uuid
252
  );
253

    
254
  if (!empty($annotations_and_sources['source_references'])) {
255
    $out .= ' ' . implode(' ', $annotations_and_sources['source_references']);
256
  }
257
  return $out . $annotations_and_sources['foot_note_keys'];
258

    
259
}
260

    
261

    
262
/**
263
 * Renders CDM DescriptionElements of the type IndividualsAssociations.
264
 *
265
 * @param array $variables
266
 *   An associative array containing:
267
 *  - element: the IndividualsAssociations element
268
 *
269
 * @return string
270
 *   html representation of the given IndividualsAssociations element
271
 *
272
 * @ingroup themeable
273
 */
274
function theme_cdm_descriptionElement_IndividualsAssociation($variables) {
275

    
276
  $element = $variables['element'];
277

    
278
  $out = '';
279

    
280
  $render_array = compose_cdm_specimenOrObservation($element->associatedSpecimenOrObservation);
281

    
282
  if (isset($element->description_L10n)) {
283
    $out .=  ' ' . $element->description_L10n;
284
  }
285

    
286
  $out .= drupal_render($render_array);
287

    
288
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
289
  $annotations_and_sources = handle_annotations_and_sources(
290
    $element,
291
    $feature_block_settings,
292
    $out, // the description element text
293
    $element->feature->uuid
294
  );
295

    
296
  if(!empty($annotations_and_sources['source_references'])){
297
    $out .= ' ' . join(' ', $annotations_and_sources['source_references'] );
298
  }
299
  return $out . $annotations_and_sources['foot_note_keys'];
300

    
301

    
302
}
303

    
304
/**
305
 * Theme function to render CDM DescriptionElements of the type TaxonInteraction.
306
 *
307
 * @param array $variables
308
 *   An associative array containing:
309
 *  - element: the TaxonInteraction element
310
 * @return html representation of the given TaxonInteraction element
311
 *
312
 * @ingroup themeable
313
 */
314
function theme_cdm_descriptionElement_TaxonInteraction($variables) {
315

    
316
  $element = $variables['element'];
317

    
318
  $out = '';
319

    
320
  if (isset($element->description_L10n)) {
321
    $out .=  ' ' . $element->description_L10n;
322
  }
323

    
324
  if(isset($element->taxon2)){
325
    $out = render_taxon_or_name($element->taxon2, url(path_to_taxon($element->taxon2->uuid)));
326
  }
327

    
328
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
329
  $annotations_and_sources = handle_annotations_and_sources(
330
    $element,
331
    $feature_block_settings,
332
    $out, // the description element text
333
    $element->feature->uuid
334
  );
335

    
336
  if(!empty($annotations_and_sources['source_references'])){
337
    $out .= ' ' . join(' ', $annotations_and_sources['source_references'] );
338
  }
339
  return $out . $annotations_and_sources['foot_note_keys'];
340

    
341
}
342

    
343

    
344

    
345
/**
346
 * @todo Please document this function.
347
 * @see http://drupal.org/node/1354
348
 */
349
function theme_cdm_IdentificationKey($variables) {
350
  $out = '';
351
  $identificationKey = $variables['identificationKey'];
352
  $doLinkToKeyPage = $variables['doLinkToKeyPage'];
353
  $showIdentificationKeyTitle = $variables['showIdentificationKeyTitle'];
354
  $parentRenderPath = RenderHints::getRenderPath();
355
  RenderHints::pushToRenderStack("IdentificationKey");
356

    
357
  if ($showIdentificationKeyTitle) {
358
    if ($doLinkToKeyPage) {
359
      $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
360
    }
361
    else {
362
      $out = $identificationKey->titleCache;
363
    }
364
  }
365
  if (isset($identificationKey->sources) && is_array($identificationKey->sources)) {
366
    // order and display sources.
367
    //TODO can the method handle_annotations_and_sources() be used here?
368
    $sources = oder_sources($identificationKey->sources, TRUE);
369
    $out .= '<div class="sources">';
370
    $out .=  implode('', $sources);
371
    $out .= '</div>';
372
  }
373
  // Display annotations.
374
  $out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
375
  RenderHints::popFromRenderStack();
376
  return $out;
377
}
378

    
379
/**
380
 * @todo Please document this function.
381
 * @see http://drupal.org/node/1354
382
 */
383
function theme_cdm_polytomousKey($variables) {
384
  $polytomousKey = $variables['polytomousKey'];
385

    
386
  // TODO settings needed.
387
  // @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
388
  // @see http://dev.e-taxonomy.eu/trac/ticket/2152
389
  $keyStyle = "linkedStyle";
390

    
391
  RenderHints::pushToRenderStack("polytomousKey");
392
  // Key nodes in linked style.
393
  $out = '<table class="polytomousKey polytomousKey_' . $keyStyle . '">';
394
  $out .= theme('cdm_polytomousKey_' . $keyStyle . '_subgraph', array('polytomousKeyNode' => $polytomousKey->root));
395
  $out .= '</table>';
396
  RenderHints::popFromRenderStack();
397
  return $out;
398
}
399

    
400
/**
401
 * @todo Please document this function.
402
 * @see http://drupal.org/node/1354
403
 */
404
function theme_cdm_polytomousKey_linkedStyle_subgraph($variables) {
405
  $polytomousKeyNode = $variables['polytomousKeyNode'];
406
  static $statementCountCharacter = '\'';
407
  $out = "";
408

    
409
  if (is_array($polytomousKeyNode->children)) {
410
    $childIndex = 0;
411

    
412
    // Render edges of the current node.
413
    foreach ($polytomousKeyNode->children as &$child) {
414

    
415
      if (!isset($child->statement) && isset($child->taxon->uuid)) {
416
        // Skip node with empty statements (see below for explanation: "Special
417
        // case").
418
        // this skipping here happens always in the next deeper level of iteration
419
        // the check below is node on the level above
420
        continue;
421
      }
422

    
423
      /*
424
       * Special case: Child nodes with empty statements but taxa as leaf are to
425
       * treated as if all those taxa where direct children of the source node.
426
       */
427
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
428
      $islinkToTaxon = isset($child->taxon->uuid);
429
      $islinkToSubKey = isset($child->subkey->uuid);
430
      $islinkToOtherNode = isset($child->otherNode);
431
      // Either NULL or 0.
432
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode;
433
      $hasQuestion = !empty($polytomousKeyNode->question->label_l10n);
434
      $hasFeature = isset($polytomousKeyNode->feature);
435

    
436
      // $indentEdge = $hasQuestion && $childIndex > 0;
437
      // Question.
438
      if ($hasQuestion && $childIndex == 0) {
439
        // Place question, as extra table row.
440
        $out .= '<tr class="question new_section">';
441
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
442
        $out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
443
        $out .= '</tr>';
444
      }
445

    
446
      $out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section' : '') . '">';
447

    
448
      if ($hasQuestion) {
449
        $out .= '<td class="nodeNumber"></td>';
450
      }
451
      else {
452
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
453
      }
454

    
455
      $out .= '<td ' . RenderHints::getHtmlElementID($child) . '  class="edge' . ($hasQuestion ? ' edge-indent' : '') . '">';
456

    
457
      // Feature.
458
      if ($hasFeature) {
459
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
460
      }
461

    
462
      // Statement.
463
      $out .= $child->statement->label_l10n;
464

    
465
      // --- Links to nodes taxa and subkeys.
466
      $out .= '<div class="nodeLink">';
467

    
468
      // Link to a PolytomousKeyNode.
469
      if ($islinkToNode) {
470
        $out .= '<div class="nodeLinkToNode">';
471
        if (isset($child->modifyingText)) {
472
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
473
        }
474
        $out .= l($child->nodeNumber, request_path(), array(
475
          'attributes' => NULL,
476
          'query' => NULL,
477
          'fragment' => $child->uuid,
478
        )) . '</div>';
479
      }
480

    
481
      // Link to a PolytomousKeyNode.
482
      if ($islinkToOtherNode) {
483
        $out .= '<div class="nodeLinkToOtherNode">';
484
        if (isset($child->modifyingText)) {
485
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
486
        }
487
        $out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], array(
488
          'attributes' => NULL,
489
          'query' => NULL,
490
          'fragment' => $child->otherNode->uuid,
491
        )) . '</div>';
492
      }
493

    
494
      // Link to one or many taxa.
495
      if ($islinkToTaxon || $islinkToManyTaxa) {
496

    
497
        if ($islinkToManyTaxa) {
498
          $taxonChildren = $child->children;
499
        }
500
        else {
501
          $taxonChildren = array(
502
            $child,
503
          );
504
        }
505

    
506
        foreach ($taxonChildren as $taxonChild) {
507
          // TODO many taxa $child->children->taxon.
508
          $out .= '<div class="nodeLinkToTaxon">';
509
          if (isset($taxonChild->modifyingText)) {
510
            $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $taxonChild->modifyingText));
511
          }
512
          $out .= render_taxon_or_name($taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
513
          $out .= '</div>';
514
        }
515

    
516
        // Link to a subkey.
517
        if ($islinkToSubKey) {
518
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', array('identificationKey' => $child->subkey)) . '</div>';
519
        }
520
      }
521

    
522
      $out .= '</div>'; // End node link.
523
      $out .= '</td>'; // End edge.
524
      $out .= '</tr>';
525

    
526
      $childIndex++;
527
    }
528

    
529
    // Recurse into child nodes.
530
    foreach ($polytomousKeyNode->children as &$child) {
531
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
532
    }
533
  }
534

    
535
  return $out;
536
}
537

    
538
/**
539
 * @todo Please document this function.
540
 * @see http://drupal.org/node/1354
541
 */
542
function theme_cdm_poytomousKeyNode_modifyingText($variables) {
543
  $out = '';
544
  $modifyingText = $variables['modifyingText'];
545
  if (is_object($modifyingText)) {
546
    $i = 0;
547
    foreach (get_object_vars($modifyingText) as $lang => $languageString) {
548
      $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">' . $languageString->text . '</span> ';
549
    }
550
  }
551
  return $out;
552
}
553

    
554
/**
555
 * Returns HTML for a list of a specific type of IdentificationKeys.
556
 *
557
 * The list can be restricteded by a taxon.
558
 *
559
 * @param array $variables
560
 *   An associative array containing:
561
 *   - type: The simple name of the cdm class implementing the interface
562
 *     IdentificationKey, valid values are:
563
 *     PolytomousKey, MediaKey, MultiAccessKey
564
 *   - taxonUuid: If given, this parameter restrict the listed keys to those
565
 *     which have the taxon identified be this uuid in scope.
566
 *
567
 * @ingroup themeable
568
 */
569
function theme_cdm_list_IdentificationKeys($variables) {
570
  $type = $variables['type'];
571
  $taxonUuid = $variables['taxonUuid'];
572
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
573
  if (!$keyList || count($keyList) == 0) {
574
    return;
575
  }
576

    
577
  RenderHints::pushToRenderStack('list_IdentificationKeys');
578
  $out = '<ul>';
579
  foreach ($keyList as $key) {
580
    $out .= '<li>';
581
    $out .= theme('cdm_IdentificationKey', array('identificationKey' => $key));
582
    $out .= '</li>';
583
  }
584
  $out .= '</ul>';
585
  $out .= theme("cdm_annotation_footnotes", array('footnoteListKey' => RenderHints::getRenderPath()));
586
  RenderHints::popFromRenderStack();
587

    
588
  return $out;
589
}
590

    
591
/**
592
 * @todo Please document this function.
593
 * @see http://drupal.org/node/1354
594
 */
595
function theme_cdm_block_IdentificationKeys($variables) {
596
  $taxonUuid = $variables['taxonUuid'];
597
  static $types = array(
598
    "PolytomousKey" => "Polytomous",
599
    "MediaKey" => "Media",
600
    "MultiAccessKey" => "Multiaccess",
601
  );
602
  RenderHints::pushToRenderStack('block_IdentificationKeys');
603
  $out = '';
604
  foreach ($types as $type => $label) {
605
    $keylist = theme('cdm_list_IdentificationKeys', array('type' => $type, 'taxonUuid' => $taxonUuid));
606
    if (!$keylist) {
607
      continue;
608
    }
609
    $out .= '<div class="' . $type . '">';
610
    $out .= '<h3>' . t($label) . "</h3>";
611
    $out .= $keylist;
612
    $out .= '</div>';
613
  }
614
  RenderHints::popFromRenderStack();
615
  return $out;
616
}
617

    
618
/**
619
 * This theming function formats the use description and use record list for
620
 * these descriptions.
621
 *
622
 * @see http://drupal.org/node/1354
623
 */
624
function theme_cdm_UseDescription($variables) {
625
  $descriptions = $variables['description'];
626
  $taxonUuid = $variables['taxonUuid'];
627
  $out = '<div id="content"><ul id="Description" class ="description">';
628
  if ($descriptions == NULL) {
629
    return;
630
  }
631

    
632
  $feature_block_settings = get_feature_block_settings(UUID_DISTRIBUTION);
633

    
634
  $descriptionSynonyms = '';
635
  $descriptionOut = '';
636
  $synonymOut = '';
637
  $currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
638

    
639
  foreach ($descriptions as $description) {
640
    $useSummary = '';
641
    foreach ($description->elements as $element) {
642

    
643
      if ($element->feature->uuid == UUID_USE && !(strlen($useSummary) > 0) && isset($element->multilanguageText_L10n)) {
644
        $useSummary = $element->multilanguageText_L10n->text;
645
      }
646
    }
647
    // uses will be ordered by source
648
    foreach ($description->sources as $source) {
649
      $is_about_current_taxon = FALSE;
650
      $originalTaxonUsedInSource = NULL;
651
      $originalTaxonPager = NULL;
652
      if ($source->originalNameString) {
653
        $request_params = array();
654
        $request_params['query'] = $source->originalNameString;
655
        $request_params['matchMode'] = "EXACT";
656
        $originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
657
        if ($originalTaxonPager->count > 0) {
658
          $originalTaxonUsedInSource = $originalTaxonPager->records[0];
659
        }
660
        else {
661
          $originalTaxonUsedInSource = $currentTaxon->name;
662
        }
663
      }
664
      else {
665
        $originalTaxonUsedInSource = $currentTaxon->name;
666
      }
667

    
668
      $is_about_current_taxon = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
669

    
670
      if (!$is_about_current_taxon) {
671
        $descriptionOut .= '<li class="descriptionText DescriptionElement">';
672
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
673
          'absolute' => TRUE,
674
          'html' => TRUE,
675
        ));
676
        $descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
677
        $descriptionOut .= $useSummary;
678
        foreach ($description->sources as $source) {
679
          $descriptionOut .= " (" . theme('cdm_OriginalSource', array(
680
              'source' => $source,
681
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
682
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1)) . ")";
683
        }
684
        $hasUseRecords = FALSE;
685
        $descriptionUseRecordOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
686
        foreach ($description->elements as $descriptionElement) {
687
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
688
            $hasUseRecords = TRUE;
689
            // FIXME localization hardcoded to English
690
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
691
            $descriptionUseRecordOut .= '<tr>';
692
            $descriptionUseRecordOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
693
            $descriptionUseRecordOut .= '</tr>';
694
          }
695
        }
696
        $descriptionUseRecordOut .= '</table></div>';
697
        if ($hasUseRecords) {
698
          $descriptionOut .= $descriptionUseRecordOut . '</li>';
699
        }
700
      }
701
      else {
702
        // TODO +/- duplicate of above, unify this code
703
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
704
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
705
          'absolute' => TRUE,
706
          'html' => TRUE,
707
        ));
708

    
709
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
710
        $synonymOut .= $useSummary;
711
        foreach ($description->sources as $source) {
712
          $synonymOut .= " (" . theme('cdm_OriginalSource', array(
713
              'source' => $source,
714
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
715
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1
716
            )) . ")";
717
        }
718

    
719
        $hasUseRecords = FALSE;
720
        $useRecordTableOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
721
        foreach ($description->elements as $descriptionElement) {
722
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
723
            $hasUseRecords = TRUE;
724
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
725
            $useRecordTableOut .= '<tr>';
726
            $useRecordTableOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
727
            $useRecordTableOut .= '</tr>';
728
          }
729
        }
730
        $useRecordTableOut .= '</table></div>';
731
        if ($hasUseRecords) {
732
          $synonymOut .= $useRecordTableOut . '</li>';
733
        }
734
      }
735

    
736
      // }
737
    }
738
  }
739
  $out .= $descriptionOut . $synonymOut;
740
  $out .= "</ul></div>";
741
  return $out;
742
}
743

    
744

    
745
/**
746
 * The theming function for a block of Uses Descriptions for a given taxon.
747
 *
748
 * The Uses block has been removed from the code but the according theme function
749
 * is kept for compatibility reasons with existing code regarding palmweb.
750
 *
751
 */
752
function theme_cdm_block_Uses($variables) {
753
  $taxonUuid = $variables['taxonUuid'];
754
  RenderHints::pushToRenderStack('block_Uses');
755

    
756
  if ($taxonUuid == NULL) {
757
    return;
758
  }
759
  $out = '';
760
  $markerTypes = array();
761
  $markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
762
  $useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
763
  if (!empty($useDescriptions)) {
764
    // FIXME use theme_block instaed of hardcoding the block html here !!!!
765
    $out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
766
    $formatUseDescriptions = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxonUuid));
767

    
768
    $out .= $formatUseDescriptions;
769
    $out .= "</div>";
770
  }
771

    
772
  return $out;
773
}
(2-2/9)