Revision 763b610c
Added by Andreas Kohlbecker over 7 years ago
modules/cdm_dataportal/includes/taxon.inc | ||
---|---|---|
61 | 61 |
$taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)); |
62 | 62 |
|
63 | 63 |
// Aggregate misapplied names having the same fullname: |
64 |
// - deduplicate misapplied names, so that the same name it not shown multiple times in case it |
|
65 |
// the duplicates only have different sensu references/author teams (see #5647) |
|
66 |
// - show the author team as sec reference |
|
67 |
// - show the according reference as footnote to this author team |
|
68 |
// - if the sec reference has no author team it should show instead the title cache |
|
69 |
// |
|
70 |
// Example: |
|
71 |
// "Xenoxylum foobar" sensu Grumbach¹; sensu Lem² |
|
72 |
// 1. Novel marsian species, Grumbach, 2022 |
|
73 |
// 2. Flora solaris, Lem, 2019 |
|
64 | 74 |
foreach ($taxonRelationships as $taxonRelation) { |
65 | 75 |
|
66 | 76 |
if (in_array($taxonRelation->type->uuid, $taxon_relationship_types)) { |
67 | 77 |
|
68 |
|
|
69 | 78 |
if ($taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR) { |
70 | 79 |
|
71 | 80 |
RenderHints::pushToRenderStack('misapplied_name_for'); // TODO the render path string should in future come from $taxonRelation->type->... |
72 | 81 |
|
73 | 82 |
$name = $taxonRelation->fromTaxon->name->titleCache; |
74 | 83 |
|
75 |
$authorteam = $NULL_AUTHORTEAM; |
|
84 |
$sensu_citation_footnote_str = null; |
|
85 |
|
|
76 | 86 |
if(isset($taxonRelation->fromTaxon->sec)) { |
77 |
// taxa not always are have a sec reference (e.g. doubtful taxa)
|
|
87 |
$sensu_citation_footnote_str = theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec));
|
|
78 | 88 |
$authorteam = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid); |
79 |
$authorteam = $authorteam->titleCache; |
|
89 |
|
|
90 |
if(isset($authorteam->titleCache)){ |
|
91 |
$authorteam_str = $authorteam->titleCache; |
|
92 |
if($taxonRelation->fromTaxon->sec->titleCache == $authorteam->titleCache){ |
|
93 |
// no need for a footnote in case the reference only consists of the author team |
|
94 |
$sensu_citation_footnote_str = ''; |
|
95 |
} |
|
96 |
} else { |
|
97 |
$authorteam_str = $sensu_citation_footnote_str; |
|
98 |
// no need for a footnote in case in case it is used as replacement for missing author teams |
|
99 |
$sensu_citation_footnote_str = ''; |
|
100 |
} |
|
101 |
} else { |
|
102 |
// taxa not always are have a sec reference (e.g. doubtful taxa) |
|
103 |
// use the NULL_AUTHORTEAM in this case |
|
104 |
$authorteam_str = $NULL_AUTHORTEAM; |
|
80 | 105 |
} |
81 | 106 |
|
82 | 107 |
if (!isset($misapplied[$name])) { |
... | ... | |
90 | 115 |
} |
91 | 116 |
|
92 | 117 |
// Collect all authors for this fullname. |
93 |
if (isset($authorteam) && $authorteam != $NULL_AUTHORTEAM) { |
|
94 |
$misapplied[$name]['authorteam'][$authorteam] = ''; |
|
95 |
$joinedAuthorTeams[$authorteam] = 'sensu ' . theme('cdm_reference', array('reference' => $taxonRelation->fromTaxon->sec)); |
|
118 |
if (isset($authorteam_str) && $authorteam_str != $NULL_AUTHORTEAM) { |
|
119 |
// prepare entry for the footnote key of the sensu citation footnote |
|
120 |
$misapplied[$name]['authorteam'][$authorteam_str] = ''; |
|
121 |
// map sensu citation footnote to the authorteam string |
|
122 |
$joinedAuthorTeams[$authorteam_str] = $sensu_citation_footnote_str; |
|
123 |
|
|
96 | 124 |
} |
97 | 125 |
|
98 | 126 |
} |
... | ... | |
110 | 138 |
// Sort the joinedAuthorTeams and create footnotes and footnotekeys. |
111 | 139 |
ksort($joinedAuthorTeams); |
112 | 140 |
$author_team_cnt = 0; |
113 |
foreach ($joinedAuthorTeams as $authorteam => $sensuCitation) {
|
|
114 |
$footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
|
|
115 |
|
|
116 |
$sensu = ++$author_team_cnt == 0 ? '' : 'sensu ';
|
|
117 |
|
|
118 |
$joinedAuthorTeams[$authorteam] = sprintf(
|
|
119 |
'<span class="sensu">%s%s%s</span>',
|
|
120 |
$sensu,
|
|
121 |
($authorteam != $NULL_AUTHORTEAM ? $authorteam : ''),
|
|
122 |
theme('cdm_footnote_key', array('footnoteKey' => $footnoteKey))
|
|
123 |
);
|
|
141 |
foreach ($joinedAuthorTeams as $authorteam_str => $sensu_citation) {
|
|
142 |
$footnoteKey = '';
|
|
143 |
if(!empty($sensu_citation)) { |
|
144 |
$footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, 'sensu ' . $sensu_citation);
|
|
145 |
$footnoteKey = theme('cdm_footnote_key', array('footnoteKey' => $footnoteKey)); |
|
146 |
}
|
|
147 |
$sensu = '';
|
|
148 |
if($authorteam_str != $NULL_AUTHORTEAM){
|
|
149 |
$sensu = ++$author_team_cnt == 0 ? '' : 'sensu ' . $authorteam_str;
|
|
150 |
}
|
|
151 |
$joinedAuthorTeams[$authorteam_str] = '<span class="sensu">' . $sensu . $footnoteKey .'</span>';
|
|
124 | 152 |
} |
125 | 153 |
|
126 | 154 |
// ---- Generate output ---- // |
... | ... | |
134 | 162 |
|
135 | 163 |
if (isset($misapplied_name['authorteam'])) { |
136 | 164 |
// Fill authors with the renderedFootnoteKey and sorting 'em. |
137 |
foreach ($misapplied_name['authorteam'] as $authorteam => &$renderedFootnoteKey) { |
|
138 |
$renderedFootnoteKey = $joinedAuthorTeams[$authorteam]; |
|
165 |
foreach ($misapplied_name['authorteam'] as $authorteam_str => &$renderedFootnoteKey) {
|
|
166 |
$renderedFootnoteKey = $joinedAuthorTeams[$authorteam_str];
|
|
139 | 167 |
} |
140 | 168 |
ksort($misapplied_name['authorteam']); |
141 | 169 |
$out .= join('; ', $misapplied_name['authorteam']); |
... | ... | |
178 | 206 |
* |
179 | 207 |
* According name relationships are also being rendered. |
180 | 208 |
* |
181 |
* @param unknown_type $taxonRelationship
|
|
209 |
* @param $taxonRelationship |
|
182 | 210 |
* @param boolean $doLinkTaxon |
183 | 211 |
* whether to create a link to the related taxon |
184 | 212 |
* @param boolean $inverse |
Also available in: Unified diff
fix #5676 displaying the reference titleCache as sensu if authors are missind; also solving other problems