Revision 35abbad4
Added by Andreas Kohlbecker over 3 years ago
modules/cdm_dataportal/cdm_dataportal.info | ||
---|---|---|
14 | 14 |
files[] = classes/RegistrationDtoComposeHandler.php |
15 | 15 |
files[] = classes/AgentComposeHandler.php |
16 | 16 |
files[] = classes/AnnotationsAndSources.php |
17 |
files[] = classes/NameRenderConfiguration.php |
|
17 | 18 |
|
18 | 19 |
configure = admin/config/cdm_dataportal/settings |
modules/cdm_dataportal/classes/NameRenderConfiguration.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
|
|
4 |
class NameRenderConfiguration { |
|
5 |
|
|
6 |
const DEFAULT_CONFIGURATION = 0; |
|
7 |
const CUSTOM_CONFIGURATION = 1; |
|
8 |
const PRE380_CONFIGURATION = 2; |
|
9 |
|
|
10 |
const CDM_PART_DEFINITIONS = 'cdm-part-definitions'; |
|
11 |
const CDM_NAME_RENDER_TEMPLATES = 'cdm-name-render-templates'; |
|
12 |
|
|
13 |
const CDM_PART_DEFINITIONS_DEFAULT = |
|
14 |
array( |
|
15 |
'ZoologicalName' => array( |
|
16 |
'namePart' => array('name' => TRUE), |
|
17 |
'nameAuthorPart' => array('name' => TRUE), |
|
18 |
'referencePart' => array('authors' => TRUE), |
|
19 |
'microreferencePart' => array('microreference' => TRUE), |
|
20 |
'secReferencePart' => array('secReference' => TRUE,), |
|
21 |
'statusPart' => array('status' => TRUE), |
|
22 |
'descriptionPart' => array('description' => TRUE), |
|
23 |
), |
|
24 |
'BotanicalName'=> array( |
|
25 |
'namePart' => array('name' => TRUE), |
|
26 |
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE), |
|
27 |
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE), |
|
28 |
'secReferencePart' => array('secReference' => TRUE,), |
|
29 |
'referenceYearPart' => array('reference.year' => TRUE), |
|
30 |
'statusPart' => array('status' => TRUE), |
|
31 |
'descriptionPart' => array('description' => TRUE), |
|
32 |
), |
|
33 |
'#DEFAULT' => array( |
|
34 |
'namePart' => array( |
|
35 |
'name' => TRUE |
|
36 |
), |
|
37 |
'nameAuthorPart' => array( |
|
38 |
'name' => TRUE, |
|
39 |
'authors' => TRUE |
|
40 |
), |
|
41 |
'referencePart' => array( |
|
42 |
'reference' => TRUE |
|
43 |
), |
|
44 |
'secReferencePart' => array( |
|
45 |
'secReference' => TRUE, |
|
46 |
), |
|
47 |
'microreferencePart' => array( |
|
48 |
'microreference' => TRUE, |
|
49 |
), |
|
50 |
'statusPart' => array( |
|
51 |
'status' => TRUE, |
|
52 |
), |
|
53 |
'descriptionPart' => array( |
|
54 |
'description' => TRUE, |
|
55 |
), |
|
56 |
) |
|
57 |
); |
|
58 |
|
|
59 |
const CDM_PART_DEFINITIONS_DEFAULT_PRE_380 = |
|
60 |
array( |
|
61 |
'ZoologicalName' => array( |
|
62 |
'namePart' => array('name' => TRUE), |
|
63 |
'nameAuthorPart' => array('name' => TRUE), |
|
64 |
'referencePart' => array('authors' => TRUE), |
|
65 |
'microreferencePart' => array('microreference' => TRUE), |
|
66 |
'statusPart' => array('status' => TRUE), |
|
67 |
'descriptionPart' => array('description' => TRUE), |
|
68 |
), |
|
69 |
'BotanicalName'=> array( |
|
70 |
'namePart' => array('name' => TRUE), |
|
71 |
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE), |
|
72 |
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE), |
|
73 |
'referenceYearPart' => array('reference.year' => TRUE), |
|
74 |
'statusPart' => array('status' => TRUE), |
|
75 |
'descriptionPart' => array('description' => TRUE), |
|
76 |
), |
|
77 |
'#DEFAULT' => array( |
|
78 |
'namePart' => array( |
|
79 |
'name' => TRUE |
|
80 |
), |
|
81 |
'nameAuthorPart' => array( |
|
82 |
'name' => TRUE, |
|
83 |
'authors' => TRUE |
|
84 |
), |
|
85 |
'referencePart' => array( |
|
86 |
'reference' => TRUE |
|
87 |
), |
|
88 |
'microreferencePart' => array( |
|
89 |
'microreference' => TRUE, |
|
90 |
), |
|
91 |
'statusPart' => array( |
|
92 |
'status' => TRUE, |
|
93 |
), |
|
94 |
'descriptionPart' => array( |
|
95 |
'description' => TRUE, |
|
96 |
), |
|
97 |
) |
|
98 |
); |
|
99 |
|
|
100 |
const CDM_NAME_RENDER_TEMPLATES_DEFAULT = |
|
101 |
array ( |
|
102 |
'taxon_page_title,polytomousKey'=> array( |
|
103 |
'namePart' => array('#uri' => TRUE), |
|
104 |
), |
|
105 |
'not_in_current_classification' => array( |
|
106 |
'nameAuthorPart' => TRUE, |
|
107 |
'referencePart' => TRUE, |
|
108 |
'statusPart' => TRUE, |
|
109 |
'secReferencePart' => TRUE, |
|
110 |
), |
|
111 |
'taxon_page_synonymy,accepted_taxon.taxon_page_synonymy,name_page,registration_page'=> array( |
|
112 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
113 |
'referencePart' => TRUE, |
|
114 |
'descriptionPart' => TRUE, |
|
115 |
'statusPart' => TRUE, |
|
116 |
), |
|
117 |
'related_taxon.other_taxon_relationship.taxon_relationships.taxon_page_synonymy'=> array( |
|
118 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
119 |
'referencePart' => TRUE, |
|
120 |
'descriptionPart' => TRUE, |
|
121 |
'statusPart' => TRUE, |
|
122 |
'secReferencePart' => TRUE, |
|
123 |
), |
|
124 |
'related_taxon.misapplied_name_for.taxon_relationships.taxon_page_synonymy' => array( |
|
125 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
126 |
'referencePart' => TRUE, |
|
127 |
'descriptionPart' => TRUE, |
|
128 |
'statusPart' => TRUE, |
|
129 |
/* no sec ref in this case, misapplied names are |
|
130 |
* de-duplicated and the sec ref is shown as footnote */ |
|
131 |
), |
|
132 |
'acceptedFor,typedesignations,list_of_taxa,homonym' => array( |
|
133 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
134 |
'referencePart' => TRUE, |
|
135 |
'statusPart' => TRUE |
|
136 |
), |
|
137 |
'#DEFAULT' => array( |
|
138 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
139 |
'referencePart' => TRUE, |
|
140 |
'statusPart' => TRUE |
|
141 |
) |
|
142 |
); |
|
143 |
|
|
144 |
const CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380 = |
|
145 |
array ( |
|
146 |
'taxon_page_title,polytomousKey'=> array( |
|
147 |
'namePart' => array('#uri' => TRUE), |
|
148 |
), |
|
149 |
'taxon_page_synonymy,related_taxon'=> array( |
|
150 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
151 |
'referencePart' => TRUE, |
|
152 |
'statusPart' => TRUE, |
|
153 |
'descriptionPart' => TRUE, |
|
154 |
), |
|
155 |
'homonym'=> array( |
|
156 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
157 |
'referenceYearPart' => TRUE, |
|
158 |
), |
|
159 |
'acceptedFor,typedesignations,list_of_taxa' => array( |
|
160 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
161 |
'referencePart' => TRUE, |
|
162 |
), |
|
163 |
'#DEFAULT' => array( |
|
164 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
165 |
'referencePart' => TRUE, |
|
166 |
) |
|
167 |
); |
|
168 |
|
|
169 |
private $default_part_definition_json = null; |
|
170 |
private $current_part_definition_json = null; |
|
171 |
|
|
172 |
|
|
173 |
private $default_render_templates_json = null; |
|
174 |
private $current_render_templates_json = null; |
|
175 |
|
|
176 |
function partDefinitionConfigurationStatus(){ |
|
177 |
|
|
178 |
$default_part_definitions_pre_380_json = json_encode(self::CDM_PART_DEFINITIONS_DEFAULT_PRE_380, JSON_PRETTY_PRINT); |
|
179 |
$this->default_part_definition_json = json_encode(self::CDM_PART_DEFINITIONS_DEFAULT, JSON_PRETTY_PRINT); |
|
180 |
$this->current_part_definition_json = json_encode(variable_get(self::CDM_PART_DEFINITIONS, self::CDM_PART_DEFINITIONS_DEFAULT), JSON_PRETTY_PRINT); |
|
181 |
|
|
182 |
$is_custom_part_definition = $this->default_part_definition_json != $this->current_part_definition_json; |
|
183 |
$is_pre_380_part_definition = $default_part_definitions_pre_380_json == $this->current_part_definition_json; |
|
184 |
if($is_pre_380_part_definition){ |
|
185 |
return self::PRE380_CONFIGURATION; |
|
186 |
} else if($is_custom_part_definition){ |
|
187 |
return self::CUSTOM_CONFIGURATION; |
|
188 |
} else { |
|
189 |
return self::DEFAULT_CONFIGURATION; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
function nameRenderTemplateConfigurationStatus(){ |
|
194 |
|
|
195 |
$default_render_templates_pre_380_json = json_encode(self::CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380, JSON_PRETTY_PRINT); |
|
196 |
$this->default_render_templates_json = json_encode(self::CDM_NAME_RENDER_TEMPLATES_DEFAULT, JSON_PRETTY_PRINT); |
|
197 |
$this->current_render_templates_json = json_encode(variable_get(self::CDM_NAME_RENDER_TEMPLATES, self::CDM_NAME_RENDER_TEMPLATES_DEFAULT), JSON_PRETTY_PRINT); |
|
198 |
$is_custom_render_template = $this->default_render_templates_json != $this->current_render_templates_json; |
|
199 |
$is_pre380_render_template = $default_render_templates_pre_380_json == $this->current_render_templates_json; |
|
200 |
if($is_pre380_render_template){ |
|
201 |
return self::PRE380_CONFIGURATION; |
|
202 |
} else if($is_custom_render_template){ |
|
203 |
return self::CUSTOM_CONFIGURATION; |
|
204 |
} else { |
|
205 |
return self::DEFAULT_CONFIGURATION; |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
public function getDefaultPartDefinitionJson() { |
|
210 |
if($this->default_part_definition_json == null){ |
|
211 |
// call the status function to initialize the fields |
|
212 |
$this->partDefinitionConfigurationStatus(); |
|
213 |
} |
|
214 |
return $this->default_part_definition_json; |
|
215 |
} |
|
216 |
|
|
217 |
public function getCurrentPartDefinitionJson() { |
|
218 |
if($this->current_part_definition_json == null){ |
|
219 |
// call the status function to initialize the fields |
|
220 |
$this->partDefinitionConfigurationStatus(); |
|
221 |
} |
|
222 |
return $this->current_part_definition_json; |
|
223 |
} |
|
224 |
|
|
225 |
public function getCurrentRenderTemplatesJson() { |
|
226 |
if($this->current_render_templates_json == null){ |
|
227 |
// call the status function to initialize the fields |
|
228 |
nameRenderTemplateConfigurationStatus(); |
|
229 |
} |
|
230 |
return $this->current_render_templates_json; |
|
231 |
} |
|
232 |
|
|
233 |
public function getDefaultRenderTemplatesJson() { |
|
234 |
if($this->default_render_templates_json == null){ |
|
235 |
// call the status function to initialize the fields |
|
236 |
nameRenderTemplateConfigurationStatus(); |
|
237 |
} |
|
238 |
return $this->default_render_templates_json; |
|
239 |
} |
|
240 |
|
|
241 |
|
|
242 |
} |
modules/cdm_dataportal/includes/name.inc | ||
---|---|---|
72 | 72 |
*/ |
73 | 73 |
function get_nameRenderTemplate($render_path, $nameLink = NULL, $referenceLink = NULL) { |
74 | 74 |
|
75 |
static $default_render_templates = NULL; |
|
76 | 75 |
static $split_render_templates = NULL; |
77 | 76 |
|
78 |
|
|
79 |
if (!isset($default_render_templates)) { |
|
80 |
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT); |
|
81 |
} |
|
82 | 77 |
if($split_render_templates == NULL) { |
83 |
$render_templates = variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates);
|
|
78 |
$render_templates = variable_get(NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES, NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES_DEFAULT);
|
|
84 | 79 |
// needs to be converted to an array |
85 | 80 |
$render_templates = (object_to_array($render_templates)); |
86 | 81 |
|
... | ... | |
222 | 217 |
*/ |
223 | 218 |
function get_partDefinition($taxonNameType) { |
224 | 219 |
|
225 |
static $default_part_definitions = null; |
|
226 |
if (!isset($default_part_definitions)) { |
|
227 |
$default_part_definitions= unserialize(CDM_PART_DEFINITIONS_DEFAULT); |
|
228 |
} |
|
229 |
|
|
230 | 220 |
static $part_definitions = null; |
231 | 221 |
if (!isset($part_definitions)) { |
232 |
$part_definitions = object_to_array(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions));
|
|
222 |
$part_definitions = object_to_array(variable_get(NameRenderConfiguration::CDM_PART_DEFINITIONS, NameRenderConfiguration::CDM_PART_DEFINITIONS_DEFAULT));
|
|
233 | 223 |
} |
234 | 224 |
|
235 | 225 |
$dtype = nameTypeToDTYPE($taxonNameType); |
... | ... | |
1368 | 1358 |
function compose_name_relationships_inline($name_relations, $current_name_uuid, $current_taxon_uuid, $suppress_if_current_name_is_source = true) { |
1369 | 1359 |
|
1370 | 1360 |
RenderHints::pushToRenderStack('homonym'); |
1371 |
// the render stack element homonyms is being used in the default render templates !!!, see CDM_NAME_RENDER_TEMPLATES_DEFAULT |
|
1361 |
// the render stack element homonyms is being used in the default render templates !!!, see NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES_DEFAULT
|
|
1372 | 1362 |
|
1373 | 1363 |
$selected_name_rel_uuids = variable_get(CDM_NAME_RELATIONSHIP_INLINE_TYPES, unserialize(CDM_NAME_RELATIONSHIP_INLINE_TYPES_DEFAULT)); |
1374 | 1364 |
$name_rel_type_filter = array('direct' => array(), 'inverse' => array()); |
modules/cdm_dataportal/settings.php | ||
---|---|---|
234 | 234 |
|
235 | 235 |
} |
236 | 236 |
|
237 |
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions'); |
|
238 |
define('CDM_PART_DEFINITIONS_DEFAULT', serialize( |
|
239 |
array( |
|
240 |
'ZoologicalName' => array( |
|
241 |
'namePart' => array('name' => TRUE), |
|
242 |
'nameAuthorPart' => array('name' => TRUE), |
|
243 |
'referencePart' => array('authors' => TRUE), |
|
244 |
'microreferencePart' => array('microreference' => TRUE), |
|
245 |
'secReferencePart' => array('secReference' => TRUE,), |
|
246 |
'statusPart' => array('status' => TRUE), |
|
247 |
'descriptionPart' => array('description' => TRUE), |
|
248 |
), |
|
249 |
'BotanicalName'=> array( |
|
250 |
'namePart' => array('name' => TRUE), |
|
251 |
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE), |
|
252 |
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE), |
|
253 |
'secReferencePart' => array('secReference' => TRUE,), |
|
254 |
'referenceYearPart' => array('reference.year' => TRUE), |
|
255 |
'statusPart' => array('status' => TRUE), |
|
256 |
'descriptionPart' => array('description' => TRUE), |
|
257 |
), |
|
258 |
'#DEFAULT' => array( |
|
259 |
'namePart' => array( |
|
260 |
'name' => TRUE |
|
261 |
), |
|
262 |
'nameAuthorPart' => array( |
|
263 |
'name' => TRUE, |
|
264 |
'authors' => TRUE |
|
265 |
), |
|
266 |
'referencePart' => array( |
|
267 |
'reference' => TRUE |
|
268 |
), |
|
269 |
'secReferencePart' => array( |
|
270 |
'secReference' => TRUE, |
|
271 |
), |
|
272 |
'microreferencePart' => array( |
|
273 |
'microreference' => TRUE, |
|
274 |
), |
|
275 |
'statusPart' => array( |
|
276 |
'status' => TRUE, |
|
277 |
), |
|
278 |
'descriptionPart' => array( |
|
279 |
'description' => TRUE, |
|
280 |
), |
|
281 |
) |
|
282 |
) |
|
283 |
) |
|
284 |
); |
|
285 |
define('CDM_PART_DEFINITIONS_DEFAULT_PRE_380', serialize( |
|
286 |
array( |
|
287 |
'ZoologicalName' => array( |
|
288 |
'namePart' => array('name' => TRUE), |
|
289 |
'nameAuthorPart' => array('name' => TRUE), |
|
290 |
'referencePart' => array('authors' => TRUE), |
|
291 |
'microreferencePart' => array('microreference' => TRUE), |
|
292 |
'statusPart' => array('status' => TRUE), |
|
293 |
'descriptionPart' => array('description' => TRUE), |
|
294 |
), |
|
295 |
'BotanicalName'=> array( |
|
296 |
'namePart' => array('name' => TRUE), |
|
297 |
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE), |
|
298 |
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE), |
|
299 |
'referenceYearPart' => array('reference.year' => TRUE), |
|
300 |
'statusPart' => array('status' => TRUE), |
|
301 |
'descriptionPart' => array('description' => TRUE), |
|
302 |
), |
|
303 |
'#DEFAULT' => array( |
|
304 |
'namePart' => array( |
|
305 |
'name' => TRUE |
|
306 |
), |
|
307 |
'nameAuthorPart' => array( |
|
308 |
'name' => TRUE, |
|
309 |
'authors' => TRUE |
|
310 |
), |
|
311 |
'referencePart' => array( |
|
312 |
'reference' => TRUE |
|
313 |
), |
|
314 |
'microreferencePart' => array( |
|
315 |
'microreference' => TRUE, |
|
316 |
), |
|
317 |
'statusPart' => array( |
|
318 |
'status' => TRUE, |
|
319 |
), |
|
320 |
'descriptionPart' => array( |
|
321 |
'description' => TRUE, |
|
322 |
), |
|
323 |
) |
|
324 |
) |
|
325 |
) |
|
326 |
); |
|
327 |
|
|
328 |
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates'); |
|
329 |
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize( |
|
330 |
array ( |
|
331 |
'taxon_page_title,polytomousKey'=> array( |
|
332 |
'namePart' => array('#uri' => TRUE), |
|
333 |
), |
|
334 |
'not_in_current_classification' => array( |
|
335 |
'nameAuthorPart' => TRUE, |
|
336 |
'referencePart' => TRUE, |
|
337 |
'statusPart' => TRUE, |
|
338 |
'secReferencePart' => TRUE, |
|
339 |
), |
|
340 |
'taxon_page_synonymy,accepted_taxon.taxon_page_synonymy,name_page,registration_page'=> array( |
|
341 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
342 |
'referencePart' => TRUE, |
|
343 |
'descriptionPart' => TRUE, |
|
344 |
'statusPart' => TRUE, |
|
345 |
), |
|
346 |
'related_taxon.other_taxon_relationship.taxon_relationships.taxon_page_synonymy'=> array( |
|
347 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
348 |
'referencePart' => TRUE, |
|
349 |
'descriptionPart' => TRUE, |
|
350 |
'statusPart' => TRUE, |
|
351 |
'secReferencePart' => TRUE, |
|
352 |
), |
|
353 |
'related_taxon.misapplied_name_for.taxon_relationships.taxon_page_synonymy' => array( |
|
354 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
355 |
'referencePart' => TRUE, |
|
356 |
'descriptionPart' => TRUE, |
|
357 |
'statusPart' => TRUE, |
|
358 |
/* no sec ref in this case, misapplied names are |
|
359 |
* de-duplicated and the sec ref is shown as footnote */ |
|
360 |
), |
|
361 |
'acceptedFor,typedesignations,list_of_taxa,homonym' => array( |
|
362 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
363 |
'referencePart' => TRUE, |
|
364 |
'statusPart' => TRUE |
|
365 |
), |
|
366 |
'#DEFAULT' => array( |
|
367 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
368 |
'referencePart' => TRUE, |
|
369 |
'statusPart' => TRUE |
|
370 |
) |
|
371 |
) |
|
372 |
)); |
|
373 |
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380', serialize( |
|
374 |
array ( |
|
375 |
'taxon_page_title,polytomousKey'=> array( |
|
376 |
'namePart' => array('#uri' => TRUE), |
|
377 |
), |
|
378 |
'taxon_page_synonymy,related_taxon'=> array( |
|
379 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
380 |
'referencePart' => TRUE, |
|
381 |
'statusPart' => TRUE, |
|
382 |
'descriptionPart' => TRUE, |
|
383 |
), |
|
384 |
'homonym'=> array( |
|
385 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
386 |
'referenceYearPart' => TRUE, |
|
387 |
), |
|
388 |
'acceptedFor,typedesignations,list_of_taxa' => array( |
|
389 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
390 |
'referencePart' => TRUE, |
|
391 |
), |
|
392 |
'#DEFAULT' => array( |
|
393 |
'nameAuthorPart' => array('#uri' => TRUE), |
|
394 |
'referencePart' => TRUE, |
|
395 |
) |
|
396 |
) |
|
397 |
)); |
|
398 |
|
|
399 | 237 |
define('CDM_SEARCH_TAXA_MODE','cdm_search_taxa_mode'); |
400 | 238 |
define('CDM_SEARCH_TAXA_MODE_DEFAULT', serialize( |
401 | 239 |
// to unset a default enntry set the value to 0 |
... | ... | |
462 | 300 |
|
463 | 301 |
define('CDM_NAME_RELATIONSHIP_LIST_TYPES', 'cdm_name_relationship_list_types'); |
464 | 302 |
|
465 |
|
|
466 | 303 |
/** |
467 | 304 |
* The drupal variable for the configuration of the information aggregation along |
468 | 305 |
* the taxon relation ships. The mapped array is associative and holds two elements: |
... | ... | |
1674 | 1511 |
The name parts are defined in the <stong>part definitions</strong>'), |
1675 | 1512 |
); |
1676 | 1513 |
|
1677 |
$default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT); |
|
1678 |
$default_part_definitions_pre_380_json = json_encode(unserialize(CDM_PART_DEFINITIONS_DEFAULT_PRE_380), JSON_PRETTY_PRINT); |
|
1679 |
$default_part_definition_json = json_encode($default_part_definitions, JSON_PRETTY_PRINT); |
|
1680 |
$current_part_definition_json = json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions), JSON_PRETTY_PRINT); |
|
1514 |
$nameRenderConfiguration = new NameRenderConfiguration(); |
|
1681 | 1515 |
|
1682 |
$is_custom_part_definition = $default_part_definition_json != $current_part_definition_json; |
|
1683 |
if($default_part_definitions_pre_380_json == $current_part_definition_json){ |
|
1684 |
$which_version_message = '(These are the old default part definition from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)'; |
|
1685 |
} else if($is_custom_part_definition){ |
|
1516 |
$partDefinitionConfigStatus = $nameRenderConfiguration->partDefinitionConfigurationStatus(); |
|
1517 |
switch($partDefinitionConfigStatus){ |
|
1518 |
case NameRenderConfiguration::PRE380_CONFIGURATION: |
|
1519 |
$which_version_message = '(These are the old default part definition from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)'; |
|
1520 |
break; |
|
1521 |
case NameRenderConfiguration::CUSTOM_CONFIGURATION: |
|
1686 | 1522 |
$which_version_message = '(This are custom part definitions, clearing the text area and and submitting the form will reset it to the default)'; |
1687 |
} else { |
|
1688 |
$which_version_message = '(These are the default part definition.)'; |
|
1523 |
break; |
|
1524 |
case NameRenderConfiguration::DEFAULT_CONFIGURATION: |
|
1525 |
default: |
|
1526 |
$which_version_message = '(These are the default part definition.)'; |
|
1689 | 1527 |
} |
1690 |
|
|
1528 |
$current_part_definition_json = $nameRenderConfiguration->getCurrentPartDefinitionJson(); |
|
1529 |
$default_part_definition_json = $nameRenderConfiguration->getDefaultPartDefinitionJson(); |
|
1691 | 1530 |
$diff_viewer_markup = ''; |
1692 |
if($is_custom_part_definition){
|
|
1531 |
if($partDefinitionConfigStatus == NameRenderConfiguration::CUSTOM_CONFIGURATION){
|
|
1693 | 1532 |
$diff_viewer_markup = diff_viewer($default_part_definition_json, $current_part_definition_json); |
1694 | 1533 |
} |
1695 | 1534 |
|
... | ... | |
1698 | 1537 |
. '</div>' |
1699 | 1538 |
. $diff_viewer_markup; |
1700 | 1539 |
|
1701 |
$form['taxon_name'][CDM_PART_DEFINITIONS] = array( |
|
1540 |
$form['taxon_name'][NameRenderConfiguration::CDM_PART_DEFINITIONS] = array(
|
|
1702 | 1541 |
'#type' => 'textarea', |
1703 | 1542 |
'#title' => t('Part definitions'), |
1704 | 1543 |
'#element_validate' => array('form_element_validate_json'), |
... | ... | |
1746 | 1585 |
</ul> |
1747 | 1586 |
An example: |
1748 | 1587 |
<pre> |
1749 |
{ |
|
1750 |
"ZoologicalName": { |
|
1751 |
"namePart": { |
|
1752 |
"name": true |
|
1753 |
}, |
|
1754 |
"referencePart": { |
|
1755 |
"authors": true |
|
1756 |
}, |
|
1757 |
"microreferencePart": { |
|
1758 |
"microreference": true |
|
1759 |
}, |
|
1760 |
"statusPart": { |
|
1761 |
"status": true |
|
1762 |
}, |
|
1763 |
"descriptionPart": { |
|
1764 |
"description": true |
|
1765 |
} |
|
1766 |
}, |
|
1767 |
"BotanicalName": { |
|
1768 |
"namePart": { |
|
1769 |
"name": true, |
|
1770 |
"authors": true |
|
1771 |
}, |
|
1772 |
"referencePart": { |
|
1773 |
"reference": true, |
|
1774 |
"microreference": true |
|
1775 |
}, |
|
1776 |
"secReferencePart": { |
|
1777 |
"secReference": true |
|
1778 |
}, |
|
1779 |
"statusPart": { |
|
1780 |
"status": true |
|
1781 |
}, |
|
1782 |
"descriptionPart": { |
|
1783 |
"description": true |
|
1784 |
} |
|
1785 |
} |
|
1786 |
} |
|
1588 |
' . $default_part_definition_json . ' |
|
1787 | 1589 |
</pre>', |
1788 | 1590 |
); |
1789 | 1591 |
|
1790 |
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT); |
|
1791 |
$default_render_templates_pre_380_json = json_encode(unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380), JSON_PRETTY_PRINT); |
|
1792 |
$default_render_templates_json = json_encode($default_render_templates, JSON_PRETTY_PRINT); |
|
1793 |
$current_render_templates_json = json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates), JSON_PRETTY_PRINT); |
|
1794 |
$is_custom_render_template = $default_render_templates_json != $current_render_templates_json; |
|
1592 |
$nameRenderTemplateConfStatus = $nameRenderConfiguration->nameRenderTemplateConfigurationStatus(); |
|
1795 | 1593 |
|
1796 |
if($default_render_templates_pre_380_json == $current_render_templates_json){ |
|
1797 |
$which_version_message = '(These are the old default render templates from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)'; |
|
1798 |
} else if($is_custom_render_template){ |
|
1799 |
$which_version_message = '(These are custom render templates, clearing the text area and and submitting the form will reset it to the default)'; |
|
1800 |
} else { |
|
1801 |
$which_version_message = '(These are the default render templates.)'; |
|
1594 |
switch($nameRenderTemplateConfStatus){ |
|
1595 |
case NameRenderConfiguration::PRE380_CONFIGURATION: |
|
1596 |
$which_version_message = '(These are the old default render templates from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)'; |
|
1597 |
break; |
|
1598 |
case NameRenderConfiguration::CUSTOM_CONFIGURATION: |
|
1599 |
$which_version_message = '(These are custom render templates, clearing the text area and and submitting the form will reset it to the default)'; |
|
1600 |
break; |
|
1601 |
case NameRenderConfiguration::DEFAULT_CONFIGURATION: |
|
1602 |
default: |
|
1603 |
$which_version_message = '(These are the default render templates.)'; |
|
1802 | 1604 |
} |
1803 |
|
|
1605 |
$default_render_templates_json = $nameRenderConfiguration->getDefaultRenderTemplatesJson(); |
|
1606 |
$current_render_templates_json = $nameRenderConfiguration->getCurrentRenderTemplatesJson(); |
|
1804 | 1607 |
$diff_viewer_markup = ''; |
1805 |
if($is_custom_render_template){
|
|
1608 |
if($nameRenderTemplateConfStatus == NameRenderConfiguration::CUSTOM_CONFIGURATION){
|
|
1806 | 1609 |
$diff_viewer_markup = diff_viewer($default_render_templates_json, $current_render_templates_json); |
1807 | 1610 |
} |
1808 | 1611 |
|
... | ... | |
1811 | 1614 |
. '</div>' |
1812 | 1615 |
. $diff_viewer_markup; |
1813 | 1616 |
|
1814 |
$form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array( |
|
1617 |
$form['taxon_name'][NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES] = array(
|
|
1815 | 1618 |
'#type' => 'textarea', |
1816 | 1619 |
'#title' => t('Name render templates'), |
1817 | 1620 |
'#element_validate' => array('form_element_validate_json'), |
... | ... | |
1860 | 1663 |
|
1861 | 1664 |
$form['#submit'] = array('submit_json_as_php_array'); |
1862 | 1665 |
// #json_elements especially defined for submit_json_as_php_array() |
1863 |
$form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
|
|
1666 |
$form['#json_elements'] = array(NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES, NameRenderConfiguration::CDM_PART_DEFINITIONS);
|
|
1864 | 1667 |
return system_settings_form($form); |
1865 | 1668 |
} |
1866 | 1669 |
|
Also available in: Unified diff
ref #9240 inntroducing class NameRenderConfiguration for all const and function for these settings; in preparation for drush function and for simpler code