Revision 5c750190
Added by Andreas Kohlbecker about 4 years ago
modules/cdm_dataportal/includes/taxon.inc | ||
---|---|---|
50 | 50 |
*/ |
51 | 51 |
function cdm_taxonRelationships($taxonRelationshipsDTO, $focusedTaxon){ |
52 | 52 |
|
53 |
static $relationship_type_order_weights = [ |
|
54 |
// |
|
55 |
UUID_PROPARTE_MISAPPLIEDNAME_FOR => 0, |
|
56 |
UUID_PARTIAL_MISAPPLIEDNAME_FOR => 0, |
|
57 |
// |
|
58 |
UUID_INVALID_DESIGNATION_FOR => 1, |
|
59 |
// |
|
60 |
UUID_MISAPPLIED_NAME_FOR => 2, |
|
61 |
// |
|
62 |
UUID_PROPARTE_SYNONYM_FOR => 3, |
|
63 |
UUID_PARTIAL_SYNONYM_FOR => 3 |
|
64 |
]; |
|
65 |
|
|
53 | 66 |
if (!$taxonRelationshipsDTO || $taxonRelationshipsDTO->size < 1) { |
54 | 67 |
return null; |
55 | 68 |
} |
... | ... | |
96 | 109 |
$symbol_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('symbol'))); |
97 | 110 |
$full_name_key = $name_text . ' ' . str_replace($name_text, '', $full_name_key) . ' ' . $symbol_text; |
98 | 111 |
|
99 |
cdm_taxonRelationships_process_relationship_dto($taxon_relation, $misapplied, $joined_refs, $full_name_key); |
|
112 |
cdm_taxonRelationships_process_relationship_dto($taxon_relation, $misapplied, $joined_refs, $relationship_type_order_weights , $full_name_key);
|
|
100 | 113 |
|
101 | 114 |
RenderHints::popFromRenderStack(); |
102 | 115 |
} else { |
... | ... | |
212 | 225 |
|
213 | 226 |
/** |
214 | 227 |
* @param $taxon_relation |
215 |
* @param $name_dedup_key |
|
216 | 228 |
* @param $misapplied |
217 | 229 |
* @param $joined_refs |
218 |
|
|
230 |
* @param $relationship_type_weights |
|
231 |
* @param $name_dedup_key |
|
219 | 232 |
*/ |
220 |
function cdm_taxonRelationships_process_relationship_dto($taxon_relation, &$misapplied, &$joined_refs, $name_dedup_key = null) { |
|
233 |
function cdm_taxonRelationships_process_relationship_dto($taxon_relation, &$misapplied, &$joined_refs, $relationship_type_weights, $name_dedup_key) { |
|
234 |
|
|
221 | 235 |
$appended_phrase_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('appendedPhrase'))); |
222 | 236 |
// remove/extract appendedPhrase, secReference, relSecReference and add placeholders if needed |
223 | 237 |
tagged_text_extract($taxon_relation->taggedText, 'appendedPhrase', true); |
224 | 238 |
$sensu_tagged_text = tagged_text_extract_reference_and_detail($taxon_relation->taggedText, "secReference", true); |
225 | 239 |
$relsec_tagged_text = tagged_text_extract_reference_and_detail($taxon_relation->taggedText, "relSecReference", true); |
226 | 240 |
|
241 |
// prepend the weight value for the relationship type to the $name_dedup_key so that the key can be used for ordering the |
|
242 |
// entries in the $misapplied array |
|
243 |
if(isset($relationship_type_weights[$taxon_relation->type->uuid])){ |
|
244 |
$reltype_weight = $relationship_type_weights[$taxon_relation->type->uuid]; |
|
245 |
} else { |
|
246 |
$reltype_weight = 99; |
|
247 |
} |
|
248 |
$name_dedup_key = str_pad( $reltype_weight, 2, '0', STR_PAD_LEFT) . '-' . $name_dedup_key; |
|
249 |
|
|
227 | 250 |
if (isset($sensu_tagged_text[1])) { |
228 | 251 |
// for de-duplication everything else needs to be equal except for appendedPhrase + MAN.sec + MAN.secDetail. see #7658#note-21 |
229 | 252 |
$name_dedup_key = str_replace(cdm_tagged_text_to_string($sensu_tagged_text), ' ', $name_dedup_key); |
... | ... | |
264 | 287 |
} |
265 | 288 |
|
266 | 289 |
if (!isset($misapplied[$name_dedup_key]['out'])) { |
290 |
// helpful for debugging: // cdm_tagged_text_add_options($taxon_relation->taggedText, array(array('filter-type' => 'symbol', 'attributes' => array('title' => array($taxon_relation->type->representations[0]->label))))); |
|
267 | 291 |
$misapplied[$name_dedup_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText); |
268 | 292 |
} else { |
269 | 293 |
// We need to add the anchors for all of the other misapplied names not |
270 | 294 |
// being rendered explicitly. |
271 | 295 |
$misapplied[$name_dedup_key]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$name_dedup_key]['out']); |
272 | 296 |
} |
297 |
|
|
273 | 298 |
} |
274 | 299 |
|
275 | 300 |
/** |
Also available in: Unified diff
ref #7766 order taxon relationships by type and scientific name, adapting tests