Revision a9dc4b35
Added by Andreas Kohlbecker about 5 years ago
modules/cdm_dataportal/includes/taxon.inc | ||
---|---|---|
65 | 65 |
|
66 | 66 |
// Aggregate misapplied names having the same fullname: |
67 | 67 |
// - deduplicate misapplied names, so that the same name it not shown multiple times in case it |
68 |
// the duplicates only have different sensu references/author teams (see #5647)
|
|
68 |
// the duplicates only have different sensu references with detail and appended phrase (see #5647)
|
|
69 | 69 |
// - show only the author team as short citation for the sec reference |
70 | 70 |
// - show the according reference as footnote to this short citation |
71 | 71 |
// |
... | ... | |
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 de-dublication key
|
|
85 |
// full name with relation symbol, rel sec as de-duplication key
|
|
86 | 86 |
// the sensu part will be removed from the key below in case it is present |
87 |
$symbol_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('symbol'))); |
|
88 | 87 |
$name_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('name'))); |
89 |
$appended_phrase_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('appendedPhrase'))); |
|
90 |
|
|
91 | 88 |
$full_name_key = cdm_tagged_text_to_string($taxon_relation->taggedText, array('symbol', 'appendedPhrase')); |
89 |
$symbol_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('symbol'))); |
|
92 | 90 |
$full_name_key = $name_text . ' ' . str_replace($name_text, '', $full_name_key) . ' ' . $symbol_text; |
93 | 91 |
|
94 |
// remove/extract appendedPhrase, secReference, relSecReference and add placeholders if needed |
|
95 |
tagged_text_extract($taxon_relation->taggedText, 'appendedPhrase'); |
|
96 |
$sensu_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "secReference", true); |
|
97 |
$relsec_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "relSecReference", true); |
|
98 |
|
|
99 |
if (isset($sensu_tagged_text[1])) { |
|
100 |
// for de-dublicationeverything else needs to be equal except for appendedPhrase + MAN.sec + MAN.secDetail. see #7658#note-21 |
|
101 |
$full_name_key = str_replace(cdm_tagged_text_to_string($sensu_tagged_text), ' ', $full_name_key); |
|
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 |
$sensu_citation_short_markup = cdm_tagged_text_to_markup($sensu_tagged_text); |
|
105 |
$sensu_citation_short = cdm_tagged_text_to_string($sensu_tagged_text); |
|
106 |
$sensu_uuid = $sensu_tagged_text[0]->entityReference->uuid; |
|
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( |
|
112 |
'order_by_key' => $sensu_citation_short, |
|
113 |
'markup' => $sensu_citation_short_markup // the footnote key will be appended later |
|
114 |
); |
|
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 |
} |
|
92 |
cdm_taxonRelationships_process_relationship_dto($taxon_relation, $misapplied, $joined_refs, $full_name_key); |
|
121 | 93 |
|
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 |
); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
if (!isset($misapplied[$full_name_key]['out'])) { |
|
139 |
$misapplied[$full_name_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText); |
|
140 |
} else { |
|
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']); |
|
144 |
} |
|
94 |
RenderHints::popFromRenderStack(); |
|
145 | 95 |
} else { |
146 | 96 |
RenderHints::pushToRenderStack('other_taxon_relationship'); |
147 | 97 |
// All relationship types except misapplied_name_for and invalid_designation_for. |
148 | 98 |
|
149 | 99 |
$taxon_relationships_lines[] = cdm_tagged_text_to_markup($taxon_relation->taggedText); |
100 |
|
|
101 |
RenderHints::popFromRenderStack(); |
|
150 | 102 |
} |
151 |
RenderHints::popFromRenderStack(); |
|
152 | 103 |
} |
153 | 104 |
} // END loop over $taxonRelationshipsDTO->relations |
105 |
|
|
154 | 106 |
} |
155 | 107 |
|
156 | 108 |
// Sort the $joined_refs and create footnotes and footnote keys. |
... | ... | |
206 | 158 |
// append the err. sec. if there is any for this MAN |
207 | 159 |
if (isset($misapplied_name['relsec_uuids'])) { |
208 | 160 |
$relsec_refs_with_fkey = array(); |
209 |
foreach ($misapplied_name['relsec_uuids'] as $relsec_uuid) { |
|
210 |
$relsec_refs_with_fkey[$joined_refs[$relsec_uuid]['order_by_key']] = $joined_refs[$relsec_uuid]['markup']; |
|
161 |
foreach ($misapplied_name['relsec_uuids'] as $relsec_data) { |
|
162 |
if($relsec_data['uuid']) { |
|
163 |
$relsec_refs_with_fkey[$relsec_data['prefix'] . $joined_refs[$relsec_data['uuid']]['order_by_key']] = $relsec_data['prefix'] . $joined_refs[$relsec_data['uuid']]['markup']; |
|
164 |
} |
|
211 | 165 |
} |
212 | 166 |
ksort($relsec_refs_with_fkey); |
213 | 167 |
$relsec_refs_with_fkey_markup = join('; ', $relsec_refs_with_fkey); |
... | ... | |
237 | 191 |
return $out; |
238 | 192 |
} |
239 | 193 |
|
194 |
/** |
|
195 |
* @param $taxon_relation |
|
196 |
* @param $name_dedup_key |
|
197 |
* @param $misapplied |
|
198 |
* @param $joined_refs |
|
199 |
|
|
200 |
*/ |
|
201 |
function cdm_taxonRelationships_process_relationship_dto($taxon_relation, &$misapplied, &$joined_refs, $name_dedup_key = null) { |
|
202 |
$appended_phrase_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('appendedPhrase'))); |
|
203 |
// remove/extract appendedPhrase, secReference, relSecReference and add placeholders if needed |
|
204 |
tagged_text_extract($taxon_relation->taggedText, 'appendedPhrase'); |
|
205 |
$sensu_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "secReference", true); |
|
206 |
$relsec_tagged_text = tagged_text_extract_secref($taxon_relation->taggedText, "relSecReference", true); |
|
207 |
|
|
208 |
if (isset($sensu_tagged_text[1])) { |
|
209 |
// for de-duplication everything else needs to be equal except for appendedPhrase + MAN.sec + MAN.secDetail. see #7658#note-21 |
|
210 |
$name_dedup_key = str_replace(cdm_tagged_text_to_string($sensu_tagged_text), ' ', $name_dedup_key); |
|
211 |
$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 |
|
212 |
$sensu_citation_detail = trim(join(' ', cdm_tagged_text_values($sensu_tagged_text, array('secMicroReference')))); |
|
213 |
$sensu_citation_short_markup = cdm_tagged_text_to_markup($sensu_tagged_text); |
|
214 |
$sensu_citation_short = cdm_tagged_text_to_string($sensu_tagged_text); |
|
215 |
$sensu_uuid = $sensu_tagged_text[0]->entityReference->uuid; |
|
216 |
$name_dedup_key = preg_replace('/\s+/', ' ', $name_dedup_key); // sanitize multiple whitespace characters |
|
217 |
$misapplied[$name_dedup_key]['sensu_uuids'][] = array('uuid' => $sensu_uuid, 'prefix' => $appended_phrase_text, 'citation_detail' => $sensu_citation_detail); |
|
218 |
$ref_key = $sensu_uuid . ($sensu_citation_detail ? '#' . $sensu_citation_detail : ''); |
|
219 |
if (!isset($joined_refs[$ref_key])) { |
|
220 |
$joined_refs[$ref_key] = array( |
|
221 |
'order_by_key' => $sensu_citation_short, |
|
222 |
'markup' => $sensu_citation_short_markup // the footnote key will be appended later |
|
223 |
); |
|
224 |
} |
|
225 |
} else if ($appended_phrase_text) { |
|
226 |
// appended phrase without reference |
|
227 |
$name_dedup_key = preg_replace('/\s+/', ' ', $name_dedup_key); // sanitize multiple whitespace characters |
|
228 |
$misapplied[$name_dedup_key]['sensu_uuids'][] = array('uuid' => null, 'prefix' => $appended_phrase_text); |
|
229 |
} |
|
230 |
|
|
231 |
if (isset($relsec_tagged_text[1])) { |
|
232 |
$appended_phrase_text = array_shift($relsec_tagged_text)->text; // remove first element which contains the "err. sec", this will be added later in this code |
|
233 |
$relsec_citation_detail = trim(join(' ', cdm_tagged_text_values($relsec_tagged_text, array('secMicroReference')))); |
|
234 |
$relsec_citation_short_markup = cdm_tagged_text_to_markup($relsec_tagged_text); |
|
235 |
$relsec_citation_short = cdm_tagged_text_to_string($relsec_tagged_text); |
|
236 |
$relsec_uuid = $relsec_tagged_text[0]->entityReference->uuid; |
|
237 |
$misapplied[$name_dedup_key]['relsec_uuids'][] = array('uuid' => $relsec_uuid, 'prefix' => $appended_phrase_text, 'citation_detail' => $relsec_citation_detail);; |
|
238 |
$ref_key = $relsec_uuid . ($relsec_citation_detail ? '#' . $relsec_citation_detail : ''); |
|
239 |
if (!isset($joined_refs[$ref_key])) { |
|
240 |
$joined_refs[$ref_key] = array( |
|
241 |
'order_by_key' => $relsec_citation_short, |
|
242 |
'markup' => $relsec_citation_short_markup // the footnote key will be appended later |
|
243 |
); |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
if (!isset($misapplied[$name_dedup_key]['out'])) { |
|
248 |
$misapplied[$name_dedup_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText); |
|
249 |
} else { |
|
250 |
// We need to add the anchors for all of the other misapplied names not |
|
251 |
// being rendered explicitly. |
|
252 |
$misapplied[$name_dedup_key]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$name_dedup_key]['out']); |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
240 | 256 |
/** |
241 | 257 |
* Renders a representation of the given taxon relationship. |
242 | 258 |
* |
Also available in: Unified diff
ref #7658 other relationship reprentation based on DTOs fully implemented