Project

General

Profile

Download (23.3 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
 * @todo Please document this function.
263
 * @see http://drupal.org/node/1354
264
 */
265
function theme_cdm_IdentificationKey($variables) {
266
  $out = '';
267
  $identificationKey = $variables['identificationKey'];
268
  $doLinkToKeyPage = $variables['doLinkToKeyPage'];
269
  $showIdentificationKeyTitle = $variables['showIdentificationKeyTitle'];
270
  $parentRenderPath = RenderHints::getRenderPath();
271
  RenderHints::pushToRenderStack("IdentificationKey");
272

    
273
  if ($showIdentificationKeyTitle) {
274
    if ($doLinkToKeyPage) {
275
      $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
276
    }
277
    else {
278
      $out = $identificationKey->titleCache;
279
    }
280
  }
281
  if (isset($identificationKey->sources) && is_array($identificationKey->sources)) {
282
    // order and display sources.
283
    //TODO can the method handle_annotations_and_sources() be used here?
284
    $sources = oder_sources($identificationKey->sources, TRUE);
285
    $out .= '<div class="sources">';
286
    $out .=  implode('', $sources);
287
    $out .= '</div>';
288
  }
289
  // Display annotations.
290
  $out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
291
  RenderHints::popFromRenderStack();
292
  return $out;
293
}
294

    
295
/**
296
 * @todo Please document this function.
297
 * @see http://drupal.org/node/1354
298
 */
299
function theme_cdm_polytomousKey($variables) {
300
  $polytomousKey = $variables['polytomousKey'];
301

    
302
  // TODO settings needed.
303
  // @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
304
  // @see http://dev.e-taxonomy.eu/trac/ticket/2152
305
  $keyStyle = "linkedStyle";
306

    
307
  RenderHints::pushToRenderStack("polytomousKey");
308
  // Key nodes in linked style.
309
  $out = '<table class="polytomousKey polytomousKey_' . $keyStyle . '">';
310
  $out .= theme('cdm_polytomousKey_' . $keyStyle . '_subgraph', array('polytomousKeyNode' => $polytomousKey->root));
311
  $out .= '</table>';
312
  RenderHints::popFromRenderStack();
313
  return $out;
314
}
315

    
316
/**
317
 * @todo Please document this function.
318
 * @see http://drupal.org/node/1354
319
 */
320
function theme_cdm_polytomousKey_linkedStyle_subgraph($variables) {
321
  $polytomousKeyNode = $variables['polytomousKeyNode'];
322
  static $statementCountCharacter = '\'';
323
  $out = "";
324

    
325
  if (is_array($polytomousKeyNode->children)) {
326
    $childIndex = 0;
327

    
328
    // Render edges of the current node.
329
    foreach ($polytomousKeyNode->children as &$child) {
330

    
331
      if (!isset($child->statement) && isset($child->taxon->uuid)) {
332
        // Skip node with empty statements (see below for explanation: "Special
333
        // case").
334
        // this skipping here happens always in the next deeper level of iteration
335
        // the check below is node on the level above
336
        continue;
337
      }
338

    
339
      /*
340
       * Special case: Child nodes with empty statements but taxa as leaf are to
341
       * treated as if all those taxa where direct children of the source node.
342
       */
343
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
344
      $islinkToTaxon = isset($child->taxon->uuid);
345
      $islinkToSubKey = isset($child->subkey->uuid);
346
      $islinkToOtherNode = isset($child->otherNode);
347
      // Either NULL or 0.
348
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode;
349
      $hasQuestion = !empty($polytomousKeyNode->question->label_l10n);
350
      $hasFeature = isset($polytomousKeyNode->feature);
351

    
352
      // $indentEdge = $hasQuestion && $childIndex > 0;
353
      // Question.
354
      if ($hasQuestion && $childIndex == 0) {
355
        // Place question, as extra table row.
356
        $out .= '<tr class="question new_section">';
357
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
358
        $out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
359
        $out .= '</tr>';
360
      }
361

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

    
364
      if ($hasQuestion) {
365
        $out .= '<td class="nodeNumber"></td>';
366
      }
367
      else {
368
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
369
      }
370

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

    
373
      // Feature.
374
      if ($hasFeature) {
375
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
376
      }
377

    
378
      // Statement.
379
      $out .= $child->statement->label_l10n;
380

    
381
      // --- Links to nodes taxa and subkeys.
382
      $out .= '<div class="nodeLink">';
383

    
384
      // Link to a PolytomousKeyNode.
385
      if ($islinkToNode) {
386
        $out .= '<div class="nodeLinkToNode">';
387
        if (isset($child->modifyingText)) {
388
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
389
        }
390
        $out .= l($child->nodeNumber, request_path(), array(
391
          'attributes' => NULL,
392
          'query' => NULL,
393
          'fragment' => $child->uuid,
394
        )) . '</div>';
395
      }
396

    
397
      // Link to a PolytomousKeyNode.
398
      if ($islinkToOtherNode) {
399
        $out .= '<div class="nodeLinkToOtherNode">';
400
        if (isset($child->modifyingText)) {
401
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
402
        }
403
        $out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], array(
404
          'attributes' => NULL,
405
          'query' => NULL,
406
          'fragment' => $child->otherNode->uuid,
407
        )) . '</div>';
408
      }
409

    
410
      // Link to one or many taxa.
411
      if ($islinkToTaxon || $islinkToManyTaxa) {
412

    
413
        if ($islinkToManyTaxa) {
414
          $taxonChildren = $child->children;
415
        }
416
        else {
417
          $taxonChildren = array(
418
            $child,
419
          );
420
        }
421

    
422
        foreach ($taxonChildren as $taxonChild) {
423
          // TODO many taxa $child->children->taxon.
424
          $out .= '<div class="nodeLinkToTaxon">';
425
          if (isset($taxonChild->modifyingText)) {
426
            $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $taxonChild->modifyingText));
427
          }
428
          $out .= render_taxon_or_name($taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
429
          $out .= '</div>';
430
        }
431

    
432
        // Link to a subkey.
433
        if ($islinkToSubKey) {
434
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', array('identificationKey' => $child->subkey)) . '</div>';
435
        }
436
      }
437

    
438
      $out .= '</div>'; // End node link.
439
      $out .= '</td>'; // End edge.
440
      $out .= '</tr>';
441

    
442
      $childIndex++;
443
    }
444

    
445
    // Recurse into child nodes.
446
    foreach ($polytomousKeyNode->children as &$child) {
447
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
448
    }
449
  }
450

    
451
  return $out;
452
}
453

    
454
/**
455
 * @todo Please document this function.
456
 * @see http://drupal.org/node/1354
457
 */
458
function theme_cdm_poytomousKeyNode_modifyingText($variables) {
459
  $out = '';
460
  $modifyingText = $variables['modifyingText'];
461
  if (is_object($modifyingText)) {
462
    $i = 0;
463
    foreach (get_object_vars($modifyingText) as $lang => $languageString) {
464
      $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">' . $languageString->text . '</span> ';
465
    }
466
  }
467
  return $out;
468
}
469

    
470
/**
471
 * Returns HTML for a list of a specific type of IdentificationKeys.
472
 *
473
 * The list can be restricteded by a taxon.
474
 *
475
 * @param array $variables
476
 *   An associative array containing:
477
 *   - type: The simple name of the cdm class implementing the interface
478
 *     IdentificationKey, valid values are:
479
 *     PolytomousKey, MediaKey, MultiAccessKey
480
 *   - taxonUuid: If given, this parameter restrict the listed keys to those
481
 *     which have the taxon identified be this uuid in scope.
482
 *
483
 * @ingroup themeable
484
 */
485
function theme_cdm_list_IdentificationKeys($variables) {
486
  $type = $variables['type'];
487
  $taxonUuid = $variables['taxonUuid'];
488
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
489
  if (!$keyList || count($keyList) == 0) {
490
    return;
491
  }
492

    
493
  RenderHints::pushToRenderStack('list_IdentificationKeys');
494
  $out = '<ul>';
495
  foreach ($keyList as $key) {
496
    $out .= '<li>';
497
    $out .= theme('cdm_IdentificationKey', array('identificationKey' => $key));
498
    $out .= '</li>';
499
  }
500
  $out .= '</ul>';
501
  $out .= theme("cdm_annotation_footnotes", array('footnoteListKey' => RenderHints::getRenderPath()));
502
  RenderHints::popFromRenderStack();
503

    
504
  return $out;
505
}
506

    
507
/**
508
 * @todo Please document this function.
509
 * @see http://drupal.org/node/1354
510
 */
511
function theme_cdm_block_IdentificationKeys($variables) {
512
  $taxonUuid = $variables['taxonUuid'];
513
  static $types = array(
514
    "PolytomousKey" => "Polytomous",
515
    "MediaKey" => "Media",
516
    "MultiAccessKey" => "Multiaccess",
517
  );
518
  RenderHints::pushToRenderStack('block_IdentificationKeys');
519
  $out = '';
520
  foreach ($types as $type => $label) {
521
    $keylist = theme('cdm_list_IdentificationKeys', array('type' => $type, 'taxonUuid' => $taxonUuid));
522
    if (!$keylist) {
523
      continue;
524
    }
525
    $out .= '<div class="' . $type . '">';
526
    $out .= '<h3>' . t($label) . "</h3>";
527
    $out .= $keylist;
528
    $out .= '</div>';
529
  }
530
  RenderHints::popFromRenderStack();
531
  return $out;
532
}
533

    
534
/**
535
 * This theming function formats the use description and use record list for
536
 * these descriptions.
537
 *
538
 * @see http://drupal.org/node/1354
539
 */
540
function theme_cdm_UseDescription($variables) {
541
  $descriptions = $variables['description'];
542
  $taxonUuid = $variables['taxonUuid'];
543
  $out = '<div id="content"><ul id="Description" class ="description">';
544
  if ($descriptions == NULL) {
545
    return;
546
  }
547

    
548
  $feature_block_settings = get_feature_block_settings(UUID_DISTRIBUTION);
549

    
550
  $descriptionSynonyms = '';
551
  $descriptionOut = '';
552
  $synonymOut = '';
553
  $currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
554

    
555
  foreach ($descriptions as $description) {
556
    $useSummary = '';
557
    foreach ($description->elements as $element) {
558

    
559
      if ($element->feature->uuid == UUID_USE && !(strlen($useSummary) > 0) && isset($element->multilanguageText_L10n)) {
560
        $useSummary = $element->multilanguageText_L10n->text;
561
      }
562
    }
563
    // uses will be ordered by source
564
    foreach ($description->sources as $source) {
565
      $is_about_current_taxon = FALSE;
566
      $originalTaxonUsedInSource = NULL;
567
      $originalTaxonPager = NULL;
568
      if ($source->originalNameString) {
569
        $request_params = array();
570
        $request_params['query'] = $source->originalNameString;
571
        $request_params['matchMode'] = "EXACT";
572
        $originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
573
        if ($originalTaxonPager->count > 0) {
574
          $originalTaxonUsedInSource = $originalTaxonPager->records[0];
575
        }
576
        else {
577
          $originalTaxonUsedInSource = $currentTaxon->name;
578
        }
579
      }
580
      else {
581
        $originalTaxonUsedInSource = $currentTaxon->name;
582
      }
583

    
584
      $is_about_current_taxon = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
585

    
586
      if (!$is_about_current_taxon) {
587
        $descriptionOut .= '<li class="descriptionText DescriptionElement">';
588
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
589
          'absolute' => TRUE,
590
          'html' => TRUE,
591
        ));
592
        $descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
593
        $descriptionOut .= $useSummary;
594
        foreach ($description->sources as $source) {
595
          $descriptionOut .= " (" . theme('cdm_OriginalSource', array(
596
              'source' => $source,
597
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
598
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1)) . ")";
599
        }
600
        $hasUseRecords = FALSE;
601
        $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>';
602
        foreach ($description->elements as $descriptionElement) {
603
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
604
            $hasUseRecords = TRUE;
605
            // FIXME localization hardcoded to English
606
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
607
            $descriptionUseRecordOut .= '<tr>';
608
            $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>';
609
            $descriptionUseRecordOut .= '</tr>';
610
          }
611
        }
612
        $descriptionUseRecordOut .= '</table></div>';
613
        if ($hasUseRecords) {
614
          $descriptionOut .= $descriptionUseRecordOut . '</li>';
615
        }
616
      }
617
      else {
618
        // TODO +/- duplicate of above, unify this code
619
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
620
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
621
          'absolute' => TRUE,
622
          'html' => TRUE,
623
        ));
624

    
625
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
626
        $synonymOut .= $useSummary;
627
        foreach ($description->sources as $source) {
628
          $synonymOut .= " (" . theme('cdm_OriginalSource', array(
629
              'source' => $source,
630
              'doLink' => $feature_block_settings['link_to_reference'] == 1,
631
              'do_link_to_name_used_in_source' => $feature_block_settings['link_to_name_used_in_source'] == 1
632
            )) . ")";
633
        }
634

    
635
        $hasUseRecords = FALSE;
636
        $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>';
637
        foreach ($description->elements as $descriptionElement) {
638
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
639
            $hasUseRecords = TRUE;
640
            $useRecordTags = explode(';', $descriptionElement->modifyingText_l10n);
641
            $useRecordTableOut .= '<tr>';
642
            $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>';
643
            $useRecordTableOut .= '</tr>';
644
          }
645
        }
646
        $useRecordTableOut .= '</table></div>';
647
        if ($hasUseRecords) {
648
          $synonymOut .= $useRecordTableOut . '</li>';
649
        }
650
      }
651

    
652
      // }
653
    }
654
  }
655
  $out .= $descriptionOut . $synonymOut;
656
  $out .= "</ul></div>";
657
  return $out;
658
}
659

    
660

    
661
/**
662
 * The theming function for a block of Uses Descriptions for a given taxon.
663
 *
664
 * The Uses block has been removed from the code but the according theme function
665
 * is kept for compatibility reasons with existing code regarding palmweb.
666
 *
667
 */
668
function theme_cdm_block_Uses($variables) {
669
  $taxonUuid = $variables['taxonUuid'];
670
  RenderHints::pushToRenderStack('block_Uses');
671

    
672
  if ($taxonUuid == NULL) {
673
    return;
674
  }
675
  $out = '';
676
  $markerTypes = array();
677
  $markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
678
  $useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
679
  if (!empty($useDescriptions)) {
680
    // FIXME use theme_block instaed of hardcoding the block html here !!!!
681
    $out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
682
    $formatUseDescriptions = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxonUuid));
683

    
684
    $out .= $formatUseDescriptions;
685
    $out .= "</div>";
686
  }
687

    
688
  return $out;
689
}
(2-2/9)