1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* CDM Dataportal settings.
|
5
|
*/
|
6
|
|
7
|
// TODO Genus UUID.
|
8
|
define('DEFAULT_TAXONTREE_RANKLIMIT', '1b11c34c-48a8-4efa-98d5-84f7f66ef43a');
|
9
|
define('CDM_TAXONOMICTREE_UUID', 'cdm_taxonomictree_uuid');
|
10
|
define ('CDM_TAXONTREE_INCLUDES', 'taxontree_includes');
|
11
|
|
12
|
define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
|
13
|
define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
|
14
|
define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
|
15
|
define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
|
16
|
define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
|
17
|
define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
|
18
|
|
19
|
/* annotationTypeKeys */
|
20
|
$annotationTypeKeys = array_keys(cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE));
|
21
|
if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
|
22
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
23
|
|
24
|
// Technical annotation are off by default.
|
25
|
unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
|
26
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
27
|
// Additional value for the NULL case.
|
28
|
$annotationTypeKeys[] = 'NULL_VALUE';
|
29
|
}
|
30
|
define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
|
31
|
|
32
|
define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE', 'bibliography_for_original_source');
|
33
|
define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT', serialize(array(
|
34
|
'enabled' => 1,
|
35
|
'key_format' => 'ALPHA'
|
36
|
)));
|
37
|
|
38
|
/* taxonRelationshipTypes */
|
39
|
define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(array(UUID_MISAPPLIED_NAME_FOR, UUID_INVALID_DESIGNATION_FOR)));
|
40
|
|
41
|
|
42
|
/* ---- MAP SETTING CONSTANTS ---- */
|
43
|
/**
|
44
|
* @var array of URIs eg. http://edit.africamuseum.be"
|
45
|
* An options array
|
46
|
*/
|
47
|
define('EDIT_MAPSERVER_URI', serialize(
|
48
|
array(
|
49
|
'http://edit.africamuseum.be'=>'Primary (http://edit.africamuseum.be)',
|
50
|
'http://edit.br.fgov.be'=>'Secondary (http://edit.br.fgov.be)',
|
51
|
)
|
52
|
)
|
53
|
);
|
54
|
define('EDIT_MAPSERVER_PATH', '/edit_wp5');
|
55
|
/**
|
56
|
* @var array of versions eg. "v1.2"
|
57
|
* An options array
|
58
|
*/
|
59
|
define('EDIT_MAPSERVER_VERSION', serialize(
|
60
|
array(
|
61
|
'v1' => 'v1' ,
|
62
|
'v1.1' => 'v1.1',
|
63
|
'v1.2_dev' => 'v1.2_dev',
|
64
|
'v1.2' => 'v1.2',
|
65
|
'v1.3_dev' => 'v1.3_dev',
|
66
|
'v1.4_dev' => 'v1.4_dev'
|
67
|
)
|
68
|
)
|
69
|
);
|
70
|
define('EDIT_MAPSERVER_URI_DEFAULT', 'http://edit.africamuseum.be');
|
71
|
define('EDIT_MAPSERVER_VERSION_DEFAULT', 'v1.2');
|
72
|
|
73
|
// --- Taxon profile settings --- /
|
74
|
define('LAYOUT_SETTING_PREFIX', 'layout_');
|
75
|
define('FEATURE_TREE_LAYOUT_DEFAULTS', serialize(
|
76
|
array(
|
77
|
'enabled' => FALSE,
|
78
|
'enclosingTag' => 'ul',
|
79
|
'entryEnclosingTag' => 'li',
|
80
|
'glue' => ' ',
|
81
|
)));
|
82
|
|
83
|
define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
|
84
|
define('CDM_TAXON_PROFILE_IMAGE', 'cdm_taxon_profile_image');
|
85
|
define('CDM_TAXON_PROFILE_IMAGE_DEFAULT', serialize(
|
86
|
array(
|
87
|
'show' => 0,
|
88
|
'maxextend' => 184,
|
89
|
'media_uri_query' => '',
|
90
|
'custom_placeholder_image_on' => 0,
|
91
|
'custom_placeholder_image_fid' => ''
|
92
|
)
|
93
|
)
|
94
|
);
|
95
|
|
96
|
define('DISTRIBUTION_STATUS_COLORS', 'distribution_status_colors');
|
97
|
|
98
|
/**
|
99
|
* Returns the array of implemented taxon page tabs.
|
100
|
* The array has fixed integer keys which must not be changed.
|
101
|
*/
|
102
|
function get_taxon_tabs_list() {
|
103
|
return array(
|
104
|
0 => 'General',
|
105
|
1 => 'Synonymy',
|
106
|
2 => 'Images',
|
107
|
3 => 'Specimens',
|
108
|
4 => 'Keys',
|
109
|
);
|
110
|
}
|
111
|
|
112
|
define('CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT', serialize(
|
113
|
array('general' => '-3', 'synonymy' => '-2', 'images' => '0', 'specimens' => '1', 'keys' => '3')
|
114
|
));
|
115
|
|
116
|
$taxon_tab_options = get_taxon_tabs_list();
|
117
|
$taxon_tab_options[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX] = 'Last visited tab';
|
118
|
|
119
|
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
|
120
|
|
121
|
/**
|
122
|
* @todo document this function.
|
123
|
*/
|
124
|
function get_taxon_options_list() {
|
125
|
$taxon_tab_options = array_flip(get_taxon_tabs_list());
|
126
|
foreach ($taxon_tab_options as $key => $value) {
|
127
|
$taxon_tab_options[$key] = t($key);
|
128
|
}
|
129
|
return $taxon_tab_options;
|
130
|
|
131
|
}
|
132
|
|
133
|
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions');
|
134
|
define('CDM_PART_DEFINITIONS_DEFAULT', serialize(
|
135
|
array(
|
136
|
'ZoologicalName' => array(
|
137
|
'namePart' => array('name' => TRUE),
|
138
|
'nameAuthorPart' => array('name' => TRUE),
|
139
|
'referencePart' => array('authors' => TRUE),
|
140
|
'microreferencePart' => array('microreference' => TRUE),
|
141
|
'statusPart' => array('status' => TRUE),
|
142
|
'descriptionPart' => array('description' => TRUE),
|
143
|
),
|
144
|
'BotanicalName'=> array(
|
145
|
'namePart' => array('name' => TRUE),
|
146
|
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
|
147
|
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
|
148
|
'referenceYearPart' => array('reference.year' => TRUE),
|
149
|
'statusPart' => array('status' => TRUE),
|
150
|
'descriptionPart' => array('description' => TRUE),
|
151
|
),
|
152
|
'#DEFAULT' => array(
|
153
|
'namePart' => array(
|
154
|
'name' => TRUE
|
155
|
),
|
156
|
'nameAuthorPart' => array(
|
157
|
'name' => TRUE,
|
158
|
'authors' => TRUE
|
159
|
),
|
160
|
'referencePart' => array(
|
161
|
'reference' => TRUE
|
162
|
),
|
163
|
'microreferencePart' => array(
|
164
|
'microreference' => TRUE,
|
165
|
),
|
166
|
'statusPart' => array(
|
167
|
'status' => TRUE,
|
168
|
),
|
169
|
'descriptionPart' => array(
|
170
|
'description' => TRUE,
|
171
|
),
|
172
|
)
|
173
|
)
|
174
|
)
|
175
|
);
|
176
|
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates');
|
177
|
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize(
|
178
|
array (
|
179
|
'taxon_page_title,polytomousKey'=> array(
|
180
|
'namePart' => array('#uri' => TRUE),
|
181
|
),
|
182
|
'taxon_page_synonymy,related_taxon'=> array(
|
183
|
'nameAuthorPart' => array('#uri' => TRUE),
|
184
|
'referencePart' => TRUE,
|
185
|
'statusPart' => TRUE,
|
186
|
'descriptionPart' => TRUE,
|
187
|
),
|
188
|
'homonym'=> array(
|
189
|
'nameAuthorPart' => array('#uri' => TRUE),
|
190
|
'referenceYearPart' => TRUE,
|
191
|
),
|
192
|
'acceptedFor,typedesignations,list_of_taxa' => array(
|
193
|
'nameAuthorPart' => array('#uri' => TRUE),
|
194
|
'referencePart' => TRUE,
|
195
|
),
|
196
|
'#DEFAULT' => array(
|
197
|
'nameAuthorPart' => array('#uri' => TRUE),
|
198
|
'referencePart' => TRUE,
|
199
|
)
|
200
|
)
|
201
|
));
|
202
|
|
203
|
define('CDM_SEARCH_TAXA_MODE','cdm_search_taxa_mode');
|
204
|
define('CDM_SEARCH_TAXA_MODE_DEFAULT', serialize(
|
205
|
// to unset a default enntry set the value to 0
|
206
|
array(
|
207
|
'doTaxa'=>'doTaxa',
|
208
|
'doSynonyms' => 'doSynonyms',
|
209
|
'doTaxaByCommonNames' => 'doTaxaByCommonNames',
|
210
|
'doMisappliedNames' => 'doMisappliedNames'
|
211
|
)
|
212
|
)
|
213
|
);
|
214
|
|
215
|
/* Gallery variables. */
|
216
|
$gallery_settings = array(
|
217
|
"cdm_dataportal_show_taxon_thumbnails" => 1,
|
218
|
"cdm_dataportal_show_synonym_thumbnails" => 0,
|
219
|
"cdm_dataportal_show_thumbnail_captions" => 1,
|
220
|
"cdm_dataportal_media_maxextend" => 120,
|
221
|
"cdm_dataportal_media_cols" => 3,
|
222
|
"cdm_dataportal_media_maxRows" => 1,
|
223
|
);
|
224
|
|
225
|
define('TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT', serialize(get_taxon_options_list()));
|
226
|
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
|
227
|
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
|
228
|
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
|
229
|
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
|
230
|
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
|
231
|
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
|
232
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
|
233
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
|
234
|
// define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
|
235
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
|
236
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
|
237
|
/**
|
238
|
* The drupal variable key for the array containing the uuids of the taxon relationship types to display in
|
239
|
* the snonymy.
|
240
|
*
|
241
|
* @var string
|
242
|
*/
|
243
|
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
|
244
|
/**
|
245
|
* The drupal variable for the configuration of the information aggregation along
|
246
|
* the taxon relation ships. The mapped arrayis associative and holds two elements:
|
247
|
* - direct: the uuids of the taxon relationship types to take into account in invers
|
248
|
* direction.
|
249
|
* - invers: the uuids of the taxon relationship types to take into account in direct
|
250
|
* direction.
|
251
|
*
|
252
|
* @var String
|
253
|
*/
|
254
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS', 'cdm_aggregate_by_taxon_relationships');
|
255
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT', serialize(
|
256
|
array(
|
257
|
'direct'=>array(),
|
258
|
'invers'=>array()
|
259
|
)
|
260
|
));
|
261
|
define('CDM_PROFILE_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
|
262
|
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
|
263
|
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
|
264
|
|
265
|
define('CDM_DISTRIBUTION_FILTER', 'cdm_distribution_filter');
|
266
|
define('CDM_DISTRIBUTION_FILTER_DEFAULT', serialize(
|
267
|
array(
|
268
|
'filter_rules' => array(
|
269
|
'statusOrderPreference' => 0,
|
270
|
'subAreaPreference' => 0,
|
271
|
),
|
272
|
'hideMarkedAreas' => array()
|
273
|
)
|
274
|
));
|
275
|
|
276
|
|
277
|
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
|
278
|
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
|
279
|
array(
|
280
|
'includeTaxonDescriptions' => 'includeTaxonDescriptions',
|
281
|
'includeOccurrences' => 0,
|
282
|
'includeTaxonNameDescriptions' => 0
|
283
|
)
|
284
|
));
|
285
|
|
286
|
define('CDM_MAP_DISTRIBUTION', 'cdm_map_distribution');
|
287
|
define('CDM_MAP_DISTRIBUTION_DEFAULT', serialize(array(
|
288
|
// needs to be merged with user setting by drupal_array_merge_deep()
|
289
|
'width' => 512, // optimum size for OSM layers is 512
|
290
|
'height' => 512 / 2, // optimum size for OSM layers 256
|
291
|
'bbox' => '', // empty to allow automatic zooming to extend
|
292
|
'show_labels' => FALSE,
|
293
|
'caption' => '',
|
294
|
'distribution_opacity' => '0.5',
|
295
|
'map_type' => 1, // 1 = 'openlayers', 0 = 'image'
|
296
|
'image_map' => array(
|
297
|
'base_layer' => '', // none, formerly this was cyprusdivs
|
298
|
'bg_color' => '1874CD',
|
299
|
'layer_style' => 'ffffff,606060,,',
|
300
|
),
|
301
|
'openlayers' => array(
|
302
|
'base_layers' => array(
|
303
|
// A layer MUST NOT BE SET in the defaults,
|
304
|
// otherwise it can not be overidden by the user settings:
|
305
|
// 'osgeo_vmap0' => 'osgeo_vmap0',
|
306
|
// it is sufficient to define the preferred layer,
|
307
|
// since it will automatically be enabled:
|
308
|
'PREFERRED' => 'osgeo_vmap0'),
|
309
|
'custom_wms_base_layer' => array(
|
310
|
'name' => NULL,
|
311
|
'url' => NULL,
|
312
|
'params' => NULL,
|
313
|
'projection' => NULL,
|
314
|
'proj4js_def' => NULL,
|
315
|
'max_extent' => NULL,
|
316
|
'units' => NULL
|
317
|
),
|
318
|
'show_layer_switcher' => TRUE,
|
319
|
'display_outside_max_extent' => FALSE
|
320
|
),
|
321
|
'legend' => array(
|
322
|
'show' => TRUE,
|
323
|
'opacity' => '0.5',
|
324
|
'font_size' => 10,
|
325
|
'font_style' => FALSE,
|
326
|
'icon_width' => 35,
|
327
|
'icon_height' => 15
|
328
|
)
|
329
|
)));
|
330
|
|
331
|
/**
|
332
|
* Merges the named array variable with the array of defaults.
|
333
|
*
|
334
|
* IMPORTANT: The array keys must be strings. When the keys are integers
|
335
|
* the merging will not take place for these entities. Number keyed entities
|
336
|
* are just appended to the result array.
|
337
|
*
|
338
|
* @param string $variable_name
|
339
|
* The variable name
|
340
|
* @param string | array $default
|
341
|
* The array containing the default values either as array or serialized as string.
|
342
|
* Unserialization is cared for if necessary
|
343
|
* @return array
|
344
|
* The merged array as returned by drupal_array_merge_deep()
|
345
|
*/
|
346
|
function get_array_variable_merged($variable_name, $default){
|
347
|
|
348
|
// unserialize if nessecary
|
349
|
if(!is_array($default)){
|
350
|
$default = unserialize($default);
|
351
|
}
|
352
|
$variable = variable_get($variable_name, array());
|
353
|
$result = drupal_array_merge_deep($default, $variable);
|
354
|
return $result;
|
355
|
}
|
356
|
|
357
|
/**
|
358
|
* @todo document this function.
|
359
|
*/
|
360
|
function getGallerySettings($gallery_config_form_name) {
|
361
|
return get_array_variable_merged($gallery_config_form_name, CDM_DATAPORTAL_GALLERY_SETTINGS);
|
362
|
}
|
363
|
|
364
|
/**
|
365
|
* Returns the string representation of the default tab.
|
366
|
*
|
367
|
* @param bool $returnTabIndex
|
368
|
* Defaults to FALSE, if set true this function will return the index number
|
369
|
* of the default tab. (used to supply default values to form elements).
|
370
|
*/
|
371
|
function get_default_taxon_tab($returnTabIndex = FALSE) {
|
372
|
|
373
|
global $user;
|
374
|
$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
375
|
$user_tab_active = 'cdm_dataportal_' . $user->uid . '_default_tab_active';
|
376
|
$user_tab = 'cdm_dataportal_' . $user->uid . '_default_tab';
|
377
|
// Get the user value if the used has chosen to overwrite the system settings.
|
378
|
$user_tab_on = variable_get($user_tab_active, FALSE);
|
379
|
if ($user_tab_on) {
|
380
|
$user_value = variable_get($user_tab, 0);
|
381
|
$index_value = $user_value;
|
382
|
// Get the system value.
|
383
|
}
|
384
|
else {
|
385
|
$system_value = variable_get('cdm_dataportal_default_tab', 0);
|
386
|
$index_value = $system_value;
|
387
|
}
|
388
|
|
389
|
// Return the index value or the string representation.
|
390
|
if ($returnTabIndex) {
|
391
|
return $index_value;
|
392
|
}
|
393
|
else {
|
394
|
return ($values[$index_value]);
|
395
|
|
396
|
}
|
397
|
}
|
398
|
|
399
|
/**
|
400
|
* preliminary mock implementation
|
401
|
*
|
402
|
* "$feature uuid": {
|
403
|
* "as_list": div|ul|ol|dl, // div: not as list, ul: as bullet list, ol: as numbered list, dl:as definition list; will be used in compose_cdm_feature_block_elements() as $enclosing_tag
|
404
|
* "link_to_reference": boolean, // render the reference as link, ignored if the element is NOT a DescriptionElementSource
|
405
|
* "link_to_name_used_in_source": boolean
|
406
|
* // references_inline:
|
407
|
* // TRUE:
|
408
|
* // 1. if element has text (TextData) the source references will be appended in brackets like "text (source references)"
|
409
|
* // 2. otherwise they are the only content (e.g. use case CITATION) and afre not put into brackets
|
410
|
* // FALSE:
|
411
|
* // they are put into the bibliography(=references) pseudo feature block
|
412
|
* "references_inline": boolean
|
413
|
* "sort_elements": SORT_ASC, SORT_DESC, NULL // whether and how to sort the elements
|
414
|
* "element_tag": span | div // only applies if "as_list" == 'div'
|
415
|
* }
|
416
|
*/
|
417
|
function get_feature_block_settings($feature_uuid = 'DEFAULT'){
|
418
|
// the default must conform to the default parameter values of
|
419
|
// compose_cdm_feature_block_elements() : $glue = '', $sort = FALSE, $enclosing_tag = 'ul'
|
420
|
// theme_cdm_descriptionElementTextData() : asListElement = NULL
|
421
|
|
422
|
// currently only element_tag is used.
|
423
|
$default = array(
|
424
|
'DEFAULT' => array(
|
425
|
'as_list' => 'ul',
|
426
|
'link_to_reference' => FALSE,
|
427
|
'link_to_name_used_in_source' => TRUE,
|
428
|
'references_inline' => TRUE,
|
429
|
'sort_elements' => FALSE,
|
430
|
'glue' => '',
|
431
|
'element_tag'=> NULL
|
432
|
)
|
433
|
);
|
434
|
|
435
|
$cichorieae_default = array(
|
436
|
'DEFAULT' => array(
|
437
|
'as_list' => 'div',
|
438
|
'link_to_reference' => TRUE,
|
439
|
'link_to_name_used_in_source' => TRUE,
|
440
|
'references_inline' => TRUE,
|
441
|
'sort_elements' => FALSE,
|
442
|
'glue' => '',
|
443
|
'element_tag'=> 'div'
|
444
|
),
|
445
|
UUID_CITATION => array(
|
446
|
'as_list' => 'div',
|
447
|
'link_to_reference' => FALSE,
|
448
|
'link_to_name_used_in_source' => FALSE,
|
449
|
'references_inline' => TRUE,
|
450
|
'sort_elements' => FALSE,
|
451
|
'glue' => '',
|
452
|
'element_tag'=> 'div'
|
453
|
),
|
454
|
UUID_CHROMOSOMES_NUMBERS => array(
|
455
|
'as_list' => 'ul',
|
456
|
'link_to_reference' => TRUE,
|
457
|
'link_to_name_used_in_source' => TRUE,
|
458
|
'references_inline' => TRUE,
|
459
|
'sort_elements' => FALSE,
|
460
|
'glue' => '',
|
461
|
'element_tag'=> 'div'
|
462
|
),
|
463
|
UUID_CHROMOSOMES => array(
|
464
|
'as_list' => 'ul',
|
465
|
'link_to_reference' => FALSE,
|
466
|
'link_to_name_used_in_source' => TRUE,
|
467
|
'references_inline' => TRUE,
|
468
|
'sort_elements' => FALSE,
|
469
|
'glue' => '',
|
470
|
'element_tag'=> 'div'
|
471
|
),
|
472
|
);
|
473
|
|
474
|
$default_theme = variable_get('theme_default', NULL);
|
475
|
|
476
|
switch ($default_theme){
|
477
|
case 'garland_cichorieae':
|
478
|
case 'cyprus': // no longer used in production, but is required for selenium tests see class eu.etaxonomy.dataportal.pages.PortalPage
|
479
|
$settings_for_theme = $cichorieae_default;
|
480
|
break;
|
481
|
case 'flore_afrique_centrale':
|
482
|
case 'flora_malesiana':
|
483
|
case 'flore_gabon':
|
484
|
$settings_for_theme = $cichorieae_default;
|
485
|
$settings_for_theme[UUID_CITATION]['as_list'] = 'ul';
|
486
|
break;
|
487
|
default:
|
488
|
$settings_for_theme = $default;
|
489
|
}
|
490
|
|
491
|
if(isset($settings_for_theme[$feature_uuid])){
|
492
|
return $settings_for_theme[$feature_uuid];
|
493
|
} else if(isset($settings_for_theme['DEFAULT'])){
|
494
|
return $settings_for_theme['DEFAULT'];
|
495
|
} else if(isset($settings_for_theme[$feature_uuid])){
|
496
|
return $default[$feature_uuid];
|
497
|
} else {
|
498
|
return $default['DEFAULT'];
|
499
|
}
|
500
|
}
|
501
|
|
502
|
/**
|
503
|
* returns the current setting for the original source bibliography
|
504
|
*
|
505
|
* Caches internally
|
506
|
*
|
507
|
* @return array
|
508
|
* the setting for the original source bibliography see BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE:
|
509
|
* - 'enabled': 1|0
|
510
|
* - 'key_format': one of 'latin', 'ROMAN', 'roman', 'ALPHA', 'alpha'
|
511
|
*/
|
512
|
function get_bibliography_settings($clear_cache = false){
|
513
|
static $bibliography_settings = null;
|
514
|
if(!$bibliography_settings || $clear_cache){
|
515
|
$bibliography_settings = get_array_variable_merged(BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE, BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT);
|
516
|
}
|
517
|
return $bibliography_settings;
|
518
|
}
|
519
|
|
520
|
/**
|
521
|
* @todo Please document this function.
|
522
|
* @see http://drupal.org/node/1354
|
523
|
*/
|
524
|
function cdm_dataportal_menu_admin(&$items) {
|
525
|
// Display section on admin/config page.
|
526
|
$items['admin/config/cdm_dataportal'] = array(
|
527
|
'title' => 'CDM Dataportal',
|
528
|
'description' => 'Settings for the CDM DataPortal.',
|
529
|
'position' => 'right',
|
530
|
'weight' => 10,
|
531
|
'page callback' => 'system_admin_menu_block_page',
|
532
|
'access arguments' => array('administer cdm_dataportal'),
|
533
|
'file' => 'system.admin.inc',
|
534
|
'file path' => drupal_get_path('module', 'system'),
|
535
|
);
|
536
|
$items['admin/config/cdm_dataportal/settings'] = array(
|
537
|
'title' => 'Settings',
|
538
|
'description' => 'Settings for the CDM DataPortal.',
|
539
|
'weight' => 0,
|
540
|
'page callback' => 'drupal_get_form',
|
541
|
'page arguments' => array('cdm_settings_general'),
|
542
|
'access arguments' => array('administer cdm_dataportal'),
|
543
|
'type' => MENU_NORMAL_ITEM,
|
544
|
);
|
545
|
$items['admin/config/cdm_dataportal/settings/general'] = array(
|
546
|
'title' => 'General',
|
547
|
'description' => 'General',
|
548
|
'weight' => 0,
|
549
|
'page callback' => 'drupal_get_form',
|
550
|
'page arguments' => array('cdm_settings_general'),
|
551
|
'access arguments' => array('administer cdm_dataportal'),
|
552
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
553
|
);
|
554
|
|
555
|
$items['admin/config/cdm_dataportal/settings/cachesite'] = array(
|
556
|
'title' => 'Cache',
|
557
|
'description' => 'Cache',
|
558
|
'access arguments' => array('administer cdm_dataportal'),
|
559
|
'page callback' => 'drupal_get_form',
|
560
|
'page arguments' => array('cdm_settings_cache'),
|
561
|
'weight' => 10,
|
562
|
'type' => MENU_LOCAL_TASK,
|
563
|
);
|
564
|
|
565
|
$items['admin/config/cdm_dataportal/settings/geo'] = array(
|
566
|
'title' => 'Geo & Map',
|
567
|
'description' => 'Geo & Map',
|
568
|
'access arguments' => array('administer cdm_dataportal'),
|
569
|
'page callback' => 'drupal_get_form',
|
570
|
'page arguments' => array('cdm_settings_geo'),
|
571
|
'weight' => 1,
|
572
|
'type' => MENU_LOCAL_TASK,
|
573
|
);
|
574
|
|
575
|
$items['admin/config/cdm_dataportal/settings/layout'] = array(
|
576
|
'title' => 'Layout',
|
577
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
578
|
'access arguments' => array('administer cdm_dataportal'),
|
579
|
'page callback' => 'drupal_get_form',
|
580
|
'page arguments' => array('cdm_settings_layout'),
|
581
|
'weight' => 2,
|
582
|
'type' => MENU_LOCAL_TASK,
|
583
|
);
|
584
|
|
585
|
$items['admin/config/cdm_dataportal/settings/layout/taxon'] = array(
|
586
|
'title' => 'Taxon',
|
587
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
588
|
'access arguments' => array('administer cdm_dataportal'),
|
589
|
'page callback' => 'drupal_get_form',
|
590
|
'page arguments' => array('cdm_settings_layout_taxon'),
|
591
|
'weight' => 1,
|
592
|
'type' => MENU_LOCAL_TASK,
|
593
|
);
|
594
|
/*
|
595
|
$items[] = array(
|
596
|
'path' => 'admin/config/cdm_dataportal/layout/synonymy',
|
597
|
'title' => t('Synonymy'),
|
598
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
599
|
'access' => user_access('administer cdm_dataportal'),
|
600
|
'callback' => 'drupal_get_form',
|
601
|
'callback arguments' => array('cdm_settings_layout_synonymy'),
|
602
|
'weight' => 1,
|
603
|
'type' => MENU_LOCAL_TASK,
|
604
|
);
|
605
|
|
606
|
$items[] = array(
|
607
|
'path' => 'admin/config/cdm_dataportal/layout/specimens',
|
608
|
'title' => t('Specimens'),
|
609
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
610
|
'access' => user_access('administer cdm_dataportal'),
|
611
|
'callback' => 'drupal_get_form',
|
612
|
'callback arguments' => array('cdm_settings_layout_specimens'),
|
613
|
'weight' => 1,
|
614
|
'type' => MENU_LOCAL_TASK,
|
615
|
);
|
616
|
*/
|
617
|
$items['admin/config/cdm_dataportal/settings/layout/search'] = array(
|
618
|
'title' => 'Search',
|
619
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
620
|
'access arguments' => array('administer cdm_dataportal'),
|
621
|
'page callback' => 'drupal_get_form',
|
622
|
'page arguments' => array('cdm_settings_layout_search'),
|
623
|
'weight' => 2,
|
624
|
'type' => MENU_LOCAL_TASK,
|
625
|
);
|
626
|
|
627
|
$items['admin/config/cdm_dataportal/settings/layout/media'] = array(
|
628
|
'title' => 'Media',
|
629
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
630
|
'access arguments' => array('administer cdm_dataportal'),
|
631
|
'page callback' => 'drupal_get_form',
|
632
|
'page arguments' => array('cdm_settings_layout_media'),
|
633
|
'weight' => 3,
|
634
|
'type' => MENU_LOCAL_TASK,
|
635
|
);
|
636
|
|
637
|
}
|
638
|
|
639
|
/**
|
640
|
* @todo document this function.
|
641
|
*/
|
642
|
function cdm_help_general_cache() {
|
643
|
$form = array();
|
644
|
$form['cache_help'] = array(
|
645
|
'#type' => 'fieldset',
|
646
|
'#title' => t('Help'),
|
647
|
'#collapsible' => TRUE,
|
648
|
'#collapsed' => TRUE,
|
649
|
);
|
650
|
$form['cache_help']['test'] = array('#value' => t('probando'));
|
651
|
return drupal_render($form);
|
652
|
$res = array();
|
653
|
$res['default'] = drupal_render($help);
|
654
|
return $res;
|
655
|
}
|
656
|
|
657
|
/**
|
658
|
* Configures the settings form for the CDM-API module.
|
659
|
*
|
660
|
* @return array
|
661
|
* Drupal settings form.
|
662
|
*/
|
663
|
function cdm_settings_general() {
|
664
|
|
665
|
$form['cdm_webservice'] = array(
|
666
|
'#type' => 'fieldset',
|
667
|
'#title' => t('CDM Server'),
|
668
|
'#collapsible' => FALSE,
|
669
|
'#collapsed' => FALSE,
|
670
|
'#description' => t('The <em>CDM Server</em> exposes data stored in a
|
671
|
CDM data base to the web via RESTful web services and thus is the source of the data
|
672
|
to be displayed by a CDM DataPotal.'),
|
673
|
);
|
674
|
|
675
|
$form['cdm_webservice']['cdm_webservice_url'] = array(
|
676
|
'#type' => 'textfield',
|
677
|
'#title' => t('CDM web service URL') . ':',
|
678
|
'#description' => t('This is the URL to the CDM-Server exposing your data
|
679
|
e.g. <em>"http://myserver.net/cdmserver/myproject"</em>'),
|
680
|
'#default_value' => variable_get('cdm_webservice_url', NULL),
|
681
|
);
|
682
|
|
683
|
$form['cdm_webservice']['cdm_webservice_debug'] = array(
|
684
|
'#type' => 'markup',
|
685
|
'#markup' => '<b>Debug CDM Web Service:</b> The web service debug box has completely been replaced '
|
686
|
. 'by the ' . l('CDM web service debug block', 'admin/structure/block/manage/cdm_api/cdm_ws_debug/configure')
|
687
|
. '. It is usually only visible for administrative roles like <i>administrator</i> and <i>CDM admin</i>'
|
688
|
);
|
689
|
|
690
|
$form['cdm_webservice']['freetext_index'] = array(
|
691
|
'#type' => 'fieldset',
|
692
|
'#title' => t('Freetext index'),
|
693
|
'#collapsible' => FALSE,
|
694
|
'#collapsed' => FALSE,
|
695
|
);
|
696
|
|
697
|
// Check the cdmserver port number and display a waring if it is not port 80
|
698
|
preg_match("#http[s]?://[0-9\p{L}\.]*:([0-9]*)/.*#u", variable_get('cdm_webservice_url', ''), $portNumberMatch, PREG_OFFSET_CAPTURE);
|
699
|
if (isset($portNumberMatch[1]) && $portNumberMatch[1] != '80') {
|
700
|
$form['cdm_webservice']['freetext_index']['message'] = array(
|
701
|
'#markup' => "<div class=\"description\">"
|
702
|
. t("The CDM web service URL contains a portnumber other than standart HTTP port 80: '!port'."
|
703
|
. " Due to this the reindex and purge fuctions may not be working if there is a firewall in between you and the CDM Server."
|
704
|
. " You may want to contact the maintainer of the according CDM Server in order to solve this problem.", array('!port' => $portNumberMatch[1][0]))
|
705
|
. "</div>",
|
706
|
);
|
707
|
};
|
708
|
|
709
|
$frontentURL = urlencode(variable_get('cdm_webservice_url', ''));
|
710
|
$trigger_link_options = array(
|
711
|
'attributes' => array(
|
712
|
'class' => 'index-trigger',
|
713
|
),
|
714
|
);
|
715
|
$form['cdm_webservice']['freetext_index']['operations'] = array(
|
716
|
'#markup' => "<div>" . t('Operations: !url1 !url2', array(
|
717
|
'!url1' => l(t("Purge"), cdm_compose_url(CDM_WS_MANAGE_PURGE, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
718
|
'!url2' => l(t("Reindex"), cdm_compose_url(CDM_WS_MANAGE_REINDEX, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
719
|
))
|
720
|
. '<div id="index-progress"></div></div>',
|
721
|
);
|
722
|
_add_js_cdm_ws_progressbar(".index-trigger", "#index-progress");
|
723
|
|
724
|
$form['cdm_webservice']['proxy'] = array(
|
725
|
'#type' => 'fieldset',
|
726
|
'#title' => t('Proxy'),
|
727
|
'#collapsible' => TRUE,
|
728
|
'#collapsed' => TRUE,
|
729
|
);
|
730
|
|
731
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] = array(
|
732
|
'#type' => 'textfield',
|
733
|
'#title' => t('Proxy URL') . ':',
|
734
|
'#description' => t('If this proxy url is set the cdm api tries
|
735
|
to connect the web service over the given proxy server.
|
736
|
Otherwise proxy usage is deactivated.'),
|
737
|
'#default_value' => variable_get('cdm_webservice_proxy_url', FALSE),
|
738
|
);
|
739
|
|
740
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] = array(
|
741
|
'#type' => 'textfield',
|
742
|
'#title' => t('Proxy port') . ':',
|
743
|
'#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
|
744
|
);
|
745
|
|
746
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] = array(
|
747
|
'#type' => 'textfield',
|
748
|
'#title' => t('Login') . ':',
|
749
|
'#default_value' => variable_get('cdm_webservice_proxy_usr', FALSE),
|
750
|
);
|
751
|
|
752
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] = array(
|
753
|
'#type' => 'textfield',
|
754
|
'#title' => t('Password') . ':',
|
755
|
'#default_value' => variable_get('cdm_webservice_proxy_pwd', FALSE),
|
756
|
);
|
757
|
|
758
|
// TODO: settings are still incomplete, compare with
|
759
|
// trunk/dataportal/inc/config_default.php.inc.
|
760
|
$form['taxon_tree'] = array(
|
761
|
'#type' => 'fieldset',
|
762
|
'#title' => t('Taxon Tree'),
|
763
|
'#collapsible' => FALSE,
|
764
|
'#collapsed' => TRUE,
|
765
|
'#description' => t('<p>When you explore your collection, you can navigate
|
766
|
it through a tree structure also called <em>Taxon Tree</em>.</p><p>To be
|
767
|
able to navigate through your collection the
|
768
|
<a href="http://drupal.org/handbook/blocks">drupal block</a>
|
769
|
<em>CDM Taxon Tree</em> should be visible for users. Enable the block at
|
770
|
<a href="./?q=admin/build/block">Administer->Site building->Blocks
|
771
|
</a></p>'),
|
772
|
);
|
773
|
|
774
|
$form['taxon_tree'][CDM_TAXONOMICTREE_UUID] = array(
|
775
|
'#type' => 'select',
|
776
|
'#title' => t('Available classifications') . ':',
|
777
|
'#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
|
778
|
'#options' => cdm_get_taxontrees_as_options(),
|
779
|
'#description' => t('Select the default taxa classification for your
|
780
|
<em>taxon tree</em>, the other classifications will be also available but
|
781
|
with a manual user change.'),
|
782
|
);
|
783
|
|
784
|
$form['taxon_tree']['taxontree_ranklimit'] = array(
|
785
|
'#type' => 'select',
|
786
|
'#title' => t('Rank of highest displayed taxon') . ':',
|
787
|
// Before DEFAULT_TAXONTREE_RANKLIMIT_UUID.
|
788
|
'#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT),
|
789
|
'#options' => cdm_rankVocabulary_as_option(),
|
790
|
'#description' => t('This is the rank of the highest displayed taxon in the
|
791
|
<em>taxon tree</em>. You can select here which rank should be at the top
|
792
|
level of the tree structure.'),
|
793
|
);
|
794
|
|
795
|
$classification_uuids = array_keys(cdm_get_taxontrees_as_options());
|
796
|
$taxontree_includes_default = array_combine($classification_uuids, $classification_uuids);
|
797
|
$form['taxon_tree'][CDM_TAXONTREE_INCLUDES] = array(
|
798
|
'#type' => 'checkboxes',
|
799
|
'#title' => t('Included Classifications') . ':',
|
800
|
'#default_value' => variable_get(CDM_TAXONTREE_INCLUDES, $taxontree_includes_default),
|
801
|
'#options' => cdm_get_taxontrees_as_options(),
|
802
|
'#description' => t('Only the checked classifications will be avaliable in the classification chooser.'),
|
803
|
);
|
804
|
|
805
|
$form['distribution'] = array(
|
806
|
'#type' => 'fieldset',
|
807
|
'#title' => t('Distributions'),
|
808
|
'#collapsible' => FALSE,
|
809
|
'#description' => 'This section covers general settings regarding distributions, map related settings are found in the '
|
810
|
. l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
|
811
|
'<p>
|
812
|
</p>',
|
813
|
);
|
814
|
|
815
|
$form['distribution'][CDM_DISTRIBUTION_FILTER] = array(
|
816
|
'#type' => 'fieldset',
|
817
|
'#title' => 'Distribution filter',
|
818
|
'#collapsible' => FALSE,
|
819
|
'#collapsed' => FALSE,
|
820
|
'#tree' => TRUE,
|
821
|
'#description' => 'The Distribution filter offers the following options
|
822
|
<ul>
|
823
|
<li><strong>Status order preference rule:</strong> In case of multiple distribution status (PresenceAbsenceTermBase) for the same area the status with the highest order is preferred, see OrderedTermBase.compareTo(OrderedTermBase).</li>
|
824
|
<li><strong>Sub area preference rule:</strong>If there is an area with a direct sub area and both areas have the same computed status only the information on the sub area should be reported, whereas the super area should be ignored.</li>
|
825
|
<li><strong>Marked area filter:</strong>Skip distributions where the area has a Marker with one of the specified MarkerTypes</li>
|
826
|
</ul>'
|
827
|
);
|
828
|
|
829
|
$cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
|
830
|
$form['distribution'][CDM_DISTRIBUTION_FILTER]['filter_rules'] = array(
|
831
|
'#type' => 'checkboxes',
|
832
|
'#title' => 'Filter rules',
|
833
|
'#default_value' => $cdm_distribution_filter['filter_rules'],
|
834
|
'#options' => array(
|
835
|
'statusOrderPreference' => 'Status order preference rule',
|
836
|
'subAreaPreference' => 'Sub area preference rule'
|
837
|
),
|
838
|
);
|
839
|
|
840
|
$marker_type_options = cdm_terms_as_options( cdm_ws_fetch_all('term', array('class' => 'MarkerType' )) );
|
841
|
$form['distribution'][CDM_DISTRIBUTION_FILTER]['hideMarkedAreas'] = array(
|
842
|
'#type' => 'checkboxes',
|
843
|
'#title' => 'Hide marked area filter',
|
844
|
'#default_value' => $cdm_distribution_filter['hideMarkedAreas'],
|
845
|
'#options' => $marker_type_options,
|
846
|
'#description' => 'Check one or more MarkerTypes to define the "hide marked area" filter .',
|
847
|
);
|
848
|
|
849
|
$form['aggregation'] = array(
|
850
|
'#type' => 'fieldset',
|
851
|
'#title' => t('Aggregation of data'),
|
852
|
'#collapsible' => FALSE,
|
853
|
'#description' => 'This section covers the different aspects of aggregating information.
|
854
|
<p>
|
855
|
</p>',
|
856
|
);
|
857
|
|
858
|
$form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
|
859
|
'#type' => 'checkboxes',
|
860
|
'#title' => 'Taxon media filter',
|
861
|
'#default_value' => variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)),
|
862
|
'#options' => array(
|
863
|
'includeTaxonDescriptions' => 'Media in taxon descriptions',
|
864
|
'includeTaxonNameDescriptions' => 'Media in name descriptions',
|
865
|
'includeOccurrences' => 'Media related to specimens and occurrences',
|
866
|
),
|
867
|
'#description' => 'This filter configures which images should be taken into account.',
|
868
|
);
|
869
|
|
870
|
$form['aggregation']['notice'] = array(
|
871
|
'#markup' => '<strong>NOTICE:</strong> The below aggregation settings can slow down the data portal, so you may want to sensibly apply these setting and you may also
|
872
|
want to make use of the caching capabilities of the dataportal.',
|
873
|
);
|
874
|
|
875
|
$form['aggregation']['media_aggregation'] = array(
|
876
|
'#type' => 'fieldset',
|
877
|
'#title' => t('Media aggregation'),
|
878
|
'#collapsible' => FALSE,
|
879
|
'#collapsed' => TRUE,
|
880
|
'#description' => t("The media aggregation is also affected by the settigs in \"<strong>Aggregation via taxon relationsships</strong>\" below."),
|
881
|
|
882
|
);
|
883
|
$form['aggregation']['media_aggregation']['cdm_images_include_children'] = array(
|
884
|
'#type' => 'select',
|
885
|
'#title' => t('Aggregation of taxon pictures') . ':',
|
886
|
'#default_value' => variable_get('cdm_images_include_children', FALSE),
|
887
|
'#options' => array(
|
888
|
0 => "Show only pictures of the current taxon",
|
889
|
1 => "Include pictures of taxonomic children",
|
890
|
),
|
891
|
'#description' => t("Choose whether to include the images of the taxonomic children. This will affect the <em>Images</em> tab and image tumbnails like in the search results."),
|
892
|
);
|
893
|
|
894
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS] = array(
|
895
|
'#type' => 'fieldset',
|
896
|
'#attributes' => array('class'=>array('clearfix')),
|
897
|
'#title' => t('Aggregation via taxon relationsships'),
|
898
|
'#collapsible' => TRUE,
|
899
|
'#collapsed' => TRUE,
|
900
|
'#tree' => TRUE,
|
901
|
'#description' => t('Information on taxa will be aggregated along the below chosen
|
902
|
taxon relation ships. This will affect images and occurrences (specimens).
|
903
|
Taxon relation ships are directed and point form one taxon to another. The taxon
|
904
|
relationships to be taken into accunt can therefore configured for the direct direction
|
905
|
and for the inverse.'),
|
906
|
);
|
907
|
|
908
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
909
|
$aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
|
910
|
|
911
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array(
|
912
|
'#type' => 'checkboxes',
|
913
|
'#title' => t('Direct'),
|
914
|
'#options' => $taxonRelationshipTypeOptions,
|
915
|
'#default_value' => $aggregate_by_taxon_relationships['direct'],
|
916
|
);
|
917
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['invers'] = array(
|
918
|
'#type' => 'checkboxes',
|
919
|
'#title' => t('Invers'),
|
920
|
'#options' => $taxonRelationshipTypeOptions,
|
921
|
'#default_value' => $aggregate_by_taxon_relationships['invers'],
|
922
|
);
|
923
|
|
924
|
// ----------------------
|
925
|
$form['cdm_js_devel_mode'] = array(
|
926
|
'#type' => 'checkbox',
|
927
|
'#title' => 'Java-script developer mode',
|
928
|
'#default_value' => variable_get('cdm_js_devel_mode', FALSE),
|
929
|
'#description' => 'In production envirionments the java script libraries
|
930
|
the cdm_dataportal is making use of are compressed and optimized. This
|
931
|
is good for performance but a caveat if you need to debug java-script. When the
|
932
|
java-script developer mode is enabled the uncompressed and commented developer
|
933
|
versions of java-script libraries will be used where possible.
|
934
|
<br/><strong>Do not use this option in production!</strong>'
|
935
|
);
|
936
|
// ----------------------
|
937
|
$form['cdm_debug_mode'] = array(
|
938
|
'#type' => 'checkbox',
|
939
|
'#title' => 'CDM page debug mode',
|
940
|
'#default_value' => variable_get('cdm_debug_mode', FALSE),
|
941
|
'#description' => 'When CDM page debug mode enabled the start and end of cdm entity page
|
942
|
creation is logged as well as any http request send via the cdm_api. The log is written to a file in the temporary
|
943
|
folder configured in the' . l('File system settings', 'admin/config/media/file-system') .
|
944
|
'. For this site the file is <code> ' . file_directory_temp() . '/drupal_debug.txt</code>
|
945
|
The log is written by the drupal devel module function <code>dd()</code>.
|
946
|
<br/><strong>Note:</strong> The start and end of the page creation is currently only logged for taxon pages only.'
|
947
|
);
|
948
|
|
949
|
// Comment @WA: D7 form api does not support reset buttons,
|
950
|
// so to mimic the D5 reset button we add one like this.
|
951
|
$form['actions']['reset'] = array(
|
952
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
953
|
'#weight' => 1000,
|
954
|
);
|
955
|
|
956
|
$form['#submit'][] = 'cdm_settings_general_submit';
|
957
|
|
958
|
return system_settings_form($form);
|
959
|
}
|
960
|
|
961
|
|
962
|
/**
|
963
|
* LAYOUT settings
|
964
|
* @return
|
965
|
* todo
|
966
|
*/
|
967
|
function cdm_settings_layout() {
|
968
|
|
969
|
$form = array();
|
970
|
|
971
|
$form['about'] = array(
|
972
|
'#markup' => '<h4>' . t('Portal Layout') . '</h4><p>' . t('This settings contains the general configurations
|
973
|
layout. If you want to configure the specific sites layout visit the
|
974
|
respective configuration site for taxon, search or media.') . '</p>',
|
975
|
);
|
976
|
|
977
|
// ---- footnotes --- //
|
978
|
$form['footnotes'] = array(
|
979
|
'#type' => 'fieldset',
|
980
|
'#title' => t('Footnotes'),
|
981
|
'#collapsible' => FALSE,
|
982
|
'#collapsed' => FALSE,
|
983
|
'#description' => t('Taxa data such authors, synonyms names, descriptions,
|
984
|
media or distribution areas may have annotations or footnotes. When the
|
985
|
footnotes are enabled they will be visible (if they exist).'),
|
986
|
);
|
987
|
|
988
|
$form['footnotes']['cdm_dataportal_all_footnotes'] = array(
|
989
|
'#type' => 'checkbox',
|
990
|
'#title' => t('Do not show footnotes'),
|
991
|
'#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
|
992
|
'#description' => t('Check this if you do not want to show any footnotes'),
|
993
|
);
|
994
|
|
995
|
$form['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
|
996
|
'#type' => 'checkbox',
|
997
|
'#title' => t('Do not show annotations footnotes'),
|
998
|
'#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
|
999
|
'#description' => t('Check this if you do not want to show annotation footnotes'),
|
1000
|
);
|
1001
|
|
1002
|
$annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType', SORT_ASC);
|
1003
|
// Additional option for the NULL case.
|
1004
|
$annotationTypeOptions['NULL_VALUE'] = t('untyped');
|
1005
|
$form['footnotes']['annotations_types_as_footnotes'] = array(
|
1006
|
'#type' => 'checkboxes',
|
1007
|
'#title' => t('Annotation types as footnotes'),
|
1008
|
'#description' => t("Only annotations of the selected type will be displayed
|
1009
|
as footnotes. You may want to turn 'technical annotations' off."),
|
1010
|
'#options' => $annotationTypeOptions,
|
1011
|
);
|
1012
|
$annotationsTypesAsFootnotes = variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
|
1013
|
if (!empty($annotationsTypesAsFootnotes)) {
|
1014
|
$form['footnotes']['annotations_types_as_footnotes']['#default_value'] = $annotationsTypesAsFootnotes;
|
1015
|
}
|
1016
|
|
1017
|
// ---- original source --- //
|
1018
|
$form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE] = array(
|
1019
|
'#type' => 'fieldset',
|
1020
|
'#tree' => TRUE,
|
1021
|
'#title' => t('Source Citations'),
|
1022
|
'#collapsible' => FALSE,
|
1023
|
'#collapsed' => FALSE,
|
1024
|
);
|
1025
|
|
1026
|
$bibliography_settings = get_bibliography_settings(true);
|
1027
|
|
1028
|
$form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['enabled'] = array(
|
1029
|
'#type' => 'checkbox',
|
1030
|
'#title' => t('Original Source in bibliography'),
|
1031
|
'#default_value' => $bibliography_settings['enabled'],
|
1032
|
'#description' => t('Show original source citations in bibliography block, instead of rendering them with other
|
1033
|
annotations in each feature block.'),
|
1034
|
);
|
1035
|
|
1036
|
$form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['key_format'] = array(
|
1037
|
'#type' => 'select',
|
1038
|
'#title' => t('The format of the key numerals'),
|
1039
|
'#default_value' => $bibliography_settings['key_format'],
|
1040
|
'#options' => array('latin' => 'Latin',
|
1041
|
'ROMAN' => 'Roman (upper case)',
|
1042
|
'roman' => 'Roman (lower case)',
|
1043
|
'ALPHA'=> 'Alphabet (upper case)',
|
1044
|
'alpha' => 'Alphabet (lower case)')
|
1045
|
);
|
1046
|
|
1047
|
// --- Advanced Search --- //
|
1048
|
$form['asearch'] = array(
|
1049
|
'#type' => 'fieldset',
|
1050
|
'#title' => t('Advanced search'),
|
1051
|
'#collapsible' => FALSE,
|
1052
|
'#collapsed' => FALSE,
|
1053
|
);
|
1054
|
|
1055
|
$form['asearch']['cdm_dataportal_show_advanced_search'] = array(
|
1056
|
'#type' => 'checkbox',
|
1057
|
'#title' => t('Show advanced search link'),
|
1058
|
'#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
|
1059
|
'#description' => t('Check this box if the link to advanced search should be show below the search box.'),
|
1060
|
);
|
1061
|
|
1062
|
// ---- Taxon Name Rendering --- //
|
1063
|
$form['taxon_name'] = array(
|
1064
|
'#type' => 'fieldset',
|
1065
|
'#title' => t('Taxon name display'),
|
1066
|
'#collapsible' => TRUE,
|
1067
|
'#collapsed' => TRUE,
|
1068
|
'#description' => t('The display of taxon names is configured by two parts.'
|
1069
|
. 'The <srong>name render templates</strong> define the parts of the name to be displayed in the different areas of the data portal pages.'
|
1070
|
. 'The name parts are defined in the <stong>part definitions</strong>'),
|
1071
|
);
|
1072
|
|
1073
|
drupal_add_js(
|
1074
|
'jQuery(document).ready( function( ) {
|
1075
|
// pretty print json
|
1076
|
var json_text = jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val();
|
1077
|
var obj = JSON.parse(json_text);
|
1078
|
jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val(JSON.stringify(obj, undefined, 2));
|
1079
|
|
1080
|
json_text = jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val();
|
1081
|
obj = JSON.parse(json_text);
|
1082
|
jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val(JSON.stringify(obj, undefined, 2));
|
1083
|
});'
|
1084
|
,array(
|
1085
|
'type' => 'inline',
|
1086
|
'scope' => 'footer'
|
1087
|
)
|
1088
|
);
|
1089
|
|
1090
|
$default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT);
|
1091
|
|
1092
|
$form['taxon_name'][CDM_PART_DEFINITIONS] = array(
|
1093
|
'#type' => 'textarea',
|
1094
|
'#title' => t('Part definitions'),
|
1095
|
'#element_validate' => array('form_element_validate_json'),
|
1096
|
'#default_value' => json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions)),
|
1097
|
'#description' => '
|
1098
|
<p>
|
1099
|
(Clearing the text area will reset it to the default)
|
1100
|
</p>
|
1101
|
<p>
|
1102
|
The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
|
1103
|
</p>
|
1104
|
<p>
|
1105
|
A full taxon name plus additional information can consist of the following elements:
|
1106
|
<ul>
|
1107
|
<li>name: the taxon name inclugin rank nbut without author</li>
|
1108
|
<li>authors: The authors of a reference, also used in taxon names</li>
|
1109
|
<li>reference: the nomenclatural reference,</li>
|
1110
|
<li>microreference: Volume, page number etc.</li>
|
1111
|
<li>status: The nomenclatural status of a name</li>
|
1112
|
<li>description: name descriptions like protologues etc ...</li>
|
1113
|
</ul>
|
1114
|
</p>
|
1115
|
<p>
|
1116
|
These elements are combined in the part definitions array to from the specific parts to be rendered.
|
1117
|
(The taxon name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example in the following)
|
1118
|
The following parts can be formed and are recognized by the system:
|
1119
|
<ul>
|
1120
|
<li>namePart: the name and rank (for example: "Lapsana communis")</li>
|
1121
|
<li>authorshipPart: the author (for example: "L.")</li>
|
1122
|
<li>nameAuthorPart: the combination of name and author part (for example: "Lapsana communis L.").</li>
|
1123
|
This is useful for zoological names where the authorshipPart belongs to the name and both should</li>
|
1124
|
be combined when a link to the taxon is rendered.</li>
|
1125
|
<li>referencePart: the nomencaltural reference (for example: "Sp. Pl. 1753")</li>
|
1126
|
<li>referenceYearPart: the publication year of the nomencaltural reference (for example: "1753")</li>
|
1127
|
<li>microreferencePart: usually the page number (for example ": 811.")</li>
|
1128
|
<li>statusPart: the nomenclatorical status</li>
|
1129
|
<li>descriptionPart: name descriptions like protologues etc ...</li>
|
1130
|
</ul>
|
1131
|
</p>
|
1132
|
<p>
|
1133
|
Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
|
1134
|
specific parts part definitions:
|
1135
|
<ul>
|
1136
|
<li>BotanicalName</li>
|
1137
|
<li>ZoologicalName</li>
|
1138
|
<li>#DEFAULT: covers ViralNames and other NonViralNames
|
1139
|
</ul>
|
1140
|
An example:
|
1141
|
<pre>
|
1142
|
{
|
1143
|
"ZoologicalName": {
|
1144
|
"namePart": {
|
1145
|
"name": true
|
1146
|
},
|
1147
|
"referencePart": {
|
1148
|
"authors": true
|
1149
|
},
|
1150
|
"microreferencePart": {
|
1151
|
"microreference": true
|
1152
|
},
|
1153
|
"statusPart": {
|
1154
|
"status": true
|
1155
|
},
|
1156
|
"descriptionPart": {
|
1157
|
"description": true
|
1158
|
}
|
1159
|
},
|
1160
|
"BotanicalName": {
|
1161
|
"namePart": {
|
1162
|
"name": true,
|
1163
|
"authors": true
|
1164
|
},
|
1165
|
"referencePart": {
|
1166
|
"reference": true,
|
1167
|
"microreference": true
|
1168
|
},
|
1169
|
"statusPart": {
|
1170
|
"status": true
|
1171
|
},
|
1172
|
"descriptionPart": {
|
1173
|
"description": true
|
1174
|
}
|
1175
|
}
|
1176
|
}
|
1177
|
</pre>',
|
1178
|
);
|
1179
|
|
1180
|
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
|
1181
|
|
1182
|
$form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array(
|
1183
|
'#type' => 'textarea',
|
1184
|
'#title' => t('Name render templates'),
|
1185
|
'#element_validate' => array('form_element_validate_json'),
|
1186
|
'#default_value' => json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates)),
|
1187
|
'#description' => '
|
1188
|
<p>
|
1189
|
(Clearing the text area will reset it to the default)
|
1190
|
</p>
|
1191
|
<p>
|
1192
|
The render templates array contains one or more name render templates to be used within the page areas identified by the
|
1193
|
render path. The render path is used as key of the array sub subelements whereas the name render template array is set as value.
|
1194
|
The following render Path keys are curretly recognized:
|
1195
|
<ul>
|
1196
|
<li>list_of_taxa</li>
|
1197
|
<li>acceptedFor</li>
|
1198
|
<li>homonym</li>
|
1199
|
<li>taxon_page_synonymy</li>
|
1200
|
<li>typedesignations</li>
|
1201
|
<li>taxon_page_title</li>
|
1202
|
<li>polytomousKey</li>
|
1203
|
<li>na: name + authorship</li>
|
1204
|
<li>nar:name + authorship + reference</li>
|
1205
|
<li>#DEFAULT</li>
|
1206
|
</ul>
|
1207
|
A single render template can be used for multiple render paths. In this case the according key of the render templates
|
1208
|
array element should be a comma separated list of render paths, without any whitespace!.
|
1209
|
</p>
|
1210
|
<p>
|
1211
|
A render template is an associative array. The keys of this array are referring to the keys as defined in the part
|
1212
|
definitions array. See <a href="#edit-cdm-part-definitions">Part definitions</a> above for more information.
|
1213
|
<p>
|
1214
|
The value of the render template element must be set to TRUE in order to let this part being rendered.
|
1215
|
The namePart, nameAuthorPart and referencePart can also hold an associative array with a single
|
1216
|
element: array(\'#uri\' => TRUE). The value of the #uri element will be replaced by the according
|
1217
|
links if the paramters $nameLink or $refenceLink are given to the name render function
|
1218
|
(this is hard coded and cannot be configured here).',
|
1219
|
);
|
1220
|
|
1221
|
// @WA: D7 form api does not support reset buttons,
|
1222
|
// so to mimic the D5 reset button we add one like this.
|
1223
|
$form['actions']['reset'] = array(
|
1224
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1225
|
'#weight' => 1000,
|
1226
|
);
|
1227
|
|
1228
|
$form['#submit'] = array('submit_json_as_php_array');
|
1229
|
// #json_elements especially defined for submit_json_as_php_array()
|
1230
|
$form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
|
1231
|
return system_settings_form($form);
|
1232
|
}
|
1233
|
|
1234
|
|
1235
|
/**
|
1236
|
* @todo Please document this function.
|
1237
|
* @see http://drupal.org/node/1354
|
1238
|
*/
|
1239
|
function cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description = '') {
|
1240
|
$form[$form_name] = array(
|
1241
|
'#type' => 'fieldset',
|
1242
|
'#title' => t($form_title),
|
1243
|
'#collapsible' => TRUE,
|
1244
|
'#collapsed' => $collapsed,
|
1245
|
'#tree' => TRUE,
|
1246
|
'#description' => t($form_description),
|
1247
|
);
|
1248
|
|
1249
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
1250
|
$gallery_settings = variable_get($form_name, $default_values);
|
1251
|
// $test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
1252
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
1253
|
/*
|
1254
|
TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
|
1255
|
$form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
|
1256
|
'#type' => 'textfield',
|
1257
|
'#title' => t('Search Page Size'),
|
1258
|
'#default_value' => $test,
|
1259
|
'#description' => t('Number of Names to display per page in search results.')
|
1260
|
);
|
1261
|
*/
|
1262
|
$form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
|
1263
|
'#type' => 'checkbox',
|
1264
|
'#title' => t('Show media thumbnails for accepted taxa'),
|
1265
|
'#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
|
1266
|
);
|
1267
|
|
1268
|
$form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
|
1269
|
'#type' => 'checkbox',
|
1270
|
'#title' => t('Show media thumbnails for synonyms'),
|
1271
|
'#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
|
1272
|
'#description' => '',
|
1273
|
);
|
1274
|
}
|
1275
|
|
1276
|
// $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
|
1277
|
$form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
|
1278
|
'#type' => 'checkbox',
|
1279
|
'#title' => t('Show captions under thumbnails'),
|
1280
|
'#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
1281
|
'#description' => '',
|
1282
|
);
|
1283
|
|
1284
|
$form[$form_name]['cdm_dataportal_media_maxextend'] = array(
|
1285
|
'#type' => 'textfield',
|
1286
|
'#title' => t('Thumbnail size') . ':',
|
1287
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
1288
|
'#description' => t('Select the size of each individual thumbnail.'),
|
1289
|
);
|
1290
|
|
1291
|
if ($form_name != CDM_DATAPORTAL_MEDIA_GALLERY_NAME) {
|
1292
|
$form[$form_name]['cdm_dataportal_media_cols'] = array(
|
1293
|
'#type' => 'textfield',
|
1294
|
'#title' => t('Number of columns') . ':',
|
1295
|
'#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
|
1296
|
'#description' => t('Group the thumbnails in columns: select how many
|
1297
|
columns the gallery should display.'),
|
1298
|
);
|
1299
|
}
|
1300
|
|
1301
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
1302
|
$form[$form_name]['cdm_dataportal_media_maxRows'] = array(
|
1303
|
'#type' => 'textfield',
|
1304
|
'#title' => t('Maximum number of rows') . ':',
|
1305
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
1306
|
'#description' => t('You can group the thumbnails in rows, select in how
|
1307
|
many rows should be the thumbnails grouped.<br/><strong>Note:</strong>
|
1308
|
If you want an unlimited number of rows please set to 0.'),
|
1309
|
);
|
1310
|
}
|
1311
|
|
1312
|
return $form;
|
1313
|
}
|
1314
|
|
1315
|
/**
|
1316
|
* @todo document this function.
|
1317
|
*/
|
1318
|
function cdm_settings_layout_taxon() {
|
1319
|
$collapsed = FALSE;
|
1320
|
$form = array();
|
1321
|
|
1322
|
$form['#submit'][] = 'cdm_settings_layout_taxon_submit';
|
1323
|
|
1324
|
$form['cdm_dataportal_show_back_to_search_results'] = array(
|
1325
|
'#type' => 'checkbox',
|
1326
|
'#title' => t('Show <em>Back to search results</em> link at the taxon site.'),
|
1327
|
'#default_value' => variable_get('cdm_dataportal_show_back_to_search_results', 1),
|
1328
|
'#description' => t('<p>If checked the link to search results is rendered at
|
1329
|
the top of the taxon site. Clicking on the link the last search performed
|
1330
|
is rendered again.</p>'),
|
1331
|
);
|
1332
|
|
1333
|
// --------- TABBED TAXON ------- //
|
1334
|
$form['taxon_tabs'] = array(
|
1335
|
'#type' => 'fieldset',
|
1336
|
'#title' => t('Taxon tabs'),
|
1337
|
'#collapsible' => TRUE,
|
1338
|
'#collapsed' => FALSE,
|
1339
|
'#description' => t('If tabbed taxon page is enabled the taxon profile will
|
1340
|
be splitted in four diferent tabs; General, Synonymy, Images and
|
1341
|
Specimens. If the taxon has no information for any of the tabs/sections
|
1342
|
such tab will be not displayed.'),
|
1343
|
);
|
1344
|
|
1345
|
$form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
|
1346
|
'#type' => 'checkbox',
|
1347
|
'#title' => t('Tabbed taxon page'),
|
1348
|
'#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
|
1349
|
'#description' => t('<p>If selected split the taxon page into individual
|
1350
|
tabs for description, images, synonymy and specimens. If not the taxon
|
1351
|
data is rendered as a long single page without tabs.</p>'),
|
1352
|
);
|
1353
|
|
1354
|
$form['taxon_tabs']['cdm_taxonpage_tabs_visibility'] = array(
|
1355
|
'#type' => 'checkboxes',
|
1356
|
'#title' => t('Tabs visibility options') . ':',
|
1357
|
'#default_value' => variable_get('cdm_taxonpage_tabs_visibility', get_taxon_options_list()),
|
1358
|
'#options' => get_taxon_options_list(),
|
1359
|
'#description' => t('Enable or disable Tabs in the Tabbed page display'),
|
1360
|
);
|
1361
|
|
1362
|
// WEIGHT
|
1363
|
$taxontabs_weights = get_array_variable_merged('cdm_taxonpage_tabs_weight', CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
|
1364
|
$form['taxon_tabs']['cdm_taxonpage_tabs_weight'] = array(
|
1365
|
'#tree' => true
|
1366
|
);
|
1367
|
// Weights range from -delta to +delta, so delta should be at least half
|
1368
|
// of the amount of tabs present.
|
1369
|
$tab_weight_delta = round(count(get_taxon_tabs_list()) / 2) + 1;
|
1370
|
foreach (get_taxon_tabs_list() as $label) {
|
1371
|
$key = strtolower($label); // turn in to string, since we need to use strings as keys
|
1372
|
$form['taxon_tabs']['cdm_taxonpage_tabs_weight'][$key] = array(
|
1373
|
'#title' => $label,
|
1374
|
'#type' => 'weight',
|
1375
|
'#default_value' => $taxontabs_weights[$key],
|
1376
|
'#delta' => $tab_weight_delta
|
1377
|
);
|
1378
|
}
|
1379
|
|
1380
|
$form['taxon_tabs']['cdm_dataportal_default_tab'] = array(
|
1381
|
'#type' => 'select',
|
1382
|
'#title' => t('Default tab to display') . ':',
|
1383
|
'#default_value' => variable_get('cdm_dataportal_default_tab', 0),
|
1384
|
'#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
|
1385
|
'#description' => t('<p>Select the default tab to display when visiting a
|
1386
|
taxon page. Only available if Tabbed Taxon Page is enable.</p>
|
1387
|
<strong>Note:</strong> After performing a search and clicking in any
|
1388
|
synonym, the taxon tab to be rendered will be the synonymy of the accepted
|
1389
|
taxon and not the above selected tab.'),
|
1390
|
);
|
1391
|
|
1392
|
/* ====== TAXON_PROFILE ====== */
|
1393
|
$form['taxon_profile'] = array(
|
1394
|
'#type' => 'fieldset',
|
1395
|
'#title' => t('Taxon profile (tab)'),
|
1396
|
'#description' => t('<p>This section covers the settings related to the taxon
|
1397
|
profile tab, also known as the <strong>"General"</strong> tab.</p>'),
|
1398
|
'#collapsible' => TRUE,
|
1399
|
'#collapsed' => TRUE,
|
1400
|
);
|
1401
|
|
1402
|
// ---- PROFILE PICTURE ----//
|
1403
|
|
1404
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE] = array(
|
1405
|
'#type' => 'fieldset',
|
1406
|
'#tree' => TRUE,
|
1407
|
'#title' => t('Taxon profile picture'),
|
1408
|
'#collapsible' => TRUE,
|
1409
|
'#collapsed' => FALSE,
|
1410
|
'#description' => t('This sections allows configuring the display of the so called taxon profile image which is displayed in the taxon profile tab.'),
|
1411
|
);
|
1412
|
|
1413
|
//FIXME migrate variables:
|
1414
|
// cdm_dataportal_show_default_image ---> CDM_TAXON_PROFILE_IMAGE['show']
|
1415
|
// FIXME
|
1416
|
// eanable file modul in profile and in update
|
1417
|
|
1418
|
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
|
1419
|
/*
|
1420
|
* 'show' => 1,
|
1421
|
* 'maxextend' => 184,
|
1422
|
* 'media_uri_query' => ''
|
1423
|
* 'custom_placeholder_image_on' => 1,
|
1424
|
* 'custom_placeholder_image_fid' => ''
|
1425
|
*/
|
1426
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['show'] = array(
|
1427
|
'#type' => 'checkbox',
|
1428
|
'#title' => t('Enable profil picture'),
|
1429
|
'#description' => t('Show the profil picture.'),
|
1430
|
'#default_value' => $taxon_profile_image_settings['show'],
|
1431
|
);
|
1432
|
|
1433
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['maxextend'] = array(
|
1434
|
'#type' => 'textfield',
|
1435
|
'#tree' => TRUE,
|
1436
|
'#title' => t('Profil picture maximum extend'),
|
1437
|
'#default_value' => $taxon_profile_image_settings['maxextend'],
|
1438
|
'#field_suffix' => 'px',
|
1439
|
'#maxlength' => 4,
|
1440
|
'#size' => 4,
|
1441
|
'#description' => t('The maximum extend in either dimension, width or height, of the profil picture in pixels.')
|
1442
|
);
|
1443
|
|
1444
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array(
|
1445
|
'#type' => 'textfield',
|
1446
|
'#tree' => TRUE,
|
1447
|
'#title' => t('Additional URI query parameter'),
|
1448
|
'#default_value' => $taxon_profile_image_settings['media_uri_query'],
|
1449
|
'#maxlength' => 1024,
|
1450
|
'#size' => 60,
|
1451
|
'#description' => t('Additional query parameters to be used when requesting for the '
|
1452
|
. 'profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.'
|
1453
|
. 'The query parameters will be appendend to the uri of the media representation part'
|
1454
|
. ' as stored in the cdm. The query parameter string must not start with a \'&\' or \'?\'')
|
1455
|
);
|
1456
|
|
1457
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array(
|
1458
|
'#type' => 'checkbox',
|
1459
|
'#title' => t('Use a custom placeholder image'),
|
1460
|
'#description' => t("This image is shown as replacement if no image of the taxon is available."),
|
1461
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_on']
|
1462
|
);
|
1463
|
|
1464
|
if($taxon_profile_image_settings['custom_placeholder_image_on'] == 1){
|
1465
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
|
1466
|
'#type' => 'managed_file',
|
1467
|
'#title' => t('Custom placeholder image file'),
|
1468
|
'#progress_indicator' => 'bar',
|
1469
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid'],
|
1470
|
// '#name' => 'custom_placeholder_image',
|
1471
|
'#upload_location' => 'public://' . CDM_TAXON_PROFILE_IMAGE .'/'
|
1472
|
);
|
1473
|
|
1474
|
if($taxon_profile_image_settings['custom_placeholder_image_fid']){
|
1475
|
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
|
1476
|
$url = file_create_url($profile_image_file->uri);
|
1477
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['preview'] = array(
|
1478
|
'#type' => 'item',
|
1479
|
'#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
|
1480
|
);
|
1481
|
}
|
1482
|
} else {
|
1483
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
|
1484
|
'#type' => 'hidden',
|
1485
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid']
|
1486
|
);
|
1487
|
}
|
1488
|
|
1489
|
|
1490
|
|
1491
|
$options = cdm_rankVocabulary_as_option();
|
1492
|
array_unshift($options, '-- DISABLED --');
|
1493
|
$form['taxon_profile']['picture']['image_hide_rank'] = array(
|
1494
|
'#type' => 'select',
|
1495
|
'#title' => t('Hide profile picture for higher ranks') . ':',
|
1496
|
'#default_value' => variable_get('image_hide_rank', '0'),
|
1497
|
'#options' => $options,
|
1498
|
'#description' => t('The taxon profile picture will not be shown for taxa with rank higher that the selected.'),
|
1499
|
);
|
1500
|
|
1501
|
// -- MEDIA THUMBNAILS -- //
|
1502
|
$form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
|
1503
|
$form_title = 'Taxon Profile Images';
|
1504
|
$form_description = '<p>The different section in the taxon profile can have images associated with them. These images are displayed in a gallery of thumbnails wich can be configuered here:</p>';
|
1505
|
$form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1506
|
|
1507
|
// ---- FEATURE TREE ---- //
|
1508
|
$form['taxon_profile']['feature_trees'] = array(
|
1509
|
'#type' => 'fieldset',
|
1510
|
'#title' => t('Features'),
|
1511
|
'#collapsible' => TRUE,
|
1512
|
'#collapsed' => FALSE,
|
1513
|
'#description' => t("This section covers settings related to the taxon's
|
1514
|
<em>Feature Tree</em>. The <em>feature tree</em> are the taxon's
|
1515
|
features such as description, distribution, common names, etc. that Drupal
|
1516
|
will render at the taxon profile page."),
|
1517
|
);
|
1518
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1519
|
$saved_uuid = variable_get(CDM_PROFILE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1520
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1521
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1522
|
}
|
1523
|
$form['taxon_profile']['feature_trees'][CDM_PROFILE_FEATURETREE_UUID] = array(
|
1524
|
'#type' => 'radios',
|
1525
|
'#title' => t('Taxon profile sections') . ':',
|
1526
|
'#default_value' => $saved_uuid,
|
1527
|
'#options' => $featureTrees['options'],
|
1528
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1529
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1530
|
'#description' => t('Select the Feature Tree to be displayed at the taxon
|
1531
|
profile. Click "Show Details" to see the Feature Tree elements.'
|
1532
|
),
|
1533
|
);
|
1534
|
$featureTrees = cdm_get_featureTrees_as_options();
|
1535
|
$saved_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1536
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1537
|
$saved_uuid = NULL;
|
1538
|
}
|
1539
|
$form['taxon_profile']['feature_trees'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
|
1540
|
'#type' => 'radios',
|
1541
|
'#title' => t('Natural language representation of structured descriptions') . ':',
|
1542
|
'#default_value' => $saved_uuid,
|
1543
|
'#options' => $featureTrees['options'],
|
1544
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1545
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1546
|
'#description' => t('Taxon descriptions can be stored in a highly structured
|
1547
|
form. The feature tree selected here will be used to generate textual
|
1548
|
representation in natural language.'
|
1549
|
),
|
1550
|
);
|
1551
|
|
1552
|
// ---- LAYOUT PER FEATURE ---- //
|
1553
|
$feature_tree = get_profile_featureTree();
|
1554
|
if (isset($feature_tree->root->childNodes)) {
|
1555
|
|
1556
|
$form_feature_list_layout = array(
|
1557
|
'#title' => t('Taxon profile layout'),
|
1558
|
'#collapsible' => TRUE,
|
1559
|
'#collapsed' => FALSE,
|
1560
|
'#type' => 'fieldset',
|
1561
|
'#description' => t('Will be available in a future release.'),
|
1562
|
);
|
1563
|
|
1564
|
$feature_list_layout_settings_disabled = TRUE;
|
1565
|
foreach ($feature_tree->root->childNodes as $featureNode) {
|
1566
|
|
1567
|
if (!$feature_list_layout_settings_disabled && isset($featureNode->feature)) {
|
1568
|
// Must not exceed 45 characters !!!
|
1569
|
$subform_id = LAYOUT_SETTING_PREFIX . $featureNode->feature->uuid;
|
1570
|
|
1571
|
$settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
|
1572
|
$systemDefaults = unserialize(FEATURE_TREE_LAYOUT_DEFAULTS);
|
1573
|
|
1574
|
$form_feature_list_layout[$subform_id] = array(
|
1575
|
'#tree' => TRUE,
|
1576
|
'#title' => 'test' . $featureNode->feature->representation_L10n,
|
1577
|
'#collapsible' => FALSE,
|
1578
|
'#collapsed' => FALSE,
|
1579
|
'#type' => 'fieldset',
|
1580
|
'#description' => t(''),
|
1581
|
);
|
1582
|
|
1583
|
$form_feature_list_layout[$subform_id]['enabled'] = array(
|
1584
|
'#type' => 'checkbox',
|
1585
|
'#title' => t('Enable'),
|
1586
|
'#default_value' => $settings['enabled'],
|
1587
|
'#description' => t('Enable user defined layout for this feature'),
|
1588
|
);
|
1589
|
|
1590
|
$form_feature_list_layout[$subform_id]['enclosingTag'] = array(
|
1591
|
'#type' => 'textfield',
|
1592
|
'#title' => t('Enclosing tag'),
|
1593
|
'#disabled' => !$settings['enabled'],
|
1594
|
'#default_value' => $settings['enclosingTag'],
|
1595
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['enclosingTag'] . "</code>'",
|
1596
|
);
|
1597
|
|
1598
|
$form_feature_list_layout[$subform_id]['entryEnclosingTag'] = array(
|
1599
|
'#type' => 'textfield',
|
1600
|
'#title' => t('Entry enclosing tag'),
|
1601
|
'#disabled' => !$settings['enabled'],
|
1602
|
'#default_value' => $settings['entryEnclosingTag'],
|
1603
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['entryEnclosingTag'] . "</code>'",
|
1604
|
);
|
1605
|
|
1606
|
$form_feature_list_layout[$subform_id]['glue'] = array(
|
1607
|
'#type' => 'textfield',
|
1608
|
'#title' => t('Glue'),
|
1609
|
'#disabled' => !$settings['enabled'],
|
1610
|
'#default_value' => $settings['glue'],
|
1611
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['glue'] . "</code>'",
|
1612
|
);
|
1613
|
|
1614
|
}
|
1615
|
|
1616
|
$form['taxon_profile']['feature_list_layout'] = $form_feature_list_layout;
|
1617
|
}
|
1618
|
}
|
1619
|
|
1620
|
// ---- DISTRIBUTION LAYOUT ---- //
|
1621
|
$form['taxon_profile']['distribution_layout'] = array(
|
1622
|
'#title' => t('Distribution'),
|
1623
|
'#collapsible' => TRUE,
|
1624
|
'#collapsed' => FALSE,
|
1625
|
'#type' => 'fieldset',
|
1626
|
'#description' => t('Select if you want to sort or not the distribution text
|
1627
|
located below the distribution map.'),
|
1628
|
);
|
1629
|
|
1630
|
$form['taxon_profile']['distribution_layout']['distribution_sort'] = array(
|
1631
|
'#type' => 'radios',
|
1632
|
'#title' => t('Sort') . ':',
|
1633
|
'#default_value' => variable_get('distribution_sort', 'NO_SORT'),
|
1634
|
'#options' => array(
|
1635
|
'NO_SORT' => t('Standard (No sort)'),
|
1636
|
'HIDE_TDWG2' => t('Sorted without TDWG Level 2'),
|
1637
|
),
|
1638
|
);
|
1639
|
|
1640
|
$form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] = array(
|
1641
|
'#type' => 'checkbox',
|
1642
|
'#title' => t('Show TextData elements on top of the map'),
|
1643
|
'#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
|
1644
|
'#description' => t('Check this if you want to appear all <code>TextData</code>
|
1645
|
elements on top of the map. Otherwise all <code>TextData</code>
|
1646
|
distribution elements will be listed below the other area elements.
|
1647
|
This option is useful if you need to have descriptive texts for each
|
1648
|
distribution map.'),
|
1649
|
);
|
1650
|
|
1651
|
$form['taxon_profile'][DISTRIBUTION_STATUS_COLORS] = array(
|
1652
|
'#type' => 'textarea',
|
1653
|
'#title' => t('Custom status colors'),
|
1654
|
'#element_validate' => array('form_element_validate_json'),
|
1655
|
'#default_value' => variable_get(DISTRIBUTION_STATUS_COLORS, ''),
|
1656
|
'#description' => t('<strong>EXPERIMENTAL!</strong><br/>This may be changed in the next release without notification.
|
1657
|
A json map object with StatusTerm.idInVocabulary as key and a hex color as value. e.g: <code>{"n":"#ff0000","p":"#00ff00"}</code>.
|
1658
|
reference list of the idInVocabulary values of absence and presence terms:
|
1659
|
<pre>
|
1660
|
Presence Term
|
1661
|
p present
|
1662
|
pd present: doubtfully present
|
1663
|
n native
|
1664
|
nq native: presence questionable
|
1665
|
nd native: doubtfully native
|
1666
|
c cultivated
|
1667
|
i introduced
|
1668
|
iq introduced: presence questionable
|
1669
|
id introduced: doubtfully introduced (perhaps cultivated only)
|
1670
|
ip introduced: uncertain degree of naturalisation
|
1671
|
ia introduced: adventitious (casual)
|
1672
|
in introduced: naturalized
|
1673
|
ic introduced: cultivated
|
1674
|
e endemic for the relevant area
|
1675
|
na naturalised
|
1676
|
iv invasive
|
1677
|
|
1678
|
AbsenceTerm
|
1679
|
a absent
|
1680
|
f reported in error
|
1681
|
nf native: reported in error
|
1682
|
if introduced: reported in error
|
1683
|
cf cultivated: reported in error
|
1684
|
ne native: formerly native
|
1685
|
ie introduced: formerly introduced
|
1686
|
|
1687
|
</pre>'),
|
1688
|
);
|
1689
|
|
1690
|
|
1691
|
/* ====== SYNONYMY ====== */
|
1692
|
$form['taxon_synonymy'] = array(
|
1693
|
'#type' => 'fieldset',
|
1694
|
'#title' => t('Taxon synonymy (tab)'),
|
1695
|
'#collapsible' => TRUE,
|
1696
|
'#collapsed' => TRUE,
|
1697
|
'#description' => t('This section covers the settings related to the taxon
|
1698
|
<strong>synonymy</strong> tab.'),
|
1699
|
);
|
1700
|
|
1701
|
$form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
|
1702
|
'#type' => 'checkbox',
|
1703
|
'#title' => t('Show accepted taxon on top of the synonymy'),
|
1704
|
'#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
|
1705
|
'#description' => t('If checked, the first homotypic taxon is a repetition
|
1706
|
of the accepted taxon most likely with the full nomenclatural reference
|
1707
|
(depending on the currently chosen theme).'),
|
1708
|
);
|
1709
|
|
1710
|
$form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
|
1711
|
'#type' => 'checkbox',
|
1712
|
'#title' => t('Display <em>is accepted for ...</em> on taxon pages when
|
1713
|
coming from a synonym link.'),
|
1714
|
'#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
|
1715
|
'#description' => t('Check this if after doing a search and clicking on a
|
1716
|
synonym you want to see the "accept of" text for the accepted synonym.'),
|
1717
|
);
|
1718
|
|
1719
|
/* === currently unused ===
|
1720
|
$nameRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
|
1721
|
$form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array(
|
1722
|
'#type' => 'checkboxes',
|
1723
|
'#title' => t('Display name relationships') . ':',
|
1724
|
'#default_value' => variable_get('name_relationships_to_show', 0),
|
1725
|
'#options' => $nameRelationshipTypeOptions,
|
1726
|
'#description' => t('Select the name relationships you want to show for the
|
1727
|
accepted taxa.'),
|
1728
|
);
|
1729
|
*/
|
1730
|
|
1731
|
$form['taxon_synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
|
1732
|
'#type' => 'checkbox',
|
1733
|
'#title' => t('Show taxon relations ships of accepted taxon'),
|
1734
|
'#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1735
|
'#description' => t('If this option is enabled the synonymy will show the
|
1736
|
below selected taxon relationships of accepted taxa.'),
|
1737
|
);
|
1738
|
|
1739
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
1740
|
$form['taxon_synonymy'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
|
1741
|
'#type' => 'checkboxes',
|
1742
|
'#title' => t('Taxon relationship types') . ':',
|
1743
|
'#description' => t('Only taxon relationships of the selected type will be
|
1744
|
displayed'),
|
1745
|
'#options' => $taxonRelationshipTypeOptions,
|
1746
|
'#default_value' => variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
|
1747
|
'#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1748
|
);
|
1749
|
|
1750
|
// ====== SPECIMENS ====== //
|
1751
|
$form['taxon_specimens'] = array(
|
1752
|
'#type' => 'fieldset',
|
1753
|
'#title' => t('Taxon specimens (tab)'),
|
1754
|
'#collapsible' => TRUE,
|
1755
|
'#collapsed' => TRUE,
|
1756
|
'#description' => t('This section covers the settings related to the taxon
|
1757
|
<strong>specimens</strong> tab.'),
|
1758
|
);
|
1759
|
|
1760
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1761
|
$saved_uuid = variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1762
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1763
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1764
|
}
|
1765
|
$form['taxon_specimens']['feature_trees'][CDM_OCCURRENCE_FEATURETREE_UUID] = array(
|
1766
|
'#type' => 'radios',
|
1767
|
'#title' => t('Specimen description feature tree') . ':',
|
1768
|
'#default_value' => $saved_uuid,
|
1769
|
'#options' => $featureTrees['options'],
|
1770
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1771
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1772
|
'#description' => t('Select the feature tree to be used for displaying specimen descriptions. Click "Show Details" to see the Feature Tree elements.'
|
1773
|
),
|
1774
|
);
|
1775
|
|
1776
|
$form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
|
1777
|
$form_title = t('Specimen media');
|
1778
|
$form_description = t('Specimens may have media which is displayed at the
|
1779
|
Specimen tab/section as a gallery. It is possible to configure the
|
1780
|
thumbnails gallery here, however for configuring how a single media should
|
1781
|
be displayed please go to !url.</p>',
|
1782
|
array(
|
1783
|
'!url' => l(t('Layout -> Media'), 'admin/config/cdm_dataportal/settings/layout/media'),
|
1784
|
));
|
1785
|
$form['taxon_specimens'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1786
|
|
1787
|
// --- MEDIA GALLERY ---- //
|
1788
|
$form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
|
1789
|
$form_title = 'Media gallery (tab)';
|
1790
|
$form_description = '<p>This section covers the settings related to the taxon <strong>media</strong> tab.
|
1791
|
Taxa may have media (usually images) and they are as thumbnails displayed. It is possible to configure
|
1792
|
the thumbnails gallery here, however for configuring how a single media should be displayed please go to
|
1793
|
<a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a></p>
|
1794
|
<p><strong>Note:</strong> These settings are only taken into account when the standard
|
1795
|
gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a>.</p>';
|
1796
|
$form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
|
1797
|
|
1798
|
// Comment @WA: D7 form api does not support reset buttons,
|
1799
|
// so to mimic the D5 reset button we add one like this.
|
1800
|
$form['actions']['reset'] = array(
|
1801
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1802
|
'#weight' => 1000,
|
1803
|
);
|
1804
|
return system_settings_form($form);
|
1805
|
}
|
1806
|
|
1807
|
/**
|
1808
|
* @todo document this function.
|
1809
|
*/
|
1810
|
function cdm_settings_layout_search() {
|
1811
|
|
1812
|
$form = array();
|
1813
|
|
1814
|
$form['#submit'][] = 'cdm_settings_layout_search_submit';
|
1815
|
|
1816
|
$form['search_settings'] = array(
|
1817
|
'#type' => 'fieldset',
|
1818
|
'#title' => t('Taxa Search'),
|
1819
|
'#collapsible' => FALSE,
|
1820
|
'#collapsed' => FALSE,
|
1821
|
'#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
|
1822
|
the block <em>CDM Taxon Search</em> should be enabled and visible for users
|
1823
|
where they can write the text to be searched. You can find Drupal block configuration
|
1824
|
site at <a href="./?q=admin/build/block">Administer->Site building->Blocks</a></p> '),
|
1825
|
);
|
1826
|
|
1827
|
$form['search_settings']['simple_search_ignore_classification'] = array(
|
1828
|
'#type' => 'checkbox',
|
1829
|
'#title' => t('Ignore the chosen classification in simple search'),
|
1830
|
'#default_value' => variable_get('simple_search_ignore_classification', TRUE),
|
1831
|
'#description' => t('The simple search, which can be executed via the search block,
|
1832
|
will by default search on all classifications. Remove the tick if you want your
|
1833
|
portal to search on the classification selected in the classification browser
|
1834
|
selector.'),
|
1835
|
);
|
1836
|
|
1837
|
$form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
|
1838
|
'#type' => 'textfield',
|
1839
|
'#title' => t('Results per page') . ':',
|
1840
|
'#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
|
1841
|
'#description' => t('Number of results to display per page.'),
|
1842
|
);
|
1843
|
|
1844
|
$search_mode_default = get_array_variable_merged(CDM_SEARCH_TAXA_MODE, CDM_SEARCH_TAXA_MODE_DEFAULT);
|
1845
|
$form['search_settings']['cdm_search_taxa_mode'] = array(
|
1846
|
'#type' => 'checkboxes',
|
1847
|
'#title' => 'Search mode',
|
1848
|
'#description' => 'The taxon search can operate in different modes in order to find only taxa, synonyms,
|
1849
|
taxa by its common name and even taxa which have been used as misappied names. The settings made here will affect the default
|
1850
|
for the advance search form and the behaviour of the simple search form which always will behave according to the
|
1851
|
defaults set here.',
|
1852
|
'#options' => drupal_map_assoc(array_keys(unserialize(CDM_SEARCH_TAXA_MODE_DEFAULT))),
|
1853
|
'#default_value' => $search_mode_default
|
1854
|
);
|
1855
|
|
1856
|
// --- SEARCH TAXA GALLERY ---- //
|
1857
|
$items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
1858
|
$collapsed = FALSE;
|
1859
|
$form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
|
1860
|
$form_title = 'Taxa Search thumbnails';
|
1861
|
$form_description = 'Search results may show thumbnails. ';
|
1862
|
$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1863
|
|
1864
|
// Comment @WA: D7 form api does not support reset buttons,
|
1865
|
// so to mimic the D5 reset button we add one like this.
|
1866
|
$form['actions']['reset'] = array(
|
1867
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1868
|
'#weight' => 1000,
|
1869
|
);
|
1870
|
return system_settings_form($form);
|
1871
|
}
|
1872
|
|
1873
|
/**
|
1874
|
* @todo document this function.
|
1875
|
*/
|
1876
|
function cdm_settings_layout_media() {
|
1877
|
|
1878
|
$form = array();
|
1879
|
|
1880
|
$form['media_settings'] = array(
|
1881
|
'#type' => 'fieldset',
|
1882
|
'#title' => t('Media settings'),
|
1883
|
'#collapsible' => FALSE,
|
1884
|
'#collapsed' => FALSE,
|
1885
|
'#description' => 'This section covers layout settings for media pages.'
|
1886
|
. 'Further media related settings may be found under the taxon layout settings and on the general settings.',
|
1887
|
);
|
1888
|
|
1889
|
$form['media_settings']['image_gallery_viewer'] = array(
|
1890
|
'#type' => 'select',
|
1891
|
'#title' => t('Image viewer') . ':',
|
1892
|
'#default_value' => variable_get('image_gallery_viewer', 'default'),
|
1893
|
'#options' => array(
|
1894
|
'default' => t('Standard image viewer'),
|
1895
|
'fsi' => t('FSI viewer (requires FSI server!)'),
|
1896
|
),
|
1897
|
);
|
1898
|
|
1899
|
// --- MEDIA GALLERY ---- //
|
1900
|
$form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
|
1901
|
$form_title = 'Standard viewer';
|
1902
|
$form_description = '<p>Configure the standard image viewer.</p><p><strong>Note:</strong> the image viewer should selected otherwise settings are not taking into account.</p>';
|
1903
|
// $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
|
1904
|
$form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1905
|
|
1906
|
// @WA: D7 form api does not support reset buttons,
|
1907
|
// so to mimic the D5 reset button we add one like this.
|
1908
|
$form['actions']['reset'] = array(
|
1909
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1910
|
'#weight' => 1000,
|
1911
|
);
|
1912
|
return system_settings_form($form);
|
1913
|
}
|
1914
|
|
1915
|
/**
|
1916
|
* GEOSERVICE and Map settings.
|
1917
|
*/
|
1918
|
function cdm_settings_geo($form, &$form_state) {
|
1919
|
|
1920
|
$current_geoserver_settings = get_edit_map_service_settings();
|
1921
|
$map_distribution = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
|
1922
|
// The default layer must always be enabled
|
1923
|
$preferred_layer = $map_distribution['openlayers']['base_layers']['PREFERRED'];
|
1924
|
$map_distribution['openlayers']['base_layers'][$preferred_layer] = $preferred_layer;
|
1925
|
|
1926
|
$form = array();
|
1927
|
|
1928
|
$dummy_distribution_query = NULL;
|
1929
|
if($map_distribution['map_type'] != 1){
|
1930
|
// we need to apply a dummy query since the map serice requires for image maps
|
1931
|
// at least as and ad to be defined
|
1932
|
$dummy_distribution_query = "as=a:339966&ad=tdwg1:a:1,2,3,4,5,6,7,8,9";
|
1933
|
}
|
1934
|
$form['map_preview'] = array(
|
1935
|
'#type' => 'fieldset',
|
1936
|
'#tree' => FALSE,
|
1937
|
'#title' => t('Map preview'),
|
1938
|
'#collapsible' => FALSE,
|
1939
|
'#description' => 'The preview of the map'
|
1940
|
. ($dummy_distribution_query != null ?
|
1941
|
' may not be accurate in case if image maps, please check the map display in the taxon pages.':
|
1942
|
'.<br/>Hold down Strg and drag with your mouse to select a bbox to zoom to. <br/>The bbox of the visible area of the map is always displayed below the map.')
|
1943
|
);
|
1944
|
$form['map_preview']['map'] = compose_map(NULL, $dummy_distribution_query, NULL,
|
1945
|
array(
|
1946
|
'move' => "this.cdmOpenlayersMap.printInfo",
|
1947
|
'#execute' => "this.cdmOpenlayersMap.printInfo"
|
1948
|
)
|
1949
|
);
|
1950
|
|
1951
|
|
1952
|
/*
|
1953
|
* GEO SERVER
|
1954
|
*/
|
1955
|
$form['edit_map_server'] = array(
|
1956
|
'#type' => 'fieldset',
|
1957
|
'#tree' => true,
|
1958
|
'#title' => t('EDIT map service'),
|
1959
|
'#collapsible' => TRUE,
|
1960
|
'#collapsed' => TRUE,
|
1961
|
'#description' => t('Configuration and selection of your geo server.
|
1962
|
The Geo Server is responsible for generating the maps.'),
|
1963
|
);
|
1964
|
|
1965
|
$form['edit_map_server']['base_uri'] = array(
|
1966
|
'#type' => 'select',
|
1967
|
'#title' => t('EDIT map service') . ':',
|
1968
|
'#default_value' => $current_geoserver_settings['base_uri'],
|
1969
|
'#options' => unserialize(EDIT_MAPSERVER_URI),
|
1970
|
'#description' => t('Select the EDIT map server you want to use within your data portal.'),
|
1971
|
);
|
1972
|
$form['edit_map_server']['version'] = array(
|
1973
|
'#type' => 'select',
|
1974
|
'#title' => t('Version') . ':',
|
1975
|
'#default_value' => $current_geoserver_settings['version'],
|
1976
|
'#options' => unserialize(EDIT_MAPSERVER_VERSION),
|
1977
|
'#description' => t('The version of the EDIT map services'),
|
1978
|
);
|
1979
|
|
1980
|
$localhostkey = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
|
1981
|
$gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
|
1982
|
$form['gmap_api_key'] = array(
|
1983
|
'#type' => 'textfield',
|
1984
|
'#title' => t('Google maps API key') . ':',
|
1985
|
'#default_value' => variable_get('gmap_api_key', $gmap_api_key),
|
1986
|
'#description' => t('If you want to use the Google Maps Layer, a key is
|
1987
|
needed. If you need a key, visit
|
1988
|
<a href="http://code.google.com/intl/en/apis/maps/signup.html">google maps api key</a>.
|
1989
|
<br/><strong>Note:</strong> The following key: <code>!localhostkey</code>
|
1990
|
is the default key for the localhost (127.0.0.1).',
|
1991
|
array('!localhostkey' => $localhostkey)),
|
1992
|
);
|
1993
|
|
1994
|
|
1995
|
/*
|
1996
|
* MAP SETTINGS
|
1997
|
*/
|
1998
|
|
1999
|
$form[CDM_MAP_DISTRIBUTION] = array(
|
2000
|
'#type' => 'fieldset',
|
2001
|
'#tree' => TRUE,
|
2002
|
'#title' => t('Maps settings'),
|
2003
|
'#collapsible' => TRUE,
|
2004
|
'#collapsed' => TRUE,
|
2005
|
'#description' => t('General configuration for all map types.'),
|
2006
|
);
|
2007
|
|
2008
|
/*
|
2009
|
* settings for the distribution map are used also for specimens map!!!!
|
2010
|
*/
|
2011
|
|
2012
|
$form[CDM_MAP_DISTRIBUTION]['width'] = array(
|
2013
|
'#type' => 'textfield',
|
2014
|
'#title' => 'Width',
|
2015
|
'#default_value' => $map_distribution['width'],
|
2016
|
'#maxlength' => 4,
|
2017
|
'#size' => 4,
|
2018
|
'#description' => 'Width of the map. To allow OSM baselayers to zoom out to the full extend of the world the map width must be
|
2019
|
a multiple of 256px since the osm tiles from tile.openstreetmap.org have a size of 256px x 256px and frational zoom
|
2020
|
levels are not possible in this case.',
|
2021
|
);
|
2022
|
$form[CDM_MAP_DISTRIBUTION]['height'] = array(
|
2023
|
'#type' => 'textfield',
|
2024
|
'#title' => 'Height',
|
2025
|
'#default_value' => $map_distribution['height'],
|
2026
|
'#maxlength' => 4,
|
2027
|
'#size' => 4,
|
2028
|
'#description' => 'Height of the map. Depending on the chosen base layer you may want to choose the height equal
|
2029
|
to the width or half of the width. Any other aspect ratio is also possible if desired.',
|
2030
|
);
|
2031
|
|
2032
|
$form[CDM_MAP_DISTRIBUTION]['bbox'] = array(
|
2033
|
'#type' => 'textfield',
|
2034
|
'#title' => 'Bounding box',
|
2035
|
'#default_value' => $map_distribution['bbox'],
|
2036
|
'#description' => t('The bounding box (left, bottom, right, top) defines the area to be initially displayed in maps.
|
2037
|
Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong>
|
2038
|
to let the map <strong>automatically zoom</strong> to the bounds enclosing the shown data.</p>
|
2039
|
<strong>TIP: </strong>You can use the map preview above to choose a bbox from the map. Maybe you need to change the map type to OpeLayers.
|
2040
|
Hold down Strg and drag with your mouse to select a bbox to zoom to. The bbox of the visible area of the map is always displayed
|
2041
|
below the map from where you can copy the bbox string.</p>'),
|
2042
|
);
|
2043
|
|
2044
|
$form[CDM_MAP_DISTRIBUTION]['show_labels'] = array(
|
2045
|
'#type' => 'checkbox',
|
2046
|
'#title' => 'Display area labels',
|
2047
|
'#default_value' => $map_distribution['show_labels'],
|
2048
|
'#description' => t('The map will show name labels of the areas'),
|
2049
|
);
|
2050
|
|
2051
|
$form[CDM_MAP_DISTRIBUTION]['caption'] = array(
|
2052
|
'#type' => 'textfield',
|
2053
|
'#title' => 'Map caption',
|
2054
|
'#default_value' => $map_distribution['caption'],
|
2055
|
'#description' => t('The caption will be shown below the map.'),
|
2056
|
);
|
2057
|
|
2058
|
$form[CDM_MAP_DISTRIBUTION]['distribution_opacity'] = array(
|
2059
|
'#type' => 'textfield',
|
2060
|
'#title' => 'Distribution layer opacity',
|
2061
|
'#default_value' => $map_distribution['distribution_opacity'],
|
2062
|
'#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions (the countries or regions) will
|
2063
|
fully visible, while a value near to 0.0 will be not much visible.'),
|
2064
|
);
|
2065
|
|
2066
|
$form[CDM_MAP_DISTRIBUTION]['map_type'] = array(
|
2067
|
'#type' => 'radios',
|
2068
|
'#title' => 'Map types',
|
2069
|
'#options' => array(
|
2070
|
1 => "OpenLayers dynamic map viewer",
|
2071
|
0 => "Plain image",
|
2072
|
),
|
2073
|
'#default_value' => $map_distribution['map_type'],
|
2074
|
'#description' => 'Two different map types are available :
|
2075
|
<ul><li><em>OpenLayers</em>: Display the maps in an interactive viewer
|
2076
|
which allows zooming and panning. If enabled you can configure the default layer
|
2077
|
(background of your maps) below.</li>
|
2078
|
<li><em>Plain image</em>: The map will be static non interactive
|
2079
|
image.</li></ul>',
|
2080
|
);
|
2081
|
$open_layers_is_enabled = $map_distribution['map_type'] == 1;
|
2082
|
|
2083
|
|
2084
|
// --- Plain Image Settings --- //
|
2085
|
$form[CDM_MAP_DISTRIBUTION]['image_map'] = array(
|
2086
|
'#type' => 'fieldset',
|
2087
|
'#title' => 'Plain image map settings',
|
2088
|
'#tree' => TRUE,
|
2089
|
'#collapsible' => TRUE,
|
2090
|
'#collapsed' => $open_layers_is_enabled,
|
2091
|
'#description' => 'The settings in this section are still expertimental
|
2092
|
and can only be used with the EDIT map service version 1.1 or above.',
|
2093
|
);
|
2094
|
$edit_mapserver_version = get_edit_map_service_version_number();
|
2095
|
if ($edit_mapserver_version < 1.1) {
|
2096
|
$form[CDM_MAP_DISTRIBUTION]['image_map']['#description'] = '<div class="messages warning">' . t("The chosen EDIT map service version ($edit_mapserver_version) is too low, it must be at least 1.1") . '</div>'
|
2097
|
. $form[CDM_MAP_DISTRIBUTION]['image_map']['#description'];
|
2098
|
}
|
2099
|
|
2100
|
$form[CDM_MAP_DISTRIBUTION]['image_map']['base_layer'] = array(
|
2101
|
'#type' => 'textfield',
|
2102
|
'#title' => 'Background layer',
|
2103
|
'#default_value' => $map_distribution['image_map']['base_layer'],
|
2104
|
'#description' => t('Background layer. For available layers inspect !url1 or !url2.', array(
|
2105
|
'!url1' => l('deegree-csw', 'http://edit.africamuseum.be:8080/deegree-csw/md_search.jsp'),
|
2106
|
'!url2' => l('geoserver layers', 'http://edit.africamuseum.be/geoserver/web/'),
|
2107
|
)),
|
2108
|
);
|
2109
|
|
2110
|
$form[CDM_MAP_DISTRIBUTION]['image_map']['bg_color'] = array(
|
2111
|
'#type' => 'textfield',
|
2112
|
'#title' => 'Background color',
|
2113
|
'#default_value' => $map_distribution['image_map']['bg_color'],
|
2114
|
);
|
2115
|
|
2116
|
$form[CDM_MAP_DISTRIBUTION]['image_map']['layer_style'] = array(
|
2117
|
'#type' => 'textfield',
|
2118
|
'#title' => 'Background layer style',
|
2119
|
// Only line color by now.
|
2120
|
'#default_value' => $map_distribution['image_map']['layer_style'],
|
2121
|
'#description' => 'Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}',
|
2122
|
);
|
2123
|
|
2124
|
$form[CDM_MAP_DISTRIBUTION]['image_map']['projection'] = array(
|
2125
|
'#type' => 'textfield',
|
2126
|
'#title' => 'Projection',
|
2127
|
'#default_value' => drupal_array_get_nested_value($map_distribution, array('image_map', 'projection')),
|
2128
|
'#description' => 'Spatial Reference System (SRS) identifier ) optional ( Defines projections in WMS GetMap request.
|
2129
|
Using EPSG:4326 (WGS84 lat/long) is the default but can be changed
|
2130
|
on-the-fly to different UTM and much more zone specific. Examples: EPSG:4326, EPSG:900913, EPSG:3857, EPSG:7777777',
|
2131
|
);
|
2132
|
|
2133
|
|
2134
|
// --- OpenLayers Settings --- //
|
2135
|
$form[CDM_MAP_DISTRIBUTION]['openlayers'] = array(
|
2136
|
'#type' => 'fieldset',
|
2137
|
'#title' => 'OpenLayers settings',
|
2138
|
'#tree' => TRUE,
|
2139
|
'#collapsible' => TRUE,
|
2140
|
'#collapsed' => !$open_layers_is_enabled,
|
2141
|
'#description' => '',
|
2142
|
);
|
2143
|
|
2144
|
|
2145
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['display_outside_max_extent'] = array(
|
2146
|
'#type' => 'checkbox',
|
2147
|
'#title' => 'Display outside max extent',
|
2148
|
'#default_value' => $map_distribution['openlayers']['display_outside_max_extent'],
|
2149
|
'#description' => t('Allows the map to display parts of the layers which are outside
|
2150
|
the max extent if the aspect ratio of the map and of the baselayer
|
2151
|
are not equal.'),
|
2152
|
);
|
2153
|
|
2154
|
|
2155
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['show_layer_switcher'] = array(
|
2156
|
'#type' => 'checkbox',
|
2157
|
'#title' => 'Show Layer Switcher',
|
2158
|
'#default_value' => $map_distribution['openlayers']['show_layer_switcher'],
|
2159
|
'#description' => 'The Layer Switcher control displays a table of contents
|
2160
|
for the map. This allows the user interface to switch between
|
2161
|
base layers and to show or hide overlays. By default the switcher is
|
2162
|
shown minimized on the right edge of the map, the user may expand it
|
2163
|
by clicking on the handle.',
|
2164
|
);
|
2165
|
|
2166
|
if (!$open_layers_is_enabled) {
|
2167
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'] = '<div class="messages warning">'
|
2168
|
. 'The Openlayers viewer is currently not enabled! (see section Maps settings above )</div>'
|
2169
|
. $form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'];
|
2170
|
}
|
2171
|
|
2172
|
$baselayer_options = array(
|
2173
|
/*
|
2174
|
NOTICE: must correspond to the layers defined in
|
2175
|
js/openlayers_,ap.js#getLayersByName()
|
2176
|
*/
|
2177
|
'osgeo_vmap0' => "Metacarta Vmap0 (OSGeo server)", // EPSG:4326: EPSG:900913
|
2178
|
'metacarta_vmap0' => "Metacarta Vmap0 (MetaCarta Labs server)", // EPSG:4326, EPSG:900913
|
2179
|
// all others EPSG:900913
|
2180
|
// 'edit-vmap0_world_basic' => 'EDIT Vmap0',
|
2181
|
'edit-etopo1' => "ETOPO1 Global Relief Model",
|
2182
|
'mapnik' => 'OpenStreetMap',
|
2183
|
'mapquest_open' => "MapQuest",
|
2184
|
'mapquest_sat' => "MapQuest Sattelite",
|
2185
|
// 'osmarender' => 'OpenStreetMap (Tiles@home)',
|
2186
|
'gmap' => 'Google Streets',
|
2187
|
'gsat' => 'Google Satellite',
|
2188
|
'ghyb' => 'Google Hybrid',
|
2189
|
// 'veroad' => 'Virtual Earth Roads',
|
2190
|
// 'veaer' => 'Virtual Earth Aerial',
|
2191
|
// 'vehyb' => 'Virtual Earth Hybrid',
|
2192
|
// 'yahoo' => 'Yahoo Street',
|
2193
|
// 'yahoosat' => 'Yahoo Satellite',
|
2194
|
// 'yahoohyb' => 'Yahoo Hybrid',
|
2195
|
'custom_wms_base_layer_1' => 'Custom WMS base layer (needs to be manually configured below!)',
|
2196
|
);
|
2197
|
|
2198
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['base_layers'] = array(
|
2199
|
'#type' => 'checkboxes_preferred',
|
2200
|
'#title' => 'Base Layers',
|
2201
|
'#options' => $baselayer_options,
|
2202
|
'#default_value' => $map_distribution['openlayers']['base_layers'],
|
2203
|
'#description' => 'Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.',
|
2204
|
);
|
2205
|
|
2206
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer'] = array(
|
2207
|
'#type' => 'fieldset',
|
2208
|
'#title' => 'Custom WMS base layer',
|
2209
|
'#tree' => TRUE,
|
2210
|
'#collapsible' => FALSE,
|
2211
|
'#collapsed' => FALSE,
|
2212
|
'#description' => 'Here you an define a custom wms layer as additional base layer.',
|
2213
|
);
|
2214
|
|
2215
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['name'] = array(
|
2216
|
'#type' => 'textfield',
|
2217
|
'#title' => 'Layer name',
|
2218
|
// Only line color by now.
|
2219
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['name'],
|
2220
|
'#description' => 'A arbitrary name for the layer.',
|
2221
|
);
|
2222
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['url'] = array(
|
2223
|
'#type' => 'textfield',
|
2224
|
'#title' => 'WMS url',
|
2225
|
// Only line color by now.
|
2226
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['url'],
|
2227
|
'#description' => 'Base url for the WMS (e.g. http://wms.jpl.nasa.gov/wms.cgi)'
|
2228
|
);
|
2229
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['params'] = array(
|
2230
|
'#type' => 'textarea',
|
2231
|
'#title' => 'WMS parameters',
|
2232
|
'#element_validate' => array('form_element_validate_json'),
|
2233
|
// Only line color by now.
|
2234
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['params'],
|
2235
|
'#description' => 'An javasript object with key/value pairs representing the GetMap query string parameters and parameter values, entered in valid JSON. For example:
|
2236
|
<pre> {
|
2237
|
"Layers": "topp:em_tiny_jan2003",
|
2238
|
"Format": "image/png",
|
2239
|
"BGCOLOR": "0xe0faff"
|
2240
|
}
|
2241
|
</pre>'
|
2242
|
);
|
2243
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['projection'] = array(
|
2244
|
'#type' => 'textfield',
|
2245
|
'#title' => 'Projection',
|
2246
|
// Only line color by now.
|
2247
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['projection'],
|
2248
|
'#description' => 'The desired projection for the layer (e.g. EPSG:4326, EPSG:900913, EPSG:3857)'
|
2249
|
);
|
2250
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['proj4js_def'] = array(
|
2251
|
'#type' => 'textfield',
|
2252
|
'#maxlength' => 256,
|
2253
|
'#title' => 'proj4js definition',
|
2254
|
// Only line color by now.
|
2255
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['proj4js_def'],
|
2256
|
'#description' => 'The <a href="http://trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js">proj4js definition</a> for the projection named above.
|
2257
|
The definitions for
|
2258
|
EPSG:102067, EPSG:102757, EPSG:102758, EPSG:21781, EPSG:26591, EPSG:26912, EPSG:27200, EPSG:27563, EPSG:3857,
|
2259
|
EPSG:41001, EPSG:4139, EPSG:4181, EPSG:42304, EPSG:4272, EPSG:4302, EPSG:900913
|
2260
|
are already predefined and must be added here again. If your dont know the defintion of your desired projection,
|
2261
|
go to <a href="http://spatialreference.org/">http://spatialreference.org/</a>, search for your projection and
|
2262
|
choose to display the proj4js definition string.
|
2263
|
<h5>Quick Reference on the commion proj4js definition parameters:</h5>
|
2264
|
<pre>
|
2265
|
+a Semimajor radius of the ellipsoid axis
|
2266
|
+alpha ? Used with Oblique Mercator and possibly a few others
|
2267
|
+axis Axis orientation (new in 4.8.0)
|
2268
|
+b Semiminor radius of the ellipsoid axis
|
2269
|
+datum Datum name (see `proj -ld`)
|
2270
|
+ellps Ellipsoid name (see `proj -le`)
|
2271
|
+k Scaling factor (old name)
|
2272
|
+k_0 Scaling factor (new name)
|
2273
|
+lat_0 Latitude of origin
|
2274
|
+lat_1 Latitude of first standard parallel
|
2275
|
+lat_2 Latitude of second standard parallel
|
2276
|
+lat_ts Latitude of true scale
|
2277
|
+lon_0 Central meridian
|
2278
|
+lonc ? Longitude used with Oblique Mercator and possibly a few others
|
2279
|
+lon_wrap Center longitude to use for wrapping (see below)
|
2280
|
+nadgrids Filename of NTv2 grid file to use for datum transforms (see below)
|
2281
|
+no_defs Don\'t use the /usr/share/proj/proj_def.dat defaults file
|
2282
|
+over Allow longitude output outside -180 to 180 range, disables wrapping (see below)
|
2283
|
+pm Alternate prime meridian (typically a city name, see below)
|
2284
|
+proj Projection name (see `proj -l`)
|
2285
|
+south Denotes southern hemisphere UTM zone
|
2286
|
+to_meter Multiplier to convert map units to 1.0m
|
2287
|
+towgs84 3 or 7 term datum transform parameters (see below)
|
2288
|
+units meters, US survey feet, etc.
|
2289
|
+vto_meter vertical conversion to meters.
|
2290
|
+vunits vertical units.
|
2291
|
+x_0 False easting
|
2292
|
+y_0 False northing
|
2293
|
+zone UTM zone
|
2294
|
</pre>
|
2295
|
For the full reference please refer to <a href="http://trac.osgeo.org/proj/wiki/GenParms">http://trac.osgeo.org/proj/wiki/GenParms</a>.'
|
2296
|
);
|
2297
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['max_extent'] = array(
|
2298
|
'#type' => 'textfield',
|
2299
|
'#title' => 'Maximum extent',
|
2300
|
// Only line color by now.
|
2301
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['max_extent'],
|
2302
|
'#description' => 'The maximum extent of the map as bounding box (left, bottom, right, top) in the units of the map.'
|
2303
|
);
|
2304
|
$form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['units'] = array(
|
2305
|
'#type' => 'textfield',
|
2306
|
'#title' => 'Units',
|
2307
|
'#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['units'],
|
2308
|
'#description' => 'The layer map units. Defaults to null. Possible values are ‘degrees’ (or ‘dd’), ‘m’, ‘ft’, ‘km’, ‘mi’, ‘inches’. Normally taken from the projection. Only required if both map and layers do not define a projection, or if they define a projection which does not define units.'
|
2309
|
);
|
2310
|
|
2311
|
/*
|
2312
|
* Map Legend
|
2313
|
*/
|
2314
|
$form[CDM_MAP_DISTRIBUTION]['legend'] = array(
|
2315
|
'#type' => 'fieldset',
|
2316
|
'#title' => 'Map legend',
|
2317
|
'#tree' => TRUE,
|
2318
|
'#collapsible' => TRUE,
|
2319
|
'#collapsed' => TRUE,
|
2320
|
'#description' => 'Configure the maps legend.',
|
2321
|
);
|
2322
|
|
2323
|
$form[CDM_MAP_DISTRIBUTION]['legend']['show'] = array(
|
2324
|
'#type' => 'checkbox',
|
2325
|
'#title' => 'Display a map legend',
|
2326
|
'#default_value' => $map_distribution['legend']['show'],
|
2327
|
'#description' => 'Check this if you like a legend to be displayed with the maps.',
|
2328
|
);
|
2329
|
|
2330
|
$form[CDM_MAP_DISTRIBUTION]['legend']['opacity'] = array(
|
2331
|
'#type' => 'textfield',
|
2332
|
'#title' => 'Legend opacity',
|
2333
|
'#default_value' => $map_distribution['legend']['opacity'],
|
2334
|
'#description' => 'Valid values range from 0.0 to 1.0. Value 1.0 means the legend will be fully visible, while a value near
|
2335
|
to 0.0 will be not much visible.',
|
2336
|
);
|
2337
|
|
2338
|
$form[CDM_MAP_DISTRIBUTION]['legend']['font_size'] = array(
|
2339
|
'#type' => 'textfield',
|
2340
|
'#title' => 'Font size',
|
2341
|
'#default_value' => $map_distribution['legend']['font_size'],
|
2342
|
'#description' => 'Font size in pixels.',
|
2343
|
);
|
2344
|
|
2345
|
$fontStyles = array(
|
2346
|
0 => "plane",
|
2347
|
1 => "italic",
|
2348
|
);
|
2349
|
$form[CDM_MAP_DISTRIBUTION]['legend']['font_style'] = array(
|
2350
|
'#type' => 'select',
|
2351
|
'#title' => 'Available font styles',
|
2352
|
'#default_value' => $map_distribution['legend']['font_style'],
|
2353
|
'#options' => $fontStyles,
|
2354
|
'#description' => 'Select a font style for the map legend.',
|
2355
|
);
|
2356
|
|
2357
|
$form[CDM_MAP_DISTRIBUTION]['legend']['icon_width'] = array(
|
2358
|
'#type' => 'textfield',
|
2359
|
'#title' => 'Icon width',
|
2360
|
'#default_value' => $map_distribution['legend']['icon_width'],
|
2361
|
'#description' => 'Legend icon width in pixels.',
|
2362
|
);
|
2363
|
$form[CDM_MAP_DISTRIBUTION]['legend']['icon_height'] = array(
|
2364
|
'#type' => 'textfield',
|
2365
|
'#title' => 'Icon height',
|
2366
|
'#default_value' => $map_distribution['legend']['icon_height'],
|
2367
|
'#description' => 'Legend icon height in pixels.',
|
2368
|
);
|
2369
|
|
2370
|
// @WA: D7 form api does not support reset buttons,
|
2371
|
// so to mimic the D5 reset button we add one like this.
|
2372
|
$form['actions']['reset'] = array(
|
2373
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
2374
|
'#weight' => 1000,
|
2375
|
);
|
2376
|
|
2377
|
return system_settings_form($form);
|
2378
|
}
|
2379
|
|
2380
|
/**
|
2381
|
* @todo document this function.
|
2382
|
*/
|
2383
|
function cdm_settings_cache() {
|
2384
|
|
2385
|
$form = array();
|
2386
|
|
2387
|
$form['cache_settings'] = array(
|
2388
|
'#type' => 'fieldset',
|
2389
|
'#title' => t('Cache Settings'),
|
2390
|
'#collapsible' => FALSE,
|
2391
|
'#collapsed' => FALSE,
|
2392
|
'#description' => t('<p>When caching is enabled all single taxon sites are
|
2393
|
stored in an internal drupal cache doing the portal response of taxa pages
|
2394
|
faster. This is possible because the sites are loaded from the cache and
|
2395
|
are not created from scratch.</p>'),
|
2396
|
);
|
2397
|
|
2398
|
$form['cache_settings']['cdm_webservice_cache'] = array(
|
2399
|
'#type' => 'checkbox',
|
2400
|
'#title' => t('<strong>Enable caching</strong>'),
|
2401
|
'#options' => cdm_help_general_cache(),
|
2402
|
'#default_value' => variable_get('cdm_webservice_cache', 1),
|
2403
|
'#description' => t('<p>Enable drupal to load taxa pages from the cache.</p>
|
2404
|
<p><strong>Note:</strong> If taxa are modified by the editor or any other
|
2405
|
application the changes will be not visible till the cache is erased.
|
2406
|
Therefore developers should deactived this feature when they are working
|
2407
|
on the CDM Dataportal Module.</p>'),
|
2408
|
);
|
2409
|
|
2410
|
$form['cache_settings']['cdm_run_cache'] = array(
|
2411
|
'#markup' => cdm_view_cache_site(),
|
2412
|
);
|
2413
|
|
2414
|
// @WA: D7 form api does not support reset buttons,
|
2415
|
// so to mimic the D5 reset button we add one like this.
|
2416
|
$form['actions']['reset'] = array(
|
2417
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
2418
|
'#weight' => 1000,
|
2419
|
);
|
2420
|
return system_settings_form($form);
|
2421
|
}
|
2422
|
|
2423
|
/**
|
2424
|
* Walk and cache all taxon pages.
|
2425
|
*/
|
2426
|
function cdm_view_cache_site() {
|
2427
|
|
2428
|
$out = '';
|
2429
|
|
2430
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cache_all_taxa.js');
|
2431
|
|
2432
|
$request_params = array();
|
2433
|
$request_params['class'] = "Taxon";
|
2434
|
|
2435
|
$cdm_ws_page_taxa_url = cdm_compose_url(CDM_WS_TAXON . ".json", NULL, queryString($request_params));
|
2436
|
$cdm_ws_page_taxa_url = uri_uriByProxy($cdm_ws_page_taxa_url);
|
2437
|
$cdm_ws_page_taxa_url = rtrim($cdm_ws_page_taxa_url, '/');
|
2438
|
|
2439
|
$out .= t('<p><strong>Cache all taxon pages</strong></p>');
|
2440
|
$out .= '<p>When you launch the cache process the cache is filled and ready to be enabled.<br/>
|
2441
|
Remember that when you load the taxa from the cache last changes on taxa will be not visible till you erase
|
2442
|
the cache and fill it again.</p>';
|
2443
|
$out .= '<p>Before running the cache bot you have to empty the cache manually.</p>';
|
2444
|
|
2445
|
$out .= '<div>' . t('This caching process may take long time and could cause heavy load on your server') . '</div>';
|
2446
|
$out .= '<div id="progress"></div>';
|
2447
|
|
2448
|
// Comment @WA: A form within a form is not valid html and not needed here.
|
2449
|
// Also, it would be recommended just to include this part of the form in the
|
2450
|
// rest of the form array in cdm_settings_cache().
|
2451
|
// $out .= '<form id="cache_site">';
|
2452
|
$out .= '<input type="hidden" name="pageTaxaUrl" value="' . $cdm_ws_page_taxa_url . '"/>';
|
2453
|
$out .= '<input type="hidden" name="taxonPageUrl" value="' . url('cdm_dataportal/taxon/') . '"/>';
|
2454
|
$out .= '<input type="button" name="start" value="' . t('Start') . '"/>';
|
2455
|
$out .= '<input type="button" name="stop" value="' . t('Stop') . '"/>';
|
2456
|
// $out .= '</form>';
|
2457
|
$out .= '</div>';
|
2458
|
/*
|
2459
|
foreach($taxonPager->records as $taxon){
|
2460
|
cdm_dataportal_taxon_view($uuid);
|
2461
|
}
|
2462
|
*/
|
2463
|
return $out;
|
2464
|
}
|
2465
|
|
2466
|
|
2467
|
function cdm_settings_layout_taxon_submit($form, &$form_state){
|
2468
|
if (isset($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'])) {
|
2469
|
$file = file_load($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid']);
|
2470
|
if(is_object($file)){
|
2471
|
$file->status = FILE_STATUS_PERMANENT;
|
2472
|
file_save($file);
|
2473
|
file_usage_add($file, 'cdm_dataportal', CDM_TAXON_PROFILE_IMAGE, 0);
|
2474
|
}
|
2475
|
}
|
2476
|
// rebuild the menu if the show tabs setting has changed, otherwise the change will not have a consistent effect
|
2477
|
if(variable_get('cdm_dataportal_taxonpage_tabs', 1) != $form_state['values']['cdm_dataportal_taxonpage_tabs']){
|
2478
|
// we first need to set the variable to persist the changes setting
|
2479
|
variable_set('cdm_dataportal_taxonpage_tabs', $form_state['values']['cdm_dataportal_taxonpage_tabs']);
|
2480
|
menu_rebuild();
|
2481
|
}
|
2482
|
}
|
2483
|
|
2484
|
function cdm_settings_layout_search_submit($form, &$form_state){
|
2485
|
// the visibility of media thumbnails also affects the ui of the search results
|
2486
|
// so reset the according session variable
|
2487
|
// 1. in order to give the user immediate
|
2488
|
// feedback on potential setting changes
|
2489
|
// 2. let refresh the default if it has changed
|
2490
|
if (isset($_SESSION['pageoption']['searchtaxa']['showThumbnails'])) {
|
2491
|
unset($_SESSION['pageoption']['searchtaxa']['showThumbnails']);
|
2492
|
}
|
2493
|
}
|
2494
|
|
2495
|
/**
|
2496
|
* Form validation handler for cdm_settings_general
|
2497
|
*
|
2498
|
* @param $form
|
2499
|
* @param $form_state
|
2500
|
*/
|
2501
|
function cdm_settings_general_validate($form, &$form_state) {
|
2502
|
|
2503
|
if (!str_endsWith($form_state['values']['cdm_webservice_url'], '/')) {
|
2504
|
$form_state['values']['cdm_webservice_url'] .= '/';
|
2505
|
}
|
2506
|
|
2507
|
}
|
2508
|
|
2509
|
/**
|
2510
|
* Form submit handler for settings general.
|
2511
|
*
|
2512
|
* tasks performed:
|
2513
|
* - clear the [cdm][taxonomictree_uuid] session variable since this taxonomictree_uuid might no longer bee valid
|
2514
|
*
|
2515
|
* @param $form
|
2516
|
* @param $form_state
|
2517
|
*/
|
2518
|
function cdm_settings_general_submit($form, &$form_state){
|
2519
|
// clear the [cdm][taxonomictree_uuid] session variable since this taxonomictree_uuid might no longer bee valid
|
2520
|
unset($_SESSION['cdm']['taxonomictree_uuid']);
|
2521
|
}
|
2522
|
|
2523
|
/**
|
2524
|
* Form validation handler for cdm_settings_cache
|
2525
|
*/
|
2526
|
function cdm_settings_cache_validate($form, &$form_state) {
|
2527
|
if ($form_state['values']['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)) {
|
2528
|
cache_clear_all(NULL, 'cache_cdm_ws');
|
2529
|
// Better clear secref_cache since I can not be sure if the cache has not
|
2530
|
// be used during this response.
|
2531
|
cdm_api_secref_cache_clear();
|
2532
|
}
|
2533
|
|
2534
|
}
|
2535
|
|
2536
|
/**
|
2537
|
* Returns an associative array of the currently chosen settings for the EDIT map service or the defaults as
|
2538
|
* specified in EDIT_MAPSERVER_URI_DEFAULT and EDIT_MAPSERVER_VERSION_DEFAULT:
|
2539
|
* - base_uri: the protocol and host part , e.g.: http://edit.africamuseum.be
|
2540
|
* - version: the version, e.g.: v1.1
|
2541
|
*
|
2542
|
* @return array
|
2543
|
* An associative array of the currently chosen settings for the EDIT map service or the defaults.
|
2544
|
*/
|
2545
|
function get_edit_map_service_settings() {
|
2546
|
|
2547
|
$settings = variable_get('edit_map_server', array(
|
2548
|
'base_uri' => EDIT_MAPSERVER_URI_DEFAULT,
|
2549
|
'version' => EDIT_MAPSERVER_VERSION_DEFAULT
|
2550
|
)
|
2551
|
);
|
2552
|
|
2553
|
return $settings;
|
2554
|
}
|
2555
|
|
2556
|
/**
|
2557
|
* Returns the full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
2558
|
*
|
2559
|
* @return string
|
2560
|
* The full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
2561
|
*/
|
2562
|
function get_edit_map_service_full_uri() {
|
2563
|
$settings = get_edit_map_service_settings();
|
2564
|
return $settings['base_uri'] . EDIT_MAPSERVER_PATH . '/' . $settings['version'];
|
2565
|
}
|
2566
|
|
2567
|
|
2568
|
/**
|
2569
|
* Returns the version number of the currently selected edit mapserver as a float
|
2570
|
*
|
2571
|
* @return float
|
2572
|
* The version number of the currently selected edit mapserver as a float.
|
2573
|
* Returns 0 on error.
|
2574
|
*/
|
2575
|
function get_edit_map_service_version_number() {
|
2576
|
|
2577
|
$pattern = '/v([\d\.]+).*$/';
|
2578
|
|
2579
|
$settings = get_edit_map_service_settings();
|
2580
|
preg_match($pattern, $settings['version'], $matches, PREG_OFFSET_CAPTURE);
|
2581
|
if (isset($matches[1])) {
|
2582
|
// Convert string to float.
|
2583
|
$version = 1 + $matches[1][0] - 1;
|
2584
|
return $version;
|
2585
|
}
|
2586
|
else {
|
2587
|
// Report error.
|
2588
|
drupal_set_message(t(" Invalid EDIT map service version number: '!version'",
|
2589
|
array(
|
2590
|
'!version' => $settings['version'],
|
2591
|
'warning')
|
2592
|
)
|
2593
|
);
|
2594
|
return 0;
|
2595
|
}
|
2596
|
}
|
2597
|
|
2598
|
/**
|
2599
|
* Returns the array of selected items in a options array
|
2600
|
*
|
2601
|
* @param array $options
|
2602
|
* An options array as generated by a form element like checkoxes, select ...,
|
2603
|
*/
|
2604
|
function get_selection($options) {
|
2605
|
$selection = array();
|
2606
|
foreach ($options as $key=>$val) {
|
2607
|
if (!empty($val)) {
|
2608
|
$selection[] = $val;
|
2609
|
}
|
2610
|
}
|
2611
|
return $selection;
|
2612
|
}
|
2613
|
|
2614
|
|
2615
|
/**
|
2616
|
* Implements hook_element_info().
|
2617
|
*
|
2618
|
* Allows modules to declare their own Form API element types and specify their default values.
|
2619
|
*
|
2620
|
* @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_element_info/7
|
2621
|
*/
|
2622
|
function cdm_dataportal_element_info() {
|
2623
|
$type['checkboxes_preferred'] = array(
|
2624
|
'#input' => TRUE,
|
2625
|
'#process' => array('checkboxes_preferred_expand'),
|
2626
|
'#after_build' => array('checkboxes_preferred_after_build'),
|
2627
|
'#theme' => array('checkboxes_preferred'),
|
2628
|
// '#theme_wrapper' => array('form_element'),
|
2629
|
);
|
2630
|
return $type;
|
2631
|
}
|
2632
|
|
2633
|
/**
|
2634
|
* #process callback function for the custom form element type 'checkbox_preferred'
|
2635
|
*
|
2636
|
*
|
2637
|
*/
|
2638
|
function checkboxes_preferred_expand($element, &$form_state, $form) {
|
2639
|
|
2640
|
// First of all create checkboxes for each of the elements
|
2641
|
$element = form_process_checkboxes($element);
|
2642
|
|
2643
|
// compose the element name
|
2644
|
$parents = array();
|
2645
|
array_deep_copy($element['#parents'], $parents);
|
2646
|
$parents[count($parents) -1 ] .= '_preferred';
|
2647
|
$element_name = $parents[0];
|
2648
|
for ($i=1; $i < count($parents); $i++){
|
2649
|
$element_name .= '[' . $parents[$i] . ']';
|
2650
|
}
|
2651
|
|
2652
|
$children = element_children($element);
|
2653
|
|
2654
|
$element['table_start'] = array(
|
2655
|
'#markup' => '<table class="checkboxes_preferred"><tr><th></th><th>' . t('Enabled') . '</th><th>' . t('Default') . '</th></tr>',
|
2656
|
'#weight' => -1,
|
2657
|
);
|
2658
|
|
2659
|
// prepare first part each of the table rows which contains the row label
|
2660
|
$weight = 0;
|
2661
|
foreach ($children as $key) {
|
2662
|
$odd_even = $weight % 4 == 0 ? 'odd' : 'even';
|
2663
|
$element[$key]['#weight'] = $weight;
|
2664
|
$element[$key]['#prefix'] = '<tr class="' . $odd_even . '"><td>' . t($element['#options'][$key]) . '</td><td>';
|
2665
|
$element[$key]['#suffix'] = '</td>';
|
2666
|
unset($element[$key]['#title']);
|
2667
|
$weight += 2;
|
2668
|
}
|
2669
|
$weight = 0;
|
2670
|
|
2671
|
// add a radio button to each of the checkboxes, the
|
2672
|
// check boxes have already been created at the beginning
|
2673
|
// of this function
|
2674
|
if (count($element['#options']) > 0) {
|
2675
|
foreach ($element['#options'] as $key => $choice) {
|
2676
|
if (!isset($element[$key . '_preferred'])) {
|
2677
|
$element[$key . '_preferred'] = array(
|
2678
|
'#type' => 'radio',
|
2679
|
'#name' => $element_name,
|
2680
|
'#return_value' => check_plain($key),
|
2681
|
'#default_value' => empty($element['#default_value_2']) ? NULL : $element['#default_value_2'],
|
2682
|
'#attributes' => $element['#attributes'],
|
2683
|
'#parents' => $element['#parents'],
|
2684
|
// '#spawned' => TRUE,
|
2685
|
'#weight' => $weight + 1,
|
2686
|
'#prefix' => '<td>', // add a prefix to start a new table cell
|
2687
|
'#suffix' => '</td></tr>', // add a prefix to close the tabel row
|
2688
|
);
|
2689
|
}
|
2690
|
$weight += 2;
|
2691
|
}
|
2692
|
}
|
2693
|
|
2694
|
// end the table
|
2695
|
$element['table_end'] = array(
|
2696
|
'#markup' => '</table>',
|
2697
|
'#weight' => $weight++,
|
2698
|
);
|
2699
|
|
2700
|
return $element;
|
2701
|
}
|
2702
|
|
2703
|
/**
|
2704
|
* Theme function for the custom form field 'checkboxes_preferred'.
|
2705
|
*/
|
2706
|
function theme_checkboxes_preferred($variables) {
|
2707
|
$element = $variables['element'];
|
2708
|
$out = '<div id="edit-baselayers-wrapper" class="form-item">';
|
2709
|
$out .= '<label for="edit-baselayers">' . $element['#title'] . '</label>';
|
2710
|
$out .= drupal_render_children($element);
|
2711
|
$out .= '<div class="description">' . $element['#description'] . '</div>';
|
2712
|
$out .= '</div>';
|
2713
|
return $out;
|
2714
|
}
|
2715
|
|
2716
|
/**
|
2717
|
* Callback for checkboxes preferred for widget which will
|
2718
|
* be called after the form or element is built. The call
|
2719
|
* back is configured in the form element by setting it as
|
2720
|
* #after_build parameter.
|
2721
|
*
|
2722
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#after_build
|
2723
|
*
|
2724
|
* @param $element
|
2725
|
* Nested array of form elements that comprise the form.
|
2726
|
* @param $form_state
|
2727
|
* A keyed array containing the current state of the form.
|
2728
|
* This includes the current persistent storage data for the form.
|
2729
|
* Additional information, like the sanitized $_POST data,
|
2730
|
* is also accumulated here in $form_state['input']
|
2731
|
*
|
2732
|
* @return the modified form array
|
2733
|
*/
|
2734
|
function checkboxes_preferred_after_build($element, &$form_state) {
|
2735
|
|
2736
|
$parent_id = $element['#parents'][count($element['#parents']) - 1];
|
2737
|
|
2738
|
if ($_POST && count($_POST) > 0) {
|
2739
|
// TODO use $form_state['input'] instead of POST !!!
|
2740
|
// First pass of form processing.
|
2741
|
$parents = array();
|
2742
|
array_deep_copy($element['#parents'], $parents);
|
2743
|
$parents[count($parents) - 1] .= '_preferred';
|
2744
|
$preferred_layer = drupal_array_get_nested_value($_POST, $parents);
|
2745
|
$element['#value']['PREFERRED'] = $preferred_layer;
|
2746
|
// $form_state[$parent_id] = $element['#value'];
|
2747
|
// $form_state['values']['baselayers'] = $element['#value'];
|
2748
|
$form_state_element_values = &drupal_array_get_nested_value($form_state['values'], $element['#parents']);
|
2749
|
$form_state_element_values = $element['#value'];
|
2750
|
}
|
2751
|
else {
|
2752
|
// Second pass of form processing.
|
2753
|
$preferred_layer = $element['#value']['PREFERRED'];
|
2754
|
}
|
2755
|
|
2756
|
// Also set the chosen value (not sure if this is good Drupal style ....).
|
2757
|
foreach ($children = element_children($element) as $key) {
|
2758
|
if (!empty($element[$key]['#type']) && $element[$key]['#type'] == 'radio') {
|
2759
|
$element[$key]['#value'] = $preferred_layer;
|
2760
|
}
|
2761
|
}
|
2762
|
// The default layer must always be enabled.
|
2763
|
$element[$preferred_layer]['#value'] = $preferred_layer;
|
2764
|
|
2765
|
return $element;
|
2766
|
}
|
2767
|
|
2768
|
function radios_prepare_options_suffix(&$elements){
|
2769
|
|
2770
|
$childrenKeys = element_children($elements);
|
2771
|
foreach($childrenKeys as $key){
|
2772
|
if(!is_array($elements[$key]['#theme_wrappers'])){
|
2773
|
$elements[$key]['#theme_wrappers'] = array();
|
2774
|
}
|
2775
|
if(isset($elements['#options_suffixes'][$key])){
|
2776
|
$elements[$key]['#theme_wrappers'][] = 'radio_options_suffix';
|
2777
|
$elements[$key]['#options_suffix'] = $elements['#options_suffixes'][$key];
|
2778
|
}
|
2779
|
}
|
2780
|
return $elements;
|
2781
|
|
2782
|
}
|
2783
|
|
2784
|
/**
|
2785
|
* TODO
|
2786
|
* @param unknown $variables
|
2787
|
*/
|
2788
|
function theme_radio_options_suffix($variables) {
|
2789
|
$element = $variables['element'];
|
2790
|
if(isset($element['#options_suffix'])) {
|
2791
|
$element['#children'] .= $element['#options_suffix'];
|
2792
|
}
|
2793
|
return $element['#children'];
|
2794
|
}
|
2795
|
|
2796
|
|
2797
|
/**
|
2798
|
* Element validate callback for text field and arrays containing json.
|
2799
|
*
|
2800
|
* @param $element
|
2801
|
* The form element to validate
|
2802
|
* @param $form_state
|
2803
|
* A keyed array containing the current state of the form.
|
2804
|
* @param $form
|
2805
|
* Nested array of form elements that comprise the form.
|
2806
|
*/
|
2807
|
function form_element_validate_json($element, &$form_state, $form) {
|
2808
|
if (!empty($element['#value'])) {
|
2809
|
json_decode($element['#value']);
|
2810
|
if(json_last_error() != JSON_ERROR_NONE){
|
2811
|
form_error($element, t('The form element %title contains invalid JSON. You can check the syntax with ', array('%title' => $element['#title'])) . l('JSONLint', 'http://jsonlint.com/'));
|
2812
|
}
|
2813
|
}
|
2814
|
}
|
2815
|
|
2816
|
/**
|
2817
|
* Form submission handler for textareas and textfields containing JSON.
|
2818
|
*
|
2819
|
* The contained JSON will be converted into an php array
|
2820
|
* or object and will be stored in the variables as such.
|
2821
|
*
|
2822
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#submit
|
2823
|
*
|
2824
|
* @param $form
|
2825
|
* Nested array of form elements that comprise the form.
|
2826
|
* @param $form_state
|
2827
|
* A keyed array containing the current state of the form.
|
2828
|
*
|
2829
|
*/
|
2830
|
function submit_json_as_php_array($form, &$form_state) {
|
2831
|
if (is_array($form['#json_elements'])) {
|
2832
|
foreach ($form['#json_elements'] as $element){
|
2833
|
if (trim($form_state['values'][$element])) {
|
2834
|
$form_state['values'][$element] = (array) json_decode($form_state['values'][$element]);
|
2835
|
} else {
|
2836
|
$form_state['values'][$element] = NULL;
|
2837
|
}
|
2838
|
}
|
2839
|
}
|
2840
|
}
|