Project

General

Profile

Revision 23ebb91f

ID23ebb91f5f1ea45fa5b2b27f5a16f371bf53002f
Parent a0f26798
Child 18c71cd1

Added by Andreas Kohlbecker about 3 years ago

ref #7658 fixing final problems in MAN display related to appendedPhrase, citationDetail, footnotes

View differences:

modules/cdm_dataportal/includes/taxon.inc
82 82

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

  
85
          // full name with relation symbol, rel sec as deduplication key
85
          // full name with relation symbol, rel sec as de-dublication key
86 86
          // the sensu part will be removed from the key below in case it is present
87 87
          $symbol_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('symbol')));
88 88
          $name_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('name')));
89
          // remove quotes surrounding the name
90
          $name_text = str_replace('"', '', $name_text);
91
          $name_text = str_replace('"', '', $name_text);
92
          $full_name_key = $name_text . ' ' . cdm_tagged_text_to_string($taxon_relation->taggedText, array('name', 'symbol')) . " " . $symbol_text;
89
          $appended_phrase_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('appendedPhrase')));
93 90

  
94
          // Render the first name found as representative for all others.
95
          //###OLD: $misapplied[$name]['out'] = cdm_related_taxon($taxon_relation->fromTaxon, UUID_MISAPPLIED_NAME_FOR);
91
          $full_name_key = cdm_tagged_text_to_string($taxon_relation->taggedText, array('symbol', 'appendedPhrase'));
92
          $full_name_key = $name_text . ' ' . str_replace($name_text, '', $full_name_key) . ' ' . $symbol_text;
93

  
94
          // remove/extract appendedPhrase, secReference, relSecReference and add placeholders if needed
95
          tagged_text_extract($taxon_relation->taggedText, 'appendedPhrase');
96 96
          $sensu_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "secReference", true);
97 97
          $relsec_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "relSecReference", true);
98 98

  
99

  
100 99
          if (isset($sensu_tagged_text[1])) {
101
            // everything else needs to be equal except for MAN.sec and MAN.secDetail. see #7658#note-21
100
            // for de-dublicationeverything else needs to be equal except for appendedPhrase + MAN.sec + MAN.secDetail. see #7658#note-21
102 101
            $full_name_key = str_replace(cdm_tagged_text_to_string($sensu_tagged_text), ' ', $full_name_key);
103
            array_shift($sensu_tagged_text); // remove first element which contains the "sensu", this will be added later in this code
102
            $appended_phrase_text = $appended_phrase_text . array_shift($sensu_tagged_text)->text; // remove first element which contains the "sensu", this will be added later in this code
103
            $sensu_citation_detail = trim(join(' ', cdm_tagged_text_values($sensu_tagged_text, array('secMicroReference'))));
104 104
            $sensu_citation_short_markup = cdm_tagged_text_to_markup($sensu_tagged_text);
105 105
            $sensu_citation_short = cdm_tagged_text_to_string($sensu_tagged_text);
106 106
            $sensu_uuid = $sensu_tagged_text[0]->entityReference->uuid;
107
            $misapplied[$full_name_key]['sensu_uuids'][] = $sensu_uuid;
108
            if (!isset($joined_refs[$sensu_uuid])) {
109
              $joined_refs[$sensu_uuid] = array(
107
            $full_name_key = preg_replace('/\s+/', ' ', $full_name_key); // sanitize multiple whitespace characters
108
            $misapplied[$full_name_key]['sensu_uuids'][] = array('uuid' => $sensu_uuid, 'prefix' => $appended_phrase_text, 'citation_detail' => $sensu_citation_detail);
109
            $ref_key = $sensu_uuid .($sensu_citation_detail ? '#' . $sensu_citation_detail : '');
110
            if (!isset($joined_refs[$ref_key])) {
111
              $joined_refs[$ref_key] = array(
110 112
                'order_by_key' => $sensu_citation_short,
111 113
                'markup' => $sensu_citation_short_markup // the footnote key will be appended later
112 114
              );
113 115
            }
116
          } else if($appended_phrase_text) {
117
            // appended phrase without reference
118
            $full_name_key = preg_replace('/\s+/', ' ', $full_name_key); // sanitize multiple whitespace characters
119
            $misapplied[$full_name_key]['sensu_uuids'][] = array('uuid' => null, 'prefix' => $appended_phrase_text);
120
          }
114 121

  
115
            if (isset($relsec_tagged_text[1])) {
116
              array_shift($relsec_tagged_text); // remove first element which contains the "err. sec", this will be added later in this code
117
              $relsec_citation_short_markup = cdm_tagged_text_to_markup($relsec_tagged_text);
118
              $relsec_citation_short = cdm_tagged_text_to_string($relsec_tagged_text);
119
              $relsec_uuid = $relsec_tagged_text[0]->entityReference->uuid;
120
              $misapplied[$full_name_key]['relsec_uuids'][] = $relsec_uuid;
121
              if (!isset($joined_refs[$relsec_uuid])) {
122
                $joined_refs[$relsec_uuid] = array(
123
                  'order_by_key' => $relsec_citation_short,
124
                  'markup' => $relsec_citation_short_markup // the footnote key will be appended later
125
                );
126
              }
122
          if (isset($relsec_tagged_text[1])) {
123
            array_shift($relsec_tagged_text); // remove first element which contains the "err. sec", this will be added later in this code
124
            $relsec_citation_detail = trim(join(' ', cdm_tagged_text_values($relsec_tagged_text, array('secMicroReference'))));
125
            $relsec_citation_short_markup = cdm_tagged_text_to_markup($relsec_tagged_text);
126
            $relsec_citation_short = cdm_tagged_text_to_string($relsec_tagged_text);
127
            $relsec_uuid = $relsec_tagged_text[0]->entityReference->uuid;
128
            $misapplied[$full_name_key]['relsec_uuids'][] = $relsec_uuid;
129
            $ref_key = $relsec_uuid . ($relsec_citation_detail ? '#' . $relsec_citation_detail : '');
130
            if (!isset($joined_refs[$ref_key])) {
131
              $joined_refs[$ref_key] = array(
132
                'order_by_key' => $relsec_citation_short,
133
                'markup' => $relsec_citation_short_markup // the footnote key will be appended later
134
              );
127 135
            }
136
          }
128 137

  
129
            if (!isset($misapplied[$full_name_key]['out'])) {
130
              $misapplied[$full_name_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText);
131
            } else {
132
              // We need to add the anchors for all of the other misapplied names not
133
              // being rendered explicitly.
134
              $misapplied[$full_name_key]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$full_name_key]['out']);
135
            }
138
          if (!isset($misapplied[$full_name_key]['out'])) {
139
            $misapplied[$full_name_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText);
136 140
          } else {
137
            RenderHints::pushToRenderStack('other_taxon_relationship');
138
            // All relationship types except misapplied_name_for and invalid_designation_for.
139
            $taxon_relationships_lines[] = cdm_taxonRelationship($taxon_relation, TRUE, _is_invers_taxonRelationship($taxon_relation, $focusedTaxon));
141
            // We need to add the anchors for all of the other misapplied names not
142
            // being rendered explicitly.
143
            $misapplied[$full_name_key]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$full_name_key]['out']);
140 144
          }
141

  
142
          RenderHints::popFromRenderStack();
145
        } else {
146
          RenderHints::pushToRenderStack('other_taxon_relationship');
147
          // All relationship types except misapplied_name_for and invalid_designation_for.
148
          $taxon_relationships_lines[] = cdm_taxonRelationship($taxon_relation, TRUE, _is_invers_taxonRelationship($taxon_relation, $focusedTaxon));
143 149
        }
150
        RenderHints::popFromRenderStack();
144 151
      }
145 152
    } // END loop over $taxonRelationshipsDTO->relations
146 153
  }
......
154 161
  });
155 162

  
156 163

  
157
  foreach ($joined_refs as $sensu_uuid => $sensu_strings) {
158
    $footnote_key = '';
164
  foreach ($joined_refs as $ref_key => $sensu_strings) {
159 165
    if(!empty($sensu_strings)) {
166
      $ref_key_tokens = explode('#', $ref_key);
167
      $sensu_uuid = $ref_key_tokens[0];
160 168
      $sensu_reference = cdm_ws_get(CDM_WS_REFERENCE, $sensu_uuid);
161 169
      if(!$sensu_reference){
162 170
        drupal_set_message("Problem fetching sensu reference with uuid " . $sensu_uuid, 'error');
......
164 172
      if($sensu_strings['order_by_key'] != $sensu_reference->titleCache){
165 173
        $footnote_key = FootnoteManager::addNewFootnote($footnote_list_key, $sensu_reference->titleCache);
166 174
        $footnote_key = theme('cdm_footnote_key', array('footnoteKey' => $footnote_key));
167

  
168
        $joined_refs[$sensu_uuid]['markup'] = '<span class="sensu">' . $sensu_strings['markup'] . $footnote_key . '</span>';
175
        $joined_refs[$ref_key]['markup'] = '<span class="sensu">' . $sensu_strings['markup'] . $footnote_key . '</span>';
169 176
      }
170 177
    }
171 178
  }
172 179

  
173 180
  // ---- Generate output ---- //
174 181
  $out = '<div class="taxon-relationships">';
175
  if (is_array($misapplied) && count($misapplied) > 0) {
182
  if (count($misapplied) > 0) {
176 183
    ksort($misapplied); // order the misapplied by scientific name
177 184
    $out .= '<ul class="misapplied">';
178 185

  
186
    // create the list entries per misapplied name
179 187
    foreach ($misapplied as $misapplied_name) {
180 188
      $misapplied_name_markup = $misapplied_name['out'];
181

  
189
      // all sensu and auct. for this MAN
182 190
      if (isset($misapplied_name['sensu_uuids'])) {
183 191
        $sensu_refs_with_fkey = array();
184
        foreach ($misapplied_name['sensu_uuids'] as $sensu_uuid) {
185
          $sensu_refs_with_fkey[$joined_refs[$sensu_uuid]['order_by_key']] = $joined_refs[$sensu_uuid]['markup'];
192
        foreach ($misapplied_name['sensu_uuids'] as $sensu_data) {
193
          if($sensu_data['uuid']){
194
            $joined_ref_key = $sensu_data['uuid'] . ($sensu_data['citation_detail'] ? '#' .  $sensu_data['citation_detail'] : '');
195
            $sensu_refs_with_fkey[$sensu_data['prefix'] . $joined_refs[$joined_ref_key]['order_by_key']] = $sensu_data['prefix'] . $joined_refs[$joined_ref_key]['markup'];
196
          } else {
197
            $sensu_refs_with_fkey[$sensu_data['prefix']] = $sensu_data['prefix'];
198
          }
186 199
        }
187 200
        ksort($sensu_refs_with_fkey);
188 201
        $sensu_refs_with_fkey_markup = join('; ', $sensu_refs_with_fkey);
189
        $misapplied_name_markup = str_replace('{PLACEHOLDER_secReference}', ' sensu ' . $sensu_refs_with_fkey_markup, $misapplied_name_markup);
202
        $misapplied_name_markup = str_replace('{PLACEHOLDER_secReference}', $sensu_refs_with_fkey_markup, $misapplied_name_markup);
190 203
      }
191 204

  
205
      // append the err. sec. if there is any for this MAN
192 206
      if (isset($misapplied_name['relsec_uuids'])) {
193 207
        $relsec_refs_with_fkey = array();
194 208
        foreach ($misapplied_name['relsec_uuids'] as $relsec_uuid) {
......
198 212
        $relsec_refs_with_fkey_markup = join('; ', $relsec_refs_with_fkey);
199 213
        $misapplied_name_markup = str_replace('{PLACEHOLDER_relSecReference}', ', err. sec. ' . $relsec_refs_with_fkey_markup, $misapplied_name_markup);
200 214
      }
201

  
202
      $out .= '<li class="synonym"><span class="misapplied">' . $misapplied_name_markup . ' </span>';
203
      $out .= '</li>';
215
      // final line
216
      $out .= '<li class="synonym"><span class="misapplied">' . $misapplied_name_markup . ' </span></li>';
204 217
    }
205 218
    $out .= '</ul>';
206 219
  }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)