Project

General

Profile

« Previous | Next » 

Revision 3c088da3

Added by Andreas Kohlbecker over 5 years ago

ref #7884 ref #7890 fixining some problems in name relations rendering

View differences:

modules/cdm_dataportal/includes/name.inc
571 571
 * @param $name_relations
572 572
 *    The list of CDM NameRelationsips
573 573
 * @param $current_name_uuid
574
 *    The Uuid of the name for which the relations are to be rendered
574
 *    The Uuid of the name for which the relations are to be rendered, the current name will be hidden when
575
 *    rendering the relation an only the other name is shown. Parameter is REQUIRED.
576
 * @param $suppress_if_current_name_is_source
577
 *    The display of the relation will be
578
 *    suppressed is the current name is on the source of the relation edge.
579
 *    That is if it is on the from side of the relation. Except for 'blocking name for' which is
580
 *    an inverse relation. For this relation type the toName is taken in to account.
575 581
 * @param $current_taxon_uuid
576 582
 *    The taxon to be omitted from related taxa. This is only used to create links, see path_to_name()
577 583
 * @return String
578 584
 *    The markup for the name relationships
579 585
 */
580
function render_name_relationships_of($name_relations, $current_name_uuid, $current_taxon_uuid) {
586
function render_name_relationships_of($name_relations, $current_name_uuid, $current_taxon_uuid, $suppress_if_current_name_is_source = true) {
581 587

  
582 588
  static $inverse_name_rels_uuids = array(UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR);
583 589

  
......
590 596

  
591 597
  if ($name_relations) {
592 598
    foreach ($name_relations as $name_rel) {
593
      if(!(isset($selected_name_rel_uuids[$name_rel->type->uuid]) && $selected_name_rel_uuids[$name_rel->type->uuid])){
599
      if (!(isset($selected_name_rel_uuids[$name_rel->type->uuid]) && $selected_name_rel_uuids[$name_rel->type->uuid])) {
594 600
        // skip if not selected in the settings
595 601
        continue;
596 602
      }
603
      $is_inverse_relation = array_search($name_rel->type->uuid, $inverse_name_rels_uuids) !== false;
604
      $is_current_name_to_name = $current_name_uuid == $name_rel->toName->uuid;
605
      $is_current_name_from_name = $current_name_uuid == $name_rel->fromName->uuid;
597 606
      $relationship_markup = null;
598
      if(array_search($name_rel->type->uuid, $inverse_name_rels_uuids) !== false) {
599
        // case of UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR
600
        //to relation ships -> only shown at toName-synonym
601
        $highlited_synonym_uuid = isset ($name_rel->fromName->taxonBases[0]->uuid) ? $name_rel->fromName->taxonBases[0]->uuid : '';
602
        if (true|| $current_name_uuid == $name_rel->toName->uuid) {
603
          $relationship_markup = render_taxon_or_name($name_rel->fromName,
604
            url(path_to_name($name_rel->fromName->uuid, $current_taxon_uuid, $highlited_synonym_uuid))
605
          );
606
        }
607 607

  
608
      } else {
608
      if($is_current_name_to_name && ($suppress_if_current_name_is_source && $is_inverse_relation || !$suppress_if_current_name_is_source)){
609
        $highlited_synonym_uuid = isset ($name_rel->fromName->taxonBases[0]->uuid) ? $name_rel->fromName->taxonBases[0]->uuid : '';
610
        $relationship_markup = render_taxon_or_name($name_rel->fromName,
611
          url(path_to_name($name_rel->fromName->uuid, $current_taxon_uuid, $highlited_synonym_uuid))
612
        );
613
      } else if($is_current_name_from_name && ($suppress_if_current_name_is_source && !$is_inverse_relation || !$suppress_if_current_name_is_source)){
609 614
        $highlited_synonym_uuid = isset ($name_rel->toName->taxonBases[0]->uuid) ? $name_rel->toName->taxonBases[0]->uuid : '';
610
        //from relation ships -> only shown at fromName-synonym
611
        if (true ||$current_name_uuid == $name_rel->fromName->uuid) {
612
          $relationship_markup = render_taxon_or_name($name_rel->toName,
613
            url(path_to_name($name_rel->toName->uuid, $current_taxon_uuid, $highlited_synonym_uuid))
614
          );
615
        }
615
        $relationship_markup = render_taxon_or_name($name_rel->toName,
616
          url(path_to_name($name_rel->toName->uuid, $current_taxon_uuid, $highlited_synonym_uuid))
617
        );
616 618
      }
617

  
619
        
618 620
      if($relationship_markup){
619 621
        if (count($relations_array)) {
620 622
          // lat: "non nec" == german: "weder noch"

Also available in: Unified diff