Project

General

Profile

« Previous | Next » 

Revision f5e7f68e

Added by Andreas Kohlbecker over 5 years ago

ref #7977 display of specimen type designations and stableURIs

View differences:

modules/cdm_dataportal/cdm_api/webservice_uris.php
18 18
define('CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS', 'portal/name/$0/typeDesignations');
19 19
define('CDM_WS_PORTAL_NAME_NAME_RELATIONS', 'portal/name/$0/nameRelations');
20 20

  
21
define('CDM_TYPEDESIGNATION', 'typedesignation/$0');
22

  
21 23
define('CDM_WS_TAXON', 'taxon');
22 24
define('CDM_WS_TAXON_CLASSIFICATIONS', 'taxon/$0/classifications');
23 25
define('CDM_WS_TAXON_FINDBY_DESCRIPTIONELEMENT_FULLTEXT', 'taxon/findByDescriptionElementFullText');
modules/cdm_dataportal/cdm_dataportal.module
2039 2039
    }
2040 2040
    if(is_object($registration_dto->orderdTypeDesignationWorkingSets)) {
2041 2041
      $field_unit_uuids = array();
2042
      $specimen_type_designation_refs = array();
2042 2043
      $name_type_designation_refs = array();
2043 2044
      foreach ((array)$registration_dto->orderdTypeDesignationWorkingSets as $field_unit_ref => $obj) {
2044 2045
        $tokens = explode("#", $field_unit_ref);
2046
        foreach ($obj as $type_status => $entity_reference_list) {
2047
          // NOTE: there is always only one element, since we use the foreach to extract the objects field name and value
2048
          $entity_reference = $entity_reference_list[0];
2049
        }
2045 2050
        if ($tokens[0] == 'NameTypeDesignation') {
2046
          foreach ($obj as $type_status => $entity_reference) {
2047
            // NOTE: there is always only one element, since we use the foreach to extract the field name an value
2048
            $name_type_designation_refs[$type_status] = $entity_reference[0];
2051
          foreach ($obj as $type_status => $entity_reference_list) {
2052
            $name_type_designation_refs[$type_status] = $entity_reference;
2049 2053
          }
2050
        } else {
2054
        } else if ($tokens[0] == 'FieldUnit'){
2051 2055
          $field_unit_uuids[] = $tokens[1];
2056
          $specimen_type_designation_refs[$type_status] = $entity_reference;
2057
        } else {
2058
          drupal_set_message("Unimplemented type: " . $tokens[0], 'error');
2052 2059
        }
2053 2060
      }
2054 2061
      if (count($name_type_designation_refs) > 0) {
......
2058 2065
        $render_array['name_type_designations']['#weight'] = 22;
2059 2066
      }
2060 2067
      if (count($field_unit_uuids) > 0) {
2061
        $render_array['specimen_table'] = compose_specimen_table($field_unit_uuids);
2068
        $render_array['specimen_type_designations'] = compose_specimen_type_designations($specimen_type_designation_refs);
2069
        // $render_array['specimen_table'] = compose_specimen_table($field_unit_uuids);
2062 2070
        // below citation (weight=20)
2063 2071
        $render_array['specimen_table']['#weight'] = 30;
2064 2072
      }
modules/cdm_dataportal/includes/name.inc
569 569
/**
570 570
 * Composes the TypedEntityReference to name type designations passed as associatve array.
571 571
 *
572
 * @param $name_type_designations array
572
 * @param $$type_entity_refs array
573 573
 *   an associative array of name type type => TypedEntityReference for name type designations as
574 574
 *   produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager
575 575
 *
......
578 578
function compose_name_type_designations($type_entity_refs){
579 579
  $render_array = array();
580 580
  foreach($type_entity_refs as $type_status => $name_type){
581
    $render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type)  . '"><span class="type_status">'. ucfirst($type_status) . "</span>: " . $name_type->label . '</div>');
581
    $type_designation = cdm_ws_get(CDM_TYPEDESIGNATION, array($name_type->uuid, 'preferredUri'));
582
    if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){
583
      $preferredStableUri = $type_designation->typeSpecimen->preferredStableUri;
584
    }
585
    $render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type)  . '"><span class="type_status">'. ucfirst($type_status) . "</span>: "
586
      . $name_type->label
587
      . ($preferredStableUri ? " ". l($preferredStableUri,  $preferredStableUri) : '')
588
      . '</div>');
589
  }
590
  return $render_array;
591
}
592

  
593
/**
594
 * Composes the TypedEntityReference to specimen type designations passed as associatve array.
595
 *
596
 * @param $type_entity_refs array
597
 *   an associative array of specimen type type => TypedEntityReference for specimen type designations as
598
 *   produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager
599
 *
600
 * @ingroup compose
601
 */
602
function compose_specimen_type_designations($type_entity_refs){
603
  $render_array = array();
604
  foreach($type_entity_refs as $type_status => $specimen_type){
605
    $type_designation = cdm_ws_get(CDM_TYPEDESIGNATION, array($specimen_type->uuid));
606
    $preferredStableUri = '';
607
    if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){
608
      $preferredStableUri = $type_designation->typeSpecimen->preferredStableUri;
609
    }
610
    $render_array[] = markup_to_render_array('<div class="specimen_type_designation ' . html_class_attribute_ref($specimen_type)  . '"><span class="type_status">'
611
      . ucfirst($type_status)
612
      . "</span>: "
613
      . $specimen_type->label
614
      . ($preferredStableUri ? " ". l($preferredStableUri,  $preferredStableUri) : '')
615
      . '</div>');
582 616
  }
583 617
  return $render_array;
584 618
}

Also available in: Unified diff