1 |
2fd6da0b
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Functions for dealing with CDM entities from the package model.name
|
5 |
|
|
*
|
6 |
|
|
* @copyright
|
7 |
|
|
* (C) 2007-2015 EDIT
|
8 |
|
|
* European Distributed Institute of Taxonomy
|
9 |
|
|
* http://www.e-taxonomy.eu
|
10 |
|
|
*
|
11 |
|
|
* The contents of this module are subject to the Mozilla
|
12 |
|
|
* Public License Version 1.1.
|
13 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*
|
15 |
|
|
* @author
|
16 |
|
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* @defgroup compose Compose functions
|
21 |
|
|
* @{
|
22 |
|
|
* Functions which are composing Drupal render arays
|
23 |
|
|
*
|
24 |
|
|
* The cdm_dataportal module needs to compose rather complex render arrays from
|
25 |
|
|
* the data returned by the CDM REST service. The compose functions are
|
26 |
|
|
* responsible for creating the render arrays.
|
27 |
|
|
*
|
28 |
|
|
* All these functions are also implementations of the compose_hook()
|
29 |
|
|
* which is used in the proxy_content() function.
|
30 |
|
|
* @}
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/**
|
35 |
|
|
* Provides the name render template to be used within the page elements identified the the $renderPath.
|
36 |
|
|
*
|
37 |
a565e612
|
Andreas Kohlbecker
|
* The render templates arrays contains one or more name render templates to be used within the page elements identified the the
|
38 |
2fd6da0b
|
Andreas Kohlbecker
|
* renderPath. The renderPath is the key of the subelements whereas the value is the name render template.
|
39 |
|
|
*
|
40 |
a565e612
|
Andreas Kohlbecker
|
* The render paths used for a cdm_dataportal page can be visualized by supplying the HTTP query parameter RENDER_PATH=1.
|
41 |
|
|
*
|
42 |
|
|
* It will be tried to find the best matching default RenderTemplate by stripping the dot separated render path
|
43 |
|
|
* element by element. If no matching template is found the DEFAULT will be used:
|
44 |
|
|
*
|
45 |
|
|
* - related_taxon.heterotypicSynonymyGroup.taxon_page_synonymy
|
46 |
|
|
* - related_taxon.heterotypicSynonymyGroup.taxon_page_synonymy
|
47 |
|
|
* - related_taxon.heterotypicSynonymyGroup.taxon_page_synonymy
|
48 |
2fd6da0b
|
Andreas Kohlbecker
|
*
|
49 |
|
|
* A single render template can be used for multiple render paths. In this case the according key of the render templates
|
50 |
|
|
* array element should be the list of these render paths concatenated by ONLY a comma character without any whitespace.
|
51 |
|
|
*
|
52 |
|
|
* A render template is an associative array. The keys of this array are referring to the keys as defined in the part
|
53 |
|
|
* definitions array.
|
54 |
|
|
* @see get_partDefinition($taxonNameType) for more information
|
55 |
|
|
*
|
56 |
|
|
* The value of the render template element must be set to TRUE in order to let this part being rendered.
|
57 |
|
|
* The namePart, nameAuthorPart and referencePart can also hold an associative array with a single
|
58 |
|
|
* element: array('#uri' => TRUE). The value of the #uri element will be replaced by the according
|
59 |
|
|
* links if the parameters $nameLink or $refenceLink are set.
|
60 |
|
|
*
|
61 |
a565e612
|
Andreas Kohlbecker
|
* @param string $render_path
|
62 |
2fd6da0b
|
Andreas Kohlbecker
|
* The render path can consist of multiple dot separated elements
|
63 |
|
|
* @see RenderHints::getRenderPath()
|
64 |
|
|
* @param string $nameLink
|
65 |
87aa88d6
|
Andreas Kohlbecker
|
* The link path or URL to be used for name parts if a link is forseen in the template
|
66 |
2fd6da0b
|
Andreas Kohlbecker
|
* matching the given $renderPath.
|
67 |
|
|
* @param string $referenceLink
|
68 |
|
|
* The link path ot URL to be used for nomenclatural reference parts if a link is forseen
|
69 |
|
|
* in the template matching the given $renderPath.
|
70 |
|
|
* @return array
|
71 |
|
|
* An associative array, the render template
|
72 |
|
|
*/
|
73 |
a565e612
|
Andreas Kohlbecker
|
function get_nameRenderTemplate($render_path, $nameLink = NULL, $referenceLink = NULL) {
|
74 |
2fd6da0b
|
Andreas Kohlbecker
|
|
75 |
|
|
static $default_render_templates = NULL;
|
76 |
03f4f6f7
|
Andreas Kohlbecker
|
static $split_render_templates = NULL;
|
77 |
|
|
|
78 |
|
|
|
79 |
2fd6da0b
|
Andreas Kohlbecker
|
if (!isset($default_render_templates)) {
|
80 |
|
|
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
|
81 |
|
|
}
|
82 |
03f4f6f7
|
Andreas Kohlbecker
|
if($split_render_templates == NULL) {
|
83 |
2fd6da0b
|
Andreas Kohlbecker
|
$render_templates = variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates);
|
84 |
|
|
// needs to be converted to an array
|
85 |
db725031
|
Andreas Kohlbecker
|
$render_templates = (object_to_array($render_templates));
|
86 |
03f4f6f7
|
Andreas Kohlbecker
|
|
87 |
|
|
// separate render templates which are combined with a comma
|
88 |
|
|
$split_render_templates = array();
|
89 |
|
|
foreach($render_templates as $key => $template){
|
90 |
|
|
if(strpos($key, ',')){
|
91 |
|
|
foreach(explode(',', $key) as $path){
|
92 |
|
|
$split_render_templates[$path] = $template;
|
93 |
|
|
}
|
94 |
|
|
} else {
|
95 |
|
|
$split_render_templates[$key] = $template;
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
99 |
|
|
|
100 |
|
|
// get the base element of the renderPath
|
101 |
a565e612
|
Andreas Kohlbecker
|
if (($separatorPos = strpos($render_path, '.')) > 0) {
|
102 |
|
|
$renderPath_base = substr($render_path, 0, $separatorPos);
|
103 |
2fd6da0b
|
Andreas Kohlbecker
|
} else {
|
104 |
a565e612
|
Andreas Kohlbecker
|
$renderPath_base = $render_path;
|
105 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
106 |
|
|
|
107 |
03f4f6f7
|
Andreas Kohlbecker
|
$template = NULL;
|
108 |
2fd6da0b
|
Andreas Kohlbecker
|
// 1. try to find a template using the render path base element
|
109 |
03f4f6f7
|
Andreas Kohlbecker
|
if(array_key_exists($renderPath_base, $split_render_templates)){
|
110 |
|
|
$template = (array)$split_render_templates[$renderPath_base];
|
111 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
112 |
|
|
|
113 |
a565e612
|
Andreas Kohlbecker
|
// 2. Find best matching default RenderTemplate
|
114 |
2fd6da0b
|
Andreas Kohlbecker
|
// by stripping the dot separated render path element by element
|
115 |
a565e612
|
Andreas Kohlbecker
|
// if no matching template is found the DEFAULT will be used.
|
116 |
|
|
while (!is_array($template) && strlen($render_path) > 0) {
|
117 |
03f4f6f7
|
Andreas Kohlbecker
|
foreach ($split_render_templates as $path => $t) {
|
118 |
a565e612
|
Andreas Kohlbecker
|
if ($path == $render_path) {
|
119 |
2fd6da0b
|
Andreas Kohlbecker
|
$template = $t;
|
120 |
|
|
break;
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
// shorten by one element
|
124 |
a565e612
|
Andreas Kohlbecker
|
$render_path = substr($render_path, strrpos($render_path, '.') + 1, strlen($render_path));
|
125 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
126 |
|
|
|
127 |
03f4f6f7
|
Andreas Kohlbecker
|
|
128 |
2fd6da0b
|
Andreas Kohlbecker
|
// 3. Otherwise get default RenderTemplate from theme.
|
129 |
|
|
if (!is_array($template)) {
|
130 |
03f4f6f7
|
Andreas Kohlbecker
|
$template = $split_render_templates['#DEFAULT'];
|
131 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
132 |
|
|
|
133 |
|
|
// --- set the link uris to the according template fields if they exist
|
134 |
|
|
if(isset($template['nameAuthorPart']) && isset($template['nameAuthorPart']['#uri'])) {
|
135 |
|
|
if ($nameLink) {
|
136 |
|
|
$template['nameAuthorPart']['#uri'] = $nameLink;
|
137 |
|
|
}
|
138 |
|
|
else {
|
139 |
|
|
unset($template['nameAuthorPart']['#uri']);
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
if ($nameLink && isset($template['namePart']['#uri'])) {
|
144 |
|
|
$template['namePart']['#uri'] = $nameLink;
|
145 |
|
|
}
|
146 |
|
|
else {
|
147 |
|
|
unset($template['namePart']['#uri']);
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
if ($referenceLink && isset($template['referencePart']['#uri'])) {
|
151 |
|
|
$template['referencePart']['#uri'] = $referenceLink;
|
152 |
|
|
}
|
153 |
|
|
else {
|
154 |
|
|
unset($template['referencePart']['#uri']);
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
return $template;
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
/**
|
161 |
|
|
* The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
|
162 |
|
|
*
|
163 |
|
|
* A full taxon name plus additional information can consist of the following elements:
|
164 |
|
|
*
|
165 |
|
|
* - name: the taxon name inclugin rank nbut without author
|
166 |
|
|
* - authorTeam: The authors of a reference, also used in taxon names
|
167 |
|
|
* - authors: The authors of a reference, also used in taxon names
|
168 |
|
|
* - reference: the nomenclatural reference,
|
169 |
|
|
* - microreference: Volume, page number etc.
|
170 |
|
|
* - status: The nomenclatural status of a name
|
171 |
|
|
* - description: name descriptions like protologues etc ...
|
172 |
|
|
*
|
173 |
|
|
* These elements are combined in the part definitions array to from the specific parts to be rendered.
|
174 |
|
|
* Usually the following parts are formed:
|
175 |
|
|
*
|
176 |
|
|
* The name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example here:
|
177 |
|
|
* - namePart: the name and rank (in example: "Lapsana communis")
|
178 |
|
|
* - authorshipPart: the author (in example: "L.")
|
179 |
|
|
* - nameAuthorPart: the combination of name and author part (in example: "Lapsana communis L.").
|
180 |
|
|
* This is useful for zoological names where the authorshipPart belongs to the name and both should
|
181 |
|
|
* be combined when a link to the taxon is rendered.
|
182 |
|
|
* - referencePart: the nomencaltural reference (in example: "Sp. Pl. 1753")
|
183 |
|
|
* - microreferencePart: usually the page number (in example ": 811.")
|
184 |
|
|
* - statusPart: the nomenclatorical status
|
185 |
|
|
* - descriptionPart:
|
186 |
|
|
*
|
187 |
|
|
* Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
|
188 |
|
|
* specific parts part definitions:
|
189 |
|
|
*
|
190 |
|
|
* - BotanicalName
|
191 |
|
|
* - ZoologicalName
|
192 |
|
|
* - #DEFAULT: covers ViralNames and general NonViralNames
|
193 |
|
|
*
|
194 |
|
|
* An example:
|
195 |
|
|
* @code
|
196 |
|
|
* array(
|
197 |
|
|
* 'ZoologicalName' => array(
|
198 |
|
|
* 'namePart' => array('name' => TRUE),
|
199 |
|
|
* 'referencePart' => array('authorTeam' => TRUE),
|
200 |
|
|
* 'microreferencePart' => array('microreference' => TRUE),
|
201 |
|
|
* 'statusPart' => array('status' => TRUE),
|
202 |
|
|
* 'descriptionPart' => array('description' => TRUE),
|
203 |
|
|
* ),
|
204 |
|
|
* 'BotanicalName' => array(
|
205 |
|
|
* 'namePart' => array(
|
206 |
|
|
* 'name' => TRUE,
|
207 |
|
|
* 'authors' => TRUE,
|
208 |
|
|
* ),
|
209 |
|
|
* 'referencePart' => array(
|
210 |
|
|
* 'reference' => TRUE,
|
211 |
|
|
* 'microreference' => TRUE,
|
212 |
|
|
* ),
|
213 |
|
|
* 'statusPart' => array('status' => TRUE),
|
214 |
|
|
* 'descriptionPart' => array('description' => TRUE),
|
215 |
|
|
* ),
|
216 |
|
|
* );
|
217 |
|
|
* @endcode
|
218 |
|
|
*
|
219 |
828a0c8c
|
Andreas Kohlbecker
|
* @param object $taxonNameType
|
220 |
|
|
* A cdm TaxonNameType entity
|
221 |
|
|
*
|
222 |
2fd6da0b
|
Andreas Kohlbecker
|
*/
|
223 |
|
|
function get_partDefinition($taxonNameType) {
|
224 |
|
|
|
225 |
|
|
static $default_part_definitions = null;
|
226 |
|
|
if (!isset($default_part_definitions)) {
|
227 |
|
|
$default_part_definitions= unserialize(CDM_PART_DEFINITIONS_DEFAULT);
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
static $part_definitions = null;
|
231 |
|
|
if (!isset($part_definitions)) {
|
232 |
db725031
|
Andreas Kohlbecker
|
$part_definitions = object_to_array(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions));
|
233 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
234 |
|
|
|
235 |
c2545e1c
|
Andreas Kohlbecker
|
$dtype = nameTypeToDTYPE($taxonNameType);
|
236 |
2fd6da0b
|
Andreas Kohlbecker
|
if (array_key_exists($taxonNameType, $part_definitions)) {
|
237 |
|
|
return $part_definitions[$taxonNameType];
|
238 |
c2545e1c
|
Andreas Kohlbecker
|
} else if (array_key_exists($dtype, $part_definitions)) {
|
239 |
|
|
return $part_definitions[$dtype];
|
240 |
2fd6da0b
|
Andreas Kohlbecker
|
} else {
|
241 |
|
|
return $part_definitions['#DEFAULT']; // covers ViralNames and general NonViralNames
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
}
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
/**
|
248 |
|
|
* Renders the markup for a CDM TaxonName instance.
|
249 |
|
|
*
|
250 |
|
|
* The layout of the name representation is configured by the
|
251 |
|
|
* part_definitions and render_templates (see get_partDefinition() and
|
252 |
|
|
* get_nameRenderTemplate())
|
253 |
|
|
*
|
254 |
6679207a
|
Andreas Kohlbecker
|
* @param $taxon_name_or_taxon_base
|
255 |
|
|
* A cdm TaxonBase or TaxonName entity
|
256 |
20bfe15b
|
Andreas Kohlbecker
|
* @param $name_link
|
257 |
6679207a
|
Andreas Kohlbecker
|
* URI to the taxon, @param $reference_link
|
258 |
|
|
* URI to the reference, @param bool $show_annotations
|
259 |
2fd6da0b
|
Andreas Kohlbecker
|
* turns the display of annotations on
|
260 |
6679207a
|
Andreas Kohlbecker
|
* @param bool $is_type_designation
|
261 |
2fd6da0b
|
Andreas Kohlbecker
|
* To indicate that the supplied taxon name is a name type designation.
|
262 |
6679207a
|
Andreas Kohlbecker
|
* @param array $skiptags
|
263 |
2fd6da0b
|
Andreas Kohlbecker
|
* an array of name elements tags like 'name', 'rank' to skip. The name part
|
264 |
|
|
* 'authors' will not ber affected by this filter. This part is managed though the render template
|
265 |
|
|
* mechanism.
|
266 |
6679207a
|
Andreas Kohlbecker
|
* @param bool $is_invalid
|
267 |
c35bab7f
|
Andreas Kohlbecker
|
* Indicates that this taxon is invalid. In this case the name part will be shown in double quotes.
|
268 |
|
|
* This is useful when rendering taxon relation ships.
|
269 |
2fd6da0b
|
Andreas Kohlbecker
|
*
|
270 |
|
|
* @return string
|
271 |
|
|
* The markup for a taxon name.
|
272 |
6679207a
|
Andreas Kohlbecker
|
* @see path_to_taxon(), must be processed by url() before passing to this method
|
273 |
|
|
* @see path_to_reference(), must be processed by url() before passing to this method
|
274 |
2fd6da0b
|
Andreas Kohlbecker
|
*/
|
275 |
20bfe15b
|
Andreas Kohlbecker
|
function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $reference_link = NULL,
|
276 |
c35bab7f
|
Andreas Kohlbecker
|
$show_annotations = true, $is_type_designation = false, $skiptags = array(), $is_invalid = false) {
|
277 |
2fd6da0b
|
Andreas Kohlbecker
|
|
278 |
ea3933d7
|
Andreas Kohlbecker
|
$is_doubtful = false;
|
279 |
|
|
|
280 |
2fd6da0b
|
Andreas Kohlbecker
|
if($taxon_name_or_taxon_base->class == 'Taxon' || $taxon_name_or_taxon_base->class == 'Synonym'){
|
281 |
e95b14dd
|
Andreas Kohlbecker
|
if(isset($taxon_name_or_taxon_base->name)){
|
282 |
|
|
$taxonName = $taxon_name_or_taxon_base->name;
|
283 |
|
|
} else {
|
284 |
|
|
$taxonName = cdm_ws_get(CDM_WS_TAXON . '/$0/name', array($taxon_name_or_taxon_base->uuid));
|
285 |
|
|
}
|
286 |
ea3933d7
|
Andreas Kohlbecker
|
$is_doubtful = $taxon_name_or_taxon_base->doubtful;
|
287 |
de7bcbcc
|
Andreas Kohlbecker
|
// use the TaxonBase.tagged_title so we have the secRef
|
288 |
|
|
$tagged_title = $taxon_name_or_taxon_base->taggedTitle;
|
289 |
2fd6da0b
|
Andreas Kohlbecker
|
} else {
|
290 |
102f8c26
|
Andreas Kohlbecker
|
// assuming this is a TaxonName
|
291 |
2fd6da0b
|
Andreas Kohlbecker
|
$taxonName = $taxon_name_or_taxon_base;
|
292 |
de7bcbcc
|
Andreas Kohlbecker
|
if(isset($taxonName->taggedFullTitle)){
|
293 |
|
|
$tagged_title = $taxon_name_or_taxon_base->taggedFullTitle;
|
294 |
|
|
} else {
|
295 |
|
|
$tagged_title = $taxon_name_or_taxon_base->taggedName;
|
296 |
|
|
}
|
297 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
298 |
|
|
|
299 |
|
|
|
300 |
20bfe15b
|
Andreas Kohlbecker
|
$renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $name_link, $reference_link);
|
301 |
c2545e1c
|
Andreas Kohlbecker
|
$partDefinition = get_partDefinition($taxonName->nameType);
|
302 |
2fd6da0b
|
Andreas Kohlbecker
|
|
303 |
|
|
// Apply definitions to template.
|
304 |
|
|
foreach ($renderTemplate as $part => $uri) {
|
305 |
|
|
|
306 |
|
|
if (isset($partDefinition[$part])) {
|
307 |
|
|
$renderTemplate[$part] = $partDefinition[$part];
|
308 |
|
|
}
|
309 |
|
|
if (is_array($uri) && isset($uri['#uri'])) {
|
310 |
|
|
$renderTemplate[$part]['#uri'] = $uri['#uri'];
|
311 |
|
|
}
|
312 |
|
|
}
|
313 |
|
|
|
314 |
de7bcbcc
|
Andreas Kohlbecker
|
$secref_tagged_text = tagged_text_extract_reference_and_detail($tagged_title);
|
315 |
|
|
// taxon names will have the nomenclatural reference in the tagged full title:
|
316 |
|
|
$nomref_tagged_text = tagged_text_extract_reference($tagged_title);
|
317 |
|
|
$nom_status_tagged_text = tagged_text_extract_nomstatus($tagged_title);
|
318 |
c35bab7f
|
Andreas Kohlbecker
|
$appended_phrase_tagged_text = array(); // this is filled later
|
319 |
|
|
|
320 |
de7bcbcc
|
Andreas Kohlbecker
|
normalize_tagged_text($tagged_title);
|
321 |
2fd6da0b
|
Andreas Kohlbecker
|
|
322 |
61fc6c93
|
Andreas Kohlbecker
|
$is_valid_tagged_title =
|
323 |
de7bcbcc
|
Andreas Kohlbecker
|
isset($tagged_title)
|
324 |
|
|
&& is_array($tagged_title)
|
325 |
|
|
&& isset($tagged_title[0]->text)
|
326 |
|
|
&& is_string($tagged_title[0]->text)
|
327 |
|
|
&& $tagged_title[0]->text != ''
|
328 |
61fc6c93
|
Andreas Kohlbecker
|
&& isset($tagged_title[0]->type);
|
329 |
2fd6da0b
|
Andreas Kohlbecker
|
$lastAuthorElementString = FALSE;
|
330 |
|
|
|
331 |
c35bab7f
|
Andreas Kohlbecker
|
$name_encasement = $is_invalid ? '"' : '';
|
332 |
54a3c136
|
Andreas Kohlbecker
|
$doubtful_marker = $is_doubtful ? '? ' : ''; //   = NARROW NO-BREAK SPACE
|
333 |
2330b553
|
Andreas Kohlbecker
|
$doubtful_marker_markup = '';
|
334 |
|
|
|
335 |
|
|
if($doubtful_marker){
|
336 |
|
|
$doubtful_marker_markup = '<span class="doubtful">' . $doubtful_marker . '</span>';
|
337 |
61fc6c93
|
Andreas Kohlbecker
|
if($tagged_title[0]->text == '?' ){
|
338 |
|
|
// remove the first tagged text element
|
339 |
|
|
unset($tagged_title[0]);
|
340 |
|
|
}
|
341 |
2330b553
|
Andreas Kohlbecker
|
}
|
342 |
c35bab7f
|
Andreas Kohlbecker
|
|
343 |
|
|
// split off all appendedPhrase item from the end of the array (usually there only should be one)
|
344 |
de7bcbcc
|
Andreas Kohlbecker
|
while($tagged_title[count($tagged_title)-1]->type == "appendedPhrase"){
|
345 |
|
|
$appended_phrase_tagged_text[] = array_pop($tagged_title);
|
346 |
c35bab7f
|
Andreas Kohlbecker
|
}
|
347 |
|
|
|
348 |
2fd6da0b
|
Andreas Kohlbecker
|
// Got to use second entry as first one, see ToDo comment below ...
|
349 |
61fc6c93
|
Andreas Kohlbecker
|
if ($is_valid_tagged_title) {
|
350 |
2fd6da0b
|
Andreas Kohlbecker
|
|
351 |
de7bcbcc
|
Andreas Kohlbecker
|
$taggedName = $tagged_title;
|
352 |
2fd6da0b
|
Andreas Kohlbecker
|
$hasNamePart_with_Authors = isset($renderTemplate['namePart']) && isset($renderTemplate['namePart']['authors']);
|
353 |
|
|
$hasNameAuthorPart_with_Authors = isset($renderTemplate['nameAuthorPart']) && isset($renderTemplate['nameAuthorPart']['authors']);
|
354 |
|
|
|
355 |
c35bab7f
|
Andreas Kohlbecker
|
|
356 |
2fd6da0b
|
Andreas Kohlbecker
|
if (!(($hasNamePart_with_Authors) || ($hasNameAuthorPart_with_Authors))) {
|
357 |
|
|
// Find author and split off from name.
|
358 |
|
|
// TODO expecting to find the author as the last element.
|
359 |
|
|
/*
|
360 |
|
|
if($taggedName[count($taggedName)- 1]->type == 'authors'){
|
361 |
|
|
$authorTeam = $taggedName[count($taggedName)- 1]->text;
|
362 |
|
|
unset($taggedName[count($taggedName)- 1]);
|
363 |
|
|
}
|
364 |
|
|
*/
|
365 |
|
|
|
366 |
|
|
// Remove all authors.
|
367 |
|
|
$taggedNameNew = array();
|
368 |
|
|
foreach ($taggedName as $element) {
|
369 |
|
|
if ($element->type != 'authors') {
|
370 |
|
|
$taggedNameNew[] = $element;
|
371 |
|
|
}
|
372 |
|
|
else {
|
373 |
|
|
$lastAuthorElementString = $element->text;
|
374 |
|
|
}
|
375 |
|
|
}
|
376 |
|
|
$taggedName = $taggedNameNew;
|
377 |
e90899ac
|
Andreas Kohlbecker
|
unset($taggedNameNew);
|
378 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
379 |
0f129a6f
|
Andreas Kohlbecker
|
$name = '<span class="' . $taxonName->class . '">' . $doubtful_marker_markup . $name_encasement . cdm_tagged_text_to_markup($taggedName, $skiptags) . $name_encasement . '</span>';
|
380 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
381 |
|
|
else {
|
382 |
61fc6c93
|
Andreas Kohlbecker
|
// use titleCache instead
|
383 |
2330b553
|
Andreas Kohlbecker
|
$name = '<span class="' . $taxonName->class . '_titleCache">' . $doubtful_marker_markup . $name_encasement . $taxonName->titleCache . $name_encasement . '</span>';
|
384 |
c35bab7f
|
Andreas Kohlbecker
|
}
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
if(isset($appended_phrase_tagged_text[0])){
|
388 |
54a3c136
|
Andreas Kohlbecker
|
$name .= ' <span class="appended-phrase">'. cdm_tagged_text_to_markup($appended_phrase_tagged_text) . '</span>';
|
389 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
390 |
|
|
|
391 |
|
|
// Fill name into $renderTemplate.
|
392 |
c35bab7f
|
Andreas Kohlbecker
|
array_setr('name', $name , $renderTemplate);
|
393 |
2fd6da0b
|
Andreas Kohlbecker
|
|
394 |
|
|
// Fill with authorTeam.
|
395 |
|
|
/*
|
396 |
|
|
if($authorTeam){
|
397 |
|
|
$authorTeamHtml = ' <span class="authorTeam">'.$authorTeam.'</span>';
|
398 |
|
|
array_setr('authorTeam', $authorTeamHtml, $renderTemplate);
|
399 |
|
|
}
|
400 |
|
|
*/
|
401 |
|
|
|
402 |
|
|
// Fill with reference.
|
403 |
|
|
if (isset($renderTemplate['referencePart']) && !$is_type_designation) {
|
404 |
|
|
|
405 |
eaff53f7
|
Andreas Kohlbecker
|
$registrations = cdm_ws_get(CDM_WS_NAME, array($taxonName->uuid, "registrations"));
|
406 |
|
|
$registration_markup = render_registrations($registrations);
|
407 |
|
|
|
408 |
2fd6da0b
|
Andreas Kohlbecker
|
// default separator
|
409 |
|
|
$separator = '';
|
410 |
|
|
|
411 |
|
|
// [Eckhard]:"Komma nach dem Taxonnamen ist grunsätzlich falsch,
|
412 |
|
|
// Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt."
|
413 |
c21cfd4b
|
Andreas Kohlbecker
|
if (isset($renderTemplate['referencePart']['reference'])) {
|
414 |
2fd6da0b
|
Andreas Kohlbecker
|
$microreference = NULL;
|
415 |
6679207a
|
Andreas Kohlbecker
|
if (isset($renderTemplate['referencePart']['microreference'])&& isset($taxonName->nomenclaturalSource->citationMicroReference)) {
|
416 |
|
|
$microreference = $taxonName->nomenclaturalSource->citationMicroReference;
|
417 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
418 |
6679207a
|
Andreas Kohlbecker
|
if(count($nomref_tagged_text) == 0 && isset($taxonName->nomenclaturalSource->citation)){
|
419 |
c21cfd4b
|
Andreas Kohlbecker
|
// TODO is this case still relevant? The tagged text should already contain all information!
|
420 |
6679207a
|
Andreas Kohlbecker
|
$citation = cdm_ws_getNomenclaturalReference($taxonName->nomenclaturalSource->citation->uuid, $microreference);
|
421 |
de7bcbcc
|
Andreas Kohlbecker
|
// Find preceding element of the reference.
|
422 |
|
|
$precedingKey = get_preceding_contentElementKey('reference', $renderTemplate);
|
423 |
|
|
if (str_beginsWith($citation, ", in")) {
|
424 |
|
|
$citation = substr($citation, 2);
|
425 |
|
|
$separator = ' ';
|
426 |
|
|
}
|
427 |
|
|
elseif (!str_beginsWith($citation, "in") && $precedingKey == 'authors') {
|
428 |
|
|
$separator = ', ';
|
429 |
|
|
} else {
|
430 |
|
|
$separator = ' ';
|
431 |
|
|
}
|
432 |
|
|
$referenceArray['#separator'] = $separator;
|
433 |
|
|
$referenceArray['#html'] = '<span class="reference">' . $citation . '</span>' . $registration_markup;
|
434 |
2fd6da0b
|
Andreas Kohlbecker
|
} else {
|
435 |
de7bcbcc
|
Andreas Kohlbecker
|
// this ist the case for taxon names
|
436 |
|
|
$referenceArray['#html'] = cdm_tagged_text_to_markup($nomref_tagged_text);
|
437 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
438 |
|
|
|
439 |
|
|
|
440 |
|
|
array_setr('reference', $referenceArray, $renderTemplate);
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
// If authors have been removed from the name part the last named authorteam
|
444 |
|
|
// should be added to the reference citation, otherwise, keep the separator
|
445 |
|
|
// out of the reference.
|
446 |
|
|
if (isset($renderTemplate['referencePart']['authors']) && $lastAuthorElementString) {
|
447 |
|
|
// If the nomenclaturalReference citation is not included in the
|
448 |
eaff53f7
|
Andreas Kohlbecker
|
// reference part but display of the microreference
|
449 |
2fd6da0b
|
Andreas Kohlbecker
|
// is wanted, append the microreference to the authorTeam.
|
450 |
|
|
$citation = '';
|
451 |
|
|
if (!isset($renderTemplate['referencePart']['reference']) && isset($renderTemplate['referencePart']['microreference'])) {
|
452 |
|
|
$separator = ": ";
|
453 |
|
|
$citation = $taxonName->nomenclaturalMicroReference;
|
454 |
|
|
}
|
455 |
|
|
$referenceArray['#html'] = ' <span class="reference">' . $lastAuthorElementString . $separator . $citation . '</span>';
|
456 |
|
|
array_setr('authors', $referenceArray, $renderTemplate);
|
457 |
|
|
}
|
458 |
|
|
}
|
459 |
|
|
|
460 |
|
|
$is_reference_year = false;
|
461 |
|
|
if (isset($renderTemplate['referenceYearPart']['reference.year'])) {
|
462 |
6679207a
|
Andreas Kohlbecker
|
if(isset($taxonName->nomenclaturalSource->citation->datePublished)){
|
463 |
|
|
$referenceArray['#html'] = ' <span class="reference">' . timePeriodToString($taxonName->nomenclaturalSource->citation->datePublished) . '</span>';
|
464 |
2fd6da0b
|
Andreas Kohlbecker
|
array_setr('reference.year', $referenceArray, $renderTemplate);
|
465 |
|
|
$is_reference_year = true;
|
466 |
|
|
}
|
467 |
|
|
}
|
468 |
|
|
|
469 |
e90899ac
|
Andreas Kohlbecker
|
// Fill with status.
|
470 |
dce1dacc
|
Andreas Kohlbecker
|
if(isset($renderTemplate['statusPart']['status'])){
|
471 |
1d0407b7
|
Andreas Kohlbecker
|
if (isset($nom_status_tagged_text[0])) {
|
472 |
222784c5
|
Andreas Kohlbecker
|
$tt_to_markup_options = array('html' => false);
|
473 |
|
|
foreach ($nom_status_tagged_text as &$tt){
|
474 |
|
|
if($tt->type == 'nomStatus'&& isset($tt->entityReference)) {
|
475 |
|
|
$nom_status = cdm_ws_get(CDM_WS_NOMENCLATURALSTATUS, array($tt->entityReference->uuid));
|
476 |
8202a2c0
|
Andreas Kohlbecker
|
$nom_status_fkey = handle_nomenclatural_status_as_footnote($nom_status);
|
477 |
222784c5
|
Andreas Kohlbecker
|
$tt->text .= $nom_status_fkey;
|
478 |
|
|
$tt_to_markup_options['html'] = true;
|
479 |
|
|
}
|
480 |
|
|
}
|
481 |
|
|
array_setr(
|
482 |
|
|
'status',
|
483 |
e9ac7c6f
|
Andreas Kohlbecker
|
'<span class="nomenclatural_status">' . cdm_tagged_text_to_markup($nom_status_tagged_text, array('postSeparator'), 'span', $tt_to_markup_options) . '</span>',
|
484 |
|
|
$renderTemplate);
|
485 |
e90899ac
|
Andreas Kohlbecker
|
}
|
486 |
|
|
}
|
487 |
|
|
|
488 |
2fd6da0b
|
Andreas Kohlbecker
|
if (isset($renderTemplate['secReferencePart'])){
|
489 |
|
|
if(isset($secref_tagged_text[1])){
|
490 |
e90899ac
|
Andreas Kohlbecker
|
$post_separator_markup = $is_reference_year ? '.': '';
|
491 |
6aad9da8
|
Andreas Kohlbecker
|
if(isset($nom_status_tagged_text[count($nom_status_tagged_text) - 1]) && ($nom_status_tagged_text[count($nom_status_tagged_text) - 1]->type == 'postSeparator')){
|
492 |
4a1ab871
|
Andreas Kohlbecker
|
$post_separator_markup = cdm_tagged_text_to_markup(array($nom_status_tagged_text[count($nom_status_tagged_text) - 1 ]));
|
493 |
e90899ac
|
Andreas Kohlbecker
|
};
|
494 |
2fd6da0b
|
Andreas Kohlbecker
|
array_setr('secReference',
|
495 |
e90899ac
|
Andreas Kohlbecker
|
$post_separator_markup
|
496 |
2fd6da0b
|
Andreas Kohlbecker
|
. ' <span class="sec_reference">'
|
497 |
4bfe18f9
|
Andreas Kohlbecker
|
. join('', cdm_tagged_text_values($secref_tagged_text))
|
498 |
2fd6da0b
|
Andreas Kohlbecker
|
. '</span>', $renderTemplate);
|
499 |
|
|
}
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
// Fill with protologues etc...
|
503 |
|
|
$descriptionHtml = '';
|
504 |
|
|
if (array_setr('description', TRUE, $renderTemplate)) {
|
505 |
|
|
$descriptions = cdm_ws_get(CDM_WS_PORTAL_NAME_DESCRIPTIONS, $taxonName->uuid);
|
506 |
20bfe15b
|
Andreas Kohlbecker
|
if($descriptions){
|
507 |
|
|
foreach ($descriptions as $description) {
|
508 |
|
|
if (!empty($description)) {
|
509 |
|
|
foreach ($description->elements as $description_element) {
|
510 |
|
|
$second_citation = '';
|
511 |
|
|
if (isset($description_element->multilanguageText_L10n) && $description_element->multilanguageText_L10n->text) {
|
512 |
1c7c424f
|
Andreas Kohlbecker
|
if(isset($description_element->feature) && $description_element->feature->uuid == UUID_ADDITIONAL_PUBLICATION){
|
513 |
|
|
$prefix = '& ';
|
514 |
|
|
} else {
|
515 |
|
|
$prefix = '';
|
516 |
|
|
}
|
517 |
|
|
$second_citation = ' [' . $prefix . $description_element->multilanguageText_L10n->text . '].';
|
518 |
20bfe15b
|
Andreas Kohlbecker
|
}
|
519 |
|
|
$descriptionHtml .= $second_citation;
|
520 |
|
|
$descriptionHtml .= cdm_description_element_media(
|
521 |
|
|
$description_element,
|
522 |
|
|
array(
|
523 |
|
|
'application/pdf',
|
524 |
|
|
'image/png',
|
525 |
|
|
'image/jpeg',
|
526 |
|
|
'image/gif',
|
527 |
|
|
'text/html',
|
528 |
|
|
)
|
529 |
|
|
);
|
530 |
2fd6da0b
|
Andreas Kohlbecker
|
|
531 |
20bfe15b
|
Andreas Kohlbecker
|
}
|
532 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
533 |
|
|
}
|
534 |
|
|
}
|
535 |
|
|
array_setr('description', $descriptionHtml, $renderTemplate);
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
// Render.
|
539 |
f695daf4
|
Andreas Kohlbecker
|
$out = '';
|
540 |
|
|
if(isset($_REQUEST['RENDER_PATH'])){
|
541 |
|
|
// developer option to show the render path with each taxon name
|
542 |
|
|
$out .= '<span class="render-path">' . RenderHints::getRenderPath() . '</span>';
|
543 |
|
|
}
|
544 |
|
|
$out .= '<span class="' . html_class_attribute_ref($taxon_name_or_taxon_base)
|
545 |
|
|
. '" data-cdm-ref="/name/' . $taxonName->uuid . '" data-cdm-render-path="' . RenderHints::getRenderPath() .'">';
|
546 |
2fd6da0b
|
Andreas Kohlbecker
|
|
547 |
|
|
foreach ($renderTemplate as $partName => $part) {
|
548 |
|
|
$separator = '';
|
549 |
|
|
$partHtml = '';
|
550 |
|
|
$uri = FALSE;
|
551 |
|
|
if (!is_array($part)) {
|
552 |
|
|
continue;
|
553 |
|
|
}
|
554 |
|
|
if (isset($part['#uri']) && is_string($part['#uri'])) {
|
555 |
|
|
$uri = $part['#uri'];
|
556 |
|
|
unset($part['#uri']);
|
557 |
|
|
}
|
558 |
|
|
foreach ($part as $key => $content) {
|
559 |
|
|
$html = '';
|
560 |
|
|
if (is_array($content)) {
|
561 |
|
|
$html = $content['#html'];
|
562 |
|
|
if(isset($content['#separator'])) {
|
563 |
|
|
$separator = $content['#separator'];
|
564 |
|
|
}
|
565 |
|
|
}
|
566 |
|
|
elseif (is_string($content)) {
|
567 |
|
|
$html = $content;
|
568 |
|
|
}
|
569 |
|
|
$partHtml .= '<span class="' . $key . '">' . $html . '</span>';
|
570 |
|
|
}
|
571 |
|
|
if ($uri) {
|
572 |
|
|
// cannot use l() here since the #uri aleady should have been processed through uri() at this point
|
573 |
|
|
$out .= $separator . '<a href="' . $uri . '" class="' . $partName . '">' . $partHtml . '</a>';
|
574 |
|
|
|
575 |
|
|
}
|
576 |
|
|
else {
|
577 |
|
|
$out .= $separator . $partHtml;
|
578 |
|
|
}
|
579 |
|
|
}
|
580 |
|
|
$out .= '</span>';
|
581 |
|
|
if ($show_annotations) {
|
582 |
d8069342
|
Andreas Kohlbecker
|
// $out .= render_entities_annotations_as_footnote_keys([$taxonName]);
|
583 |
2fd6da0b
|
Andreas Kohlbecker
|
}
|
584 |
|
|
return $out;
|
585 |
|
|
}
|
586 |
|
|
|
587 |
7212f0bc
|
Andreas Kohlbecker
|
|
588 |
|
|
|
589 |
|
|
/**
|
590 |
26b8a1bc
|
Andreas Kohlbecker
|
* Composes information for a registration from a dto object.
|
591 |
|
|
*
|
592 |
|
|
* Registrations which are not yet published are suppressed.
|
593 |
7212f0bc
|
Andreas Kohlbecker
|
*
|
594 |
|
|
* @param $registration_dto
|
595 |
|
|
* @param $with_citation
|
596 |
|
|
* Whether to show the citation.
|
597 |
|
|
*
|
598 |
|
|
* @return array
|
599 |
|
|
* A drupal render array with the elements:
|
600 |
26b8a1bc
|
Andreas Kohlbecker
|
* - 'name'
|
601 |
|
|
* - 'name-relations'
|
602 |
|
|
* - 'specimen_type_designations'
|
603 |
|
|
* - 'name_type_designations'
|
604 |
7212f0bc
|
Andreas Kohlbecker
|
* - 'citation'
|
605 |
26b8a1bc
|
Andreas Kohlbecker
|
* - 'registration_date_and_institute'
|
606 |
7212f0bc
|
Andreas Kohlbecker
|
* @ingroup compose
|
607 |
|
|
*/
|
608 |
26b8a1bc
|
Andreas Kohlbecker
|
function compose_registration_dto_full($registration_dto, $with_citation = true)
|
609 |
7212f0bc
|
Andreas Kohlbecker
|
{
|
610 |
54c10803
|
Andreas Kohlbecker
|
$render_array = array(
|
611 |
|
|
'#prefix' => '<div class="registration">',
|
612 |
|
|
'#suffix' => '</div>'
|
613 |
|
|
);
|
614 |
7212f0bc
|
Andreas Kohlbecker
|
|
615 |
26b8a1bc
|
Andreas Kohlbecker
|
if(!(isset($registration_dto->identifier) && $registration_dto->status == 'PUBLISHED')){
|
616 |
|
|
return $render_array;
|
617 |
|
|
}
|
618 |
|
|
|
619 |
b7e96f18
|
Andreas Kohlbecker
|
$render_array['sub_headline'] = markup_to_render_array(join(", ", registration_types($registration_dto)),-10, '<h3 class="registration_type">' . t('Event: '), '</h3>' );
|
620 |
c5abae79
|
Andreas Kohlbecker
|
$render_array['nomenclatural_act'] = array(
|
621 |
|
|
'#weight' => 0,
|
622 |
|
|
'#prefix' => '<div class="nomenclatural_act">',
|
623 |
b7e96f18
|
Andreas Kohlbecker
|
|
624 |
c5abae79
|
Andreas Kohlbecker
|
'#suffix' => '</div>'
|
625 |
|
|
);
|
626 |
b90ef618
|
Andreas Kohlbecker
|
|
627 |
e69c4103
|
Andreas Kohlbecker
|
// name
|
628 |
991ae630
|
Andreas Kohlbecker
|
$name_relations = null;
|
629 |
26b8a1bc
|
Andreas Kohlbecker
|
if($registration_dto->nameRef){
|
630 |
|
|
$name = cdm_ws_get(CDM_WS_PORTAL_NAME, $registration_dto->nameRef->uuid);
|
631 |
a7560a18
|
Andreas Kohlbecker
|
cdm_load_tagged_full_title($name);
|
632 |
c5abae79
|
Andreas Kohlbecker
|
$render_array['nomenclatural_act']['published_name'] = markup_to_render_array('<div class="published-name">' . render_taxon_or_name($name, url(path_to_name($name->uuid))) . '</div>', 0);
|
633 |
26b8a1bc
|
Andreas Kohlbecker
|
$name_relations = cdm_ws_fetch_all(str_replace("$0", $registration_dto->nameRef->uuid, CDM_WS_PORTAL_NAME_NAME_RELATIONS));
|
634 |
991ae630
|
Andreas Kohlbecker
|
// need to create the name relationships later, so that the foot notes are in correct order, see section // name relations
|
635 |
2dce3b2a
|
Andreas Kohlbecker
|
} else {
|
636 |
|
|
// in this case the registration must have a
|
637 |
|
|
$name = cdm_ws_get(CDM_WS_PORTAL_NAME, $registration_dto->typifiedNameRef->uuid);
|
638 |
54c10803
|
Andreas Kohlbecker
|
$render_array['typified_name'] = markup_to_render_array('<p class="typified-name">for ' . render_taxon_or_name($name, url(path_to_name($name->uuid))) . '</p>', 40);
|
639 |
26b8a1bc
|
Andreas Kohlbecker
|
}
|
640 |
991ae630
|
Andreas Kohlbecker
|
|
641 |
e69c4103
|
Andreas Kohlbecker
|
// typedesignation in detail
|
642 |
26b8a1bc
|
Andreas Kohlbecker
|
if(is_object($registration_dto->orderdTypeDesignationWorkingSets)) {
|
643 |
|
|
$field_unit_uuids = array();
|
644 |
|
|
$specimen_type_designation_refs = array();
|
645 |
|
|
$name_type_designation_refs = array();
|
646 |
67f5eac2
|
Andreas Kohlbecker
|
foreach ((array)$registration_dto->orderdTypeDesignationWorkingSets as $workingset_ref => $obj) {
|
647 |
|
|
$tokens = explode("#", $workingset_ref);
|
648 |
|
|
$types_in_fieldunit = get_object_vars($obj); // convert into associative array
|
649 |
|
|
|
650 |
26b8a1bc
|
Andreas Kohlbecker
|
if ($tokens[0] == 'NameTypeDesignation') {
|
651 |
67f5eac2
|
Andreas Kohlbecker
|
foreach ($types_in_fieldunit as $type_status => $entity_reference_list) {
|
652 |
|
|
if(!isset($name_type_designation_refs[$type_status])){
|
653 |
|
|
$name_type_designation_refs[$type_status] = $entity_reference_list;
|
654 |
|
|
} else {
|
655 |
|
|
array_push($name_type_designation_refs[$type_status] ,$entity_reference_list);
|
656 |
|
|
}
|
657 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
658 |
26b8a1bc
|
Andreas Kohlbecker
|
} else if ($tokens[0] == 'FieldUnit'){
|
659 |
|
|
$field_unit_uuids[] = $tokens[1];
|
660 |
67f5eac2
|
Andreas Kohlbecker
|
foreach ($types_in_fieldunit as $type_status => $entity_reference_list) {
|
661 |
|
|
if(!isset($specimen_type_designation_refs[$type_status])){
|
662 |
|
|
$specimen_type_designation_refs[$type_status] = $entity_reference_list;
|
663 |
|
|
} else {
|
664 |
|
|
array_push($specimen_type_designation_refs[$type_status], $entity_reference_list);
|
665 |
|
|
}
|
666 |
|
|
}
|
667 |
26b8a1bc
|
Andreas Kohlbecker
|
} else {
|
668 |
|
|
drupal_set_message("Unimplemented type: " . $tokens[0], 'error');
|
669 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
670 |
|
|
}
|
671 |
991ae630
|
Andreas Kohlbecker
|
// type designations which are in this nomenclatural act.
|
672 |
26b8a1bc
|
Andreas Kohlbecker
|
if (count($name_type_designation_refs) > 0) {
|
673 |
c5abae79
|
Andreas Kohlbecker
|
$render_array['nomenclatural_act']['name_type_designations'] = compose_name_type_designations($name_type_designation_refs);
|
674 |
|
|
$render_array['nomenclatural_act']['name_type_designations']['#prefix'] = '<p class="name_type_designations">';
|
675 |
|
|
$render_array['nomenclatural_act']['name_type_designations']['#suffix'] = '</p>';
|
676 |
|
|
$render_array['nomenclatural_act']['name_type_designations']['#weight'] = 20;
|
677 |
26b8a1bc
|
Andreas Kohlbecker
|
}
|
678 |
|
|
if (count($field_unit_uuids) > 0) {
|
679 |
e69c4103
|
Andreas Kohlbecker
|
$specimen_type_designations_array = compose_specimen_type_designations($specimen_type_designation_refs, true);
|
680 |
c5abae79
|
Andreas Kohlbecker
|
$render_array['nomenclatural_act']['specimen_type_designations'] = $specimen_type_designations_array['type_designations'];
|
681 |
41a348be
|
Andreas Kohlbecker
|
$render_array['map'] = $specimen_type_designations_array['map'];
|
682 |
c5abae79
|
Andreas Kohlbecker
|
$render_array['map']['#weight'] = $render_array['nomenclatural_act']['#weight'] + 20;
|
683 |
26b8a1bc
|
Andreas Kohlbecker
|
}
|
684 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
685 |
|
|
|
686 |
991ae630
|
Andreas Kohlbecker
|
// name relations
|
687 |
|
|
if($name_relations){
|
688 |
|
|
$render_array['nomenclatural_act']['name_relations'] = compose_name_relationships_list($name_relations, $registration_dto->nameRef->uuid, null);
|
689 |
|
|
$render_array['nomenclatural_act']['name_relations']['#weight'] = 10;
|
690 |
|
|
}
|
691 |
|
|
|
692 |
7212f0bc
|
Andreas Kohlbecker
|
// citation
|
693 |
|
|
if ($with_citation) {
|
694 |
|
|
$render_array['citation'] = markup_to_render_array(
|
695 |
c5abae79
|
Andreas Kohlbecker
|
"<div class=\"citation nomenclatural_act_citation" . html_class_attribute_ref(new TypedEntityReference("Reference", $registration_dto->citationUuid)) . "\">"
|
696 |
|
|
. "<span class=\"label\">published in: </span>"
|
697 |
2ffe4d59
|
Andreas Kohlbecker
|
. $registration_dto->bibliographicInRefCitationString
|
698 |
|
|
. l(custom_icon_font_markup('icon-interal-link-alt-solid', array('class' => array('superscript'))), path_to_reference($registration_dto->citationUuid), array('html' => true))
|
699 |
c5abae79
|
Andreas Kohlbecker
|
. "</div>",
|
700 |
|
|
$render_array['nomenclatural_act']['#weight'] + 10 );
|
701 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
702 |
|
|
|
703 |
1c30a02b
|
Andreas Kohlbecker
|
$render_array['nomenclatural_act']['footnotes'] = markup_to_render_array(render_footnotes(),100);
|
704 |
0e617798
|
Andreas Kohlbecker
|
|
705 |
7212f0bc
|
Andreas Kohlbecker
|
// registration date and office
|
706 |
12466422
|
Andreas Kohlbecker
|
$registration_date_insitute_markup = render_registration_date_and_institute($registration_dto);
|
707 |
26b8a1bc
|
Andreas Kohlbecker
|
if($registration_date_insitute_markup){
|
708 |
|
|
$render_array['registration_date_and_institute'] = markup_to_render_array(
|
709 |
|
|
$registration_date_insitute_markup . '</p>',
|
710 |
|
|
100);
|
711 |
|
|
}
|
712 |
|
|
|
713 |
0e617798
|
Andreas Kohlbecker
|
|
714 |
26b8a1bc
|
Andreas Kohlbecker
|
return $render_array;
|
715 |
|
|
}
|
716 |
|
|
|
717 |
|
|
|
718 |
|
|
/**
|
719 |
|
|
* Composes a compact representation for a registrationDTO object
|
720 |
|
|
*
|
721 |
|
|
* Registrations which are not yet published are suppressed.
|
722 |
|
|
*
|
723 |
|
|
* @param $registration_dto
|
724 |
|
|
* @param $style string
|
725 |
|
|
* The style of how to compose the 'identifier' and 'registration_date_and_institute' part with the summary
|
726 |
|
|
* - 'citation': Similar to the arrearance of nomenclatural acts in print media
|
727 |
|
|
* - 'list-item' : style suitable for result lists etc
|
728 |
|
|
*
|
729 |
|
|
* @return array
|
730 |
|
|
* A drupal render array with the elements:
|
731 |
|
|
* - 'registration-metadata' when $style == 'list-item'
|
732 |
|
|
* - 'summary'
|
733 |
|
|
* @ingroup compose
|
734 |
|
|
*/
|
735 |
|
|
function compose_registration_dto_compact($registration_dto, $style = 'citation', $tag_enclosing_summary = 'p')
|
736 |
|
|
{
|
737 |
|
|
$render_array = array();
|
738 |
|
|
$media_link_map = array();
|
739 |
|
|
|
740 |
|
|
if(!(isset($registration_dto->identifier) && $registration_dto->status == 'PUBLISHED')){
|
741 |
|
|
return $render_array;
|
742 |
|
|
}
|
743 |
|
|
|
744 |
12466422
|
Andreas Kohlbecker
|
$registration_date_insitute_markup = render_registration_date_and_institute($registration_dto, 'span');
|
745 |
977bba78
|
Andreas Kohlbecker
|
$itentifier_markup = l($registration_dto->identifier, path_to_registration($registration_dto->identifier), array('attributes' => array('class' => array('identifier'))));
|
746 |
26b8a1bc
|
Andreas Kohlbecker
|
|
747 |
f461a488
|
Andreas Kohlbecker
|
$tagged_text_options = array();
|
748 |
|
|
if(isset($registration_dto->nameRef)){
|
749 |
|
|
$tagged_text_options[] = array(
|
750 |
|
|
'filter-type' => 'name',
|
751 |
|
|
'prefix' => '<span class="registered_name">',
|
752 |
|
|
'suffix' => '</span>',
|
753 |
|
|
);
|
754 |
|
|
} else {
|
755 |
|
|
$tagged_text_options[] = array(
|
756 |
|
|
'filter-type' => 'name',
|
757 |
|
|
'prefix' => '<span class="referenced_typified_name">',
|
758 |
|
|
'suffix' => '</span>',
|
759 |
|
|
);
|
760 |
|
|
}
|
761 |
|
|
cdm_tagged_text_add_options($registration_dto->summaryTaggedText, $tagged_text_options);
|
762 |
26b8a1bc
|
Andreas Kohlbecker
|
$taggged_text_expanded = cdm_tagged_text_expand_entity_references($registration_dto->summaryTaggedText);
|
763 |
|
|
foreach ($taggged_text_expanded as $tagged_text){
|
764 |
|
|
if(isset($tagged_text->entityReference->type) && $tagged_text->entityReference->type == 'SpecimenTypeDesignation') {
|
765 |
|
|
$mediaDTOs = cdm_ws_get('typedesignation/$0/media', array($tagged_text->entityReference->uuid));
|
766 |
|
|
if(isset($mediaDTOs[0]->uri)){
|
767 |
|
|
$media_url_key = '{link-' . $mediaDTOs[0]->uuid . '}';
|
768 |
|
|
$tagged_text->text = str_replace('[icon]', '[icon]' . $media_url_key, $tagged_text->text);
|
769 |
|
|
$media_link_map[$media_url_key] = cdm_external_uri($mediaDTOs[0]->uri, true);
|
770 |
|
|
}
|
771 |
|
|
}
|
772 |
|
|
}
|
773 |
|
|
$registation_markup = cdm_tagged_text_to_markup($taggged_text_expanded);
|
774 |
|
|
foreach($media_link_map as $media_url_key => $link){
|
775 |
|
|
$registation_markup = str_replace($media_url_key, $link, $registation_markup);
|
776 |
|
|
}
|
777 |
|
|
if($style == 'citation') {
|
778 |
|
|
$registation_markup = $registation_markup . ' ' . $itentifier_markup . ' ' . $registration_date_insitute_markup;
|
779 |
|
|
} else {
|
780 |
|
|
$render_array['registration-metadata'] = markup_to_render_array('<div class="registration-metadata">' . $itentifier_markup . ' ' . $registration_date_insitute_markup. "</div>", -10);
|
781 |
|
|
}
|
782 |
f461a488
|
Andreas Kohlbecker
|
$render_array['summary'] = markup_to_render_array('<' . $tag_enclosing_summary . ' class="registration-summary">' . $registation_markup . '</' . $tag_enclosing_summary . '>', 0);
|
783 |
26b8a1bc
|
Andreas Kohlbecker
|
|
784 |
|
|
return $render_array;
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
|
788 |
|
|
/**
|
789 |
|
|
* Renders the registrationDate and institutionTitleCache of the $registration_dto as markup.
|
790 |
|
|
*
|
791 |
|
|
* @param $registration_dto
|
792 |
|
|
* @return string
|
793 |
|
|
* The markup or an empty string
|
794 |
|
|
*/
|
795 |
12466422
|
Andreas Kohlbecker
|
function render_registration_date_and_institute($registration_dto, $enclosing_tag = 'p') {
|
796 |
|
|
$registration_date_institute_markup = '';
|
797 |
26b8a1bc
|
Andreas Kohlbecker
|
if ($registration_dto->registrationDate) {
|
798 |
7212f0bc
|
Andreas Kohlbecker
|
$date_string = format_datetime($registration_dto->registrationDate);
|
799 |
26b8a1bc
|
Andreas Kohlbecker
|
if (isset($registration_dto->institutionTitleCache) && $registration_dto->institutionTitleCache) {
|
800 |
12466422
|
Andreas Kohlbecker
|
$registration_date_institute_markup =
|
801 |
7212f0bc
|
Andreas Kohlbecker
|
t("Registration on @date in @institution", array(
|
802 |
|
|
'@date' => $date_string,
|
803 |
|
|
'@institution' => $registration_dto->institutionTitleCache,
|
804 |
|
|
));
|
805 |
|
|
} else {
|
806 |
12466422
|
Andreas Kohlbecker
|
$registration_date_institute_markup =
|
807 |
7212f0bc
|
Andreas Kohlbecker
|
t("Registration on @date", array(
|
808 |
|
|
'@date' => $date_string
|
809 |
|
|
));
|
810 |
|
|
}
|
811 |
12466422
|
Andreas Kohlbecker
|
$registration_date_institute_markup = '<' .$enclosing_tag . ' class="registration-date-and-institute">'. $registration_date_institute_markup . '</' .$enclosing_tag . '>';
|
812 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
813 |
12466422
|
Andreas Kohlbecker
|
return $registration_date_institute_markup;
|
814 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
815 |
|
|
|
816 |
|
|
|
817 |
eaff53f7
|
Andreas Kohlbecker
|
/**
|
818 |
|
|
* @param $registrations
|
819 |
|
|
* @return string
|
820 |
|
|
*/
|
821 |
|
|
function render_registrations($registrations)
|
822 |
|
|
{
|
823 |
|
|
$registration_markup = '';
|
824 |
|
|
$registration_markup_array = array();
|
825 |
|
|
if ($registrations) {
|
826 |
|
|
foreach ($registrations as $reg) {
|
827 |
|
|
$registration_markup_array[] = render_registration($reg);
|
828 |
|
|
}
|
829 |
|
|
$registration_markup = " Registration" . (count($registration_markup_array) > 1 ? 's: ' : ': ')
|
830 |
|
|
. join(', ', $registration_markup_array);
|
831 |
|
|
}
|
832 |
|
|
return $registration_markup;
|
833 |
|
|
}
|
834 |
|
|
|
835 |
471192e3
|
Andreas Kohlbecker
|
|
836 |
7212f0bc
|
Andreas Kohlbecker
|
/**
|
837 |
|
|
* Renders a registration
|
838 |
|
|
*
|
839 |
26b8a1bc
|
Andreas Kohlbecker
|
* TODO replace by compose_registration_dto_compact
|
840 |
7212f0bc
|
Andreas Kohlbecker
|
* @param $registration
|
841 |
|
|
*/
|
842 |
|
|
function render_registration($registration){
|
843 |
|
|
$markup = '';
|
844 |
|
|
|
845 |
|
|
if(isset($registration->identifier) && $registration->status == 'PUBLISHED'){
|
846 |
|
|
$office_class_attribute = '';
|
847 |
|
|
if(isset($registration->institution->titleCache)){
|
848 |
26b8a1bc
|
Andreas Kohlbecker
|
$office_class_attribute = registration_intitute_class_attribute($registration);
|
849 |
7212f0bc
|
Andreas Kohlbecker
|
}
|
850 |
977bba78
|
Andreas Kohlbecker
|
$markup = "<span class=\"registration $office_class_attribute\">" . l($registration->identifier, path_to_registration($registration->identifier)) . ', '
|
851 |
7212f0bc
|
Andreas Kohlbecker
|
. preg_replace('/^([^T]*)(.*)$/', '${1}', $registration->registrationDate)
|
852 |
|
|
. '</span>';
|
853 |
|
|
}
|
854 |
|
|
return $markup;
|
855 |
|
|
}
|
856 |
|
|
|
857 |
26b8a1bc
|
Andreas Kohlbecker
|
/**
|
858 |
|
|
* @param $registration
|
859 |
|
|
* @return string
|
860 |
|
|
*/
|
861 |
|
|
function registration_intitute_class_attribute($registration_dto)
|
862 |
|
|
{
|
863 |
|
|
if(isset($registration_dto->institutionTitleCache)){
|
864 |
|
|
$institutionTitleCache = $registration_dto->institutionTitleCache;
|
865 |
|
|
} else {
|
866 |
|
|
// fall back option to also support cdm entities
|
867 |
|
|
$institutionTitleCache = @$registration_dto->institution->titleCache;
|
868 |
|
|
}
|
869 |
|
|
return $institutionTitleCache ? 'registration-' . strtolower(preg_replace('/[^a-zA-Z0-9]/', '-', $institutionTitleCache)) : '';
|
870 |
|
|
}
|
871 |
|
|
|
872 |
7212f0bc
|
Andreas Kohlbecker
|
|
873 |
79904336
|
Andreas Kohlbecker
|
/**
|
874 |
|
|
* Renders and array of CDM TypeDesignations
|
875 |
|
|
*
|
876 |
0e617798
|
Andreas Kohlbecker
|
* - NameTypeDesignation
|
877 |
|
|
* - SpecimenTypeDesignation
|
878 |
|
|
* - TextualTypeDesignation
|
879 |
|
|
*
|
880 |
79904336
|
Andreas Kohlbecker
|
* @param object $type_designations an array of cdm TypeDesignation entities
|
881 |
|
|
* to render
|
882 |
|
|
* @param string $enclosing_tag the tag element type to enclose the whole list
|
883 |
|
|
* of type designation with. By default this DOM element is <ul>
|
884 |
|
|
* @param string $element_tag the tag element type to be used for each
|
885 |
|
|
* type designation item.
|
886 |
|
|
* @param bool $link_to_specimen_page whether a specimen in type designation element
|
887 |
|
|
* should be a link or not.
|
888 |
|
|
*
|
889 |
|
|
* @return string The markup.
|
890 |
|
|
*
|
891 |
|
|
* @InGroup Render
|
892 |
|
|
*/
|
893 |
|
|
function render_type_designations($type_designations, $enclosing_tag = 'ul', $element_tag = 'li', $link_to_specimen_page = true) {
|
894 |
|
|
|
895 |
|
|
// need to add element to render path since type designations
|
896 |
|
|
// need other name render template
|
897 |
|
|
RenderHints::pushToRenderStack('typedesignations');
|
898 |
|
|
|
899 |
|
|
$out = '<' . $enclosing_tag .' class="typeDesignations">';
|
900 |
|
|
$specimen_type_designations = array();
|
901 |
|
|
$name_type_designations = array();
|
902 |
|
|
$textual_type_designations = array();
|
903 |
|
|
$separator = ',';
|
904 |
|
|
|
905 |
|
|
foreach ($type_designations as $type_designation) {
|
906 |
|
|
switch ($type_designation->class) {
|
907 |
|
|
case 'SpecimenTypeDesignation':
|
908 |
|
|
$specimen_type_designations[] = $type_designation;
|
909 |
|
|
break;
|
910 |
|
|
case 'NameTypeDesignation':
|
911 |
|
|
$name_type_designations[] = $type_designation;
|
912 |
|
|
break;
|
913 |
|
|
case 'TextualTypeDesignation':
|
914 |
|
|
$textual_type_designations[] = $type_designation;
|
915 |
|
|
break;
|
916 |
|
|
default: throw new Exception('Unknown type designation class: ' . $type_designation->class);
|
917 |
|
|
}
|
918 |
|
|
}
|
919 |
|
|
|
920 |
|
|
// NameTypeDesignation ..................................
|
921 |
|
|
if(!empty($name_type_designations)){
|
922 |
04d5812b
|
Andreas Kohlbecker
|
usort($name_type_designations, "compare_type_designations_by_status");
|
923 |
79904336
|
Andreas Kohlbecker
|
foreach($name_type_designations as $name_type_designation){
|
924 |
|
|
if ($name_type_designation->notDesignated) {
|
925 |
|
|
$out .= '<'. $element_tag .' class="' . html_class_attribute_ref($name_type_designation) . '">' . type_designation_status_label_markup($name_type_designation) . ': '
|
926 |
|
|
. t('not designated') . '</'. $element_tag .'>';
|
927 |
|
|
}
|
928 |
|
|
elseif (isset($name_type_designation->typeName)) {
|
929 |
|
|
$link_to_name_page = url(path_to_name($name_type_designation->typeName->uuid));
|
930 |
|
|
$out .= '<'. $element_tag .' class="' . html_class_attribute_ref($name_type_designation) . '">' . type_designation_status_label_markup($name_type_designation) ;
|
931 |
|
|
|
932 |
|
|
if (!empty($name_type_designation->citation)) {
|
933 |
|
|
$out .= type_designation_citation_layout($name_type_designation, $separator); // TODO type_designation_citation_layout() needs most probably to be replaced
|
934 |
|
|
|
935 |
|
|
}
|
936 |
|
|
$referenceUri = '';
|
937 |
6679207a
|
Andreas Kohlbecker
|
if (isset($name_type_designation->typeName->nomenclaturalSource->citation)) {
|
938 |
|
|
$referenceUri = url(path_to_reference($name_type_designation->typeName->nomenclaturalSource->citation->uuid));
|
939 |
79904336
|
Andreas Kohlbecker
|
}
|
940 |
|
|
$out .= ': ' . render_taxon_or_name($name_type_designation->typeName, $link_to_name_page, $referenceUri, TRUE, TRUE);
|
941 |
|
|
}
|
942 |
991ae630
|
Andreas Kohlbecker
|
$annotations_and_sources = handle_annotations_and_sources(
|
943 |
|
|
$name_type_designation,
|
944 |
|
|
typedesignations_annotations_and_sources_config(),
|
945 |
|
|
'',
|
946 |
|
|
RenderHints::getFootnoteListKey());
|
947 |
|
|
$out .= $annotations_and_sources['foot_note_keys'];
|
948 |
79904336
|
Andreas Kohlbecker
|
}
|
949 |
|
|
} // END NameTypeDesignation
|
950 |
|
|
|
951 |
|
|
// SpecimenTypeDesignation ...................................
|
952 |
|
|
if (!empty($specimen_type_designations)) {
|
953 |
|
|
usort($specimen_type_designations, "compare_specimen_type_designation");
|
954 |
|
|
foreach ($specimen_type_designations as $specimen_type_designation) {
|
955 |
|
|
$type_citation_markup = '';
|
956 |
|
|
|
957 |
|
|
if (!empty($specimen_type_designation->citation)) {
|
958 |
|
|
|
959 |
e7f3789b
|
Andreas Kohlbecker
|
$citation_footnote_str = cdm_reference_markup($specimen_type_designation->citation, null, false, true);
|
960 |
79904336
|
Andreas Kohlbecker
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $specimen_type_designation->citation->uuid);
|
961 |
|
|
|
962 |
|
|
if (!empty($author_team->titleCache)) {
|
963 |
|
|
$year = @timePeriodToString($specimen_type_designation->citation->datePublished, true, 'YYYY');
|
964 |
|
|
$authorteam_str = $author_team->titleCache . ($year ? ' ' : '') . $year;
|
965 |
|
|
if ($authorteam_str == $specimen_type_designation->citation->titleCache) {
|
966 |
|
|
$citation_footnote_str = '';
|
967 |
|
|
}
|
968 |
|
|
} else {
|
969 |
|
|
$authorteam_str = $citation_footnote_str;
|
970 |
|
|
// no need for a footnote in case in case it is used as replacement for missing author teams
|
971 |
|
|
$citation_footnote_str = '';
|
972 |
|
|
}
|
973 |
|
|
|
974 |
|
|
// for being registered a typedesignation MUST HAVE a citation, so it is save to handle the
|
975 |
|
|
// Registration output in if condition checking if the citation is present
|
976 |
|
|
$registration_markup = render_registrations($specimen_type_designation->registrations);
|
977 |
|
|
$citation_footnote_str .= ($citation_footnote_str ? ' ' : '') . $registration_markup;
|
978 |
|
|
|
979 |
|
|
$footnote_key_markup = '';
|
980 |
|
|
if ($citation_footnote_str) {
|
981 |
|
|
// footnotes should be rendered in the parent element so we
|
982 |
|
|
// are relying on the FootnoteListKey set there
|
983 |
|
|
$_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $citation_footnote_str);
|
984 |
d8069342
|
Andreas Kohlbecker
|
$footnote_key_markup = render_footnote_key($_fkey2, $separator, TRUE);
|
985 |
79904336
|
Andreas Kohlbecker
|
}
|
986 |
|
|
|
987 |
|
|
$type_citation_markup .= ' (' . t('designated by') . ' <span class="typeReference">' . $authorteam_str . '</span>';
|
988 |
|
|
if (!empty($specimen_type_designation->citationMicroReference)) {
|
989 |
|
|
$type_citation_markup .= ': ' . trim($specimen_type_designation->citationMicroReference);
|
990 |
|
|
}
|
991 |
|
|
$type_citation_markup .= $footnote_key_markup . ')';
|
992 |
|
|
|
993 |
|
|
}
|
994 |
|
|
|
995 |
991ae630
|
Andreas Kohlbecker
|
|
996 |
79904336
|
Andreas Kohlbecker
|
$out .= '<'. $element_tag .' class="' . html_class_attribute_ref($specimen_type_designation) . '">';
|
997 |
|
|
$out .= type_designation_status_label_markup($specimen_type_designation) . $type_citation_markup;
|
998 |
|
|
|
999 |
|
|
|
1000 |
|
|
$derivedUnitFacadeInstance = null;
|
1001 |
|
|
if (isset($specimen_type_designation->typeSpecimen)) {
|
1002 |
|
|
$derivedUnitFacadeInstance = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $specimen_type_designation->typeSpecimen->uuid);
|
1003 |
|
|
}
|
1004 |
|
|
|
1005 |
|
|
if (!empty($derivedUnitFacadeInstance->titleCache)) {
|
1006 |
|
|
$specimen_markup = $derivedUnitFacadeInstance->titleCache;
|
1007 |
|
|
if($link_to_specimen_page && isset($derivedUnitFacadeInstance->specimenLabel) && $derivedUnitFacadeInstance->specimenLabel){
|
1008 |
|
|
$specimen_markup = str_replace($derivedUnitFacadeInstance->specimenLabel, l($derivedUnitFacadeInstance->specimenLabel, path_to_specimen($specimen_type_designation->typeSpecimen->uuid)), $specimen_markup);
|
1009 |
|
|
}
|
1010 |
991ae630
|
Andreas Kohlbecker
|
$annotations_and_sources = handle_annotations_and_sources(
|
1011 |
|
|
$derivedUnitFacadeInstance,
|
1012 |
|
|
typedesignations_annotations_and_sources_config(),
|
1013 |
|
|
'',
|
1014 |
|
|
RenderHints::getFootnoteListKey()
|
1015 |
|
|
);
|
1016 |
79904336
|
Andreas Kohlbecker
|
$out .= ': <span class="' . html_class_attribute_ref($specimen_type_designation->typeSpecimen) . '">'
|
1017 |
|
|
. $specimen_markup
|
1018 |
|
|
. '</span>'; // . ': ' . theme('cdm_specimen', array('specimenTypeDesignation' => $derivedUnitFacadeInstance));
|
1019 |
|
|
if(!empty($derivedUnitFacadeInstance->preferredStableUri)){
|
1020 |
|
|
$out .= ' ' . l($derivedUnitFacadeInstance->preferredStableUri, $derivedUnitFacadeInstance->preferredStableUri, array('absolute' => true));
|
1021 |
|
|
}
|
1022 |
991ae630
|
Andreas Kohlbecker
|
$out .= $annotations_and_sources['foot_note_keys'];
|
1023 |
79904336
|
Andreas Kohlbecker
|
}
|
1024 |
|
|
$out .= '</'. $element_tag .'>';
|
1025 |
|
|
}
|
1026 |
|
|
} // END Specimen type designations
|
1027 |
|
|
|
1028 |
|
|
// TextualTypeDesignation .........................
|
1029 |
04d5812b
|
Andreas Kohlbecker
|
usort($textual_type_designations, 'compare_textual_type_designation');
|
1030 |
79904336
|
Andreas Kohlbecker
|
if(!empty($textual_type_designations)) {
|
1031 |
|
|
foreach ($textual_type_designations as $textual_type_designation) {
|
1032 |
|
|
$annotations_and_sources = handle_annotations_and_sources(
|
1033 |
|
|
$textual_type_designation,
|
1034 |
|
|
array(
|
1035 |
3c4a5472
|
Andreas Kohlbecker
|
// these settings differ from those provided by typedesignations_annotations_and_sources_config()
|
1036 |
|
|
// TODO is this by purpose? please document the reason for the difference
|
1037 |
79904336
|
Andreas Kohlbecker
|
'sources_as_content' => false, // as footnotes
|
1038 |
|
|
'link_to_name_used_in_source' => false,
|
1039 |
|
|
'link_to_reference' => true,
|
1040 |
a6c4c53c
|
Andreas Kohlbecker
|
'add_footnote_keys' => true,
|
1041 |
|
|
'bibliography_aware' => false
|
1042 |
|
|
),
|
1043 |
79904336
|
Andreas Kohlbecker
|
'',
|
1044 |
991ae630
|
Andreas Kohlbecker
|
RenderHints::getFootnoteListKey() // passing a defined key to avoid a separate annotation footnote key see https://dev.e-taxonomy.eu/redmine/issues/8543
|
1045 |
79904336
|
Andreas Kohlbecker
|
);
|
1046 |
a6c4c53c
|
Andreas Kohlbecker
|
$encasement = $textual_type_designation->verbatim ? '"' : '';
|
1047 |
|
|
$out .= '<' . $element_tag . ' class="' . html_class_attribute_ref($textual_type_designation) . '">' . type_designation_status_label_markup(null)
|
1048 |
|
|
. ': ' . $encasement . trim($textual_type_designation->text_L10n->text) . $encasement . $annotations_and_sources['foot_note_keys'] .'</' . $element_tag . '>';
|
1049 |
|
|
// if(is_array( $annotations_and_sources['source_references'])){
|
1050 |
|
|
// $citation_markup = join(', ', $annotations_and_sources['source_references']);
|
1051 |
|
|
// }
|
1052 |
|
|
// $out .= $citation_markup;
|
1053 |
79904336
|
Andreas Kohlbecker
|
}
|
1054 |
|
|
}
|
1055 |
|
|
|
1056 |
991ae630
|
Andreas Kohlbecker
|
// Footnotes for citations, collection acronyms.
|
1057 |
79904336
|
Andreas Kohlbecker
|
// footnotes should be rendered in the parent element so we
|
1058 |
|
|
// are relying on the FootnoteListKey set there
|
1059 |
|
|
$_fkey = FootnoteManager::addNewFootnote(
|
1060 |
|
|
RenderHints::getFootnoteListKey(),
|
1061 |
|
|
(isset($derivedUnitFacadeInstance->collection->titleCache) ? $derivedUnitFacadeInstance->collection->titleCache : FALSE)
|
1062 |
|
|
);
|
1063 |
d8069342
|
Andreas Kohlbecker
|
$out .= render_footnote_key($_fkey, $separator);
|
1064 |
79904336
|
Andreas Kohlbecker
|
$out .= '</' . $enclosing_tag .'>';
|
1065 |
|
|
|
1066 |
|
|
RenderHints::popFromRenderStack();
|
1067 |
|
|
|
1068 |
|
|
return $out;
|
1069 |
|
|
}
|
1070 |
|
|
|
1071 |
|
|
|
1072 |
a9a04561
|
Andreas Kohlbecker
|
/**
|
1073 |
|
|
* Composes the textual representation for the type designation of taxon name identified by the uuid in with a map for the location data.
|
1074 |
41a348be
|
Andreas Kohlbecker
|
*
|
1075 |
a9a04561
|
Andreas Kohlbecker
|
* @param $taxon_name_uuid
|
1076 |
10858926
|
Andreas Kohlbecker
|
* @param $show_specimen_details
|
1077 |
a9a04561
|
Andreas Kohlbecker
|
* @return array
|
1078 |
ae177dac
|
Andreas Kohlbecker
|
* A drupal render array with the following elements:
|
1079 |
a9a04561
|
Andreas Kohlbecker
|
* - 'type_designations'
|
1080 |
|
|
* - 'map'
|
1081 |
ae177dac
|
Andreas Kohlbecker
|
* - 'specimens'
|
1082 |
a9a04561
|
Andreas Kohlbecker
|
*
|
1083 |
|
|
* @ingroup compose
|
1084 |
|
|
*/
|
1085 |
10858926
|
Andreas Kohlbecker
|
function compose_type_designations($taxon_name_uuid, $show_specimen_details = false)
|
1086 |
a9a04561
|
Andreas Kohlbecker
|
{
|
1087 |
41a348be
|
Andreas Kohlbecker
|
$render_array = array(
|
1088 |
|
|
'type_designations' => array(),
|
1089 |
|
|
'map' => array(),
|
1090 |
|
|
);
|
1091 |
a9a04561
|
Andreas Kohlbecker
|
$type_designations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $taxon_name_uuid);
|
1092 |
|
|
if ($type_designations) {
|
1093 |
fb939fdc
|
Andreas Kohlbecker
|
usort($type_designations, 'compare_specimen_type_designation');
|
1094 |
a9a04561
|
Andreas Kohlbecker
|
$render_array['type_designations'] = markup_to_render_array(
|
1095 |
0c720425
|
Andreas Kohlbecker
|
render_type_designations($type_designations, 'div', 'div')
|
1096 |
a9a04561
|
Andreas Kohlbecker
|
);
|
1097 |
|
|
|
1098 |
|
|
$render_array['map'] = compose_type_designations_map($type_designations);
|
1099 |
|
|
}
|
1100 |
|
|
return $render_array;
|
1101 |
|
|
}
|
1102 |
|
|
|
1103 |
|
|
|
1104 |
471192e3
|
Andreas Kohlbecker
|
/**
|
1105 |
|
|
* Composes the TypedEntityReference to name type designations passed as associatve array.
|
1106 |
|
|
*
|
1107 |
991ae630
|
Andreas Kohlbecker
|
* @param $type_entity_refs_by_status array
|
1108 |
471192e3
|
Andreas Kohlbecker
|
* an associative array of name type type => TypedEntityReference for name type designations as
|
1109 |
|
|
* produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager
|
1110 |
|
|
*
|
1111 |
|
|
* @ingroup compose
|
1112 |
|
|
*/
|
1113 |
991ae630
|
Andreas Kohlbecker
|
function compose_name_type_designations($type_entity_refs_by_status){
|
1114 |
471192e3
|
Andreas Kohlbecker
|
$render_array = array();
|
1115 |
e1e2d593
|
Andreas Kohlbecker
|
$preferredStableUri = '';
|
1116 |
991ae630
|
Andreas Kohlbecker
|
foreach($type_entity_refs_by_status as $type_status => $name_type_entityRefs){
|
1117 |
|
|
foreach ($name_type_entityRefs as $name_type_entity_ref){
|
1118 |
|
|
$type_designation = cdm_ws_get(CDM_WS_TYPEDESIGNATION, array($name_type_entity_ref->uuid, 'preferredUri'));
|
1119 |
|
|
$footnote_keys = '';
|
1120 |
|
|
|
1121 |
f5396e17
|
Andreas Kohlbecker
|
if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){
|
1122 |
|
|
$preferredStableUri = $type_designation->typeSpecimen->preferredStableUri;
|
1123 |
|
|
}
|
1124 |
991ae630
|
Andreas Kohlbecker
|
// annotations and sources for the $derived_unit_facade_dto
|
1125 |
|
|
$annotations_and_sources = handle_annotations_and_sources(
|
1126 |
|
|
$name_type_entity_ref,
|
1127 |
|
|
typedesignations_annotations_and_sources_config(),
|
1128 |
|
|
'',
|
1129 |
|
|
RenderHints::getFootnoteListKey()
|
1130 |
|
|
);
|
1131 |
|
|
|
1132 |
|
|
$render_array[] = markup_to_render_array('<div class="name_type_designation ' . html_class_attribute_ref($name_type_entity_ref) . '"><span class="type-status">'. ucfirst($type_status) . "</span>: "
|
1133 |
|
|
. $name_type_entity_ref->label
|
1134 |
f5396e17
|
Andreas Kohlbecker
|
. ($preferredStableUri ? " ". l($preferredStableUri, $preferredStableUri) : '')
|
1135 |
991ae630
|
Andreas Kohlbecker
|
. $annotations_and_sources['foot_note_keys']
|
1136 |
f5396e17
|
Andreas Kohlbecker
|
. '</div>');
|
1137 |
|
|
}
|
1138 |
f5e7f68e
|
Andreas Kohlbecker
|
}
|
1139 |
|
|
return $render_array;
|
1140 |
|
|
}
|
1141 |
|
|
|
1142 |
|
|
/**
|
1143 |
41a348be
|
Andreas Kohlbecker
|
* Composes the specimen type designations with map from the the $type_entity_refs
|
1144 |
f5e7f68e
|
Andreas Kohlbecker
|
*
|
1145 |
|
|
* @param $type_entity_refs array
|
1146 |
|
|
* an associative array of specimen type type => TypedEntityReference for specimen type designations as
|
1147 |
|
|
* produced by the eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager
|
1148 |
|
|
*
|
1149 |
e69c4103
|
Andreas Kohlbecker
|
* @param $show_media_specimen
|
1150 |
41a348be
|
Andreas Kohlbecker
|
* @return array
|
1151 |
6abd581c
|
Andreas Kohlbecker
|
* A drupal render array with the following elements:
|
1152 |
41a348be
|
Andreas Kohlbecker
|
* - 'type_designations'
|
1153 |
|
|
* - 'map'
|
1154 |
|
|
*
|
1155 |
|
|
* @ingroup compose
|
1156 |
|
|
*
|
1157 |
f5e7f68e
|
Andreas Kohlbecker
|
*/
|
1158 |
e69c4103
|
Andreas Kohlbecker
|
function compose_specimen_type_designations($type_entity_refs, $show_media_specimen){
|
1159 |
204e8173
|
Andreas Kohlbecker
|
|
1160 |
f5e7f68e
|
Andreas Kohlbecker
|
$render_array = array();
|
1161 |
204e8173
|
Andreas Kohlbecker
|
|
1162 |
41a348be
|
Andreas Kohlbecker
|
$type_designation_list = array();
|
1163 |
d8de8d4d
|
Andreas Kohlbecker
|
uksort($type_entity_refs, "compare_type_designation_status_labels");
|
1164 |
0e617798
|
Andreas Kohlbecker
|
foreach($type_entity_refs as $type_status => $type_designation_entity_refs){
|
1165 |
|
|
foreach($type_designation_entity_refs as $type_designation_entity_ref){
|
1166 |
204e8173
|
Andreas Kohlbecker
|
|
1167 |
0e617798
|
Andreas Kohlbecker
|
$type_designation = cdm_ws_get(CDM_WS_PORTAL_TYPEDESIGNATION, array($type_designation_entity_ref->uuid));
|
1168 |
e69c4103
|
Andreas Kohlbecker
|
$type_designation_list[] = $type_designation; // collect for the map
|
1169 |
|
|
|
1170 |
0e617798
|
Andreas Kohlbecker
|
$derived_unit_facade_dto = cdm_ws_get(CDM_WS_PORTAL_DERIVEDUNIT_FACADE, $type_designation->typeSpecimen->uuid);
|
1171 |
b8a0efb3
|
Andreas Kohlbecker
|
// the media specimen is not contained in the $type_designation returned by CDM_PORTAL_TYPEDESIGNATION, so we need to fetch it separately
|
1172 |
|
|
$mediaSpecimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($type_designation->typeSpecimen->uuid, 'mediaSpecimen'));
|
1173 |
|
|
|
1174 |
204e8173
|
Andreas Kohlbecker
|
|
1175 |
67f5eac2
|
Andreas Kohlbecker
|
$preferredStableUri = '';
|
1176 |
|
|
$citation_markup = '';
|
1177 |
|
|
$media = '';
|
1178 |
204e8173
|
Andreas Kohlbecker
|
|
1179 |
0e617798
|
Andreas Kohlbecker
|
// annotations and sources for the $derived_unit_facade_dto
|
1180 |
|
|
$annotations_and_sources = handle_annotations_and_sources(
|
1181 |
|
|
$derived_unit_facade_dto,
|
1182 |
991ae630
|
Andreas Kohlbecker
|
typedesignations_annotations_and_sources_config(),
|
1183 |
0e617798
|
Andreas Kohlbecker
|
'',
|
1184 |
991ae630
|
Andreas Kohlbecker
|
RenderHints::getFootnoteListKey()
|
1185 |
0e617798
|
Andreas Kohlbecker
|
);
|
1186 |
|
|
$source_citations = $annotations_and_sources['source_references'];
|
1187 |
|
|
$foot_note_keys = $annotations_and_sources['foot_note_keys'];
|
1188 |
|
|
|
1189 |
67f5eac2
|
Andreas Kohlbecker
|
// preferredStableUri
|
1190 |
|
|
if(isset($type_designation->typeSpecimen->preferredStableUri) && $type_designation->typeSpecimen->preferredStableUri){
|
1191 |
|
|
$preferredStableUri = $type_designation->typeSpecimen->preferredStableUri;
|
1192 |
204e8173
|
Andreas Kohlbecker
|
}
|
1193 |
67f5eac2
|
Andreas Kohlbecker
|
|
1194 |
e69c4103
|
Andreas Kohlbecker
|
if($show_media_specimen && $mediaSpecimen){
|
1195 |
67f5eac2
|
Andreas Kohlbecker
|
// compose output
|
1196 |
|
|
// mediaURI
|
1197 |
|
|
if(isset($mediaSpecimen->representations[0])) {
|
1198 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
1199 |
|
|
$captionElements = array(
|
1200 |
|
|
'#uri' => t('open media'),
|
1201 |
|
|
'elements' => array('-none-'),
|
1202 |
|
|
'sources_as_content' => true
|
1203 |
|
|
);
|
1204 |
|
|
$media = compose_cdm_media_gallerie(array(
|
1205 |
|
|
'mediaList' => array($mediaSpecimen),
|
1206 |
0e617798
|
Andreas Kohlbecker
|
'galleryName' => CDM_DATAPORTAL_TYPE_SPECIMEN_GALLERY_NAME . '_' . $type_designation_entity_ref->uuid,
|
1207 |
67f5eac2
|
Andreas Kohlbecker
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
1208 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
1209 |
|
|
'captionElements' => $captionElements,
|
1210 |
|
|
));
|
1211 |
|
|
}
|
1212 |
0e617798
|
Andreas Kohlbecker
|
// citation and detail for the media specimen
|
1213 |
67f5eac2
|
Andreas Kohlbecker
|
$annotations_and_sources = handle_annotations_and_sources(
|
1214 |
0e617798
|
Andreas Kohlbecker
|
$mediaSpecimen,
|
1215 |
26f042e4
|
Andreas Kohlbecker
|
typedesignations_annotations_and_sources_config(),
|
1216 |
0e617798
|
Andreas Kohlbecker
|
'',
|
1217 |
a067cc04
|
Andreas Kohlbecker
|
RenderHints::getFootnoteListKey()
|
1218 |
67f5eac2
|
Andreas Kohlbecker
|
);
|
1219 |
|
|
if(is_array( $annotations_and_sources['source_references'])){
|
1220 |
0e617798
|
Andreas Kohlbecker
|
$source_citations = array_merge($source_citations, $annotations_and_sources['source_references']);
|
1221 |
|
|
}
|
1222 |
|
|
if($annotations_and_sources['foot_note_keys']){
|
1223 |
|
|
$foot_note_keys .= ', ' . $annotations_and_sources['foot_note_keys'];
|
1224 |
67f5eac2
|
Andreas Kohlbecker
|
}
|
1225 |
204e8173
|
Andreas Kohlbecker
|
}
|
1226 |
|
|
|
1227 |
0e617798
|
Andreas Kohlbecker
|
$citation_markup = join(', ', $source_citations);
|
1228 |
|
|
|
1229 |
|
|
$specimen_markup = $derived_unit_facade_dto->titleCache;
|
1230 |
|
|
if(isset($derived_unit_facade_dto->specimenLabel) && $derived_unit_facade_dto->specimenLabel){
|
1231 |
|
|
$specimen_markup = str_replace(
|
1232 |
|
|
$derived_unit_facade_dto->specimenLabel,
|
1233 |
|
|
l($derived_unit_facade_dto->specimenLabel, path_to_specimen($type_designation->typeSpecimen->uuid)), $specimen_markup);
|
1234 |
e69c4103
|
Andreas Kohlbecker
|
}
|
1235 |
|
|
|
1236 |
0e617798
|
Andreas Kohlbecker
|
$type_designation_render_array = markup_to_render_array(
|
1237 |
|
|
'<div class="type_designation_entity_ref ' . html_class_attribute_ref($type_designation_entity_ref) . '">
|
1238 |
2154d631
|
Andreas Kohlbecker
|
<span class="type-status">' . ucfirst($type_status) . "</span>: "
|
1239 |
0e617798
|
Andreas Kohlbecker
|
. $specimen_markup . $foot_note_keys
|
1240 |
67f5eac2
|
Andreas Kohlbecker
|
. ($citation_markup ? ' '. $citation_markup : '')
|
1241 |
|
|
. ($preferredStableUri ? " ". l($preferredStableUri, $preferredStableUri) : '')
|
1242 |
|
|
. $media
|
1243 |
|
|
. '</div>');
|
1244 |
e69c4103
|
Andreas Kohlbecker
|
|
1245 |
|
|
$render_array['type_designations'][] = $type_designation_render_array;
|
1246 |
67f5eac2
|
Andreas Kohlbecker
|
}
|
1247 |
471192e3
|
Andreas Kohlbecker
|
}
|
1248 |
41a348be
|
Andreas Kohlbecker
|
if(count($type_designation_list) > 0 ){
|
1249 |
|
|
$render_array['map'] = compose_type_designations_map($type_designation_list);
|
1250 |
|
|
} else {
|
1251 |
|
|
$render_array['map'] = array();
|
1252 |
|
|
}
|
1253 |
471192e3
|
Andreas Kohlbecker
|
return $render_array;
|
1254 |
|
|
}
|
1255 |
|
|
|
1256 |
991ae630
|
Andreas Kohlbecker
|
/**
|
1257 |
|
|
* Provides the default configuration for typedesignations which
|
1258 |
|
|
* are passed to the handle_annotations_and_sources()
|
1259 |
|
|
* function:
|
1260 |
|
|
* - 'sources_as_content' => TRUE,
|
1261 |
|
|
* - 'link_to_name_used_in_source' => FALSE,
|
1262 |
|
|
* - 'link_to_reference' => TRUE,
|
1263 |
|
|
* - 'add_footnote_keys' => FALSE,
|
1264 |
|
|
* - 'bibliography_aware' => FALSE
|
1265 |
|
|
*
|
1266 |
|
|
* @return array
|
1267 |
|
|
*/
|
1268 |
|
|
function typedesignations_annotations_and_sources_config() {
|
1269 |
|
|
static $annotations_and_sources_config = [
|
1270 |
|
|
'sources_as_content' => TRUE,
|
1271 |
|
|
'link_to_name_used_in_source' => FALSE,
|
1272 |
|
|
'link_to_reference' => TRUE,
|
1273 |
|
|
'add_footnote_keys' => FALSE,
|
1274 |
|
|
'bibliography_aware' => FALSE
|
1275 |
|
|
];
|
1276 |
|
|
return $annotations_and_sources_config;
|
1277 |
|
|
}
|
1278 |
|
|
|
1279 |
2fd6da0b
|
Andreas Kohlbecker
|
/**
|
1280 |
ef686dd8
|
Andreas Kohlbecker
|
* @param $name_rel
|
1281 |
|
|
* @param $current_name_uuid
|
1282 |
|
|
* @param $current_taxon_uuid
|
1283 |
|
|
* @param $suppress_if_current_name_is_source // FIXME UNUSED !!!!
|
1284 |
|
|
* @param $show_name_cache_only
|
1285 |
|
|
* The nameCache will be shown instead of the titleCache if this parameter is true.
|
1286 |
|
|
* @return null|string
|
1287 |
26f042e4
|
Andreas Kohlbecker
|
* The markup or null
|
1288 |
ef686dd8
|
Andreas Kohlbecker
|
*/
|
1289 |
96614dfe
|
Andreas Kohlbecker
|
function name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid, $show_name_cache_only = false){
|
1290 |
ef686dd8
|
Andreas Kohlbecker
|
|
1291 |
|
|
$relationship_markup = null;
|
1292 |
|
|
|
1293 |
|
|
$current_name_is_toName = $current_name_uuid == $name_rel->toName->uuid;
|
1294 |
|
|
|
1295 |
|
|
if($current_name_is_toName){
|
1296 |
|
|
$name = $name_rel->fromName;
|
1297 |
|
|
} else {
|
1298 |
|
|
$name = $name_rel->toName;
|
1299 |
|
|
}
|
1300 |
|
|
|
1301 |
a7560a18
|
Andreas Kohlbecker
|
cdm_load_tagged_full_title($name);
|
1302 |
|
|
|
1303 |
ef686dd8
|
Andreas Kohlbecker
|
$highlited_synonym_uuid = isset ($name->taxonBases[0]->uuid) ? $name->taxonBases[0]->uuid : '';
|
1304 |
|
|
if(!$show_name_cache_only){
|
1305 |
|
|
$relationship_markup = render_taxon_or_name($name,
|
1306 |
2f65af04
|
Andreas Kohlbecker
|
url(path_to_name($name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false))
|
1307 |
ef686dd8
|
Andreas Kohlbecker
|
);
|
1308 |
|
|
} else {
|
1309 |
|
|
$relationship_markup = l(
|
1310 |
|
|
'<span class="' . html_class_attribute_ref($name) . '"">' . $name->nameCache . '</span>',
|
1311 |
2f65af04
|
Andreas Kohlbecker
|
path_to_name($name->uuid, $current_taxon_uuid, $highlited_synonym_uuid, false),
|
1312 |
ef686dd8
|
Andreas Kohlbecker
|
array('html' => true)
|
1313 |
|
|
);
|
1314 |
|
|
}
|
1315 |
|
|
|
1316 |
|
|
return $relationship_markup;
|
1317 |
|
|
}
|
1318 |
|
|
|
1319 |
|
|
|
1320 |
|
|
/**
|
1321 |
96614dfe
|
Andreas Kohlbecker
|
* Composes an inline representation of selected name relationships
|
1322 |
16592d77
|
Andreas Kohlbecker
|
*
|
1323 |
23a017dd
|
Andreas Kohlbecker
|
* The output of this function will be usually appended to taxon name representations.
|
1324 |
ef686dd8
|
Andreas Kohlbecker
|
* Only the following types are displayed: LATER_HOMONYM, TREATED_AS_LATER_HOMONYM, BLOCKING_NAME_FOR, ORTHOGRAPHIC_VARIANT
|
1325 |
|
|
*
|
1326 |
|
|
* LATER_HOMONYM, TREATED_AS_LATER_HOMONYM, BLOCKING_NAME_FOR are displayed as
|
1327 |
|
|
* non {titleCache} nec {titleCache} nec {titleCache} whereas the related names
|
1328 |
|
|
* are ordered alphabetically.
|
1329 |
|
|
*
|
1330 |
|
|
* ORTHOGRAPHIC_VARIANT is displayed as 'ort. var. {nameCache}'
|
1331 |
23a017dd
|
Andreas Kohlbecker
|
*
|
1332 |
|
|
* Related issues:
|
1333 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/5697 "Show name conserved against as [non xxx]"
|
1334 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/6678 "How to correctly show name relationship "orth. var." in dataportal"
|
1335 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/5857
|
1336 |
ef686dd8
|
Andreas Kohlbecker
|
* - https://dev.e-taxonomy.eu/redmine/issues/2001 "[Cichorieae Portal] Name Relationship -> blocking name are not shown"
|
1337 |
0b7bbf68
|
Andreas Kohlbecker
|
*
|
1338 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param $name_relations
|
1339 |
|
|
* The list of CDM NameRelationsips
|
1340 |
|
|
* @param $current_name_uuid
|
1341 |
3c088da3
|
Andreas Kohlbecker
|
* The Uuid of the name for which the relations are to be rendered, the current name will be hidden when
|
1342 |
|
|
* rendering the relation an only the other name is shown. Parameter is REQUIRED.
|
1343 |
|
|
* @param $suppress_if_current_name_is_source
|
1344 |
|
|
* The display of the relation will be
|
1345 |
|
|
* suppressed is the current name is on the source of the relation edge.
|
1346 |
|
|
* That is if it is on the from side of the relation. Except for 'blocking name for' which is
|
1347 |
|
|
* an inverse relation. For this relation type the toName is taken in to account.
|
1348 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param $current_taxon_uuid
|
1349 |
|
|
* The taxon to be omitted from related taxa. This is only used to create links, see path_to_name()
|
1350 |
96614dfe
|
Andreas Kohlbecker
|
* @return array
|
1351 |
|
|
* A drupal render array
|
1352 |
|
|
*
|
1353 |
|
|
* @ingroup Compose
|
1354 |
0b7bbf68
|
Andreas Kohlbecker
|
*/
|
1355 |
96614dfe
|
Andreas Kohlbecker
|
function compose_name_relationships_inline($name_relations, $current_name_uuid, $current_taxon_uuid, $suppress_if_current_name_is_source = true) {
|
1356 |
f695daf4
|
Andreas Kohlbecker
|
|
1357 |
0b7bbf68
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('homonym');
|
1358 |
|
|
// the render stack element homonyms is being used in the default render templates !!!, see CDM_NAME_RENDER_TEMPLATES_DEFAULT
|
1359 |
|
|
|
1360 |
ef686dd8
|
Andreas Kohlbecker
|
$selected_name_rel_uuids = variable_get(CDM_NAME_RELATIONSHIP_INLINE_TYPES, unserialize(CDM_NAME_RELATIONSHIP_INLINE_TYPES_DEFAULT));
|
1361 |
7efd13a9
|
Andreas Kohlbecker
|
$name_rel_type_filter = array('direct' => array(), 'inverse' => array());
|
1362 |
|
|
foreach ($selected_name_rel_uuids as $uuid){
|
1363 |
|
|
$name_rel_type_filter['direct'][$uuid] = $uuid;
|
1364 |
|
|
if($uuid != UUID_NAMERELATIONSHIPTYPE_MISSPELLING){
|
1365 |
|
|
$name_rel_type_filter['inverse'][$uuid] = $uuid;
|
1366 |
|
|
}
|
1367 |
|
|
}
|
1368 |
6421984d
|
Andreas Kohlbecker
|
|
1369 |
1636cc86
|
Andreas Kohlbecker
|
$list_prefix = '<span class="name_relationships">[';
|
1370 |
|
|
$list_suffix = ']</span>';
|
1371 |
96614dfe
|
Andreas Kohlbecker
|
$item_prefix = '<span class="item">';
|
1372 |
|
|
$item_suffix = '</span> ';
|
1373 |
f8d5d6d9
|
Andreas Kohlbecker
|
$render_array = compose_name_relationships($name_relations, $name_rel_type_filter, $current_name_uuid, $current_taxon_uuid, $list_prefix, $list_suffix, $item_prefix, $item_suffix);
|
1374 |
7efd13a9
|
Andreas Kohlbecker
|
|
1375 |
|
|
// remove the glue space from the last item element which has been added by the $item_suffix = '</span> '
|
1376 |
|
|
$items_ctn = count($render_array['list']['items']);
|
1377 |
|
|
if($items_ctn){
|
1378 |
|
|
$render_array['list']['items'][$items_ctn - 1]['#suffix'] = '</span>';
|
1379 |
|
|
}
|
1380 |
0b7bbf68
|
Andreas Kohlbecker
|
|
1381 |
|
|
RenderHints::popFromRenderStack();
|
1382 |
96614dfe
|
Andreas Kohlbecker
|
return $render_array;
|
1383 |
d4ea0dd9
|
Andreas Kohlbecker
|
}
|
1384 |
|
|
|
1385 |
ef686dd8
|
Andreas Kohlbecker
|
/**
|
1386 |
|
|
* Composes an list representation of the name relationships.
|
1387 |
|
|
*
|
1388 |
|
|
* The output of this function will be usually appended to taxon name representations.
|
1389 |
|
|
*
|
1390 |
|
|
* Related issues:
|
1391 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/5697 "Show name conserved against as [non xxx]"
|
1392 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/6678 "How to correctly show name relationship "orth. var." in dataportal"
|
1393 |
|
|
* - https://dev.e-taxonomy.eu/redmine/issues/5857
|
1394 |
|
|
*
|
1395 |
|
|
* @param $name_relations
|
1396 |
|
|
* The list of CDM NameRelationsips
|
1397 |
|
|
* @param $current_name_uuid
|
1398 |
|
|
* The Uuid of the name for which the relations are to be rendered, the current name will be hidden when
|
1399 |
|
|
* rendering the relation an only the other name is shown. Parameter is REQUIRED.
|
1400 |
|
|
* @param $current_taxon_uuid
|
1401 |
|
|
* The taxon to be omitted from related taxa. This is only used to create links, see path_to_name()
|
1402 |
|
|
* @return array
|
1403 |
|
|
* A drupal render array
|
1404 |
|
|
*
|
1405 |
|
|
* @ingroup Compose
|
1406 |
|
|
*/
|
1407 |
96614dfe
|
Andreas Kohlbecker
|
function compose_name_relationships_list($name_relations, $current_name_uuid, $current_taxon_uuid) {
|
1408 |
ef686dd8
|
Andreas Kohlbecker
|
|
1409 |
|
|
// $ordered_name_relation_type_uuids = array_keys(cdm_terms_by_type_as_option('NameRelationshipType', CDM_ORDER_BY_ORDER_INDEX_ASC));
|
1410 |
|
|
|
1411 |
222784c5
|
Andreas Kohlbecker
|
$key = 'name_relationships';
|
1412 |
|
|
RenderHints::pushToRenderStack($key);
|
1413 |
b59fbdfa
|
Andreas Kohlbecker
|
if(RenderHints::isUnsetFootnoteListKey()){
|
1414 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::setFootnoteListKey($key);
|
1415 |
|
|
}
|
1416 |
ef686dd8
|
Andreas Kohlbecker
|
// the render stack element homonyms is being used in the default render templates !!!, see CDM_NAME_RENDER_TEMPLATES_DEFAULT
|
1417 |
|
|
|
1418 |
85669a85
|
Andreas Kohlbecker
|
$selected_name_rel_uuids = variable_get(CDM_NAME_RELATIONSHIP_LIST_TYPES, cdm_vocabulary_as_defaults(UUID_NAME_RELATIONSHIP_TYPE));
|
1419 |
7efd13a9
|
Andreas Kohlbecker
|
$name_rel_type_filter = array('direct' => array(), 'inverse' => array());
|
1420 |
|
|
foreach ($selected_name_rel_uuids as $uuid){
|
1421 |
|
|
$name_rel_type_filter['direct'][$uuid] = $uuid;
|
1422 |
|
|
$name_rel_type_filter['inverse'][$uuid] = $uuid;
|
1423 |
|
|
}
|
1424 |
ef686dd8
|
Andreas Kohlbecker
|
|
1425 |
96614dfe
|
Andreas Kohlbecker
|
$list_prefix = '<div class="relationships_list name_relationships">';
|
1426 |
|
|
$list_suffix = '</div>';
|
1427 |
|
|
$item_prefix = '<div class="item">';
|
1428 |
|
|
$item_suffix = '</div>';
|
1429 |
|
|
|
1430 |
f8d5d6d9
|
Andreas Kohlbecker
|
$render_array = compose_name_relationships($name_relations, $name_rel_type_filter, $current_name_uuid, $current_taxon_uuid, $list_prefix, $list_suffix, $item_prefix, $item_suffix);
|
1431 |
96614dfe
|
Andreas Kohlbecker
|
|
1432 |
|
|
RenderHints::popFromRenderStack();
|
1433 |
222784c5
|
Andreas Kohlbecker
|
if(RenderHints::getFootnoteListKey() == $key) {
|
1434 |
d8069342
|
Andreas Kohlbecker
|
$render_array['footnotes'] = markup_to_render_array(render_footnotes(RenderHints::getFootnoteListKey()));
|
1435 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::clearFootnoteListKey();
|
1436 |
|
|
}
|
1437 |
96614dfe
|
Andreas Kohlbecker
|
return $render_array;
|
1438 |
|
|
}
|
1439 |
|
|
|
1440 |
|
|
/**
|
1441 |
|
|
* @param $name_relations
|
1442 |
7efd13a9
|
Andreas Kohlbecker
|
* @param $name_rel_type_filter
|
1443 |
|
|
* Associative array with two keys:
|
1444 |
|
|
* - 'direct': the relationship type uuids for the direct direction of the relation edge to be included
|
1445 |
|
|
* - 'inverse': the relationship type uuids for the direct direction of the relation edge to be included
|
1446 |
96614dfe
|
Andreas Kohlbecker
|
* @param $current_name_uuid
|
1447 |
|
|
* @param $current_taxon_uuid
|
1448 |
|
|
* @param $list_prefix
|
1449 |
|
|
* @param $list_suffix
|
1450 |
|
|
* @param $item_prefix
|
1451 |
|
|
* @param $item_suffix
|
1452 |
|
|
* @return array
|
1453 |
|
|
*
|
1454 |
|
|
* @ingroup Compose
|
1455 |
|
|
*/
|
1456 |
7efd13a9
|
Andreas Kohlbecker
|
function compose_name_relationships($name_relations, $name_rel_type_filter, $current_name_uuid, $current_taxon_uuid,
|
1457 |
f8d5d6d9
|
Andreas Kohlbecker
|
$list_prefix, $list_suffix, $item_prefix, $item_suffix)
|
1458 |
96614dfe
|
Andreas Kohlbecker
|
{
|
1459 |
|
|
$non_nec_name_reltype_uuids = array(UUID_NAMERELATIONSHIPTYPE_LATER_HOMONYM,
|
1460 |
|
|
UUID_NAMERELATIONSHIPTYPE_TREATED_AS_LATER_HOMONYM,
|
1461 |
1636cc86
|
Andreas Kohlbecker
|
UUID_NAMERELATIONSHIPTYPE_CONSERVED_AGAINST,
|
1462 |
7efd13a9
|
Andreas Kohlbecker
|
UUID_NAMERELATIONSHIPTYPE_MISSPELLING,
|
1463 |
96614dfe
|
Andreas Kohlbecker
|
UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR);
|
1464 |
|
|
|
1465 |
ef686dd8
|
Andreas Kohlbecker
|
$render_array = array(
|
1466 |
|
|
'list' => array(
|
1467 |
96614dfe
|
Andreas Kohlbecker
|
'#prefix' => $list_prefix,
|
1468 |
|
|
'#suffix' => $list_suffix,
|
1469 |
ef686dd8
|
Andreas Kohlbecker
|
'items' => array()
|
1470 |
|
|
),
|
1471 |
|
|
'footnotes' => array()
|
1472 |
|
|
);
|
1473 |
|
|
|
1474 |
96614dfe
|
Andreas Kohlbecker
|
if ($name_relations) {
|
1475 |
ef686dd8
|
Andreas Kohlbecker
|
|
1476 |
|
|
// remove all relations which are not selected in the settings and
|
1477 |
96614dfe
|
Andreas Kohlbecker
|
// separate all LATER_HOMONYM, TREATED_AS_LATER_HOMONYM, BLOCKING_NAME_FOR relations and ORTHOGRAPHIC_VARIANTs
|
1478 |
ef686dd8
|
Andreas Kohlbecker
|
// for special handling
|
1479 |
|
|
$filtered_name_rels = array();
|
1480 |
|
|
$non_nec_name_rels = array();
|
1481 |
|
|
$orthographic_variants = array();
|
1482 |
96614dfe
|
Andreas Kohlbecker
|
foreach ($name_relations as $name_rel) {
|
1483 |
|
|
$rel_type_uuid = $name_rel->type->uuid;
|
1484 |
7efd13a9
|
Andreas Kohlbecker
|
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid;
|
1485 |
|
|
if ((!$is_inverse_relation && isset($name_rel_type_filter['direct'][$rel_type_uuid]) && $name_rel_type_filter['direct'][$rel_type_uuid])
|
1486 |
|
|
||($is_inverse_relation && isset($name_rel_type_filter['inverse'][$rel_type_uuid]) && $name_rel_type_filter['inverse'][$rel_type_uuid])) {
|
1487 |
|
|
|
1488 |
96614dfe
|
Andreas Kohlbecker
|
if (array_search($rel_type_uuid, $non_nec_name_reltype_uuids) !== false && (
|
1489 |
|
|
$current_name_uuid == $name_rel->fromName->uuid && $rel_type_uuid != UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR
|
1490 |
|
|
|| $current_name_uuid == $name_rel->toName->uuid && $rel_type_uuid == UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR
|
1491 |
|
|
)
|
1492 |
|
|
){
|
1493 |
ef686dd8
|
Andreas Kohlbecker
|
$non_nec_name_rels[] = $name_rel;
|
1494 |
96614dfe
|
Andreas Kohlbecker
|
} else if (UUID_NAMERELATIONSHIPTYPE_ORTHOGRAPHIC_VARIANT == $rel_type_uuid) {
|
1495 |
ef686dd8
|
Andreas Kohlbecker
|
$orthographic_variants[] = $name_rel;
|
1496 |
|
|
} else {
|
1497 |
96614dfe
|
Andreas Kohlbecker
|
|
1498 |
ef686dd8
|
Andreas Kohlbecker
|
$filtered_name_rels[] = $name_rel;
|
1499 |
|
|
}
|
1500 |
|
|
}
|
1501 |
|
|
}
|
1502 |
|
|
$name_relations = $filtered_name_rels;
|
1503 |
|
|
|
1504 |
|
|
usort($name_relations, 'compare_name_relations_by_term_order_index');
|
1505 |
|
|
|
1506 |
7efd13a9
|
Andreas Kohlbecker
|
// compose
|
1507 |
96614dfe
|
Andreas Kohlbecker
|
foreach ($name_relations as $name_rel) {
|
1508 |
ef686dd8
|
Andreas Kohlbecker
|
|
1509 |
96614dfe
|
Andreas Kohlbecker
|
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid;
|
1510 |
ef686dd8
|
Andreas Kohlbecker
|
|
1511 |
fef841d4
|
Andreas Kohlbecker
|
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel);
|
1512 |
96614dfe
|
Andreas Kohlbecker
|
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid);
|
1513 |
ef686dd8
|
Andreas Kohlbecker
|
|
1514 |
|
|
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation);
|
1515 |
|
|
$symbol = cdm_relationship_type_term_symbol($name_rel->type, $is_inverse_relation);
|
1516 |
f8d5d6d9
|
Andreas Kohlbecker
|
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' ';
|
1517 |
|
|
$relationship_markup = $symbol_markup . $relationship_markup;
|
1518 |
96614dfe
|
Andreas Kohlbecker
|
if ($relationship_markup) {
|
1519 |
ef686dd8
|
Andreas Kohlbecker
|
$render_array['list']['items'][] = markup_to_render_array($relationship_markup,
|
1520 |
|
|
null,
|
1521 |
96614dfe
|
Andreas Kohlbecker
|
$item_prefix,
|
1522 |
|
|
$item_suffix);
|
1523 |
ef686dd8
|
Andreas Kohlbecker
|
}
|
1524 |
|
|
}
|
1525 |
|
|
|
1526 |
|
|
// name relationships to be displayed as non nec
|
1527 |
96614dfe
|
Andreas Kohlbecker
|
if (count($non_nec_name_rels) > 0) {
|
1528 |
ef686dd8
|
Andreas Kohlbecker
|
$non_nec_markup = '';
|
1529 |
96614dfe
|
Andreas Kohlbecker
|
foreach ($non_nec_name_rels as $name_rel) {
|
1530 |
|
|
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid;
|
1531 |
fef841d4
|
Andreas Kohlbecker
|
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel);
|
1532 |
96614dfe
|
Andreas Kohlbecker
|
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid);
|
1533 |
|
|
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation);
|
1534 |
ef686dd8
|
Andreas Kohlbecker
|
$symbol = $non_nec_markup ? ' nec ' : 'non';
|
1535 |
f8d5d6d9
|
Andreas Kohlbecker
|
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' ';
|
1536 |
|
|
$non_nec_markup .= $symbol_markup . $relationship_markup;
|
1537 |
96614dfe
|
Andreas Kohlbecker
|
}
|
1538 |
|
|
if ($non_nec_markup) {
|
1539 |
|
|
$render_array['list']['items'][] = markup_to_render_array($non_nec_markup,
|
1540 |
|
|
null,
|
1541 |
|
|
$item_prefix,
|
1542 |
|
|
$item_suffix);
|
1543 |
ef686dd8
|
Andreas Kohlbecker
|
}
|
1544 |
|
|
}
|
1545 |
|
|
|
1546 |
|
|
// orthographic variants
|
1547 |
96614dfe
|
Andreas Kohlbecker
|
if (count($orthographic_variants) > 0) {
|
1548 |
|
|
foreach ($orthographic_variants as $name_rel) {
|
1549 |
|
|
|
1550 |
|
|
$is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid;
|
1551 |
fef841d4
|
Andreas Kohlbecker
|
$rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel);
|
1552 |
96614dfe
|
Andreas Kohlbecker
|
$relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid, TRUE);
|
1553 |
8202a2c0
|
Andreas Kohlbecker
|
$nomref_footnote_key_markup = handle_nomenclatural_reference_as_footnote($name_rel->toName);
|
1554 |
96614dfe
|
Andreas Kohlbecker
|
$label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation);
|
1555 |
ef686dd8
|
Andreas Kohlbecker
|
$symbol = cdm_relationship_type_term_symbol($name_rel->type, $is_inverse_relation);
|
1556 |
f8d5d6d9
|
Andreas Kohlbecker
|
$symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup . ' ';
|
1557 |
222784c5
|
Andreas Kohlbecker
|
$relationship_markup = $symbol_markup . $relationship_markup . $nomref_footnote_key_markup;
|
1558 |
ef686dd8
|
Andreas Kohlbecker
|
}
|
1559 |
26f042e4
|
Andreas Kohlbecker
|
if (isset($relationship_markup) && $relationship_markup) {
|
1560 |
ef686dd8
|
Andreas Kohlbecker
|
$render_array['list']['items'][] = markup_to_render_array($relationship_markup,
|
1561 |
|
|
null,
|
1562 |
96614dfe
|
Andreas Kohlbecker
|
$item_prefix,
|
1563 |
|
|
$item_suffix);
|
1564 |
ef686dd8
|
Andreas Kohlbecker
|
}
|
1565 |
|
|
}
|
1566 |
|
|
}
|
1567 |
|
|
return $render_array;
|
1568 |
|
|
}
|
1569 |
|
|
|
1570 |
|
|
|
1571 |
222784c5
|
Andreas Kohlbecker
|
|
1572 |
d4ea0dd9
|
Andreas Kohlbecker
|
/**
|
1573 |
|
|
* @param $taxon
|
1574 |
|
|
* @return array
|
1575 |
|
|
*/
|
1576 |
|
|
function cdm_name_relationships_for_taxon($taxon)
|
1577 |
|
|
{
|
1578 |
|
|
$from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
|
1579 |
|
|
$to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
1580 |
|
|
$name_relations = array_merge($from_name_relations, $to_name_relations);
|
1581 |
|
|
return $name_relations;
|
1582 |
0b7bbf68
|
Andreas Kohlbecker
|
}
|
1583 |
|
|
|
1584 |
|
|
|
1585 |
d4ea0dd9
|
Andreas Kohlbecker
|
/**
|
1586 |
2fd6da0b
|
Andreas Kohlbecker
|
* Recursively searches the array for the $key and sets the given value.
|
1587 |
|
|
*
|
1588 |
|
|
* @param mixed $key
|
1589 |
|
|
* Key to search for.
|
1590 |
|
|
* @param mixed $value
|
1591 |
|
|
* Value to set.'
|
1592 |
|
|
* @param array $array
|
1593 |
|
|
* Array to search in.
|
1594 |
|
|
*
|
1595 |
|
|
* @return bool
|
1596 |
|
|
* True if the key has been found.
|
1597 |
|
|
*/
|
1598 |
|
|
function &array_setr($key, $value, array &$array) {
|
1599 |
|
|
$res = NULL;
|
1600 |
|
|
foreach ($array as $k => &$v) {
|
1601 |
|
|
if ($key == $k) {
|
1602 |
|
|
$v = $value;
|
1603 |
|
|
return $array;
|
1604 |
|
|
}
|
1605 |
|
|
elseif (is_array($v)) {
|
1606 |
|
|
$innerArray = array_setr($key, $value, $v);
|
1607 |
|
|
if ($innerArray) {
|
1608 |
|
|
return $array;
|
1609 |
|
|
}
|
1610 |
|
|
}
|
1611 |
|
|
}
|
1612 |
|
|
return $res;
|
1613 |
|
|
}
|
1614 |
|
|
|
1615 |
|
|
/**
|
1616 |
|
|
* @todo Please document this function.
|
1617 |
|
|
* @see http://drupal.org/node/1354
|
1618 |
|
|
*/
|
1619 |
|
|
function &get_preceding_contentElement($contentElementKey, array &$renderTemplate) {
|
1620 |
|
|
$res = NULL;
|
1621 |
|
|
$precedingElement = NULL;
|
1622 |
|
|
foreach ($renderTemplate as &$part) {
|
1623 |
|
|
foreach ($part as $key => &$element) {
|
1624 |
|
|
if ($key == $contentElementKey) {
|
1625 |
|
|
return $precedingElement;
|
1626 |
|
|
}
|
1627 |
|
|
$precedingElement = $element;
|
1628 |
|
|
}
|
1629 |
|
|
}
|
1630 |
|
|
return $res;
|
1631 |
|
|
}
|
1632 |
|
|
|
1633 |
|
|
/**
|
1634 |
|
|
* @todo Please document this function.
|
1635 |
|
|
* @see http://drupal.org/node/1354
|
1636 |
|
|
*/
|
1637 |
|
|
function &get_preceding_contentElementKey($contentElementKey, array &$renderTemplate) {
|
1638 |
|
|
$res = NULL;
|
1639 |
|
|
$precedingKey = NULL;
|
1640 |
|
|
foreach ($renderTemplate as &$part) {
|
1641 |
|
|
if (is_array($part)) {
|
1642 |
|
|
foreach ($part as $key => &$element) {
|
1643 |
|
|
if ($key == $contentElementKey) {
|
1644 |
|
|
return $precedingKey;
|
1645 |
|
|
}
|
1646 |
|
|
if (!str_beginsWith($key, '#')) {
|
1647 |
|
|
$precedingKey = $key;
|
1648 |
|
|
}
|
1649 |
|
|
}
|
1650 |
|
|
}
|
1651 |
|
|
}
|
1652 |
|
|
return $res;
|
1653 |
|
|
}
|
1654 |
c2545e1c
|
Andreas Kohlbecker
|
|
1655 |
|
|
function nameTypeToDTYPE($dtype){
|
1656 |
|
|
static $nameTypeLabelMap = array(
|
1657 |
|
|
"ICNB" => "BacterialName",
|
1658 |
|
|
"ICNAFP" => "BotanicalName",
|
1659 |
|
|
"ICNCP" => "CultivarPlantName",
|
1660 |
|
|
"ICZN" => "ZoologicalName",
|
1661 |
|
|
"ICVCN" => "ViralName",
|
1662 |
|
|
"Any taxon name" => "TaxonName",
|
1663 |
|
|
"NonViral" => "TaxonName",
|
1664 |
|
|
"Fungus" => "BotanicalName",
|
1665 |
|
|
"Plant" => "BotanicalName",
|
1666 |
|
|
"Algae" => "BotanicalName",
|
1667 |
|
|
);
|
1668 |
|
|
return $nameTypeLabelMap[$dtype];
|
1669 |
|
|
|
1670 |
|
|
}
|
1671 |
ef686dd8
|
Andreas Kohlbecker
|
|
1672 |
|
|
|
1673 |
|
|
function compare_name_relations_by_term_order_index($name_rel1, $name_rel2){
|
1674 |
|
|
return compare_terms_by_order_index($name_rel1->type, $name_rel2->type);
|
1675 |
|
|
}
|
1676 |
b90ef618
|
Andreas Kohlbecker
|
|
1677 |
|
|
/**
|
1678 |
|
|
* Provides an array with the different registration types covered by the passed registration.
|
1679 |
|
|
*
|
1680 |
|
|
* The labels in the returned array are translatable.
|
1681 |
|
|
*
|
1682 |
|
|
* See also https://dev.e-taxonomy.eu/redmine/issues/8016
|
1683 |
|
|
*
|
1684 |
|
|
* @param $registration_dto
|
1685 |
|
|
* @return array
|
1686 |
|
|
* An array of the labels describing the different registration types covered by the passed registration.
|
1687 |
|
|
*/
|
1688 |
|
|
function registration_types($registration_dto){
|
1689 |
|
|
$reg_type_labels = array();
|
1690 |
|
|
if(isset($registration_dto->nameRef)){
|
1691 |
0a02c62f
|
Andreas Kohlbecker
|
$reg_type_labels["name"] = t("new name");
|
1692 |
|
|
$reg_type_labels["taxon"] = t("new taxon");
|
1693 |
b90ef618
|
Andreas Kohlbecker
|
$name_relations = cdm_ws_fetch_all(str_replace("$0", $registration_dto->nameRef->uuid, CDM_WS_PORTAL_NAME_NAME_RELATIONS));
|
1694 |
0a02c62f
|
Andreas Kohlbecker
|
$is_new_combination = true;
|
1695 |
b90ef618
|
Andreas Kohlbecker
|
foreach($name_relations as $name_rel){
|
1696 |
|
|
if(isset($name_rel->type->uuid)){
|
1697 |
|
|
$name_is_from_name = $registration_dto->nameRef->uuid == $name_rel->fromName->uuid;
|
1698 |
|
|
switch($name_rel->type->uuid) {
|
1699 |
|
|
case UUID_NAMERELATIONSHIPTYPE_BASIONYM:
|
1700 |
|
|
if(!$name_is_from_name){
|
1701 |
0a02c62f
|
Andreas Kohlbecker
|
$reg_type_labels["basionym"] = t("new combination");
|
1702 |
|
|
$is_new_combination = true;
|
1703 |
b90ef618
|
Andreas Kohlbecker
|
}
|
1704 |
|
|
break;
|
1705 |
|
|
case UUID_NAMERELATIONSHIPTYPE_REPLACED_SYNONYM:
|
1706 |
|
|
if(!$name_is_from_name) {
|
1707 |
0a02c62f
|
Andreas Kohlbecker
|
$is_new_combination = true;
|
1708 |
b90ef618
|
Andreas Kohlbecker
|
}
|
1709 |
|
|
break;
|
1710 |
|
|
case UUID_NAMERELATIONSHIPTYPE_VALIDATED_BY_NAME:
|
1711 |
|
|
if(!$name_is_from_name) {
|
1712 |
0a02c62f
|
Andreas Kohlbecker
|
$reg_type_labels["validation"] = t("validation");
|
1713 |
b90ef618
|
Andreas Kohlbecker
|
}
|
1714 |
|
|
break;
|
1715 |
|
|
case UUID_NAMERELATIONSHIPTYPE_ORTHOGRAPHIC_VARIANT:
|
1716 |
|
|
if(!$name_is_from_name) {
|
1717 |
0a02c62f
|
Andreas Kohlbecker
|
$reg_type_labels["orth_var"] = t("orthographical correction");
|
1718 |
b90ef618
|
Andreas Kohlbecker
|
}break;
|
1719 |
|
|
default:
|
1720 |
|
|
// NOTHING
|
1721 |
|
|
}
|
1722 |
|
|
}
|
1723 |
|
|
}
|
1724 |
0a02c62f
|
Andreas Kohlbecker
|
if($is_new_combination){
|
1725 |
|
|
unset($reg_type_labels["taxon"]);
|
1726 |
|
|
}
|
1727 |
b90ef618
|
Andreas Kohlbecker
|
}
|
1728 |
|
|
if(isset($registration_dto->orderdTypeDesignationWorkingSets)){
|
1729 |
0a02c62f
|
Andreas Kohlbecker
|
$reg_type_labels[] = t("new nomenclatural type");
|
1730 |
b90ef618
|
Andreas Kohlbecker
|
}
|
1731 |
|
|
return $reg_type_labels;
|
1732 |
b059b449
|
Andreas Kohlbecker
|
}
|
1733 |
|
|
|
1734 |
|
|
/**
|
1735 |
|
|
* Collects and deduplicates the type designations associated with the passes synonyms.
|
1736 |
|
|
*
|
1737 |
|
|
* @param $synonymy_group
|
1738 |
|
|
* An array containing a homotypic or heterotypic group of names.
|
1739 |
5f188298
|
Andreas Kohlbecker
|
* @param $accepted_taxon_name_uuid
|
1740 |
34852f2d
|
Andreas Kohlbecker
|
* The uuid of the accepted taxon name. Optional parameter which is required when composing
|
1741 |
|
|
* the information for the homotypic group. In this case the accepted taxon is not included
|
1742 |
|
|
* in the $synonymy_group and must therefor passed in this second parameter.
|
1743 |
|
|
*
|
1744 |
b059b449
|
Andreas Kohlbecker
|
* @return array
|
1745 |
|
|
* The type designations
|
1746 |
|
|
*/
|
1747 |
dfbc27b0
|
Andreas Kohlbecker
|
function type_designations_for_synonymy_group($synonymy_group, $accepted_taxon_name_uuid = null)
|
1748 |
|
|
{
|
1749 |
|
|
if (count($synonymy_group) > 0) {
|
1750 |
34852f2d
|
Andreas Kohlbecker
|
$name_uuid = array_pop($synonymy_group)->name->uuid;
|
1751 |
|
|
} else {
|
1752 |
|
|
$name_uuid = $accepted_taxon_name_uuid;
|
1753 |
|
|
}
|
1754 |
|
|
if ($name_uuid) {
|
1755 |
|
|
$type_designations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS_IN_HOMOTYPICAL_GROUP, $name_uuid);
|
1756 |
|
|
if ($type_designations) {
|
1757 |
3d14fdcf
|
Andreas Kohlbecker
|
return $type_designations;
|
1758 |
|
|
}
|
1759 |
b059b449
|
Andreas Kohlbecker
|
}
|
1760 |
34852f2d
|
Andreas Kohlbecker
|
|
1761 |
dfbc27b0
|
Andreas Kohlbecker
|
return array();
|
1762 |
fb939fdc
|
Andreas Kohlbecker
|
}
|
1763 |
|
|
|
1764 |
|
|
|
1765 |
|
|
/**
|
1766 |
04d5812b
|
Andreas Kohlbecker
|
* Compares two SpecimenTypeDesignations
|
1767 |
fb939fdc
|
Andreas Kohlbecker
|
*
|
1768 |
|
|
* @param object $a
|
1769 |
|
|
* A SpecimenTypeDesignation.
|
1770 |
|
|
* @param object $b
|
1771 |
|
|
* SpecimenTypeDesignation.
|
1772 |
|
|
*/
|
1773 |
|
|
function compare_specimen_type_designation($a, $b) {
|
1774 |
|
|
|
1775 |
04d5812b
|
Andreas Kohlbecker
|
$cmp_by_status = compare_type_designations_by_status($a,$b);
|
1776 |
|
|
if($cmp_by_status !== 0){
|
1777 |
|
|
return $cmp_by_status;
|
1778 |
|
|
}
|
1779 |
fb939fdc
|
Andreas Kohlbecker
|
|
1780 |
|
|
$aQuantifier = FALSE;
|
1781 |
|
|
$bQuantifier = FALSE;
|
1782 |
|
|
if ($aQuantifier == $bQuantifier) {
|
1783 |
|
|
// Sort alphabetically.
|
1784 |
|
|
$a_text = isset($a->typeSpecimen->titleCache) ? preg_replace('/[\[\]\"]/', '', $a->typeSpecimen->titleCache) : '';
|
1785 |
|
|
$b_text = isset($b->typeSpecimen->titleCache) ? preg_replace('/[\[\]\"]/', '', $b->typeSpecimen->titleCache) : '';
|
1786 |
|
|
return strcasecmp($a_text, $b_text);
|
1787 |
|
|
}
|
1788 |
04d5812b
|
Andreas Kohlbecker
|
return ($aQuantifier < $bQuantifier) ? -1 : (($aQuantifier > $bQuantifier) ? 1 : 0);
|
1789 |
|
|
}
|
1790 |
|
|
|
1791 |
|
|
/**
|
1792 |
|
|
* Compares the status of two TypeDesignations
|
1793 |
|
|
*
|
1794 |
|
|
* @param object $a
|
1795 |
|
|
* A TypeDesignation
|
1796 |
|
|
* @param object $b
|
1797 |
|
|
* TypeDesignation
|
1798 |
|
|
*/
|
1799 |
|
|
function compare_type_designations_by_status($a, $b) {
|
1800 |
e5a89a58
|
Andreas Kohlbecker
|
$status_a = isset($a->typeStatus) ? $a->typeStatus : null;
|
1801 |
|
|
$status_b = isset($b->typeStatus) ? $b->typeStatus : null;
|
1802 |
|
|
return compare_type_designation_status($status_a, $status_b);
|
1803 |
fb939fdc
|
Andreas Kohlbecker
|
}
|
1804 |
|
|
|
1805 |
|
|
/**
|
1806 |
04d5812b
|
Andreas Kohlbecker
|
* Compares two TypeDesignationStatusBase
|
1807 |
fb939fdc
|
Andreas Kohlbecker
|
*
|
1808 |
|
|
* @param object $a
|
1809 |
|
|
* A TypeDesignationStatusBase.
|
1810 |
|
|
* @param object $b
|
1811 |
|
|
* TypeDesignationStatusBase.
|
1812 |
|
|
*/
|
1813 |
|
|
function compare_type_designation_status($a, $b) {
|
1814 |
|
|
$type_status_order = type_status_order();
|
1815 |
|
|
$aQuantifier = FALSE;
|
1816 |
|
|
$bQuantifier = FALSE;
|
1817 |
|
|
if (isset($a->label) && isset($b->label)) {
|
1818 |
|
|
$aQuantifier = array_search($a->label, $type_status_order);
|
1819 |
|
|
$bQuantifier = array_search($b->label, $type_status_order);
|
1820 |
|
|
}
|
1821 |
04d5812b
|
Andreas Kohlbecker
|
return ($aQuantifier < $bQuantifier) ? -1 : (($aQuantifier > $bQuantifier) ? 1 : 0);
|
1822 |
|
|
}
|
1823 |
|
|
|
1824 |
|
|
/**
|
1825 |
|
|
* Compares the two TextualTypeDesignations
|
1826 |
|
|
*
|
1827 |
|
|
* @param object $a
|
1828 |
|
|
* A TextualTypeDesignations.
|
1829 |
|
|
* @param object $b
|
1830 |
|
|
* TextualTypeDesignations.
|
1831 |
|
|
*/
|
1832 |
|
|
function compare_textual_type_designation($a, $b) {
|
1833 |
|
|
|
1834 |
|
|
$cmp_by_status = compare_type_designations_by_status($a,$b);
|
1835 |
|
|
if($cmp_by_status !== 0){
|
1836 |
|
|
return $cmp_by_status;
|
1837 |
|
|
}
|
1838 |
|
|
|
1839 |
|
|
$aQuantifier = FALSE;
|
1840 |
|
|
$bQuantifier = FALSE;
|
1841 |
|
|
if ($aQuantifier == $bQuantifier) {
|
1842 |
|
|
// Sort alphabetically.
|
1843 |
|
|
$a_text = isset($a->text_L10n->text) ? $a->text_L10n->text : '';
|
1844 |
|
|
$b_text = isset($b->text_L10n->text) ? $b->text_L10n->text : '';
|
1845 |
|
|
return strcasecmp($a_text, $b_text);
|
1846 |
|
|
}
|
1847 |
|
|
return ($aQuantifier < $bQuantifier) ? -1 : (($aQuantifier > $bQuantifier) ? 1 : 0);
|
1848 |
fb939fdc
|
Andreas Kohlbecker
|
}
|
1849 |
|
|
|
1850 |
d8de8d4d
|
Andreas Kohlbecker
|
|
1851 |
|
|
/**
|
1852 |
|
|
* Compares two SpecimenTypeDesignation status labels
|
1853 |
|
|
*
|
1854 |
|
|
* @param string $a
|
1855 |
|
|
* A TypeDesignationStatus label.
|
1856 |
|
|
* @param string $b
|
1857 |
|
|
* A TypeDesignationStatus label.
|
1858 |
|
|
*/
|
1859 |
|
|
function compare_type_designation_status_labels($a, $b) {
|
1860 |
|
|
|
1861 |
|
|
$type_status_order = type_status_order();
|
1862 |
|
|
|
1863 |
|
|
$aQuantifier = FALSE;
|
1864 |
|
|
$bQuantifier = FALSE;
|
1865 |
|
|
if (isset($a) && isset($b)) {
|
1866 |
|
|
$aQuantifier = array_search($a, $type_status_order);
|
1867 |
|
|
$bQuantifier = array_search($b, $type_status_order);
|
1868 |
|
|
}
|
1869 |
|
|
return ($aQuantifier < $bQuantifier) ? -1 : 1;
|
1870 |
|
|
}
|
1871 |
|
|
|
1872 |
fb939fdc
|
Andreas Kohlbecker
|
/**
|
1873 |
|
|
* @return array
|
1874 |
|
|
*/
|
1875 |
|
|
function type_status_order()
|
1876 |
|
|
{
|
1877 |
|
|
/*
|
1878 |
|
|
This is the desired sort order as of now: Holotype Isotype Lectotype
|
1879 |
|
|
Isolectotype Syntype.
|
1880 |
|
|
TODO Basically, what we are trying to do is, we define
|
1881 |
|
|
an ordered array of TypeDesignation-states and use the index of this array
|
1882 |
|
|
for comparison. This array has to be filled with the cdm- TypeDesignation
|
1883 |
|
|
states and the order should be parameterisable inside the dataportal.
|
1884 |
|
|
*/
|
1885 |
|
|
// Make that static for now.
|
1886 |
|
|
$type_status_order = array(
|
1887 |
|
|
'Epitype',
|
1888 |
|
|
'Holotype',
|
1889 |
|
|
'Isotype',
|
1890 |
|
|
'Lectotype',
|
1891 |
|
|
'Isolectotype',
|
1892 |
|
|
'Syntype',
|
1893 |
|
|
'Paratype'
|
1894 |
|
|
);
|
1895 |
|
|
return $type_status_order;
|
1896 |
4eab6eeb
|
Andreas Kohlbecker
|
}
|
1897 |
|
|
|
1898 |
|
|
/**
|
1899 |
|
|
* Return HTML for the lectotype citation with the correct layout.
|
1900 |
|
|
*
|
1901 |
|
|
* This function prints the lectotype citation with the correct layout.
|
1902 |
|
|
* Lectotypes are renderized in the synonymy tab of a taxon if they exist.
|
1903 |
|
|
*
|
1904 |
|
|
* @param mixed $typeDesignation
|
1905 |
|
|
* Object containing the lectotype citation to print.
|
1906 |
|
|
*
|
1907 |
|
|
* @return string
|
1908 |
|
|
* Valid html string.
|
1909 |
|
|
*/
|
1910 |
|
|
function type_designation_citation_layout($typeDesignation, $footnote_separator = ',') {
|
1911 |
|
|
$res = '';
|
1912 |
|
|
$citation = $typeDesignation->citation;
|
1913 |
|
|
$pages = $typeDesignation->citationMicroReference;
|
1914 |
|
|
if(isset($typeDesignation->typeStatus->uuid) && isset($typeDesignation->typeStatus->representation_L10n)) {
|
1915 |
|
|
if ( $typeDesignation->typeStatus->uuid == UUID_NTD_ORIGINAL_DESIGNATION || $typeDesignation->typeStatus->uuid == UUID_NTD_MONOTYPY) {
|
1916 |
|
|
$res = ' (' . $typeDesignation->typeStatus->representation_L10n . ')';
|
1917 |
|
|
return $res;
|
1918 |
|
|
}
|
1919 |
|
|
}
|
1920 |
|
|
|
1921 |
|
|
if ($citation) {
|
1922 |
|
|
// $type = $typeDesignation_citation->type;
|
1923 |
|
|
$year = isset($citation->datePublished->start) ? substr($citation->datePublished->start, 0, 4) : '';
|
1924 |
|
|
$author = isset($citation->authorship->titleCache) ? $citation->authorship->titleCache : '';
|
1925 |
|
|
$res .= ' (designated by ';
|
1926 |
|
|
$res .= $author;
|
1927 |
|
|
$res .= ($year ? ' ' . $year : '');
|
1928 |
|
|
$res .= ($pages ? ': ' . $pages : '');
|
1929 |
|
|
// $res .= ')';
|
1930 |
|
|
|
1931 |
|
|
// footnotes should be rendered in the parent element so we
|
1932 |
|
|
// are relying on the FootnoteListKey set there
|
1933 |
|
|
$fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $typeDesignation->citation->titleCache);
|
1934 |
d8069342
|
Andreas Kohlbecker
|
$res .= render_footnote_key($fkey_typeDesignation, $footnote_separator,TRUE) . ')';
|
1935 |
4eab6eeb
|
Andreas Kohlbecker
|
}
|
1936 |
|
|
return $res;
|
1937 |
|
|
}
|
1938 |
|
|
|
1939 |
|
|
/**
|
1940 |
|
|
* Creates markup for the status of a type designation. In case the status or its representation is missing the label will be set to "Type"
|
1941 |
|
|
*
|
1942 |
|
|
* @param $type_designation
|
1943 |
|
|
* @return string
|
1944 |
|
|
*/
|
1945 |
|
|
function type_designation_status_label_markup($type_designation)
|
1946 |
|
|
{
|
1947 |
|
|
return '<span class="type-status">'
|
1948 |
|
|
. ((isset($type_designation->typeStatus->representation_L10n)) ? ucfirst($type_designation->typeStatus->representation_L10n) : t('Type')) . '</span>'
|
1949 |
|
|
;
|
1950 |
|
|
}
|