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
|
|
11
|
define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
|
12
|
define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
|
13
|
define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
|
14
|
define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
|
15
|
define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
|
16
|
define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
|
17
|
|
18
|
/* annotationTypeKeys */
|
19
|
$annotationTypeKeys = array_keys(cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE));
|
20
|
if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
|
21
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
22
|
|
23
|
// Technical annotation are off by default.
|
24
|
unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
|
25
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
26
|
// Additional value for the NULL case.
|
27
|
$annotationTypeKeys[] = 'NULL_VALUE';
|
28
|
}
|
29
|
define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
|
30
|
|
31
|
/* taxonRelationshipTypes */
|
32
|
define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(array(UUID_MISAPPLIED_NAME_FOR, UUID_INVALID_DESIGNATION_FOR)));
|
33
|
|
34
|
/* Gallery variables. */
|
35
|
$gallery_settings = array(
|
36
|
"cdm_dataportal_show_taxon_thumbnails" => 1,
|
37
|
"cdm_dataportal_show_synonym_thumbnails" => 0,
|
38
|
"cdm_dataportal_show_thumbnail_captions" => 1,
|
39
|
"cdm_dataportal_media_maxextend" => 120,
|
40
|
"cdm_dataportal_media_cols" => 3,
|
41
|
"cdm_dataportal_media_maxRows" => 1,
|
42
|
);
|
43
|
|
44
|
/* ---- MAP SETTING CONSTANTS ---- */
|
45
|
/**
|
46
|
* @var array of URIs eg. http://edit.africamuseum.be"
|
47
|
* An options array
|
48
|
*/
|
49
|
define('EDIT_MAPSERVER_URI', serialize(
|
50
|
array(
|
51
|
'http://edit.africamuseum.be'=>'Primary (http://edit.africamuseum.be)',
|
52
|
'http://edit.br.fgov.be'=>'Secondary (http://edit.br.fgov.be)',
|
53
|
)
|
54
|
)
|
55
|
);
|
56
|
define('EDIT_MAPSERVER_PATH', '/edit_wp5');
|
57
|
/**
|
58
|
* @var array of versions eg. "v1.2"
|
59
|
* An options array
|
60
|
*/
|
61
|
define('EDIT_MAPSERVER_VERSION', serialize(
|
62
|
array(
|
63
|
'v1' => 'v1' ,
|
64
|
'v1.1' => 'v1.1',
|
65
|
'v1.2_dev' => 'v1.2_dev'
|
66
|
)
|
67
|
)
|
68
|
);
|
69
|
define('EDIT_MAPSERVER_URI_DEFAULT', 'http://edit.africamuseum.be');
|
70
|
define('EDIT_MAPSERVER_VERSION_DEFAULT', 'v1.1');
|
71
|
|
72
|
// --- Taxon profile settings --- /
|
73
|
define('LAYOUT_SETTING_PREFIX', 'layout_');
|
74
|
define('FEATURE_TREE_LAYOUT_DEFAULTS', serialize(
|
75
|
array(
|
76
|
'enabled' => FALSE,
|
77
|
'enclosingTag' => 'ul',
|
78
|
'entryEnclosingTag' => 'li',
|
79
|
'glue' => ' ',
|
80
|
)));
|
81
|
|
82
|
define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
|
83
|
define('CDM_DEFAULT_IMAGE_MAXEXTEND', 'cdm_default_image_maxextend');
|
84
|
define('CDM_DEFAULT_IMAGE_MAXEXTEND_DEFAULT', 184);
|
85
|
define('CDM_DEFAULT_REPLACEMENT_IMAGE', 'cdm_default_replacement_image');
|
86
|
|
87
|
|
88
|
/**
|
89
|
* @todo document this function
|
90
|
*/
|
91
|
function get_taxon_tabs_list() {
|
92
|
return array(
|
93
|
0 => 'General',
|
94
|
1 => 'Synonymy',
|
95
|
2 => 'Images',
|
96
|
3 => 'Specimens',
|
97
|
4 => 'Keys',
|
98
|
);
|
99
|
}
|
100
|
|
101
|
$taxon_tab_options = get_taxon_tabs_list();
|
102
|
$taxon_tab_options[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX] = 'Last visited tab';
|
103
|
|
104
|
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
|
105
|
|
106
|
/**
|
107
|
* @todo document this function.
|
108
|
*/
|
109
|
function get_taxon_options_list() {
|
110
|
$taxon_tab_options = array_flip(get_taxon_tabs_list());
|
111
|
foreach ($taxon_tab_options as $key => $value) {
|
112
|
$taxon_tab_options[$key] = t($key);
|
113
|
}
|
114
|
return $taxon_tab_options;
|
115
|
|
116
|
}
|
117
|
|
118
|
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions');
|
119
|
define('CDM_PART_DEFINITIONS_DEFAULT', serialize(
|
120
|
array(
|
121
|
'ZoologicalName' => array(
|
122
|
'namePart' => array('name' => TRUE),
|
123
|
'nameAuthorPart' => array('name' => TRUE),
|
124
|
'referencePart' => array('authors' => TRUE),
|
125
|
'microreferencePart' => array('microreference' => TRUE),
|
126
|
'statusPart' => array('status' => TRUE),
|
127
|
'descriptionPart' => array('description' => TRUE),
|
128
|
),
|
129
|
'BotanicalName'=> array(
|
130
|
'namePart' => array('name' => TRUE),
|
131
|
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
|
132
|
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
|
133
|
'statusPart' => array('status' => TRUE),
|
134
|
'descriptionPart' => array('description' => TRUE),
|
135
|
),
|
136
|
'#DEFAULT' => array(
|
137
|
'namePart' => array(
|
138
|
'name' => TRUE
|
139
|
),
|
140
|
'nameAuthorPart' => array(
|
141
|
'name' => TRUE,
|
142
|
'authors' => TRUE
|
143
|
),
|
144
|
'referencePart' => array(
|
145
|
'reference' => TRUE
|
146
|
),
|
147
|
'microreferencePart' => array(
|
148
|
'microreference' => TRUE,
|
149
|
),
|
150
|
'statusPart' => array(
|
151
|
'status' => TRUE,
|
152
|
),
|
153
|
'descriptionPart' => array(
|
154
|
'description' => TRUE,
|
155
|
),
|
156
|
)
|
157
|
)
|
158
|
)
|
159
|
);
|
160
|
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates');
|
161
|
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize(
|
162
|
array (
|
163
|
'taxon_page_title,polytomousKey'=> array(
|
164
|
'namePart' => array('#uri' => TRUE),
|
165
|
),
|
166
|
'taxon_page_synonymy,related_taxon'=> array(
|
167
|
'nameAuthorPart' => array('#uri' => TRUE),
|
168
|
'referencePart' => TRUE,
|
169
|
'statusPart' => TRUE,
|
170
|
'descriptionPart' => TRUE,
|
171
|
),
|
172
|
'acceptedFor,typedesignations,list_of_taxa' => array(
|
173
|
'nameAuthorPart' => array('#uri' => TRUE),
|
174
|
'referencePart' => TRUE,
|
175
|
),
|
176
|
'#DEFAULT' => array(
|
177
|
'nameAuthorPart' => array('#uri' => TRUE),
|
178
|
'referencePart' => TRUE,
|
179
|
)
|
180
|
)
|
181
|
));
|
182
|
|
183
|
define('TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT', serialize(get_taxon_options_list()));
|
184
|
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
|
185
|
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
|
186
|
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
|
187
|
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
|
188
|
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
|
189
|
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
|
190
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
|
191
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
|
192
|
// define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
|
193
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
|
194
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
|
195
|
/**
|
196
|
* The drupal variable key for the array containing the uuids of the taxon relationship types to display in
|
197
|
* the snonymy.
|
198
|
*
|
199
|
* @var string
|
200
|
*/
|
201
|
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
|
202
|
/**
|
203
|
* The drupal variable for the configuration of the information aggregation along
|
204
|
* the taxon relation ships. The mapped arrayis associative and holds two elements:
|
205
|
* - direct: the uuids of the taxon relationship types to take into account in invers
|
206
|
* direction.
|
207
|
* - invers: the uuids of the taxon relationship types to take into account in direct
|
208
|
* direction.
|
209
|
*
|
210
|
* @var String
|
211
|
*/
|
212
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS', 'cdm_aggregate_by_taxon_relationships');
|
213
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT', serialize(
|
214
|
array(
|
215
|
'direct'=>array(),
|
216
|
'invers'=>array()
|
217
|
)
|
218
|
));
|
219
|
define('CDM_PROFILE_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
|
220
|
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
|
221
|
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
|
222
|
|
223
|
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
|
224
|
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
|
225
|
array(
|
226
|
'includeTaxonDescriptions' => 'includeTaxonDescriptions',
|
227
|
'includeOccurrences' => 0,
|
228
|
'includeTaxonNameDescriptions' => 0
|
229
|
)
|
230
|
));
|
231
|
|
232
|
/**
|
233
|
* @todo document this function.
|
234
|
*/
|
235
|
function getGallerySettings($gallery_config_form_name) {
|
236
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
237
|
return variable_get($gallery_config_form_name, $default_values);
|
238
|
}
|
239
|
|
240
|
/**
|
241
|
* Returns the string representation of the default tab.
|
242
|
*
|
243
|
* @param bool $returnTabIndex
|
244
|
* Defaults to FALSE, if set true this function will return the index number
|
245
|
* of the default tab. (used to supply default values to form elements).
|
246
|
*/
|
247
|
function get_default_taxon_tab($returnTabIndex = FALSE) {
|
248
|
|
249
|
global $user;
|
250
|
$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
251
|
$user_tab_active = 'cdm_dataportal_' . $user->uid . '_default_tab_active';
|
252
|
$user_tab = 'cdm_dataportal_' . $user->uid . '_default_tab';
|
253
|
// Get the user value if the used has chosen to overwrite the system settings.
|
254
|
$user_tab_on = variable_get($user_tab_active, FALSE);
|
255
|
if ($user_tab_on) {
|
256
|
$user_value = variable_get($user_tab, 0);
|
257
|
$index_value = $user_value;
|
258
|
// Get the system value.
|
259
|
}
|
260
|
else {
|
261
|
$system_value = variable_get('cdm_dataportal_default_tab', 0);
|
262
|
$index_value = $system_value;
|
263
|
}
|
264
|
|
265
|
// Return the index value or the string representation.
|
266
|
if ($returnTabIndex) {
|
267
|
return $index_value;
|
268
|
}
|
269
|
else {
|
270
|
return ($values[$index_value]);
|
271
|
}
|
272
|
|
273
|
}
|
274
|
|
275
|
/**
|
276
|
* @todo Please document this function.
|
277
|
* @see http://drupal.org/node/1354
|
278
|
*/
|
279
|
function cdm_dataportal_menu_admin(&$items) {
|
280
|
// Display section on admin/config page.
|
281
|
$items['admin/config/cdm_dataportal'] = array(
|
282
|
'title' => 'CDM Dataportal',
|
283
|
'description' => 'Settings for the CDM DataPortal.',
|
284
|
'position' => 'right',
|
285
|
'weight' => 10,
|
286
|
'page callback' => 'system_admin_menu_block_page',
|
287
|
'access arguments' => array('administer cdm_dataportal'),
|
288
|
'file' => 'system.admin.inc',
|
289
|
'file path' => drupal_get_path('module', 'system'),
|
290
|
);
|
291
|
$items['admin/config/cdm_dataportal/settings'] = array(
|
292
|
'title' => 'Settings',
|
293
|
'description' => 'Settings for the CDM DataPortal.',
|
294
|
'weight' => 0,
|
295
|
'page callback' => 'drupal_get_form',
|
296
|
'page arguments' => array('cdm_settings_general'),
|
297
|
'access arguments' => array('administer cdm_dataportal'),
|
298
|
'type' => MENU_NORMAL_ITEM,
|
299
|
);
|
300
|
$items['admin/config/cdm_dataportal/settings/general'] = array(
|
301
|
'title' => 'General',
|
302
|
'description' => 'General',
|
303
|
'weight' => 0,
|
304
|
'page callback' => 'drupal_get_form',
|
305
|
'page arguments' => array('cdm_settings_general'),
|
306
|
'access arguments' => array('administer cdm_dataportal'),
|
307
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
308
|
);
|
309
|
|
310
|
$items['admin/config/cdm_dataportal/settings/cachesite'] = array(
|
311
|
'title' => 'Cache',
|
312
|
'description' => 'Cache',
|
313
|
'access arguments' => array('administer cdm_dataportal'),
|
314
|
'page callback' => 'drupal_get_form',
|
315
|
'page arguments' => array('cdm_settings_cache'),
|
316
|
'weight' => 10,
|
317
|
'type' => MENU_LOCAL_TASK,
|
318
|
);
|
319
|
|
320
|
$items['admin/config/cdm_dataportal/settings/geo'] = array(
|
321
|
'title' => 'Geo & Map',
|
322
|
'description' => 'Geo & Map',
|
323
|
'access arguments' => array('administer cdm_dataportal'),
|
324
|
'page callback' => 'drupal_get_form',
|
325
|
'page arguments' => array('cdm_settings_geo'),
|
326
|
'weight' => 1,
|
327
|
'type' => MENU_LOCAL_TASK,
|
328
|
);
|
329
|
|
330
|
$items['admin/config/cdm_dataportal/settings/layout'] = array(
|
331
|
'title' => 'Layout',
|
332
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
333
|
'access arguments' => array('administer cdm_dataportal'),
|
334
|
'page callback' => 'drupal_get_form',
|
335
|
'page arguments' => array('cdm_settings_layout'),
|
336
|
'weight' => 2,
|
337
|
'type' => MENU_LOCAL_TASK,
|
338
|
);
|
339
|
|
340
|
$items['admin/config/cdm_dataportal/settings/layout/taxon'] = array(
|
341
|
'title' => 'Taxon',
|
342
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
343
|
'access arguments' => array('administer cdm_dataportal'),
|
344
|
'page callback' => 'drupal_get_form',
|
345
|
'page arguments' => array('cdm_settings_layout_taxon'),
|
346
|
'weight' => 1,
|
347
|
'type' => MENU_LOCAL_TASK,
|
348
|
);
|
349
|
/*
|
350
|
$items[] = array(
|
351
|
'path' => 'admin/config/cdm_dataportal/layout/synonymy',
|
352
|
'title' => t('Synonymy'),
|
353
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
354
|
'access' => user_access('administer cdm_dataportal'),
|
355
|
'callback' => 'drupal_get_form',
|
356
|
'callback arguments' => array('cdm_settings_layout_synonymy'),
|
357
|
'weight' => 1,
|
358
|
'type' => MENU_LOCAL_TASK,
|
359
|
);
|
360
|
|
361
|
$items[] = array(
|
362
|
'path' => 'admin/config/cdm_dataportal/layout/specimens',
|
363
|
'title' => t('Specimens'),
|
364
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
365
|
'access' => user_access('administer cdm_dataportal'),
|
366
|
'callback' => 'drupal_get_form',
|
367
|
'callback arguments' => array('cdm_settings_layout_specimens'),
|
368
|
'weight' => 1,
|
369
|
'type' => MENU_LOCAL_TASK,
|
370
|
);
|
371
|
*/
|
372
|
$items['admin/config/cdm_dataportal/settings/layout/search'] = array(
|
373
|
'title' => 'Search',
|
374
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
375
|
'access arguments' => array('administer cdm_dataportal'),
|
376
|
'page callback' => 'drupal_get_form',
|
377
|
'page arguments' => array('cdm_settings_layout_search'),
|
378
|
'weight' => 2,
|
379
|
'type' => MENU_LOCAL_TASK,
|
380
|
);
|
381
|
|
382
|
$items['admin/config/cdm_dataportal/settings/layout/media'] = array(
|
383
|
'title' => 'Media',
|
384
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
385
|
'access arguments' => array('administer cdm_dataportal'),
|
386
|
'page callback' => 'drupal_get_form',
|
387
|
'page arguments' => array('cdm_settings_layout_media'),
|
388
|
'weight' => 3,
|
389
|
'type' => MENU_LOCAL_TASK,
|
390
|
);
|
391
|
|
392
|
}
|
393
|
|
394
|
/**
|
395
|
* @todo document this function.
|
396
|
*/
|
397
|
function cdm_help_general_cache() {
|
398
|
$form = array();
|
399
|
$form['cache_help'] = array(
|
400
|
'#type' => 'fieldset',
|
401
|
'#title' => t('Help'),
|
402
|
'#collapsible' => TRUE,
|
403
|
'#collapsed' => TRUE,
|
404
|
);
|
405
|
$form['cache_help']['test'] = array('#value' => t('probando'));
|
406
|
return drupal_render($form);
|
407
|
$res = array();
|
408
|
$res['default'] = drupal_render($help);
|
409
|
return $res;
|
410
|
}
|
411
|
|
412
|
/**
|
413
|
* Configures the settings form for the CDM-API module.
|
414
|
*
|
415
|
* @return array
|
416
|
* Drupal settings form.
|
417
|
*/
|
418
|
function cdm_settings_general() {
|
419
|
|
420
|
$form['cdm_webservice'] = array(
|
421
|
'#type' => 'fieldset',
|
422
|
'#title' => t('CDM Server'),
|
423
|
'#collapsible' => FALSE,
|
424
|
'#collapsed' => FALSE,
|
425
|
'#description' => t('The <em>CDM Server</em> exposes data stored in a
|
426
|
CDM data base to the web via RESTful web services and thus is the source of the data
|
427
|
to be displayed by a CDM DataPotal.'),
|
428
|
);
|
429
|
|
430
|
$form['cdm_webservice']['cdm_webservice_url'] = array(
|
431
|
'#type' => 'textfield',
|
432
|
'#title' => t('CDM web service URL') . ':',
|
433
|
'#description' => t('This is the URL to the CDM-Server exposing your data
|
434
|
e.g. <em>"http://localhost:8080/cichorieae/"</em> The URL <strong>must end
|
435
|
with a slash</strong> character!'),
|
436
|
'#default_value' => variable_get('cdm_webservice_url', NULL),
|
437
|
);
|
438
|
|
439
|
$form['cdm_webservice']['cdm_webservice_debug'] = array(
|
440
|
'#type' => 'checkbox',
|
441
|
'#title' => t('<b>Debug CDM Web Service</b>'),
|
442
|
'#default_value' => variable_get('cdm_webservice_debug', 1),
|
443
|
'#description' => t('The black web service debug box will appear at the top
|
444
|
of each page. When clicked it toggles open and provides a list of all HTTP
|
445
|
requests which have been made while building of this page.<br />
|
446
|
<strong>Note:</strong> this is a feature dedicated to developers. It will
|
447
|
only be visible when logged in and if the user has suffucicient rights to
|
448
|
see this debug box.'),
|
449
|
);
|
450
|
|
451
|
$form['cdm_webservice']['freetext_index'] = array(
|
452
|
'#type' => 'fieldset',
|
453
|
'#title' => t('Freetext index'),
|
454
|
'#collapsible' => FALSE,
|
455
|
'#collapsed' => FALSE,
|
456
|
);
|
457
|
|
458
|
// Check the cdmserver port number and display a waring if it is not port 80
|
459
|
preg_match("#http[s]?://[0-9\p{L}\.]*:([0-9]*)/.*#u", variable_get('cdm_webservice_url', ''), $portNumberMatch, PREG_OFFSET_CAPTURE);
|
460
|
if (isset($portNumberMatch[1]) && $portNumberMatch[1] != '80') {
|
461
|
$form['cdm_webservice']['freetext_index']['message'] = array(
|
462
|
'#markup' => "<div class=\"description\">"
|
463
|
. t("The CDM web service URL contains a portnumber other than standart HTTP port 80: '!port'."
|
464
|
. " Due to this the reindex and purge fuctions may not be working if there is a firewall in between you and the CDM Server."
|
465
|
. " You may want to contact the maintainer of the according CDM Server in order to solve this problem.", array('!port' => $portNumberMatch[1][0]))
|
466
|
. "</div>",
|
467
|
);
|
468
|
};
|
469
|
|
470
|
$frontentURL = urlencode(variable_get('cdm_webservice_url', ''));
|
471
|
$trigger_link_options = array(
|
472
|
'attributes' => array(
|
473
|
'class' => 'index-trigger',
|
474
|
),
|
475
|
);
|
476
|
$form['cdm_webservice']['freetext_index']['operations'] = array(
|
477
|
'#markup' => "<div>" . t('Operations: !url1 !url2', array(
|
478
|
'!url1' => l(t("Purge"), cdm_compose_url(CDM_WS_MANAGE_PURGE, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
479
|
'!url2' => l(t("Reindex"), cdm_compose_url(CDM_WS_MANAGE_REINDEX, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
480
|
))
|
481
|
. '<div id="index-progress"></div></div>',
|
482
|
);
|
483
|
_add_js_cdm_ws_progressbar(".index-trigger", "#index-progress");
|
484
|
|
485
|
$form['cdm_webservice']['proxy'] = array(
|
486
|
'#type' => 'fieldset',
|
487
|
'#title' => t('Proxy'),
|
488
|
'#collapsible' => TRUE,
|
489
|
'#collapsed' => TRUE,
|
490
|
);
|
491
|
|
492
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] = array(
|
493
|
'#type' => 'textfield',
|
494
|
'#title' => t('Proxy URL') . ':',
|
495
|
'#description' => t('If this proxy url is set the cdm api tries
|
496
|
to connect the web service over the given proxy server.
|
497
|
Otherwise proxy usage is deactivated.'),
|
498
|
'#default_value' => variable_get('cdm_webservice_proxy_url', FALSE),
|
499
|
);
|
500
|
|
501
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] = array(
|
502
|
'#type' => 'textfield',
|
503
|
'#title' => t('Proxy port') . ':',
|
504
|
'#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
|
505
|
);
|
506
|
|
507
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] = array(
|
508
|
'#type' => 'textfield',
|
509
|
'#title' => t('Login') . ':',
|
510
|
'#default_value' => variable_get('cdm_webservice_proxy_usr', FALSE),
|
511
|
);
|
512
|
|
513
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] = array(
|
514
|
'#type' => 'textfield',
|
515
|
'#title' => t('Password') . ':',
|
516
|
'#default_value' => variable_get('cdm_webservice_proxy_pwd', FALSE),
|
517
|
);
|
518
|
|
519
|
// TODO: settings are still incomplete, compare with
|
520
|
// trunk/dataportal/inc/config_default.php.inc.
|
521
|
$form['taxon_tree'] = array(
|
522
|
'#type' => 'fieldset',
|
523
|
'#title' => t('Taxon Tree'),
|
524
|
'#collapsible' => FALSE,
|
525
|
'#collapsed' => TRUE,
|
526
|
'#description' => t('<p>When you explore your collection, you can navigate
|
527
|
it through a tree structure also called <em>Taxon Tree</em>.</p><p>To be
|
528
|
able to navigate through your collection the
|
529
|
<a href="http://drupal.org/handbook/blocks">drupal block</a>
|
530
|
<em>CDM Taxon Tree</em> should be visible for users. Enable the block at
|
531
|
<a href="./?q=admin/build/block">Administer->Site building->Blocks
|
532
|
</a></p>'),
|
533
|
);
|
534
|
|
535
|
$form['taxon_tree'][CDM_TAXONOMICTREE_UUID] = array(
|
536
|
'#type' => 'select',
|
537
|
'#title' => t('Available classifications') . ':',
|
538
|
'#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
|
539
|
'#options' => cdm_get_taxontrees_as_options(),
|
540
|
'#description' => t('Select the default taxa classification for your
|
541
|
<em>taxon tree</em>, the other classifications will be also available but
|
542
|
with a manual user change.'),
|
543
|
);
|
544
|
|
545
|
$form['taxon_tree']['taxontree_ranklimit'] = array(
|
546
|
'#type' => 'select',
|
547
|
'#title' => t('Rank of highest displayed taxon') . ':',
|
548
|
// Before DEFAULT_TAXONTREE_RANKLIMIT_UUID.
|
549
|
'#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT),
|
550
|
'#options' => cdm_rankVocabulary_as_option(),
|
551
|
'#description' => t('This is the rank of the highest displayed taxon in the
|
552
|
<em>taxon tree</em>. You can select here which rank should be at the top
|
553
|
level of the tree structure.'),
|
554
|
);
|
555
|
|
556
|
$form['aggregation'] = array(
|
557
|
'#type' => 'fieldset',
|
558
|
'#title' => t('Aggregation of data'),
|
559
|
'#collapsible' => FALSE,
|
560
|
'#description' => t("This section covers the different aspects of aggregating information.
|
561
|
<p>
|
562
|
</p>"),
|
563
|
|
564
|
);
|
565
|
|
566
|
$form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
|
567
|
'#type' => 'checkboxes',
|
568
|
'#title' => 'Taxon media filter',
|
569
|
'#default_value' => variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)),
|
570
|
'#options' => array(
|
571
|
'includeTaxonDescriptions' => 'Media in taxon descriptions',
|
572
|
'includeTaxonNameDescriptions' => 'Media in name descriptions',
|
573
|
'includeOccurrences' => 'Media related to specimens and occurrences',
|
574
|
),
|
575
|
'#description' => 'This filter configures which images should be taken into account.',
|
576
|
);
|
577
|
|
578
|
$form['aggregation']['notice'] = array(
|
579
|
'#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
|
580
|
want to make use of the caching capabilities of the dataportal.',
|
581
|
);
|
582
|
|
583
|
$form['aggregation']['media_aggregation'] = array(
|
584
|
'#type' => 'fieldset',
|
585
|
'#title' => t('Media aggregation'),
|
586
|
'#collapsible' => FALSE,
|
587
|
'#collapsed' => TRUE,
|
588
|
'#description' => t("The media aggregation is also affected by the settigs in \"<strong>Aggregation via taxon relationsships</strong>\" below."),
|
589
|
|
590
|
);
|
591
|
$form['aggregation']['media_aggregation']['cdm_images_include_children'] = array(
|
592
|
'#type' => 'select',
|
593
|
'#title' => t('Aggregation of taxon pictures') . ':',
|
594
|
'#default_value' => variable_get('cdm_images_include_children', FALSE),
|
595
|
'#options' => array(
|
596
|
0 => "Show only pictures of the current taxon",
|
597
|
1 => "Include pictures of taxonomic children",
|
598
|
),
|
599
|
'#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."),
|
600
|
);
|
601
|
|
602
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS] = array(
|
603
|
'#type' => 'fieldset',
|
604
|
'#attributes' => array('class'=>array('clearfix')),
|
605
|
'#title' => t('Aggregation via taxon relationsships'),
|
606
|
'#collapsible' => TRUE,
|
607
|
'#collapsed' => TRUE,
|
608
|
'#tree' => TRUE,
|
609
|
'#description' => t('Information on taxa will be aggregated along the below chosen
|
610
|
taxon relation ships. This will affect images and occurrences (specimens).
|
611
|
Taxon relation ships are directed and point form one taxon to another. The taxon
|
612
|
relationships to be taken into accunt can therefore configured for the direct direction
|
613
|
and for the inverse.'),
|
614
|
);
|
615
|
|
616
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
617
|
$aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
|
618
|
|
619
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array(
|
620
|
'#type' => 'checkboxes',
|
621
|
'#title' => t('Direct'),
|
622
|
'#options' => $taxonRelationshipTypeOptions,
|
623
|
'#default_value' => $aggregate_by_taxon_relationships['direct'],
|
624
|
);
|
625
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['invers'] = array(
|
626
|
'#type' => 'checkboxes',
|
627
|
'#title' => t('Invers'),
|
628
|
'#options' => $taxonRelationshipTypeOptions,
|
629
|
'#default_value' => $aggregate_by_taxon_relationships['invers'],
|
630
|
);
|
631
|
|
632
|
// Comment @WA: D7 form api does not support reset buttons,
|
633
|
// so to mimic the D5 reset button we add one like this.
|
634
|
$form['actions']['reset'] = array(
|
635
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
636
|
'#weight' => 1000,
|
637
|
);
|
638
|
|
639
|
return system_settings_form($form);
|
640
|
}
|
641
|
|
642
|
|
643
|
/**
|
644
|
* LAYOUT settings
|
645
|
* @return unknown_type
|
646
|
* todo
|
647
|
*/
|
648
|
function cdm_settings_layout() {
|
649
|
|
650
|
$form = array();
|
651
|
|
652
|
$form['about'] = array(
|
653
|
'#markup' => '<h4>' . t('Portal Layout') . '</h4><p>' . t('This settings contains the general configurations
|
654
|
layout. If you want to configure the specific sites layout visit the
|
655
|
respective configuration site for taxon, search or media.') . '</p>',
|
656
|
);
|
657
|
|
658
|
// ---- footnotes --- //
|
659
|
$form['footnotes'] = array(
|
660
|
'#type' => 'fieldset',
|
661
|
'#title' => t('Footnotes'),
|
662
|
'#collapsible' => FALSE,
|
663
|
'#collapsed' => FALSE,
|
664
|
'#description' => t('Taxa data such authors, synonyms names, descriptions,
|
665
|
media or distribution areas may have annotations or footnotes. When the
|
666
|
footnotes are enabled they will be visible (if they exist).'),
|
667
|
);
|
668
|
|
669
|
$form['footnotes']['cdm_dataportal_all_footnotes'] = array(
|
670
|
'#type' => 'checkbox',
|
671
|
'#title' => t('Do not show footnotes'),
|
672
|
'#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
|
673
|
'#description' => t('Check this if you do not want to show any footnotes'),
|
674
|
);
|
675
|
|
676
|
$form['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
|
677
|
'#type' => 'checkbox',
|
678
|
'#title' => t('Do not show annotations footnotes'),
|
679
|
'#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
|
680
|
'#description' => t('Check this if you do not want to show annotation footnotes'),
|
681
|
);
|
682
|
|
683
|
$annotationTypeOptions = cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE);
|
684
|
// Additional option for the NULL case.
|
685
|
$annotationTypeOptions['NULL_VALUE'] = t('untyped');
|
686
|
$form['footnotes']['annotations_types_as_footnotes'] = array(
|
687
|
'#type' => 'checkboxes',
|
688
|
'#title' => t('Annotation types as footnotes'),
|
689
|
'#description' => t("Only annotations of the selected type will be displayed
|
690
|
as footnotes. You may want to turn 'technical annotations' off."),
|
691
|
'#options' => $annotationTypeOptions,
|
692
|
);
|
693
|
$annotationsTypesAsFootnotes = variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
|
694
|
if (!empty($annotationsTypesAsFootnotes)) {
|
695
|
$form['footnotes']['annotations_types_as_footnotes']['#default_value'] = $annotationsTypesAsFootnotes;
|
696
|
}
|
697
|
|
698
|
// --- Advanced Search --- //
|
699
|
$form['asearch'] = array(
|
700
|
'#type' => 'fieldset',
|
701
|
'#title' => t('Advanced search'),
|
702
|
'#collapsible' => FALSE,
|
703
|
'#collapsed' => FALSE,
|
704
|
);
|
705
|
$form['asearch']['cdm_dataportal_show_advanced_search'] = array(
|
706
|
'#type' => 'checkbox',
|
707
|
'#title' => t('Show advanced search link'),
|
708
|
'#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
|
709
|
'#description' => t('Check this box if the link to advanced search should be show below the search box.'),
|
710
|
);
|
711
|
|
712
|
// ---- Taxon Name Rendering --- //
|
713
|
$form['taxon_name'] = array(
|
714
|
'#type' => 'fieldset',
|
715
|
'#title' => t('Taxon name display'),
|
716
|
'#collapsible' => TRUE,
|
717
|
'#collapsed' => TRUE,
|
718
|
'#description' => t('The display of taxon names is configured by two parts.'
|
719
|
. 'The <srong>name render templates</strong> define the parts of the name to be displayed in the different areas of the data portal pages.'
|
720
|
. 'The name parts are defined in the <stong>part definitions</strong>'),
|
721
|
);
|
722
|
|
723
|
drupal_add_js(
|
724
|
'jQuery(document).ready( function( ) {
|
725
|
// pretty print json
|
726
|
var json_text = jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val();
|
727
|
var obj = JSON.parse(json_text);
|
728
|
jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val(JSON.stringify(obj, undefined, 2));
|
729
|
|
730
|
json_text = jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val();
|
731
|
obj = JSON.parse(json_text);
|
732
|
jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val(JSON.stringify(obj, undefined, 2));
|
733
|
});'
|
734
|
,array(
|
735
|
'type' => 'inline',
|
736
|
'scope' => 'footer'
|
737
|
)
|
738
|
);
|
739
|
|
740
|
//TODO remove after all portals are using the settings
|
741
|
$default_part_definitions = theme('get_partDefinition', array());
|
742
|
if(!is_array($default_part_definitions)) {
|
743
|
$default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT);
|
744
|
}
|
745
|
|
746
|
$form['taxon_name'][CDM_PART_DEFINITIONS] = array(
|
747
|
'#type' => 'textarea',
|
748
|
'#title' => t('Part definitions'),
|
749
|
'#element_validate' => array('form_element_validate_json'),
|
750
|
'#default_value' => json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions)),
|
751
|
'#description' => '
|
752
|
<p>
|
753
|
(Clearing the text area will reset it to the default)
|
754
|
</p>
|
755
|
<p>
|
756
|
The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
|
757
|
</p>
|
758
|
<p>
|
759
|
A full taxon name plus additional information can consist of the following elements:
|
760
|
<ul>
|
761
|
<li>name: the taxon name inclugin rank nbut without author</li>
|
762
|
<li>authors: The authors of a reference, also used in taxon names</li>
|
763
|
<li>reference: the nomenclatural reference,</li>
|
764
|
<li>microreference: Volume, page number etc.</li>
|
765
|
<li>status: The nomenclatural status of a name</li>
|
766
|
<li>description: name descriptions like protologues etc ...</li>
|
767
|
</ul>
|
768
|
</p>
|
769
|
<p>
|
770
|
These elements are combined in the part definitions array to from the specific parts to be rendered.
|
771
|
(The taxon name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example in the following)
|
772
|
Usually the following parts are formed:
|
773
|
<ul>
|
774
|
<li>namePart: the name and rank (in example: "Lapsana communis")</li>
|
775
|
<li>authorshipPart: the author (in example: "L.")</li>
|
776
|
<li>nameAuthorPart: the combination of name and author part (in example: "Lapsana communis L.").</li>
|
777
|
This is useful for zoological names where the authorshipPart belongs to the name and both should</li>
|
778
|
be combined when a link to the taxon is rendered.</li>
|
779
|
<li>referencePart: the nomencaltural reference (in example: "Sp. Pl. 1753")</li>
|
780
|
<li>microreferencePart: usually the page number (in example ": 811.")</li>
|
781
|
<li>statusPart: the nomenclatorical status</li>
|
782
|
<li>descriptionPart: name descriptions like protologues etc ...</li>
|
783
|
</ul>
|
784
|
</p>
|
785
|
<p>
|
786
|
Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
|
787
|
specific parts part definitions:
|
788
|
<ul>
|
789
|
<li>BotanicalName</li>
|
790
|
<li>ZoologicalName</li>
|
791
|
<li>#DEFAULT: covers ViralNames and other NonViralNames
|
792
|
</ul>
|
793
|
An example:
|
794
|
<pre>
|
795
|
{
|
796
|
"ZoologicalName": {
|
797
|
"namePart": {
|
798
|
"name": true
|
799
|
},
|
800
|
"referencePart": {
|
801
|
"authors": true
|
802
|
},
|
803
|
"microreferencePart": {
|
804
|
"microreference": true
|
805
|
},
|
806
|
"statusPart": {
|
807
|
"status": true
|
808
|
},
|
809
|
"descriptionPart": {
|
810
|
"description": true
|
811
|
}
|
812
|
},
|
813
|
"BotanicalName": {
|
814
|
"namePart": {
|
815
|
"name": true,
|
816
|
"authors": true
|
817
|
},
|
818
|
"referencePart": {
|
819
|
"reference": true,
|
820
|
"microreference": true
|
821
|
},
|
822
|
"statusPart": {
|
823
|
"status": true
|
824
|
},
|
825
|
"descriptionPart": {
|
826
|
"description": true
|
827
|
}
|
828
|
}
|
829
|
}
|
830
|
</pre>',
|
831
|
);
|
832
|
|
833
|
//TODO remove after all portals are using the settings
|
834
|
$default_render_templates = theme('get_nameRenderTemplate', array());
|
835
|
if(!is_array($default_render_templates)) {
|
836
|
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
|
837
|
}
|
838
|
|
839
|
$form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array(
|
840
|
'#type' => 'textarea',
|
841
|
'#title' => t('Name render templates'),
|
842
|
'#element_validate' => array('form_element_validate_json'),
|
843
|
'#default_value' => json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates)),
|
844
|
'#description' => '
|
845
|
<p>
|
846
|
(Clearing the text area will reset it to the default)
|
847
|
</p>
|
848
|
<p>
|
849
|
The render templates array contains one or more name render templates to be used within the page areas identified by the
|
850
|
render path. The render path is used as key of the array sub subelements whereas the name render template array is set as value.
|
851
|
The following render Path keys are curretly recognized:
|
852
|
<ul>
|
853
|
<li>list_of_taxa:</li>
|
854
|
<li>acceptedFor:</li>
|
855
|
<li>taxon_page_synonymy</li>
|
856
|
<li>typedesignations</li>
|
857
|
<li>taxon_page_title</li>
|
858
|
<li>polytomousKey</li>
|
859
|
<li>na: name + authorship</li>
|
860
|
<li>nar:name + authorship + reference</li>
|
861
|
<li>#DEFAULT</li>
|
862
|
</ul>
|
863
|
A single render template can be used for multiple render paths. In this case the according key of the render templates
|
864
|
array element should be a comma separated list of render paths, without any whitespace!.
|
865
|
</p>
|
866
|
<p>
|
867
|
A render template is an associative array. The keys of this array are referring to the keys as defined in the part
|
868
|
definitions array. See <a href="#edit-cdm-part-definitions">Part definitions</a> above for more information.
|
869
|
<p>
|
870
|
The value of the render template element must be set to TRUE in order to let this part being rendered.
|
871
|
The namePart, nameAuthorPart and referencePart can also hold an associative array with a single
|
872
|
element: array(\'#uri\' => TRUE). The value of the #uri element will be replaced by the according
|
873
|
links if the paramters $nameLink or $refenceLink are given to the name render function
|
874
|
(this is hard coded and cannot be configured here).',
|
875
|
);
|
876
|
|
877
|
// @WA: D7 form api does not support reset buttons,
|
878
|
// so to mimic the D5 reset button we add one like this.
|
879
|
$form['actions']['reset'] = array(
|
880
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
881
|
'#weight' => 1000,
|
882
|
);
|
883
|
|
884
|
$form['#submit'] = array('submit_json_as_php_array');
|
885
|
// #json_elements especially defined for submit_json_as_php_array()
|
886
|
$form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
|
887
|
return system_settings_form($form);
|
888
|
}
|
889
|
|
890
|
|
891
|
/**
|
892
|
* @todo Please document this function.
|
893
|
* @see http://drupal.org/node/1354
|
894
|
*/
|
895
|
function cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description = '') {
|
896
|
$form[$form_name] = array(
|
897
|
'#type' => 'fieldset',
|
898
|
'#title' => t($form_title),
|
899
|
'#collapsible' => TRUE,
|
900
|
'#collapsed' => $collapsed,
|
901
|
'#tree' => TRUE,
|
902
|
'#description' => t($form_description),
|
903
|
);
|
904
|
|
905
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
906
|
$gallery_settings = variable_get($form_name, $default_values);
|
907
|
// $test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
908
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
909
|
/*
|
910
|
TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
|
911
|
$form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
|
912
|
'#type' => 'textfield',
|
913
|
'#title' => t('Search Page Size'),
|
914
|
'#default_value' => $test,
|
915
|
'#description' => t('Number of Names to display per page in search results.')
|
916
|
);
|
917
|
*/
|
918
|
$form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
|
919
|
'#type' => 'checkbox',
|
920
|
'#title' => t('Show media thumbnails for accepted taxa'),
|
921
|
'#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
|
922
|
);
|
923
|
|
924
|
$form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
|
925
|
'#type' => 'checkbox',
|
926
|
'#title' => t('Show media thumbnails for synonyms'),
|
927
|
'#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
|
928
|
'#description' => '',
|
929
|
);
|
930
|
}
|
931
|
|
932
|
// $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
|
933
|
$form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
|
934
|
'#type' => 'checkbox',
|
935
|
'#title' => t('Show captions under thumbnails'),
|
936
|
'#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
937
|
'#description' => '',
|
938
|
);
|
939
|
|
940
|
$form[$form_name]['cdm_dataportal_media_maxextend'] = array(
|
941
|
'#type' => 'textfield',
|
942
|
'#title' => t('Thumbnail size') . ':',
|
943
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
944
|
'#description' => t('Select the size of each individual thumbnail.'),
|
945
|
);
|
946
|
|
947
|
if ($form_name != CDM_DATAPORTAL_MEDIA_GALLERY_NAME) {
|
948
|
$form[$form_name]['cdm_dataportal_media_cols'] = array(
|
949
|
'#type' => 'textfield',
|
950
|
'#title' => t('Number of columns') . ':',
|
951
|
'#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
|
952
|
'#description' => t('Group the thumbnails in columns: select how many
|
953
|
columns the gallery should display.'),
|
954
|
);
|
955
|
}
|
956
|
|
957
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
958
|
$form[$form_name]['cdm_dataportal_media_maxRows'] = array(
|
959
|
'#type' => 'textfield',
|
960
|
'#title' => t('Maximum number of rows') . ':',
|
961
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
962
|
'#description' => t('You can group the thumbnails in rows, select in how
|
963
|
many rows should be the thumbnails grouped.<br/><strong>Note:</strong>
|
964
|
If you want an unlimited number of rows please set to 0.'),
|
965
|
);
|
966
|
}
|
967
|
|
968
|
return $form;
|
969
|
}
|
970
|
|
971
|
/**
|
972
|
* @todo document this function.
|
973
|
*/
|
974
|
function cdm_settings_layout_taxon() {
|
975
|
$collapsed = FALSE;
|
976
|
$form = array();
|
977
|
|
978
|
$form['#submit'][] = 'cdm_settings_layout_taxon_submit';
|
979
|
|
980
|
$form['cdm_dataportal_show_back_to_search_results'] = array(
|
981
|
'#type' => 'checkbox',
|
982
|
'#title' => t('Show <em>Back to search results</em> link at the taxon site.'),
|
983
|
'#default_value' => variable_get('cdm_dataportal_show_back_to_search_results', 1),
|
984
|
'#description' => t('<p>If checked the link to search results is rendered at
|
985
|
the top of the taxon site. Clicking on the link the last search performed
|
986
|
is rendered again.</p>'),
|
987
|
);
|
988
|
|
989
|
// --------- TABBED TAXON ------- //
|
990
|
$form['taxon_tabs'] = array(
|
991
|
'#type' => 'fieldset',
|
992
|
'#title' => t('Taxon tabs'),
|
993
|
'#collapsible' => TRUE,
|
994
|
'#collapsed' => FALSE,
|
995
|
'#description' => t('If tabbed taxon page is enabled the taxon profile will
|
996
|
be splitted in four diferent tabs; General, Synonymy, Images and
|
997
|
Specimens. If the taxon has no information for any of the tabs/sections
|
998
|
such tab will be not displayed.'),
|
999
|
);
|
1000
|
|
1001
|
$form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
|
1002
|
'#type' => 'checkbox',
|
1003
|
'#title' => t('Tabbed taxon page'),
|
1004
|
'#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
|
1005
|
'#description' => t('<p>If selected split the taxon page into individual
|
1006
|
tabs for description, images, synonymy and specimens. If not the taxon
|
1007
|
data is rendered as a long single page without tabs.</p>'),
|
1008
|
);
|
1009
|
|
1010
|
$form['taxon_tabs']['cdm_taxonpage_tabs_visibility'] = array(
|
1011
|
'#type' => 'checkboxes',
|
1012
|
'#title' => t('Tabs visibility options') . ':',
|
1013
|
'#default_value' => variable_get('cdm_taxonpage_tabs_visibility', get_taxon_options_list()),
|
1014
|
'#options' => get_taxon_options_list(),
|
1015
|
'#description' => t('Enable or disable Tabs in the Tabbed page display'),
|
1016
|
);
|
1017
|
|
1018
|
$form['taxon_tabs']['cdm_dataportal_default_tab'] = array(
|
1019
|
'#type' => 'select',
|
1020
|
'#title' => t('Default tab to display') . ':',
|
1021
|
'#default_value' => variable_get('cdm_dataportal_default_tab', 0),
|
1022
|
'#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
|
1023
|
'#description' => t('<p>Select the default tab to display when visiting a
|
1024
|
taxon page. Only available if Tabbed Taxon Page is enable.</p>
|
1025
|
<strong>Note:</strong> After performing a search and clicking in any
|
1026
|
synonym, the taxon tab to be rendered will be the synonymy of the accepted
|
1027
|
taxon and not the above selected tab.'),
|
1028
|
);
|
1029
|
|
1030
|
/* ====== TAXON_PROFILE ====== */
|
1031
|
$form['taxon_profile'] = array(
|
1032
|
'#type' => 'fieldset',
|
1033
|
'#title' => t('Taxon profile (tab)'),
|
1034
|
'#description' => t('<p>This section covers the settings related to the taxon
|
1035
|
profile tab, also known as the <strong>"General"</strong> tab.</p>'),
|
1036
|
'#collapsible' => TRUE,
|
1037
|
'#collapsed' => TRUE,
|
1038
|
);
|
1039
|
|
1040
|
// ---- PROFILE PICTURE ----//
|
1041
|
$form['taxon_profile']['picture'] = array(
|
1042
|
'#type' => 'fieldset',
|
1043
|
'#title' => t('Taxon profile picture'),
|
1044
|
'#collapsible' => TRUE,
|
1045
|
'#collapsed' => FALSE,
|
1046
|
'#description' => t('This sections allows configuring the display of the so called taxon profile image which is displayed in the taxon profile tab.'),
|
1047
|
);
|
1048
|
|
1049
|
$form['taxon_profile']['picture']['cdm_dataportal_show_default_image'] = array(
|
1050
|
'#type' => 'checkbox',
|
1051
|
'#title' => t('Enable profil picture'),
|
1052
|
'#default_value' => variable_get('cdm_dataportal_show_default_image', FALSE),
|
1053
|
'#description' => t('Show the profil picture.'),
|
1054
|
);
|
1055
|
|
1056
|
$form['taxon_profile']['picture'][CDM_DEFAULT_IMAGE_MAXEXTEND] = array(
|
1057
|
'#type' => 'textfield',
|
1058
|
'#tree' => TRUE,
|
1059
|
'#title' => t('Profil picture maximum extend'),
|
1060
|
'#default_value' => variable_get(CDM_DEFAULT_IMAGE_MAXEXTEND, CDM_DEFAULT_IMAGE_MAXEXTEND_DEFAULT),
|
1061
|
'#field_suffix' => 'px',
|
1062
|
'#maxlength' => 4,
|
1063
|
'#size' => 4,
|
1064
|
'#description' => t('The maximum extend in either dimension, width or height, of the profil picture in pixels.')
|
1065
|
);
|
1066
|
|
1067
|
$form['taxon_profile']['picture'][CDM_DEFAULT_REPLACEMENT_IMAGE] = array(
|
1068
|
'#type' => 'managed_file',
|
1069
|
'#name' => CDM_DEFAULT_REPLACEMENT_IMAGE,
|
1070
|
'#title' => t('Default image replcement'),
|
1071
|
'#size' => 40,
|
1072
|
'#description' => t("This image is shown as replacement if no image of the taxon is available."),
|
1073
|
'#upload_location' => 'public://'
|
1074
|
);
|
1075
|
|
1076
|
$options = cdm_rankVocabulary_as_option();
|
1077
|
array_unshift($options, '-- DISABLED --');
|
1078
|
$form['taxon_profile']['picture']['image_hide_rank'] = array(
|
1079
|
'#type' => 'select',
|
1080
|
'#title' => t('Hide profile picture for higher ranks') . ':',
|
1081
|
'#default_value' => variable_get('image_hide_rank', '0'),
|
1082
|
'#options' => $options,
|
1083
|
'#description' => t('The taxon profile picture will not be shown for taxa with rank higher that the selected.'),
|
1084
|
);
|
1085
|
|
1086
|
// -- MEDIA THUMBNAILS -- //
|
1087
|
$form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
|
1088
|
$form_title = 'Taxon Profile Images';
|
1089
|
$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>';
|
1090
|
$form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1091
|
|
1092
|
// ---- FEATURE TREE ---- //
|
1093
|
$form['taxon_profile']['feature_trees'] = array(
|
1094
|
'#type' => 'fieldset',
|
1095
|
'#title' => t('Features'),
|
1096
|
'#collapsible' => TRUE,
|
1097
|
'#collapsed' => FALSE,
|
1098
|
'#description' => t("This section covers settings related to the taxon's
|
1099
|
<em>Feature Tree</em>. The <em>feature tree</em> are the taxon's
|
1100
|
features such as description, distribution, common names, etc. that Drupal
|
1101
|
will render at the taxon profile page."),
|
1102
|
);
|
1103
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1104
|
$saved_uuid = variable_get(CDM_PROFILE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1105
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1106
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1107
|
}
|
1108
|
$form['taxon_profile']['feature_trees'][CDM_PROFILE_FEATURETREE_UUID] = array(
|
1109
|
'#type' => 'radios',
|
1110
|
'#title' => t('Taxon profile sections') . ':',
|
1111
|
'#default_value' => $saved_uuid,
|
1112
|
'#options' => $featureTrees['options'],
|
1113
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1114
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1115
|
'#description' => t('Select the Feature Tree to be displayed at the taxon
|
1116
|
profile. Click "Show Details" to see the Feature Tree elements.'
|
1117
|
),
|
1118
|
);
|
1119
|
$featureTrees = cdm_get_featureTrees_as_options();
|
1120
|
$saved_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1121
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1122
|
$saved_uuid = NULL;
|
1123
|
}
|
1124
|
$form['taxon_profile']['feature_trees'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
|
1125
|
'#type' => 'radios',
|
1126
|
'#title' => t('Natural language representation of structured descriptions') . ':',
|
1127
|
'#default_value' => $saved_uuid,
|
1128
|
'#options' => $featureTrees['options'],
|
1129
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1130
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1131
|
'#description' => t('Taxon descriptions can be stored in a highly structured
|
1132
|
form. The feature tree selected here will be used to generate textual
|
1133
|
representation in natural language.'
|
1134
|
),
|
1135
|
);
|
1136
|
|
1137
|
// ---- LAYOUT PER FEATURE ---- //
|
1138
|
$feature_tree = get_profile_featureTree();
|
1139
|
if (isset($feature_tree->root->children)) {
|
1140
|
|
1141
|
$form_feature_list_layout = array(
|
1142
|
'#title' => t('Taxon profile layout'),
|
1143
|
'#collapsible' => TRUE,
|
1144
|
'#collapsed' => FALSE,
|
1145
|
'#type' => 'fieldset',
|
1146
|
'#description' => t('Will be available in a future release.'),
|
1147
|
);
|
1148
|
|
1149
|
$feature_list_layout_settings_disabled = TRUE;
|
1150
|
foreach ($feature_tree->root->children as $featureNode) {
|
1151
|
|
1152
|
if (!$feature_list_layout_settings_disabled && isset($featureNode->feature)) {
|
1153
|
// Must not exceed 45 characters !!!
|
1154
|
$subform_id = LAYOUT_SETTING_PREFIX . $featureNode->feature->uuid;
|
1155
|
|
1156
|
$settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
|
1157
|
$systemDefaults = unserialize(FEATURE_TREE_LAYOUT_DEFAULTS);
|
1158
|
|
1159
|
$form_feature_list_layout[$subform_id] = array(
|
1160
|
'#tree' => TRUE,
|
1161
|
'#title' => 'test' . $featureNode->feature->representation_L10n,
|
1162
|
'#collapsible' => FALSE,
|
1163
|
'#collapsed' => FALSE,
|
1164
|
'#type' => 'fieldset',
|
1165
|
'#description' => t(''),
|
1166
|
);
|
1167
|
|
1168
|
$form_feature_list_layout[$subform_id]['enabled'] = array(
|
1169
|
'#type' => 'checkbox',
|
1170
|
'#title' => t('Enable'),
|
1171
|
'#default_value' => $settings['enabled'],
|
1172
|
'#description' => t('Enable user defined layout for this feature'),
|
1173
|
);
|
1174
|
|
1175
|
$form_feature_list_layout[$subform_id]['enclosingTag'] = array(
|
1176
|
'#type' => 'textfield',
|
1177
|
'#title' => t('Enclosing tag'),
|
1178
|
'#disabled' => !$settings['enabled'],
|
1179
|
'#default_value' => $settings['enclosingTag'],
|
1180
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['enclosingTag'] . "</code>'",
|
1181
|
);
|
1182
|
|
1183
|
$form_feature_list_layout[$subform_id]['entryEnclosingTag'] = array(
|
1184
|
'#type' => 'textfield',
|
1185
|
'#title' => t('Entry enclosing tag'),
|
1186
|
'#disabled' => !$settings['enabled'],
|
1187
|
'#default_value' => $settings['entryEnclosingTag'],
|
1188
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['entryEnclosingTag'] . "</code>'",
|
1189
|
);
|
1190
|
|
1191
|
$form_feature_list_layout[$subform_id]['glue'] = array(
|
1192
|
'#type' => 'textfield',
|
1193
|
'#title' => t('Glue'),
|
1194
|
'#disabled' => !$settings['enabled'],
|
1195
|
'#default_value' => $settings['glue'],
|
1196
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['glue'] . "</code>'",
|
1197
|
);
|
1198
|
|
1199
|
}
|
1200
|
|
1201
|
$form['taxon_profile']['feature_list_layout'] = $form_feature_list_layout;
|
1202
|
}
|
1203
|
}
|
1204
|
|
1205
|
// ---- DISTRIBUTION LAYOUT ---- //
|
1206
|
$form['taxon_profile']['distribution_layout'] = array(
|
1207
|
'#title' => t('Distribution'),
|
1208
|
'#collapsible' => TRUE,
|
1209
|
'#collapsed' => FALSE,
|
1210
|
'#type' => 'fieldset',
|
1211
|
'#description' => t('Select if you want to sort or not the distribution text
|
1212
|
located below the distribution map.'),
|
1213
|
);
|
1214
|
|
1215
|
$form['taxon_profile']['distribution_layout']['distribution_sort'] = array(
|
1216
|
'#type' => 'radios',
|
1217
|
'#title' => t('Sort') . ':',
|
1218
|
'#default_value' => variable_get('distribution_sort', 'NO_SORT'),
|
1219
|
'#options' => array(
|
1220
|
'NO_SORT' => t('Standard (No sort)'),
|
1221
|
'HIDE_TDWG2' => t('Sorted without TDWG Level 2'),
|
1222
|
),
|
1223
|
);
|
1224
|
|
1225
|
$form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] = array(
|
1226
|
'#type' => 'checkbox',
|
1227
|
'#title' => t('Show TextData elements on top of the map'),
|
1228
|
'#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
|
1229
|
'#description' => t('Check this if you want to appear all <code>TextData</code>
|
1230
|
elements on top of the map. Otherwise all <code>TextData</code>
|
1231
|
distribution elements will be listed below the other area elements.
|
1232
|
This option is useful if you need to have descriptive texts for each
|
1233
|
distribution map.'),
|
1234
|
);
|
1235
|
|
1236
|
|
1237
|
/* ====== SYNONYMY ====== */
|
1238
|
$form['taxon_synonymy'] = array(
|
1239
|
'#type' => 'fieldset',
|
1240
|
'#title' => t('Taxon synonymy (tab)'),
|
1241
|
'#collapsible' => TRUE,
|
1242
|
'#collapsed' => TRUE,
|
1243
|
'#description' => t('This section covers the settings related to the taxon
|
1244
|
<strong>synonymy</strong> tab.'),
|
1245
|
);
|
1246
|
|
1247
|
$form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
|
1248
|
'#type' => 'checkbox',
|
1249
|
'#title' => t('Show accepted taxon on top of the synonymy'),
|
1250
|
'#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
|
1251
|
'#description' => t('If checked, the first homotypic taxon is a repetition
|
1252
|
of the accepted taxon most likely with the full nomenclatural reference
|
1253
|
(depending on the currently chosen theme).'),
|
1254
|
);
|
1255
|
|
1256
|
$form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
|
1257
|
'#type' => 'checkbox',
|
1258
|
'#title' => t('Display <em>is accepted for ...</em> on taxon pages when
|
1259
|
coming from a synonym link.'),
|
1260
|
'#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
|
1261
|
'#description' => t('Check this if after doing a search and clicking on a
|
1262
|
synonym you want to see the "accept of" text for the accepted synonym.'),
|
1263
|
);
|
1264
|
|
1265
|
$nameRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
|
1266
|
$form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array(
|
1267
|
'#type' => 'checkboxes',
|
1268
|
'#title' => t('Display name relationships') . ':',
|
1269
|
'#default_value' => variable_get('name_relationships_to_show', 0),
|
1270
|
'#options' => $nameRelationshipTypeOptions,
|
1271
|
'#description' => t('Select the name relationships you want to show for the
|
1272
|
accepted taxa.'),
|
1273
|
);
|
1274
|
|
1275
|
$form['taxon_synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
|
1276
|
'#type' => 'checkbox',
|
1277
|
'#title' => t('Show taxon relations ships of accepted taxon'),
|
1278
|
'#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1279
|
'#description' => t('If this option is enabled the synonymy will show the
|
1280
|
below selected taxon relationships of accepted taxa.'),
|
1281
|
);
|
1282
|
|
1283
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
1284
|
$form['taxon_synonymy'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
|
1285
|
'#type' => 'checkboxes',
|
1286
|
'#title' => t('Taxon relationship types') . ':',
|
1287
|
'#description' => t('Only taxon relationships of the selected type will be
|
1288
|
displayed'),
|
1289
|
'#options' => $taxonRelationshipTypeOptions,
|
1290
|
'#default_value' => variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
|
1291
|
'#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1292
|
);
|
1293
|
|
1294
|
// ====== SPECIMENS ====== //
|
1295
|
$form['taxon_specimens'] = array(
|
1296
|
'#type' => 'fieldset',
|
1297
|
'#title' => t('Taxon specimens (tab)'),
|
1298
|
'#collapsible' => TRUE,
|
1299
|
'#collapsed' => TRUE,
|
1300
|
'#description' => t('This section covers the settings related to the taxon
|
1301
|
<strong>specimens</strong> tab.'),
|
1302
|
);
|
1303
|
|
1304
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1305
|
$saved_uuid = variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1306
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1307
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1308
|
}
|
1309
|
$form['taxon_specimens']['feature_trees'][CDM_OCCURRENCE_FEATURETREE_UUID] = array(
|
1310
|
'#type' => 'radios',
|
1311
|
'#title' => t('Specimen description feature tree') . ':',
|
1312
|
'#default_value' => $saved_uuid,
|
1313
|
'#options' => $featureTrees['options'],
|
1314
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1315
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1316
|
'#description' => t('Select the feature tree to be used for displaying specimen descriptions. Click "Show Details" to see the Feature Tree elements.'
|
1317
|
),
|
1318
|
);
|
1319
|
|
1320
|
$form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
|
1321
|
$form_title = t('Specimen media');
|
1322
|
$form_description = t('Specimens may have media which is displayed at the
|
1323
|
Specimen tab/section as a gallery. It is possible to configure the
|
1324
|
thumbnails gallery here, however for configuring how a single media should
|
1325
|
be displayed please go to !url.</p>',
|
1326
|
array(
|
1327
|
'!url' => l(t('Layout -> Media'), 'admin/config/cdm_dataportal/settings/layout/media'),
|
1328
|
));
|
1329
|
$form['taxon_specimens'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1330
|
|
1331
|
// --- MEDIA GALLERY ---- //
|
1332
|
$form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
|
1333
|
$form_title = 'Media gallery (tab)';
|
1334
|
$form_description = '<p>This section covers the settings related to the taxon <strong>media</strong> tab.
|
1335
|
Taxa may have media (usually images) and they are as thumbnails displayed. It is possible to configure
|
1336
|
the thumbnails gallery here, however for configuring how a single media should be displayed please go to
|
1337
|
<a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a></p>
|
1338
|
<p><strong>Note:</strong> These settings are only taken into account when the standard
|
1339
|
gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a>.</p>';
|
1340
|
$form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
|
1341
|
|
1342
|
// Comment @WA: D7 form api does not support reset buttons,
|
1343
|
// so to mimic the D5 reset button we add one like this.
|
1344
|
$form['actions']['reset'] = array(
|
1345
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1346
|
'#weight' => 1000,
|
1347
|
);
|
1348
|
return system_settings_form($form);
|
1349
|
}
|
1350
|
|
1351
|
/**
|
1352
|
* @todo document this function.
|
1353
|
*/
|
1354
|
function cdm_settings_layout_search() {
|
1355
|
|
1356
|
$form = array();
|
1357
|
|
1358
|
$form['search_settings'] = array(
|
1359
|
'#type' => 'fieldset',
|
1360
|
'#title' => t('Taxa Search'),
|
1361
|
'#collapsible' => FALSE,
|
1362
|
'#collapsed' => FALSE,
|
1363
|
'#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
|
1364
|
the block <em>CDM Taxon Search</em> should be enabled and visible for users
|
1365
|
where they can write the text to be searched. You can find Drupal block configuration
|
1366
|
site at <a href="./?q=admin/build/block">Administer->Site building->Blocks</a></p> '),
|
1367
|
);
|
1368
|
|
1369
|
$form['search_settings']['simple_search_ignore_classification'] = array(
|
1370
|
'#type' => 'checkbox',
|
1371
|
'#title' => t('Ignore the chosen classification in simple search'),
|
1372
|
'#default_value' => variable_get('simple_search_ignore_classification', TRUE),
|
1373
|
'#description' => t('The simple search, which can be executed via the search block,
|
1374
|
will by default search on all classifications. Remove the tick if you want your
|
1375
|
portal to search on the classification selected in the classification browser
|
1376
|
selector.'),
|
1377
|
);
|
1378
|
|
1379
|
$form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
|
1380
|
'#type' => 'textfield',
|
1381
|
'#title' => t('Results per page') . ':',
|
1382
|
'#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
|
1383
|
'#description' => t('Number of results to display per page.'),
|
1384
|
);
|
1385
|
|
1386
|
$form['search_settings']['cdm_search_taxa'] = array(
|
1387
|
'#type' => 'checkbox',
|
1388
|
'#title' => t('Sets the default value of <em>Search for accepted taxa</em> in the advanced search form.'),
|
1389
|
'#default_value' => variable_get('cdm_search_taxa', 1),
|
1390
|
'#description' => t('<p>If checked the <em>Search for accepted taxa </em> option will be enabled in the advanced form.</p>'),
|
1391
|
);
|
1392
|
|
1393
|
$form['search_settings']['cdm_search_synonyms'] = array(
|
1394
|
'#type' => 'checkbox',
|
1395
|
'#title' => t('Sets the default value of <em>Search for synonyms</em> in the advanced search form.'),
|
1396
|
'#default_value' => variable_get('cdm_search_synonyms', 1),
|
1397
|
'#description' => t('<p>If checked the <em>Search for synonyms</em> option will be enabled in the advanced form.</p>'),
|
1398
|
);
|
1399
|
|
1400
|
$form['search_settings']['cdm_search_common_names'] = array(
|
1401
|
'#type' => 'checkbox',
|
1402
|
'#title' => t('Sets the default value of <em>Search for common names</em> in the advanced search form.'),
|
1403
|
'#default_value' => variable_get('cdm_search_common_names', 0),
|
1404
|
'#description' => t('<p>If checked the <em>Search for common names</em> option will be enabled in the advanced form.</p>'),
|
1405
|
);
|
1406
|
|
1407
|
$form['search_settings']['cdm_search_use_default_values'] = array(
|
1408
|
'#type' => 'checkbox',
|
1409
|
'#title' => t('Sets use of default values in the advanced search form.'),
|
1410
|
'#default_value' => variable_get('cdm_search_use_default_values', 1),
|
1411
|
'#description' => t('<p>If checked the defqult values set abovewill be used for the search.</p>'),
|
1412
|
);
|
1413
|
|
1414
|
|
1415
|
// --- SEARCH TAXA GALLERY ---- //
|
1416
|
$items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
1417
|
$collapsed = FALSE;
|
1418
|
$form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
|
1419
|
$form_title = 'Taxa Search thumbnails';
|
1420
|
$form_description = 'Search results may show thumbnails. ';
|
1421
|
$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1422
|
|
1423
|
// Comment @WA: D7 form api does not support reset buttons,
|
1424
|
// so to mimic the D5 reset button we add one like this.
|
1425
|
$form['actions']['reset'] = array(
|
1426
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1427
|
'#weight' => 1000,
|
1428
|
);
|
1429
|
return system_settings_form($form);
|
1430
|
}
|
1431
|
|
1432
|
/**
|
1433
|
* @todo document this function.
|
1434
|
*/
|
1435
|
function cdm_settings_layout_media() {
|
1436
|
|
1437
|
$form = array();
|
1438
|
|
1439
|
$form['media_settings'] = array(
|
1440
|
'#type' => 'fieldset',
|
1441
|
'#title' => t('Media settings'),
|
1442
|
'#collapsible' => FALSE,
|
1443
|
'#collapsed' => FALSE,
|
1444
|
'#description' => 'This section covers layout settings for media pages.'
|
1445
|
. 'Further media related settings may be found under the taxon layout settings and on the general settings.',
|
1446
|
);
|
1447
|
|
1448
|
$form['media_settings']['image_gallery_viewer'] = array(
|
1449
|
'#type' => 'select',
|
1450
|
'#title' => t('Image viewer') . ':',
|
1451
|
'#default_value' => variable_get('image_gallery_viewer', 'default'),
|
1452
|
'#options' => array(
|
1453
|
'default' => t('Standard image viewer'),
|
1454
|
'fsi' => t('FSI viewer (requires FSI server!)'),
|
1455
|
),
|
1456
|
);
|
1457
|
|
1458
|
// --- MEDIA GALLERY ---- //
|
1459
|
$form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
|
1460
|
$form_title = 'Standard viewer';
|
1461
|
$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>';
|
1462
|
// $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
|
1463
|
$form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1464
|
|
1465
|
// @WA: D7 form api does not support reset buttons,
|
1466
|
// so to mimic the D5 reset button we add one like this.
|
1467
|
$form['actions']['reset'] = array(
|
1468
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1469
|
'#weight' => 1000,
|
1470
|
);
|
1471
|
return system_settings_form($form);
|
1472
|
}
|
1473
|
|
1474
|
/**
|
1475
|
* GEOSERVICE and Map settings.
|
1476
|
*/
|
1477
|
function cdm_settings_geo($form, &$form_state) {
|
1478
|
|
1479
|
$form = array();
|
1480
|
|
1481
|
/*
|
1482
|
GEO SERVER
|
1483
|
*/
|
1484
|
$form['edit_map_server'] = array(
|
1485
|
'#type' => 'fieldset',
|
1486
|
'#tree' => true,
|
1487
|
'#title' => t('EDIT map service'),
|
1488
|
'#collapsible' => TRUE,
|
1489
|
'#collapsed' => TRUE,
|
1490
|
'#description' => t('Configuration and selection of your geo server.
|
1491
|
The Geo Server is responsible for generating the maps.'),
|
1492
|
);
|
1493
|
|
1494
|
$current_geoserver_settings = get_edit_map_service_settings();
|
1495
|
|
1496
|
$form['edit_map_server']['base_uri'] = array(
|
1497
|
'#type' => 'select',
|
1498
|
'#title' => t('EDIT map service') . ':',
|
1499
|
'#default_value' => $current_geoserver_settings['base_uri'],
|
1500
|
'#options' => unserialize(EDIT_MAPSERVER_URI),
|
1501
|
'#description' => t('Select the EDIT map server you want to use within your data portal.'),
|
1502
|
);
|
1503
|
$form['edit_map_server']['version'] = array(
|
1504
|
'#type' => 'select',
|
1505
|
'#title' => t('Version') . ':',
|
1506
|
'#default_value' => $current_geoserver_settings['version'],
|
1507
|
'#options' => unserialize(EDIT_MAPSERVER_VERSION),
|
1508
|
'#description' => t('The version of the EDIT map services'),
|
1509
|
);
|
1510
|
|
1511
|
/*
|
1512
|
MAP SETTINGS
|
1513
|
*/
|
1514
|
$form['map_settings'] = array(
|
1515
|
'#type' => 'fieldset',
|
1516
|
'#title' => t('Maps settings'),
|
1517
|
'#collapsible' => TRUE,
|
1518
|
'#collapsed' => TRUE,
|
1519
|
'#description' => t('General configuration for all map types.'),
|
1520
|
);
|
1521
|
|
1522
|
$form['map_settings']['cdm_dataportal_geoservice_display_width'] = array(
|
1523
|
'#type' => 'textfield',
|
1524
|
'#title' => t('Maps width') . ':',
|
1525
|
'#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
|
1526
|
'#description' => t('Choose the width of your maps, the height will always
|
1527
|
be the half of the width. A value of 500 means the size will be 500 pixels
|
1528
|
width and 250 pixels height.'),
|
1529
|
);
|
1530
|
|
1531
|
$form['map_settings']['cdm_dataportal_geoservice_bounding_box'] = array(
|
1532
|
'#type' => 'textfield',
|
1533
|
'#title' => t('Fixed bounding box') . ':',
|
1534
|
'#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
|
1535
|
'#description' => t('Define surrounding of area to be displayed in maps.
|
1536
|
Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong>
|
1537
|
to let the map <strong>automatically zoom</strong> to the distribution
|
1538
|
area.'),
|
1539
|
);
|
1540
|
|
1541
|
$form['map_settings']['cdm_dataportal_geoservice_labels_on'] = array(
|
1542
|
'#type' => 'checkbox',
|
1543
|
'#title' => '<b>' . t('Display area labels') . '</b>',
|
1544
|
'#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
|
1545
|
'#description' => t('Check this if you like area names to be displayed in the maps. DOES IT WORK???? '),
|
1546
|
);
|
1547
|
|
1548
|
$form['map_settings']['cdm_dataportal_geoservice_map_caption'] = array(
|
1549
|
'#type' => 'textfield',
|
1550
|
'#title' => t('Map caption') . ':',
|
1551
|
'#default_value' => variable_get('cdm_dataportal_geoservice_map_caption', ''),
|
1552
|
'#description' => t('Define a caption for the map.'),
|
1553
|
);
|
1554
|
|
1555
|
$form['map_settings']['cdm_dataportal_geoservice_distributionOpacity'] = array(
|
1556
|
'#type' => 'textfield',
|
1557
|
'#title' => t('Distribution layer opacity') . ':',
|
1558
|
'#default_value' => variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5'),
|
1559
|
'#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions (the countries or regions) will
|
1560
|
fully visible, while a value near to 0.0 will be not much visible.'),
|
1561
|
);
|
1562
|
|
1563
|
$form['map_settings']['cdm_dataportal_map_openlayers'] = array(
|
1564
|
'#type' => 'radios',
|
1565
|
'#title' => t('Map Viewer') . ':',
|
1566
|
'#options' => array(
|
1567
|
1 => "OpenLayers dynamic mapviewer",
|
1568
|
0 => "Plain image",
|
1569
|
),
|
1570
|
'#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
|
1571
|
'#description' => t('You can choose from two different map viewers:
|
1572
|
<ul><li><em>OpenLayers</em> displays the maps in an interactive viewer
|
1573
|
which allows zooming and panning. If not enabled the maps will consist
|
1574
|
on a static image. If enabled you can configure the default layer
|
1575
|
(background of your maps) below. Only one of them will be rendered.</li>
|
1576
|
<li><em>Plain image</em> displays the map as a plain non interactive
|
1577
|
image.</li></ul>'),
|
1578
|
);
|
1579
|
|
1580
|
$openLayersEnabled = variable_get('cdm_dataportal_map_openlayers', 1) == 1;
|
1581
|
|
1582
|
|
1583
|
// --- Plain Image Settings --- //
|
1584
|
$form['map_image'] = array(
|
1585
|
'#type' => 'fieldset',
|
1586
|
'#title' => t('Plain image map settings'),
|
1587
|
'#collapsible' => TRUE,
|
1588
|
'#collapsed' => $openLayersEnabled,
|
1589
|
'#description' => t('The settings in this section are still expertimental
|
1590
|
and can only be used with the EDIT map service version 1.1 or above.'),
|
1591
|
);
|
1592
|
|
1593
|
$edit_mapserver_version = get_edit_map_service_version_number();
|
1594
|
if ($edit_mapserver_version < 1.1) {
|
1595
|
$form['map_image']['#description'] = '<div class="messages warning">' . t("The selected EDIT map service version has to small version number: $edit_mapserver_version") . '</div>'
|
1596
|
. $form['map_image']['#description'];
|
1597
|
}
|
1598
|
|
1599
|
$form['map_image']['map_base_layer'] = array(
|
1600
|
'#type' => 'textfield',
|
1601
|
'#title' => t('Background layer') . ':',
|
1602
|
'#default_value' => variable_get('map_base_layer', 'cyprusdivs'),
|
1603
|
'#description' => t('Background layer. For available layers inspect !url1 or !url2.', array(
|
1604
|
'!url1' => l(t('deegree-csw'), 'http://edit.africamuseum.be:8080/deegree-csw/md_search.jsp'),
|
1605
|
'!url2' => l(t('geoserver layers'), 'http://edit.africamuseum.be/geoserver/web/'), // http://edit.africamuseum.be/geoserver/rest/layers
|
1606
|
)),
|
1607
|
);
|
1608
|
|
1609
|
$form['map_image']['map_bg_color'] = array(
|
1610
|
'#type' => 'textfield',
|
1611
|
'#title' => t('Background color') . ':',
|
1612
|
'#default_value' => variable_get('map_bg_color', '1874CD'),
|
1613
|
);
|
1614
|
|
1615
|
$form['map_image']['map_base_layer_style'] = array(
|
1616
|
'#type' => 'textfield',
|
1617
|
'#title' => t('Background layer area style') . ':',
|
1618
|
// Only line color by now.
|
1619
|
'#default_value' => variable_get('map_base_layer_style', 'ffffff,606060,,'),
|
1620
|
'#description' => t('Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}'),
|
1621
|
);
|
1622
|
|
1623
|
|
1624
|
// --- OpenLayers Settings --- //
|
1625
|
$form['openlayers'] = array(
|
1626
|
'#type' => 'fieldset',
|
1627
|
'#title' => t('OpenLayers settings'),
|
1628
|
'#collapsible' => TRUE,
|
1629
|
'#collapsed' => !$openLayersEnabled,
|
1630
|
'#description' => '',
|
1631
|
);
|
1632
|
|
1633
|
if (!$openLayersEnabled) {
|
1634
|
$form['openlayers']['#description'] = '<div class="messages warning">' . t('The Openlayers viewer is currently not enabled! (see section Maps settings above )') . '</div>'
|
1635
|
. $form['openlayers']['#description'];
|
1636
|
}
|
1637
|
|
1638
|
$baselayer_options = array(
|
1639
|
/*
|
1640
|
NOTICE: must correspond to the layers defined in
|
1641
|
js/openlayers_,ap.js#getLayersByName()
|
1642
|
*/
|
1643
|
'osgeo_vmap0' => "Metacarta Vmap0 (OSGeo server)", // EPSG:4326: EPSG:900913
|
1644
|
'metacarta_vmap0' => "Metacarta Vmap0 (MetaCarta Labs server)", // EPSG:4326, EPSG:900913
|
1645
|
// all others EPSG:900913
|
1646
|
// 'edit-vmap0_world_basic' => 'EDIT Vmap0',
|
1647
|
'edit-etopo1' => "ETOPO1 Global Relief Model",
|
1648
|
'mapnik' => 'OpenStreetMap',
|
1649
|
'osmarender' => 'OpenStreetMap (Tiles@home)',
|
1650
|
'gmap' => 'Google Streets',
|
1651
|
'gsat' => 'Google Satellite',
|
1652
|
'ghyb' => 'Google Hybrid',
|
1653
|
'veroad' => 'Virtual Earth Roads',
|
1654
|
'veaer' => 'Virtual Earth Aerial',
|
1655
|
'vehyb' => 'Virtual Earth Hybrid',
|
1656
|
// 'yahoo' => 'Yahoo Street',
|
1657
|
// 'yahoosat' => 'Yahoo Satellite',
|
1658
|
// 'yahoohyb' => 'Yahoo Hybrid',
|
1659
|
);
|
1660
|
|
1661
|
$form['openlayers']['baselayers'] = array(
|
1662
|
'#type' => 'checkboxes_preferred',
|
1663
|
'#title' => t('Base Layers') . ':',
|
1664
|
'#options' => $baselayer_options,
|
1665
|
'#default_value' => variable_get('baselayers', array('metacarta_vmap0' => "metacarta_vmap0", 'PREFERRED' => 'metacarta_vmap0')),
|
1666
|
'#description' => t('Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.'),
|
1667
|
);
|
1668
|
|
1669
|
// cdm_dataportal_geoservice_showLayerSwitcher
|
1670
|
$form['openlayers']['cdm_dataportal_geoservice_showLayerSwitcher'] = array(
|
1671
|
'#type' => 'checkbox',
|
1672
|
'#title' => '<b>' . t('Show Layer Switcher') . '</b>',
|
1673
|
'#default_value' => variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE),
|
1674
|
'#description' => t('
|
1675
|
The Layer Switcher control displays a table of contents
|
1676
|
for the map. This allows the user interface to switch between
|
1677
|
BaseLayers and to show or hide Overlays. By default the switcher is
|
1678
|
shown minimized on the right edge of the map, the user may expand it
|
1679
|
by clicking on the handle.'
|
1680
|
),
|
1681
|
);
|
1682
|
|
1683
|
$localhostkey = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
|
1684
|
$gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
|
1685
|
$form['openlayers']['gmap_api_key'] = array(
|
1686
|
'#type' => 'textfield',
|
1687
|
'#title' => t('Google maps API key') . ':',
|
1688
|
'#default_value' => variable_get('gmap_api_key', $gmap_api_key),
|
1689
|
'#description' => t('If you want to use the Google Maps Layer, a key is
|
1690
|
needed. If you need a key, visit
|
1691
|
<a href="http://code.google.com/intl/en/apis/maps/signup.html">google maps api key</a>.
|
1692
|
<br/><strong>Note:</strong> The following key: <code>!localhostkey</code>
|
1693
|
is the default key for the localhost (127.0.0.1). The key in use is the
|
1694
|
one above this text.', array('!localhostkey' => $localhostkey)),
|
1695
|
);
|
1696
|
|
1697
|
$form['cdm_dataportal_geoservice_map_legend'] = array(
|
1698
|
'#type' => 'fieldset',
|
1699
|
'#title' => t('Map legend'),
|
1700
|
'#collapsible' => TRUE,
|
1701
|
'#collapsed' => TRUE,
|
1702
|
'#description' => t('Configure the maps legend.'),
|
1703
|
);
|
1704
|
|
1705
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_on'] = array(
|
1706
|
'#type' => 'checkbox',
|
1707
|
'#title' => '<b>' . t('Display a map legend') . '</b>',
|
1708
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
|
1709
|
'#description' => t('Check this if you like a legend to be displayed with the maps.'),
|
1710
|
);
|
1711
|
|
1712
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legendOpacity'] = array(
|
1713
|
'#type' => 'textfield',
|
1714
|
'#title' => t('Legend opacity'),
|
1715
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5'),
|
1716
|
'#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the legend will be fully visible, while a value near
|
1717
|
to 0.0 will be not much visible.'),
|
1718
|
);
|
1719
|
|
1720
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_size'] = array(
|
1721
|
'#type' => 'textfield',
|
1722
|
'#title' => t('Font size'),
|
1723
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_size', 10),
|
1724
|
'#description' => t('Font size in pixels.'),
|
1725
|
);
|
1726
|
|
1727
|
$fontStyles = array(
|
1728
|
0 => "plane",
|
1729
|
1 => "italic",
|
1730
|
);
|
1731
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_style'] = array(
|
1732
|
'#type' => 'select',
|
1733
|
'#title' => t('Available font styles'),
|
1734
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_style', FALSE),
|
1735
|
'#options' => $fontStyles,
|
1736
|
'#description' => t('Select a font style for the map legend.'),
|
1737
|
);
|
1738
|
|
1739
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_width'] = array(
|
1740
|
'#type' => 'textfield',
|
1741
|
'#title' => t('Legend icon width'),
|
1742
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_width', 35),
|
1743
|
'#description' => t('Legend icon width in pixels.'),
|
1744
|
);
|
1745
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_height'] = array(
|
1746
|
'#type' => 'textfield',
|
1747
|
'#title' => t('Legend icon height'),
|
1748
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_height', 15),
|
1749
|
'#description' => t('Legend icon height in pixels.'),
|
1750
|
);
|
1751
|
|
1752
|
// @WA: D7 form api does not support reset buttons,
|
1753
|
// so to mimic the D5 reset button we add one like this.
|
1754
|
$form['actions']['reset'] = array(
|
1755
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1756
|
'#weight' => 1000,
|
1757
|
);
|
1758
|
|
1759
|
return system_settings_form($form);
|
1760
|
}
|
1761
|
|
1762
|
/**
|
1763
|
* @todo document this function.
|
1764
|
*/
|
1765
|
function cdm_settings_cache() {
|
1766
|
|
1767
|
$form = array();
|
1768
|
|
1769
|
$form['cache_settings'] = array(
|
1770
|
'#type' => 'fieldset',
|
1771
|
'#title' => t('Cache Settings'),
|
1772
|
'#collapsible' => FALSE,
|
1773
|
'#collapsed' => FALSE,
|
1774
|
'#description' => t('<p>When caching is enabled all single taxon sites are
|
1775
|
stored in an internal drupal cache doing the portal response of taxa pages
|
1776
|
faster. This is possible because the sites are loaded from the cache and
|
1777
|
are not created from scratch.</p>'),
|
1778
|
);
|
1779
|
|
1780
|
$form['cache_settings']['cdm_webservice_cache'] = array(
|
1781
|
'#type' => 'checkbox',
|
1782
|
'#title' => t('<strong>Enable caching</strong>'),
|
1783
|
'#options' => cdm_help_general_cache(),
|
1784
|
'#default_value' => variable_get('cdm_webservice_cache', 1),
|
1785
|
'#description' => t('<p>Enable drupal to load taxa pages from the cache.</p>
|
1786
|
<p><strong>Note:</strong> If taxa are modified by the editor or any other
|
1787
|
application the changes will be not visible till the cache is erased.
|
1788
|
Therefore developers should deactived this feature when they are working
|
1789
|
on the CDM Dataportal Module.</p>'),
|
1790
|
);
|
1791
|
|
1792
|
$form['cache_settings']['cdm_run_cache'] = array(
|
1793
|
'#markup' => cdm_view_cache_site(),
|
1794
|
);
|
1795
|
|
1796
|
// @WA: D7 form api does not support reset buttons,
|
1797
|
// so to mimic the D5 reset button we add one like this.
|
1798
|
$form['actions']['reset'] = array(
|
1799
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1800
|
'#weight' => 1000,
|
1801
|
);
|
1802
|
return system_settings_form($form);
|
1803
|
}
|
1804
|
|
1805
|
/**
|
1806
|
* Walk and cache all taxon pages.
|
1807
|
*/
|
1808
|
function cdm_view_cache_site() {
|
1809
|
|
1810
|
$out = '';
|
1811
|
|
1812
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cache_all_taxa.js');
|
1813
|
|
1814
|
$request_params = array();
|
1815
|
$request_params['class'] = "Taxon";
|
1816
|
|
1817
|
$cdm_ws_page_taxa_url = cdm_compose_url(CDM_WS_TAXON . ".json", NULL, queryString($request_params));
|
1818
|
$cdm_ws_page_taxa_url = uri_uriByProxy($cdm_ws_page_taxa_url);
|
1819
|
$cdm_ws_page_taxa_url = rtrim($cdm_ws_page_taxa_url, '/');
|
1820
|
|
1821
|
$out .= t('<p><strong>Cache all taxon pages</strong></p>');
|
1822
|
$out .= '<p>When you launch the cache process the cache is filled and ready to be enabled.<br/>
|
1823
|
Remember that when you load the taxa from the cache last changes on taxa will be not visible till you erase
|
1824
|
the cache and fill it again.</p>';
|
1825
|
$out .= '<p>Before running the cache bot you have to empty the cache manually.</p>';
|
1826
|
|
1827
|
$out .= '<div>' . t('This caching process may take long time and could cause heavy load on your server') . '</div>';
|
1828
|
$out .= '<div id="progress"></div>';
|
1829
|
|
1830
|
// Comment @WA: A form within a form is not valid html and not needed here.
|
1831
|
// Also, it would be recommended just to include this part of the form in the
|
1832
|
// rest of the form array in cdm_settings_cache().
|
1833
|
// $out .= '<form id="cache_site">';
|
1834
|
$out .= '<input type="hidden" name="pageTaxaUrl" value="' . $cdm_ws_page_taxa_url . '"/>';
|
1835
|
$out .= '<input type="hidden" name="taxonPageUrl" value="' . url('cdm_dataportal/taxon/') . '"/>';
|
1836
|
$out .= '<input type="button" name="start" value="' . t('Start') . '"/>';
|
1837
|
$out .= '<input type="button" name="stop" value="' . t('Stop') . '"/>';
|
1838
|
// $out .= '</form>';
|
1839
|
$out .= '</div>';
|
1840
|
/*
|
1841
|
foreach($taxonPager->records as $taxon){
|
1842
|
cdm_dataportal_taxon_view($uuid);
|
1843
|
}
|
1844
|
*/
|
1845
|
return $out;
|
1846
|
}
|
1847
|
|
1848
|
|
1849
|
function cdm_settings_layout_taxon_submit($form, &$form_state){
|
1850
|
if (isset($form_state['values'][CDM_DEFAULT_REPLACEMENT_IMAGE])) {
|
1851
|
$file = file_load($form_state['values'][CDM_DEFAULT_REPLACEMENT_IMAGE]);
|
1852
|
|
1853
|
$file->status = FILE_STATUS_PERMANENT;
|
1854
|
|
1855
|
file_save($file);
|
1856
|
}
|
1857
|
}
|
1858
|
|
1859
|
/**
|
1860
|
* Form validation handler for ?
|
1861
|
*
|
1862
|
* Comment @WA: currently this handler is not used.
|
1863
|
* It seems partly for cdm_settings_general en partly for cdm_settings_cache?
|
1864
|
* Then you can change the name into cdm_settings_general_validate() or
|
1865
|
* cdm_settings_cache_validate().
|
1866
|
* But cdm_api_secref_cache_clear is not doing anything (yet)?
|
1867
|
*/
|
1868
|
function cdm_settings_validate($form, &$form_state) {
|
1869
|
|
1870
|
if (!str_endsWith($form_state['values']['cdm_webservice_url'], '/')) {
|
1871
|
// form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
|
1872
|
$form_state['values']['cdm_webservice_url'] .= '/';
|
1873
|
}
|
1874
|
|
1875
|
if ($form_state['values']['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)) {
|
1876
|
cache_clear_all(NULL, 'cache_cdm_ws');
|
1877
|
// Better clear secref_cache since I can not be sure if the cache has not
|
1878
|
// be used during this response.
|
1879
|
cdm_api_secref_cache_clear();
|
1880
|
}
|
1881
|
}
|
1882
|
|
1883
|
/**
|
1884
|
* Returns an associative array of the currently chosen settings for the EDIT map service or the defaults as
|
1885
|
* specified in EDIT_MAPSERVER_URI_DEFAULT and EDIT_MAPSERVER_VERSION_DEFAULT:
|
1886
|
* - base_uri: the protocol and host part , e.g.: http://edit.africamuseum.be
|
1887
|
* - version: the version, e.g.: v1.1
|
1888
|
*
|
1889
|
* @return array
|
1890
|
* An associative array of the currently chosen settings for the EDIT map service or the defaults.
|
1891
|
*/
|
1892
|
function get_edit_map_service_settings() {
|
1893
|
|
1894
|
$settings = variable_get('edit_map_server', array(
|
1895
|
'base_uri' => EDIT_MAPSERVER_URI_DEFAULT,
|
1896
|
'version' => EDIT_MAPSERVER_VERSION_DEFAULT
|
1897
|
)
|
1898
|
);
|
1899
|
// replace old non tree like settings by default
|
1900
|
// TODO to be removed after release 3.1.5
|
1901
|
if(!is_array($settings)){
|
1902
|
variable_del('edit_map_server');
|
1903
|
return get_edit_map_service_settings();
|
1904
|
}
|
1905
|
|
1906
|
return $settings;
|
1907
|
}
|
1908
|
|
1909
|
/**
|
1910
|
* Returns the full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
1911
|
*
|
1912
|
* @return string
|
1913
|
* The full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
1914
|
*/
|
1915
|
function get_edit_map_service_full_uri() {
|
1916
|
$settings = get_edit_map_service_settings();
|
1917
|
return $settings['base_uri'] . EDIT_MAPSERVER_PATH . '/' . $settings['version'];
|
1918
|
}
|
1919
|
|
1920
|
|
1921
|
/**
|
1922
|
* Returns the version number of the currently selected edit mapserver as a float
|
1923
|
*
|
1924
|
* @return float
|
1925
|
* The version number of the currently selected edit mapserver as a float.
|
1926
|
* Returns 0 on error.
|
1927
|
*/
|
1928
|
function get_edit_map_service_version_number() {
|
1929
|
|
1930
|
$pattern = '/v([\d\.]+).*$/';
|
1931
|
|
1932
|
$settings = get_edit_map_service_settings();
|
1933
|
preg_match($pattern, $settings['version'], $matches, PREG_OFFSET_CAPTURE);
|
1934
|
if (isset($matches[1])) {
|
1935
|
// Convert string to float.
|
1936
|
$version = 1 + $matches[1][0] - 1;
|
1937
|
return $version;
|
1938
|
}
|
1939
|
else {
|
1940
|
// Report error.
|
1941
|
drupal_set_message(t(" Invalid EDIT map service version number: '!version'",
|
1942
|
array(
|
1943
|
'!version' => $settings['version'],
|
1944
|
'warning')
|
1945
|
)
|
1946
|
);
|
1947
|
return 0;
|
1948
|
}
|
1949
|
}
|
1950
|
|
1951
|
/**
|
1952
|
* Returns the array of selected items in a options array
|
1953
|
*
|
1954
|
* @param array $options
|
1955
|
* An options array as generated by a form element like checkoxes, select ...,
|
1956
|
*/
|
1957
|
function get_selection($options) {
|
1958
|
$selection = array();
|
1959
|
foreach ($options as $key=>$val) {
|
1960
|
if (!empty($val)) {
|
1961
|
$selection[] = $val;
|
1962
|
}
|
1963
|
}
|
1964
|
return $selection;
|
1965
|
}
|
1966
|
|
1967
|
|
1968
|
/**
|
1969
|
* Implements hook_element_info().
|
1970
|
*
|
1971
|
* Allows modules to declare their own Form API element types and specify their default values.
|
1972
|
*
|
1973
|
* @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_element_info/7
|
1974
|
*/
|
1975
|
function cdm_dataportal_element_info() {
|
1976
|
$type['checkboxes_preferred'] = array(
|
1977
|
'#input' => TRUE,
|
1978
|
'#process' => array('checkboxes_preferred_expand'),
|
1979
|
'#after_build' => array('checkboxes_preferred_after_build'),
|
1980
|
'#theme' => array('checkboxes_preferred'),
|
1981
|
// '#theme_wrapper' => array('form_element'),
|
1982
|
);
|
1983
|
return $type;
|
1984
|
}
|
1985
|
|
1986
|
/**
|
1987
|
* #process callback function for the custom form element type 'checkbox_preferred'
|
1988
|
*
|
1989
|
*
|
1990
|
*/
|
1991
|
function checkboxes_preferred_expand($element, &$form_state, $form) {
|
1992
|
|
1993
|
// First of all create checkboxes for each of the elements
|
1994
|
$element = form_process_checkboxes($element);
|
1995
|
|
1996
|
$children = element_children($element);
|
1997
|
|
1998
|
$element['table_start'] = array(
|
1999
|
'#markup' => '<table class="checkboxes_preferred"><tr><th></th><th>' . t('Enabled') . '</th><th>' . t('Default') . '</th></tr>',
|
2000
|
'#weight' => -1,
|
2001
|
);
|
2002
|
|
2003
|
// prepare first part each of the table rows which contains the row label
|
2004
|
$weight = 0;
|
2005
|
foreach ($children as $key) {
|
2006
|
$odd_even = $weight % 4 == 0 ? 'odd' : 'even';
|
2007
|
$element[$key]['#weight'] = $weight;
|
2008
|
$element[$key]['#prefix'] = '<tr class="' . $odd_even . '"><td>' . t($element['#options'][$key]) . '</td><td>';
|
2009
|
$element[$key]['#suffix'] = '</td>';
|
2010
|
unset($element[$key]['#title']);
|
2011
|
$weight += 2;
|
2012
|
}
|
2013
|
$weight = 0;
|
2014
|
|
2015
|
// add a radio button to each of the checkboxes, the
|
2016
|
// check boxes have already been created at the beginning
|
2017
|
// of this function
|
2018
|
if (count($element['#options']) > 0) {
|
2019
|
foreach ($element['#options'] as $key => $choice) {
|
2020
|
if (!isset($element[$key . '_preferred'])) {
|
2021
|
$element[$key . '_preferred'] = array(
|
2022
|
'#type' => 'radio',
|
2023
|
'#name' => $element['#parents'][0] . '_preferred',
|
2024
|
'#return_value' => check_plain($key),
|
2025
|
'#default_value' => empty($element['#default_value_2']) ? NULL : $element['#default_value_2'],
|
2026
|
'#attributes' => $element['#attributes'],
|
2027
|
'#parents' => $element['#parents'],
|
2028
|
// '#spawned' => TRUE,
|
2029
|
'#weight' => $weight + 1,
|
2030
|
'#prefix' => '<td>', // add a prefix to start a new table cell
|
2031
|
'#suffix' => '</td></tr>', // add a prefix to close the tabel row
|
2032
|
);
|
2033
|
}
|
2034
|
$weight += 2;
|
2035
|
}
|
2036
|
}
|
2037
|
|
2038
|
// end the table
|
2039
|
$element['table_end'] = array(
|
2040
|
'#markup' => '</table>',
|
2041
|
'#weight' => $weight++,
|
2042
|
);
|
2043
|
|
2044
|
return $element;
|
2045
|
}
|
2046
|
|
2047
|
/**
|
2048
|
* Theme function for the custom form field 'checkboxes_preferred'.
|
2049
|
*/
|
2050
|
function theme_checkboxes_preferred($variables) {
|
2051
|
$element = $variables['element'];
|
2052
|
$out = '<div id="edit-baselayers-wrapper" class="form-item">';
|
2053
|
$out .= '<label for="edit-baselayers">' . $element['#title'] . '</label>';
|
2054
|
$out .= drupal_render_children($element);
|
2055
|
$out .= '<div class="description">' . $element['#description'] . '</div>';
|
2056
|
$out .= '</div>';
|
2057
|
return $out;
|
2058
|
}
|
2059
|
|
2060
|
/**
|
2061
|
* Callback for checkboxes preferred for widget which will
|
2062
|
* be called after the form or element is built. The call
|
2063
|
* back is configured in the form element by setting it as
|
2064
|
* #after_build parameter.
|
2065
|
*
|
2066
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#after_build
|
2067
|
*
|
2068
|
* @param $form
|
2069
|
* Nested array of form elements that comprise the form.
|
2070
|
* @param $form_state
|
2071
|
* A keyed array containing the current state of the form.
|
2072
|
*
|
2073
|
* @return the modified form array
|
2074
|
*/
|
2075
|
function checkboxes_preferred_after_build($form, &$form_state) {
|
2076
|
|
2077
|
$parent_id = $form['#parents'][0];
|
2078
|
|
2079
|
if ($_POST && count($_POST) > 0) {
|
2080
|
// First pass of form processing.
|
2081
|
$preferred_layer = $_POST[$parent_id . '_preferred'];
|
2082
|
$form['#value']['PREFERRED'] = $preferred_layer;
|
2083
|
$form_state[$parent_id] = $form['#value'];
|
2084
|
$form_state['values']['baselayers'] = $form['#value'];
|
2085
|
}
|
2086
|
else {
|
2087
|
// Second pass of form processing.
|
2088
|
$preferred_layer = $form['#value']['PREFERRED'];
|
2089
|
}
|
2090
|
|
2091
|
// Also set the chosen value (not sure if this is good Drupal style ....).
|
2092
|
foreach ($children = element_children($form) as $key) {
|
2093
|
if (!empty($form[$key]['#type']) && $form[$key]['#type'] == 'radio') {
|
2094
|
$form[$key]['#value'] = $preferred_layer;
|
2095
|
}
|
2096
|
}
|
2097
|
// The default layer must always be enabled.
|
2098
|
$form[$preferred_layer]['#value'] = $preferred_layer;
|
2099
|
|
2100
|
return $form;
|
2101
|
}
|
2102
|
|
2103
|
function radios_prepare_options_suffix(&$elements){
|
2104
|
|
2105
|
$childrenKeys = element_children($elements);
|
2106
|
foreach($childrenKeys as $key){
|
2107
|
if(!is_array($elements[$key]['#theme_wrappers'])){
|
2108
|
$elements[$key]['#theme_wrappers'] = array();
|
2109
|
}
|
2110
|
if(isset($elements['#options_suffixes'][$key])){
|
2111
|
$elements[$key]['#theme_wrappers'][] = 'radio_options_suffix';
|
2112
|
$elements[$key]['#options_suffix'] = $elements['#options_suffixes'][$key];
|
2113
|
}
|
2114
|
}
|
2115
|
return $elements;
|
2116
|
|
2117
|
}
|
2118
|
|
2119
|
/**
|
2120
|
* TODO
|
2121
|
* @param unknown $variables
|
2122
|
*/
|
2123
|
function theme_radio_options_suffix($variables) {
|
2124
|
$element = $variables['element'];
|
2125
|
if(isset($element['#options_suffix'])) {
|
2126
|
$element['#children'] .= $element['#options_suffix'];
|
2127
|
}
|
2128
|
return $element['#children'];
|
2129
|
}
|
2130
|
|
2131
|
|
2132
|
/**
|
2133
|
* Element validate callback for text field and arrays containing json.
|
2134
|
*
|
2135
|
* @param $element
|
2136
|
* The form element to validate
|
2137
|
* @param $form
|
2138
|
* Nested array of form elements that comprise the form.
|
2139
|
* @param $form_state
|
2140
|
* A keyed array containing the current state of the form.
|
2141
|
*/
|
2142
|
function form_element_validate_json($element, &$form_state, $form) {
|
2143
|
if (!empty($element['#value'])) {
|
2144
|
json_decode($element['#value']);
|
2145
|
if(json_last_error() != JSON_ERROR_NONE){
|
2146
|
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/'));
|
2147
|
}
|
2148
|
}
|
2149
|
}
|
2150
|
|
2151
|
/**
|
2152
|
* Form submission handler for textareas and textfields containing JSON.
|
2153
|
*
|
2154
|
* The contained JSON will be converted into an php array
|
2155
|
* or object and will be stores in the variables as such.
|
2156
|
*
|
2157
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#submit
|
2158
|
*
|
2159
|
* @param $form
|
2160
|
* Nested array of form elements that comprise the form.
|
2161
|
* @param $form_state
|
2162
|
* A keyed array containing the current state of the form.
|
2163
|
*
|
2164
|
*/
|
2165
|
function submit_json_as_php_array($form, &$form_state) {
|
2166
|
if (is_array($form['#json_elements'])) {
|
2167
|
foreach ($form['#json_elements'] as $element){
|
2168
|
if (trim($form_state['values'][$element])) {
|
2169
|
$form_state['values'][$element] = (array) json_decode($form_state['values'][$element]);
|
2170
|
} else {
|
2171
|
$form_state['values'][$element] = NULL;
|
2172
|
}
|
2173
|
}
|
2174
|
}
|
2175
|
}
|