Project

General

Profile

« Previous | Next » 

Revision cb993828

Added by Andreas Kohlbecker over 2 years ago

ref #9811 switching in search results to portal/taxon/{uuid}/taxonRelationshipsDTO and adapting code

View differences:

modules/cdm_dataportal/cdm_dataportal.module
2742 2742
    $taxon_nodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, $taxon->uuid);
2743 2743
  }
2744 2744

  
2745
  $taxon_node_classification_uuids = [];
2745 2746
  if ($taxon->class == "Taxon" && isset($taxon_nodes)) {
2746 2747
    foreach ($taxon_nodes as $node) {
2747 2748
      if($node->class == 'TaxonNodeDto' && isset($node->classificationUUID)){
2748 2749
        // case of TaxonNodeDto
2749
        return $node->classificationUUID == $default_classification_uuid;
2750
        $taxon_node_classification_uuids[] = $node->classificationUUID;
2750 2751
      } else if($node->class == 'TaxonNode' && isset($node->classification->uuid)) {
2751
         return $node->classification->uuid == $default_classification_uuid;
2752
        $taxon_node_classification_uuids[] =  $node->classification->uuid;
2752 2753
      }
2753 2754
    }
2754 2755
  }
2755
  return FALSE;
2756
  return _cdm_dataportal_matches_current_view($taxon_node_classification_uuids);
2757
}
2758

  
2759
/**
2760
 * Check if one uuid in the given set matches the current classification uuid.
2761
 *
2762
 * @param array $taxon_node_classification_uuids
2763
 *   A list of classification uuids.
2764
 * @return bool
2765
 */
2766
function _cdm_dataportal_matches_current_view($taxon_node_classification_uuids) {
2767

  
2768
  $default_classification_uuid = get_current_classification_uuid();
2769
  return array_search($default_classification_uuid, $taxon_node_classification_uuids) !== false;
2756 2770
}
2757 2771

  
2758 2772
/**
modules/cdm_dataportal/includes/taxon.inc
443 443
 * @param $show_classification boolean
444 444
 *
445 445
 * @ingroup compose
446
 *
447 446
 */
448 447
function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $show_classification = false) {
449 448

  
......
480 479
  // thus ...
481 480
  $table_of_accepted = array();
482 481

  
483
  foreach ($synonym_uuids as $relatedUuid) {
482
  foreach ($synonym_uuids as $misapplication_uuid) {
484 483
    $classification_filter = '';
485 484
    if($searched_in_classification_uuid){
486 485
      $classification_filter = 'classificationFilter=' . $searched_in_classification_uuid;
487 486
    }
488
    $table_of_accepted[$relatedUuid] = cdm_ws_get(
487
    $table_of_accepted[$misapplication_uuid] = cdm_ws_get(
489 488
      CDM_WS_PORTAL_TAXON_ACCEPTED,
490
      array($relatedUuid),
489
      array($misapplication_uuid),
491 490
      $classification_filter
492 491
    );
493 492
  }
494 493

  
495
  foreach ($misapplied_uuids as $relatedUuid) {
496
    $taxonRelations = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, array(
497
      $relatedUuid,
494
  foreach ($misapplied_uuids as $mispplication_uuid) {
495
    $taxonRelationsDTO = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS_DTO, array(
496
      $mispplication_uuid,
498 497
    ));
499
    if($taxonRelations){
500
      foreach ($taxonRelations as $relation) {
501
        if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_acceptedByCurrentView($relation->toTaxon)) {
502
          $table_of_accepted[$relatedUuid][] = $relation->toTaxon;
498
    if(isset($taxonRelationsDTO->relations)){
499
      foreach ($taxonRelationsDTO->relations as $relation) {
500
        if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_matches_current_view($relation->classificationsUUIDs)) {
501
          $table_of_accepted[$mispplication_uuid][] = cdm_ws_get(CDM_WS_TAXON, $relation->taxonUuid);
503 502
        }
504 503
      }
505 504
    }
......
533 532
          // $taxon_or_name this is a trick to suppress the sec reference for synonyms
534 533
          // supplying the name will cause render_taxon_or_name() to not show the sec reference
535 534
          $out .= "<div class=\"item " . $taxon_type . "\">" . render_taxon_or_name($taxon, $taxonUri, $referenceUri, true, false, $skip_render_template_parts);
536
          if($taxon_type == TAXON_TYPE_MISAPPLIEDNAME && isset_not_empty($taxon->secSource->citation)){
537
            if(isset($taxon->secSource->citation->authorship)){
535
          if($taxon_type == TAXON_TYPE_MISAPPLIEDNAME && isset_not_empty($taxon->secSource) && isset_not_empty($taxon->secSource->citation)) {
536
            if (isset($taxon->secSource->citation->authorship)) {
538 537
              $authorship = $taxon->secSource->citation->authorship->titleCache;
539
            } else {
538
            }
539
            else {
540 540
              $authorship = $taxon->secSource->citation->titleCache;
541 541
            }
542
            $out .=  ' sensu ' . $authorship;
542
            $out .= ' sensu ' . $authorship;
543 543
          }
544 544
          if ($show_classification) {
545 545
            $out .= render_classifications_for_taxon($taxon);

Also available in: Unified diff