Project

General

Profile

« Previous | Next » 

Revision 116fb348

Added by Andreas Kohlbecker over 5 years ago

ref #7658 work in progress with errors

View differences:

modules/cdm_dataportal/includes/taxon.inc
39 39
 *
40 40
 * Both relation types are currently treated the same!
41 41
 *
42
 * @param taxonRelationships
43
 * @param focusedTaxon
42
 * @param object taxonRelationships
43
 *   A TaxonRelationshipsDTO, see taxon/{uuid}/taxonRelationshipsDTO
44
 *
45
 * @param object focusedTaxon
46
 *  The taxon being in the focus of the applicaton
44 47
 *
45 48
 * @return string
46 49
 *    the rendered html
47 50
 */
48
function cdm_taxonRelationships($taxonRelationships, $focusedTaxon){
51
function cdm_taxonRelationships($taxonRelationshipsDTO, $focusedTaxon){
49 52

  
50 53
  static $NULL_AUTHORTEAM = 'NULL_AUTHORTEAM';
51 54

  
52
  if (!$taxonRelationships) {
55
  if (!$taxonRelationshipsDTO || $taxonRelationshipsDTO->size < 1) {
53 56
    return null;
54 57
  }
55 58

  
......
60 63
  $misapplied = array();
61 64
  $joinedAuthorTeams = array();
62 65

  
63
  $taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
64 66

  
65 67
  // Aggregate misapplied names having the same fullname:
66 68
  //  - deduplicate misapplied names, so that the same name it not shown multiple times in case it
......
73 75
  // "Xenoxylum foobar" sensu Grumbach¹; sensu Lem²
74 76
  //    1. Novel marsian species, Grumbach, 2022
75 77
  //    2. Flora solaris, Lem, 2019
76
  foreach ($taxonRelationships as $taxonRelation) {
78
  if (is_array($taxonRelationshipsDTO->misapplications) && count($taxonRelationshipsDTO->misapplications) > 0 ) {
79
    for ($taxonRelationshipsDTO->misapplications as $misapplication_tagged_title){
77 80

  
78
    if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
81
      if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
79 82

  
80
      if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
83
        if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) {
81 84

  
82
        RenderHints::pushToRenderStack('misapplied_name_for'); // TODO the render path string should in future come from $taxonRelation->type->...
85
          RenderHints::pushToRenderStack('misapplied_name_for'); // TODO the render path string should in future come from $taxonRelation->type->...
83 86

  
84
        $name = $taxonRelation->fromTaxon->name->titleCache;
87
          $name = $taxonRelation->fromTaxon->name->titleCache;
85 88

  
86
        $sensu_citation_footnote_str = null;
89
          $sensu_citation_footnote_str = null;
87 90

  
88
        if(isset($taxonRelation->fromTaxon->sec)) {
91
          if (isset($taxonRelation->fromTaxon->sec)) {
89 92

  
90
          $sensu_citation_footnote_str = theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
91
          $authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
93
            $sensu_citation_footnote_str = theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
94
            $authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
92 95

  
93
          if(isset($authorteam->titleCache)){
94
            $authorteam_str = $authorteam->titleCache;
95
            if($taxonRelation->fromTaxon->sec->titleCache == $authorteam->titleCache){
96
              // no need for a footnote in case the reference only consists of the author team
96
            if (isset($authorteam->titleCache)) {
97
              $authorteam_str = $authorteam->titleCache;
98
              if ($taxonRelation->fromTaxon->sec->titleCache == $authorteam->titleCache) {
99
                // no need for a footnote in case the reference only consists of the author team
100
                $sensu_citation_footnote_str = '';
101
              }
102
            } else {
103
              $authorteam_str = $sensu_citation_footnote_str;
104
              // no need for a footnote in case in case it is used as replacement for missing author teams
97 105
              $sensu_citation_footnote_str = '';
98 106
            }
99 107
          } else {
100
            $authorteam_str = $sensu_citation_footnote_str;
101
            // no need for a footnote in case in case it is used as replacement for missing author teams
102
            $sensu_citation_footnote_str = '';
108
            // taxa not always are have a sec reference (e.g. doubtful taxa)
109
            // use the NULL_AUTHORTEAM in this case
110
            $authorteam_str = $NULL_AUTHORTEAM;
103 111
          }
104
        } else {
105
          // taxa not always are have a sec reference (e.g. doubtful taxa)
106
          // use the NULL_AUTHORTEAM in this case
107
          $authorteam_str = $NULL_AUTHORTEAM;
108
        }
109 112

  
110
        if (!isset($misapplied[$name])) {
111
          // Render the first name found as representative for all others.
112
          $misapplied[$name]['out'] = cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
113
        }
114
        else {
115
          // We need to add the anchors for all of the other misapplied names not
116
          // being rendered explicitly.
117
          $misapplied[$name]['out'] = uuid_anchor($taxonRelation->fromTaxon->uuid, $misapplied[$name]['out']);
118
        }
113
          if (!isset($misapplied[$name])) {
114
            // Render the first name found as representative for all others.
115
            $misapplied[$name]['out'] = cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
116
          } else {
117
            // We need to add the anchors for all of the other misapplied names not
118
            // being rendered explicitly.
119
            $misapplied[$name]['out'] = uuid_anchor($taxonRelation->fromTaxon->uuid, $misapplied[$name]['out']);
120
          }
119 121

  
120
        // Collect all authors for this fullname.
121
        if (isset($authorteam_str) && $authorteam_str != $NULL_AUTHORTEAM) {
122
          // prepare entry for the footnote key of the sensu citation footnote
123
          $misapplied[$name]['authorteam'][$authorteam_str] = '';
124
          // map sensu citation footnote to the authorteam string
125
          $joinedAuthorTeams[$authorteam_str] = $sensu_citation_footnote_str;
122
          // Collect all authors for this fullname.
123
          if (isset($authorteam_str) && $authorteam_str != $NULL_AUTHORTEAM) {
124
            // prepare entry for the footnote key of the sensu citation footnote
125
            $misapplied[$name]['authorteam'][$authorteam_str] = '';
126
            // map sensu citation footnote to the authorteam string
127
            $joinedAuthorTeams[$authorteam_str] = $sensu_citation_footnote_str;
128

  
129
          }
126 130

  
131
        } else {
132
          RenderHints::pushToRenderStack('other_taxon_relationship');
133
          // All relationsship types but misapplied_name_for
134
          // invalid_designation_for.
135
          $taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon));
127 136
        }
128 137

  
138
        RenderHints::popFromRenderStack();
129 139
      }
130
      else {
131
        RenderHints::pushToRenderStack('other_taxon_relationship');
132
        // All relationsship types but misapplied_name_for
133
        // invalid_designation_for.
134
        $taxon_relationships_lines[] = cdm_taxonRelationship($taxonRelation, TRUE, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon));
135
      }
136

  
137
      RenderHints::popFromRenderStack();
138 140
    }
139 141
  }
140 142

  

Also available in: Unified diff