Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / settings.php @ 6eaec849

History | View | Annotate | Download (157 KB)

1
<?php
2
/**
3
 * @file
4
 * CDM Dataportal settings.
5
 */
6

    
7

    
8
  // TODO Genus UUID.
9

    
10
  define('TAXONTREE_RANKLIMIT', 'cdm_taxontree_ranklimit');
11
  define('TAXONTREE_RANKLIMIT_DEFAULT', 0);
12
  define('CDM_TAXONOMICTREE_UUID', 'cdm_taxonomictree_uuid');
13
  define('CDM_TAXONTREE_INCLUDES', 'taxontree_includes');
14

    
15
  define('CDM_SUB_TREE_FILTER_UUID', 'cdm_sub_tree_filter_uuid');
16

    
17
  define('NO_SORT', -1);
18
  define('SORT_HIERARCHICAL', 9);
19

    
20
  define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
21

    
22
  define('SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT', 1);
23
  define('SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX', 'search_results_show_thumbnail_checkbox');
24

    
25
  define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
26
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE', 0);
27
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_PAGE_SIZE', 50);
28
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_SHOW_DETERMINED_AS', 0);
29
  define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
30
  define('CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE', 'cdm_synonymy_accepted_taxon_sec_separate');
31
  define('CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL', 'cdm_synonymy_accepted_taxon_sec_separate_label');
32
  define('CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL_DEFAULT', 'Source');
33
  define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
34
  define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
35
  define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
36
  define('CDM_DATAPORTAL_SPECIMEN_DERIVATE_TREE', 0);
37

    
38
  define('CDM_WS_PORTAL_BLAST', 'http://127.0.0.1:9001/api/sequence');
39
  define('CDM_BLAST', 0);
40
  define('CDM_REGISTRATION_PRESISTENT_IDENTIFIER_AS_LINK', 'cdm_registration_presistent_identifier_as_link');
41

    
42
  /* annotationTypeKeys */
43
  $annotationTypeKeys = array_keys(cdm_vocabulary_as_option(UUID_ANNOTATION_TYPE));
44
  if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
45
    $annotationTypeKeys = array_flip($annotationTypeKeys);
46

    
47
    // Technical annotation are off by default.
48
    unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
49
    $annotationTypeKeys = array_flip($annotationTypeKeys);
50
    // Additional value for the NULL case.
51
    $annotationTypeKeys[] = 'NULL_VALUE';
52
  }
53

    
54
  define('ANNOTATION_TYPES_VISIBLE', 'annotations_types_as_footnotes');
55
  define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
56

    
57
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE', 'bibliography_for_original_source');
58
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT', serialize(array(
59
    'enabled' => 0,
60
    'key_format' => 'ALPHA'
61
  )));
62

    
63
  /* taxonRelationshipTypes */
64
  define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(
65
    array(
66
      UUID_MISAPPLIED_NAME_FOR => UUID_MISAPPLIED_NAME_FOR,
67
      UUID_PROPARTE_MISAPPLIEDNAME_FOR => UUID_PROPARTE_MISAPPLIEDNAME_FOR,
68
      UUID_PARTIAL_MISAPPLIEDNAME_FOR => UUID_PARTIAL_MISAPPLIEDNAME_FOR,
69
      UUID_PROPARTE_SYNONYM_FOR => UUID_PROPARTE_SYNONYM_FOR,
70
      UUID_PARTIAL_SYNONYM_FOR => UUID_PARTIAL_SYNONYM_FOR,
71
      UUID_INVALID_DESIGNATION_FOR => UUID_INVALID_DESIGNATION_FOR
72
    )
73
  ));
74

    
75

    
76
  /* ---- MAP SETTING CONSTANTS ---- */
77
  /**
78
   * @var array of URIs eg. http://edit.africamuseum.be"
79
   *   An options array
80
   */
81
  define('EDIT_MAPSERVER_URI', serialize(
82
      array(
83
        'http://edit.africamuseum.be'=>'Primary (http://edit.africamuseum.be)'
84
      )
85
    )
86
  );
87
  define('EDIT_MAPSERVER_PATH', '/edit_wp5');
88
  /**
89
   * @var array of versions eg. "v1.2"
90
   *   An options array
91
   */
92
  define('EDIT_MAPSERVER_VERSION', serialize(
93
      array(
94
//        'v1' => 'v1' ,           // no longer recommended
95
//        'v1.1' => 'v1.1',        // no longer recommended
96
//        'v1.2_dev' => 'v1.2_dev',// no longer recommended
97
        'v1.2' => 'v1.2',
98
        'v1.3_dev' => 'v1.3_dev (not recommended)',
99
        'v1.4_dev' => 'v1.4_dev (experimental features)'
100
      )
101
    )
102
  );
103
  define('EDIT_MAPSERVER_URI_DEFAULT', 'http://edit.africamuseum.be');
104
  define('EDIT_MAPSERVER_VERSION_DEFAULT', 'v1.2');
105

    
106
    // --- Taxon profile settings --- /
107
  define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
108
  define('CDM_TAXON_PROFILE_IMAGE', 'cdm_taxon_profile_image');
109
  define('CDM_TAXON_PROFILE_IMAGE_DEFAULT', serialize(
110
      array(
111
          'show' => 0,
112
          'maxextend' => 184,
113
          'media_uri_query' => '',
114
          'custom_placeholder_enabled' => 1,
115
          'custom_placeholder_image_on' => 0,
116
          'custom_placeholder_image_fid' => ''
117
      )
118
    )
119
  );
120

    
121

    
122
define('FEATURE_BLOCK_SETTINGS', 'feature_block_settings');
123

    
124
define('DISTRIBUTION_CONDENSED', 'distribution_condensed');
125
define('DISTRIBUTION_CONDENSED_INFO_PATH', 'distribution_condensed_info_path');
126
define('DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT', 'cdm_dataportal/help/condensed_distribution');
127
define('DISTRIBUTION_CONDENSED_RECIPE', 'distribution_condensed_recipe');
128
define('DISTRIBUTION_CONDENSED_RECIPE_DEFAULT', 'EuroPlusMed');
129

    
130
define('DISTRIBUTION_STATUS_COLORS', 'distribution_status_colors');
131
define('DISTRIBUTION_ORDER_MODE', 'distribution_order_mode');
132
define('DISTRIBUTION_ORDER_MODE_DEFAULT', 'TREE');
133
define('DISTRIBUTION_TREE_OMIT_LEVELS', 'distribution_tree_omit_levels');
134

    
135
define('CDM_SYNONYMY_AS_TAB', 'cdm_synonymy_as_tab');
136
define('CDM_SYNONYMY_AS_TAB_DEFAULT', 1);
137

    
138
/**
139
 * Returns the array of implemented taxon page tabs.
140
 * The array has fixed integer keys which must not be changed.
141
 */
142
function get_taxon_tabs_list() {
143
  $opts = array(
144
    0 => 'General',
145
    1 => 'Synonymy',
146
    2 => 'Images',
147
    3 => 'Specimens',
148
    4 => 'Keys',
149
    5 => 'Experts',
150
  );
151
  if(variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT) !== 1){
152
    // skip the Synonymy if it is shown in  the general tab
153
    unset($opts[1]);
154
  }
155
  return $opts;
156
}
157

    
158
define('CDM_TAXONPAGE_TAB_WEIGHT', 'cdm_taxonpage_tab_weight');
159
define('CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT', serialize(
160
  array(
161
    'general' => '-3',
162
    'synonymy' => '-2',
163
    'images' => '0',
164
    'specimens' => '1',
165
    'keys' => '3',
166
    'experts' => '5',
167
    )
168
));
169

    
170

    
171
// CDM_TAXONPAGE_TAB_LABELS_DEFAULT
172
define('CDM_TAXONPAGE_TAB_LABELS', 'cdm_taxonpage_tab_labels');
173
define('CDM_TAXONPAGE_TAB_LABELS_DEFAULT', serialize(
174
  array(
175
    'general' => null,
176
    'synonymy' => null,
177
    'images' => null,
178
    'specimens' => null,
179
    'keys' => null,
180
    'experts' => null,
181
  )
182
));
183

    
184
$taxon_tab_options = get_taxon_tabs_list();
185
$taxon_tab_options[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX] = 'Last visited tab';
186

    
187
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
188

    
189
/**
190
 * @todo document this function.
191
 */
192
function get_taxon_options_list() {
193
  $taxon_tab_options = array_flip(get_taxon_tabs_list());
194
  foreach ($taxon_tab_options as $key => $value) {
195
    $taxon_tab_options[$key] = t('@key', array('@key' => $key));
196
  }
197
  return $taxon_tab_options;
198

    
199
}
200

    
201
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions');
202
define('CDM_PART_DEFINITIONS_DEFAULT', serialize(
203
    array(
204
      'ZoologicalName' => array(
205
        'namePart' => array('name' => TRUE),
206
        'nameAuthorPart' => array('name' => TRUE),
207
        'referencePart' => array('authors' => TRUE),
208
        'microreferencePart' => array('microreference' => TRUE),
209
        'secReferencePart' => array('secReference' => TRUE,),
210
        'statusPart' => array('status' => TRUE),
211
        'descriptionPart' => array('description' => TRUE),
212
      ),
213
      'BotanicalName'=> array(
214
        'namePart' => array('name' => TRUE),
215
        'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
216
        'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
217
        'secReferencePart' => array('secReference' => TRUE,),
218
        'referenceYearPart' => array('reference.year' => TRUE),
219
        'statusPart' => array('status' => TRUE),
220
        'descriptionPart' => array('description' => TRUE),
221
      ),
222
     '#DEFAULT' => array(
223
        'namePart' => array(
224
            'name' => TRUE
225
        ),
226
        'nameAuthorPart' => array(
227
            'name' => TRUE,
228
            'authors' => TRUE
229
        ),
230
       'referencePart' => array(
231
         'reference' => TRUE
232
        ),
233
       'secReferencePart' => array(
234
         'secReference' => TRUE,
235
       ),
236
       'microreferencePart' => array(
237
          'microreference' => TRUE,
238
        ),
239
       'statusPart' => array(
240
          'status' => TRUE,
241
        ),
242
       'descriptionPart' => array(
243
          'description' => TRUE,
244
        ),
245
      )
246
    )
247
  )
248
);
249
define('CDM_PART_DEFINITIONS_DEFAULT_PRE_380', serialize(
250
    array(
251
      'ZoologicalName' => array(
252
        'namePart' => array('name' => TRUE),
253
        'nameAuthorPart' => array('name' => TRUE),
254
        'referencePart' => array('authors' => TRUE),
255
        'microreferencePart' => array('microreference' => TRUE),
256
        'statusPart' => array('status' => TRUE),
257
        'descriptionPart' => array('description' => TRUE),
258
      ),
259
      'BotanicalName'=> array(
260
        'namePart' => array('name' => TRUE),
261
        'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
262
        'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
263
        'referenceYearPart' => array('reference.year' => TRUE),
264
        'statusPart' => array('status' => TRUE),
265
        'descriptionPart' => array('description' => TRUE),
266
      ),
267
      '#DEFAULT' => array(
268
        'namePart' => array(
269
          'name' => TRUE
270
        ),
271
        'nameAuthorPart' => array(
272
          'name' => TRUE,
273
          'authors' => TRUE
274
        ),
275
        'referencePart' => array(
276
          'reference' => TRUE
277
        ),
278
        'microreferencePart' => array(
279
          'microreference' => TRUE,
280
        ),
281
        'statusPart' => array(
282
          'status' => TRUE,
283
        ),
284
        'descriptionPart' => array(
285
          'description' => TRUE,
286
        ),
287
      )
288
    )
289
  )
290
  );
291

    
292
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates');
293
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize(
294
  array (
295
    'taxon_page_title,polytomousKey'=> array(
296
        'namePart' => array('#uri' => TRUE),
297
      ),
298
    'not_in_current_classification' => array(
299
     'nameAuthorPart' => TRUE,
300
     'referencePart' => TRUE,
301
     'statusPart' => TRUE,
302
     'secReferencePart' => TRUE,
303
    ),
304
    'taxon_page_synonymy,accepted_taxon.taxon_page_synonymy'=> array(
305
      'nameAuthorPart' => array('#uri' => TRUE),
306
      'referencePart' => TRUE,
307
      'descriptionPart' => TRUE,
308
      'statusPart' => TRUE,
309
    ),
310
    'related_taxon.other_taxon_relationship.taxon_relationships.taxon_page_synonymy'=> array(
311
      'nameAuthorPart' => array('#uri' => TRUE),
312
      'referencePart' => TRUE,
313
      'descriptionPart' => TRUE,
314
      'statusPart' => TRUE,
315
      'secReferencePart' => TRUE,
316
    ),
317
    'related_taxon.misapplied_name_for.taxon_relationships.taxon_page_synonymy' => array(
318
      'nameAuthorPart' => array('#uri' => TRUE),
319
      'referencePart' => TRUE,
320
      'descriptionPart' => TRUE,
321
      'statusPart' => TRUE,
322
      /* no sec ref in this case, misapplied names are
323
       * de-duplicated and the sec ref is shown as footnote */
324
    ),
325
    'homonym'=> array(
326
        'nameAuthorPart' => array('#uri' => TRUE),
327
        'referenceYearPart' => TRUE,
328
        'statusPart' => TRUE,
329
    ),
330
    'acceptedFor,typedesignations,list_of_taxa' => array(
331
        'nameAuthorPart' => array('#uri' => TRUE),
332
        'referencePart' => TRUE,
333
      ),
334
    '#DEFAULT' => array(
335
        'nameAuthorPart' => array('#uri' => TRUE),
336
        'referencePart' => TRUE,
337
     )
338
  )
339
));
340
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380', serialize(
341
  array (
342
    'taxon_page_title,polytomousKey'=> array(
343
      'namePart' => array('#uri' => TRUE),
344
    ),
345
    'taxon_page_synonymy,related_taxon'=> array(
346
      'nameAuthorPart' => array('#uri' => TRUE),
347
      'referencePart' => TRUE,
348
      'statusPart' => TRUE,
349
      'descriptionPart' => TRUE,
350
    ),
351
    'homonym'=> array(
352
      'nameAuthorPart' => array('#uri' => TRUE),
353
      'referenceYearPart' => TRUE,
354
    ),
355
    'acceptedFor,typedesignations,list_of_taxa' => array(
356
      'nameAuthorPart' => array('#uri' => TRUE),
357
      'referencePart' => TRUE,
358
    ),
359
    '#DEFAULT' => array(
360
      'nameAuthorPart' => array('#uri' => TRUE),
361
      'referencePart' => TRUE,
362
    )
363
  )
364
));
365

    
366
define('CDM_SEARCH_TAXA_MODE','cdm_search_taxa_mode');
367
define('CDM_SEARCH_TAXA_MODE_DEFAULT', serialize(
368
    // to unset a default enntry set the value to 0
369
    array(
370
      'doTaxa'=>'doTaxa',
371
      'doSynonyms' => 'doSynonyms',
372
      'doTaxaByCommonNames' => 'doTaxaByCommonNames',
373
      'doMisappliedNames' => 'doMisappliedNames'
374
    )
375
  )
376
);
377

    
378
define('CDM_SEARCH_AREA_FILTER_PRESET', 'cdm_search_area_filter_preset');
379

    
380
define('SIMPLE_SEARCH_USE_LUCENE_BACKEND', 'simple_search_use_lucene_backend');
381
define('SIMPLE_SEARCH_IGNORE_CLASSIFICATION', 'simple_search_ignore_classification');
382
define('SIMPLE_SEARCH_AUTO_SUGGEST', 'cdm_search_taxa_auto_suggest');
383

    
384
/* Gallery variables. */
385
$gallery_settings = array(
386
    "cdm_dataportal_show_taxon_thumbnails" => 1,
387
    "cdm_dataportal_show_synonym_thumbnails" => 0,
388
    "cdm_dataportal_show_thumbnail_captions" => 1,
389
    "cdm_dataportal_media_maxextend" => 120,
390
    "cdm_dataportal_media_cols" => 3,
391
    "cdm_dataportal_media_maxRows" => 1,
392
);
393

    
394
define('TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT', serialize(get_taxon_options_list()));
395
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
396
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
397
define('CDM_DATAPORTAL_TYPE_SPECIMEN_GALLERY_NAME', 'type_specimen_gallery');
398
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
399
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
400
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
401
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
402
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
403
// define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
404
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
405
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
406

    
407
define('CDM_STANDARD_IMAGE_VIEWER', "cdm_standard_image_viewer");
408
define('CDM_STANDARD_IMAGE_VIEWER_DEFAULT', serialize(array(
409
  'media_representation_details_enabled' => 0
410
)));
411

    
412
/**
413
 * The drupal variable key for the array containing the uuids of the taxon relationship types to display in
414
 * the snonymy.
415
 *
416
 * @var string
417
 */
418
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
419

    
420
define('CDM_NAME_RELATIONSHIP_TYPES', 'cdm_name_relationship_types');
421
define('CDM_NAME_RELATIONSHIP_TYPES_DEFAULT', serialize(
422
    array(
423
      UUID_NAMERELATIONSHIPTYPE_LATER_HOMONYM => UUID_NAMERELATIONSHIPTYPE_LATER_HOMONYM,
424
      UUID_NAMERELATIONSHIPTYPE_TREATED_AS_LATER_HOMONYM => UUID_NAMERELATIONSHIPTYPE_TREATED_AS_LATER_HOMONYM,
425
      UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR => UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR
426
    )
427
  )
428
);
429

    
430
/**
431
 * The drupal variable for the configuration of the information aggregation along
432
 * the taxon relation ships. The mapped arrayis associative and holds two elements:
433
 *    - direct: the uuids of the taxon relationship types to take into account in invers
434
 *      direction.
435
 *    - invers: the uuids of the taxon relationship types to take into account in direct
436
 *      direction.
437
 *
438
 * @var String
439
 */
440
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS', 'cdm_aggregate_by_taxon_relationships');
441
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT', serialize(
442
    array(
443
        'direct'=>array(),
444
        'invers'=>array()
445
     )
446
   ));
447
define('CDM_PROFILE_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
448
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
449
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
450

    
451
define('CDM_DISTRIBUTION_FILTER', 'cdm_distribution_filter');
452
define('CDM_DISTRIBUTION_FILTER_DEFAULT', serialize(
453
      array(
454
      'filter_rules' => array(
455
        'statusOrderPreference' => 0,
456
        'subAreaPreference' => 0,
457
      ),
458
      'hiddenAreaMarkerType' => array()
459
     )
460
));
461

    
462
define('DISTRIBUTION_HIERARCHY_STYLE', 'distribution_hierarchy_style');
463
define('DISTRIBUTION_HIERARCHY_STYLE_DEFAULT', serialize(array(
464
  "level_0" => array(
465
    'label_suffix' => ':',
466
    'status_glue' => '',
467
    'item_glue' => ' ',
468
    'item_group_prefix' => '',
469
    'item_group_postfix' => ''
470
  ),
471
  "level_1" => array(
472
    'label_suffix' => '',
473
    'status_glue' => '', // '&#8210; '
474
    'item_glue' => '; ',
475
    'item_group_prefix' => ', ',
476
    'item_group_postfix' => ''
477
  ),
478
  "level_2" => array(
479
    'label_suffix' => '',
480
    'status_glue' => '', // '&#8210; '
481
    'item_glue' => ', ',
482
    'item_group_prefix' => ' (',
483
    'item_group_postfix' => ')'
484
  )
485
)));
486

    
487
/**
488
 * Constant for the drupal variable key distribution_map_visibility
489
 *
490
 * possible values:
491
 *  - never
492
 *  - automatic
493
 *  - always
494
 */
495
define('DISTRIBUTION_MAP_VISIBILITY', 'distribution_map_visibility');
496
define('DISTRIBUTION_MAP_VISIBILITY_DEFAULT', 'automatic');
497

    
498
/**
499
 * Constant for the drupal variable key specimen_map_visibility
500
 *
501
 * possible values:
502
 *  - never
503
 *  - automatic
504
 *  - always
505
 */
506
define('SPECIMEN_MAP_VISIBILITY', 'specimen_map_visibility');
507
define('SPECIMEN_MAP_VISIBILITY_DEFAULT', 'automatic');
508

    
509
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
510
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
511
    array(
512
        'includeTaxonDescriptions' => 'includeTaxonDescriptions',
513
        'includeOccurrences' => 0,
514
        'includeTaxonNameDescriptions' => 0
515
     )
516
  ));
517

    
518
define('CDM_MAP_DISTRIBUTION', 'cdm_map_distribution');
519
define('CDM_MAP_DISTRIBUTION_DEFAULT', serialize(array(
520
  // needs to be merged with user setting by drupal_array_merge_deep()
521
  // 'width' => 512, // optimum size for OSM layers is 512
522
  // 'height' => 512 / 2, // optimum size for OSM layers 256
523
  'aspect_ratio' => 2,
524
  'bbox' => '', // empty to allow automatic zooming to extend
525
  'maxZoom' => 15, // corresponds to the default in cdm_openlayers_map.defaults
526
  'show_labels' => FALSE,
527
  'caption' => '',
528
  'distribution_opacity' => '0.5',
529
  'map_type' => 1, //  1 = 'openlayers', 0 = 'image'
530
  'image_map' => array(
531
    'base_layer' => '', // none, formerly this was cyprusdivs
532
    'bg_color' => '1874CD',
533
    'layer_style' => 'ffffff,606060,,',
534
  ),
535
  'openlayers' => array(
536
    'base_layers' =>  array(
537
      // A layer MUST NOT BE SET in the defaults,
538
      // otherwise it can not be overidden by the user settings:
539
      // 'mapproxy_vmap0' => 'mapproxy_vmap0',
540
      // it is sufficient to define the preferred layer,
541
      // since it will automatically be enabled:
542
      'PREFERRED' => 'mapproxy_vmap0'),
543
    'custom_wms_base_layer' => array(
544
      'name' => NULL,
545
      'url' => NULL,
546
      'params' =>  NULL,
547
      'projection' => NULL,
548
      'proj4js_def' => NULL,
549
      'max_extent' => NULL,
550
      'units' => NULL,
551
      'untiled' => FALSE
552
    ),
553
    'wms_overlay_layer' => array(
554
      'name' => NULL,
555
      'url' => NULL,
556
      'params' =>  NULL,
557
      'untiled' => FALSE
558
    ),
559
    'show_layer_switcher' => TRUE,
560
    'display_outside_max_extent' => FALSE,
561
    'google_maps_api_key' => NULL,
562
  ),
563
  'legend' => array(
564
    'show' => TRUE,
565
    'opacity' => '0.5',
566
    'font_size' => 10,
567
    'font_style' => FALSE,
568
    'icon_width' => 35,
569
    'icon_height' => 15
570
  )
571
)));
572

    
573
/**
574
 * Merges the named array variable with the array of defaults.
575
 *
576
 * IMPORTANT: The array keys must be strings. When the keys are integers
577
 * the merging will not take place for these entities. Number keyed entities
578
 * are just appended to the result array.
579
 *
580
 * @param string $variable_name
581
 *     The variable name
582
 * @param string | array $default
583
 *     The array containing the default values either as array or serialized as string.
584
 *     Unserialization is cared for if necessary
585
 * @return array
586
 *     The merged array as returned by drupal_array_merge_deep()
587
 *
588
 * TODO compare with mixed_variable_get() duplicate functions? => result use this function instead of mixed_variable_get()
589
 * TODO force $default being an array
590
 */
591
function get_array_variable_merged($variable_name, $default){
592

    
593
    // unserialize if nessecary
594
    if(!is_array($default)){
595
      $default = unserialize($default);
596
    }
597
    $variable = variable_get($variable_name, array());
598
    $result = drupal_array_merge_deep($default, $variable);
599
    return $result;
600
}
601

    
602
/**
603
 * @todo document this function.
604
 */
605
function getGallerySettings($gallery_config_form_name) {
606
  return get_array_variable_merged($gallery_config_form_name, CDM_DATAPORTAL_GALLERY_SETTINGS);
607
}
608

    
609
/**
610
 * Returns the string representation of the default tab.
611
 *
612
 * @param bool $returnTabIndex
613
 *   Defaults to FALSE, if set true this function will return the index number
614
 *   of the default tab. (used to supply default values to form elements).
615
 */
616
function get_default_taxon_tab($returnTabIndex = FALSE) {
617

    
618
  global $user;
619
  $values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
620
  $user_tab_active = 'cdm_dataportal_' . $user->uid . '_default_tab_active';
621
  $user_tab = 'cdm_dataportal_' . $user->uid . '_default_tab';
622
  // Get the user value if the used has chosen to overwrite the system settings.
623
  $user_tab_on = variable_get($user_tab_active, FALSE);
624
  if ($user_tab_on) {
625
    $user_value = variable_get($user_tab, 0);
626
    $index_value = $user_value;
627
    // Get the system value.
628
  }
629
  else {
630
    $system_value = variable_get('cdm_dataportal_default_tab', 0);
631
    $index_value = $system_value;
632
  }
633

    
634
  // Return the index value or the string representation.
635
  if ($returnTabIndex) {
636
    return $index_value;
637
  }
638
  else {
639
    return ($values[$index_value]);
640
  }
641
}
642

    
643
/**
644
 * Provides the feature block settings for a specific feature which matches the $feature_uuid parameter.
645
 *
646
 * In case specifically configured settings array, like these which are stored in the drupal variables, is missing
647
 * one or more fields these fields are taken from the default. That is the specific settings are always merges
648
 * with the default.
649
 *
650
 * Note: These settings only apply to feature blocks which do not have a special rendering
651
 * the specially handled features (e.g.: Distribution, CommonNames) may make use of the
652
 * 'special' element of the settings
653
 *
654
 * @param $feature_uuid
655
 *   The uuid string representation of the feature to return the settings for
656
 *
657
 * @return array
658
 *  an associative array of settings, with the following fields:
659
 *    - as_list: string
660
 *        this setting will be used in compose_feature_block_wrap_elements() as $enclosing_tag
661
 *        possible values are:
662
 *          div: not as list,
663
 *          ul: as bullet list,
664
 *          ol: as numbered list,
665
 *          dl: as definition list
666
 *        The tag used for the inner element, thus depends on the value of this field. The
667
 *        inner tag name can be retrieved by the function cdm_feature_block_element_tag_name()
668
 *    - link_to_reference: boolean,
669
 *        render the reference as link, ignored if the element is NOT a DescriptionElementSource
670
 *    - link_to_name_used_in_source": boolean
671
 *        whether to show name in source information as link which will point to the according name page
672
 *    - sources_as_content (boolean)
673
 *        TRUE (int: 1):
674
 *          1. If element is of the CDM type TextData and the text is not empty the source references will be
675
 *             appended in brackets like "text (source references)". If the original source has name in source
676
 *             information it will be appended to the citation string,
677
 *             like : "(citation, as name in source; citation, as name in source)"
678
 *          2. if the text of the TextData is empty, the original source citations are the only content
679
 *             (e.g. use case CITATION) and are not put into brackets. In this case the nameInSource is
680
 *             prepended to the citation string like: "name in source: citation"
681
 *        FALSE (int: 0):
682
 *          Original sources are put into the bibliography(=references) pseudo feature block. If the original source
683
 *          citations are the only content, the resulting feature block content would only consist of footnotes.
684
 *          In this case the display of the respective feature block is suppressed.
685
 *          TODO if the bibliography is not enabled the sources will be treated as footnotes like annotations,
686
 *               in future however they will in this case be shown in a separate references section for each
687
 *               feature block.
688
 *    - sources_as_content_to_bibliography  (boolean)
689
 *        Only valid if sources_as_content == TRUE, will cause the sources to be also shown
690
 *        in the bibliography.
691
 *    - sort_elements
692
 *        whether and how to sort the elements
693
 *        possible values are the constants SORT_ASC, SORT_DESC, NULL,
694
 *        some feature types (Distribution) also support: SORT_HIERARCHICAL (
695
 *        TODO option to exclude levels, put in special?,
696
 *        TODO make use of this setting in compose_feature_block_wrap_elements())
697
 *    - element_tag
698
 *        specifies the tag to be used for creating the elements, only applies if "as_list" == 'div'
699
 *        possible values are span | div. the proper inner tag name can be retrieved by the function
700
 *        cdm_feature_block_element_tag_name()
701
 *    - special: array()
702
 *        an array with further settings, this field can be used for special
703
 *        settings for specialized rendering like for distributions
704
 *  }
705
 *
706
 */
707
function get_feature_block_settings($feature_uuid = 'DEFAULT') {
708
  // the default must conform to the default parameter values of
709
  // compose_feature_block_wrap_elements() : $glue = '', $sort = FALSE, $enclosing_tag = 'ul'
710
  // compose_description_element_text_data() : asListElement = NULL
711

    
712
  // see #3257 (implement means to define the features to show up in the taxonprofile and in the specimen descriptions)
713

    
714
  // ---- DEFAULTS settings
715

    
716
  // only needed as final option, when the settings are not having a default
717
  $default = array(
718
    'DEFAULT' => array(
719
      'as_list' => 'div',
720
      'link_to_reference' => 0,
721
      'link_to_name_used_in_source' => 1,
722
      'sources_as_content' => 0,
723
      'sources_as_content_to_bibliography' => 0,
724
      'sort_elements' => NO_SORT,
725
      'glue' => '',
726
      'element_tag' => NULL
727
    ),
728
    // settings for pseudo feature bibliography
729
    // only hard coded here
730
    'BIBLIOGRAPHY' => array(
731
      'as_list' => 'div',
732
      'link_to_reference' => 0,
733
      'link_to_name_used_in_source' => 1,
734
      'sources_as_content' => 0,
735
      'sources_as_content_to_bibliography' => 0,
736
      'sort_elements' => NO_SORT,
737
      'glue' => '',
738
      'element_tag' => NULL
739
    )
740
  );
741

    
742
  // will be used as preset in the settings
743
  $other_themes_default = array(
744
    'DEFAULT' => array(
745
      'as_list' => 'div',
746
      'link_to_reference' => 0,
747
      'link_to_name_used_in_source' => 1,
748
      'sources_as_content' => 0,
749
      'sources_as_content_to_bibliography' => 0,
750
      'sort_elements' => NO_SORT,
751
      'glue' => '',
752
      'element_tag' => NULL
753
    ),
754
    UUID_CITATION => array(
755
      'as_list' => 'div',
756
      'link_to_reference' => 0,
757
      'link_to_name_used_in_source' => 0,
758
      'sources_as_content' => 1,
759
      'sources_as_content_to_bibliography' => 0,
760
      'sort_elements' => SORT_ASC,
761
      'glue' => '',
762
      'element_tag' => 'div'
763
    ),
764
    UUID_DISTRIBUTION => array(
765
      'as_list' => 'div', // currently ignored
766
      'link_to_reference' => 0,
767
      'link_to_name_used_in_source' => 0,
768
      'sources_as_content' => 0,
769
      'sources_as_content_to_bibliography' => 0,
770
      'sort_elements' => NO_SORT, // will cause ...
771
      'glue' => '',
772
      'element_tag' => 'div',
773
      'special' => array()
774
    ),
775
    UUID_COMMON_NAME => array(
776
      'as_list' => 'div',
777
      'link_to_reference' => 0,
778
      'link_to_name_used_in_source' => 1,
779
      'sources_as_content' => 0,
780
      'sources_as_content_to_bibliography' => 0,
781
      'sort_elements' => NO_SORT,
782
      'glue' => '',
783
      'element_tag' => 'span'
784
    ),
785
  );
786

    
787
  // ---- Special DEFAULTS for existing portals
788
  // TODO:
789
  // this can be removed once the feature block
790
  // settings have been deployed for the first time to these portals
791

    
792
  $cichorieae_default = array(
793
    'DEFAULT' => array(
794
      'as_list' => 'div',
795
      'link_to_reference' => 1,
796
      'link_to_name_used_in_source' => 1,
797
      'sources_as_content' => 1,
798
      'sources_as_content_to_bibliography' => 0,
799
      'sort_elements' => NO_SORT,
800
      'glue' => '',
801
      'element_tag' => 'div'
802
    ),
803
    UUID_CITATION => array(
804
      'as_list' => 'div',
805
      'link_to_reference' => 0,
806
      'link_to_name_used_in_source' => 0,
807
      'sources_as_content' => 1,
808
      'sources_as_content_to_bibliography' => 0,
809
      'sort_elements' => SORT_ASC,
810
      'glue' => '',
811
      'element_tag' => 'div'
812
    ),
813
    UUID_CHROMOSOMES_NUMBERS => array(
814
      'as_list' => 'ul',
815
      'link_to_reference' => 1,
816
      'link_to_name_used_in_source' => 1,
817
      'sources_as_content' => 1,
818
      'sources_as_content_to_bibliography' => 0,
819
      'sort_elements' => NO_SORT,
820
      'glue' => '',
821
      'element_tag' => 'div'
822
    ),
823
    UUID_CHROMOSOMES => array(
824
      'as_list' => 'ul',
825
      'link_to_reference' => 0,
826
      'link_to_name_used_in_source' => 1,
827
      'sources_as_content' => 1,
828
      'sources_as_content_to_bibliography' => 0,
829
      'sort_elements' => NO_SORT,
830
      'glue' => '',
831
      'element_tag' => 'div'
832
    ),
833
    UUID_COMMON_NAME => array(
834
      'as_list' => 'div',
835
      'link_to_reference' => 0,
836
      'link_to_name_used_in_source' => 1,
837
      'sources_as_content' => 0,
838
      'sources_as_content_to_bibliography' => 0,
839
      'sort_elements' => NO_SORT,
840
      'glue' => '',
841
      'element_tag' => 'span'
842
    ),
843
  );
844

    
845
  $palmweb_default = array(
846
    'DEFAULT' => array(
847
      'as_list' => 'ul',
848
      'link_to_reference' => 1,
849
      'link_to_name_used_in_source' => 1,
850
      'sources_as_content' => 1,
851
      'sources_as_content_to_bibliography' => 1,
852
      'sort_elements' => NO_SORT,
853
      'glue' => '',
854
      'element_tag' => NULL
855
    ),
856
    UUID_CITATION => array(
857
      'as_list' => 'ul',
858
      'link_to_reference' => 1,
859
      'link_to_name_used_in_source' => 1,
860
      'sources_as_content' => 0,
861
      'sources_as_content_to_bibliography' => 1,
862
      'sort_elements' => SORT_ASC,
863
      'glue' => '',
864
      'element_tag' => 'div'
865
    ),
866
    UUID_DISTRIBUTION => array(
867
      'as_list' => 'div', // currently ignored
868
      'link_to_reference' => 1,
869
      'link_to_name_used_in_source' => 1,
870
      'sources_as_content' => 1, // FIXME seems to have no effect see Acanthophoenix rousselii (palmae)
871
      'sources_as_content_to_bibliography' => 1,
872
      'sort_elements' => NO_SORT, // will cause ...
873
      'glue' => ', ',
874
      'element_tag' => 'span',
875
      'special' => array()
876
    ),
877
  );
878

    
879
  $cyprus_default = $cichorieae_default;
880
  $cyprus_default[UUID_DISTRIBUTION] = array(
881
    'as_list' => 'div', // currently ignored
882
    'link_to_reference' => 0,
883
    'link_to_name_used_in_source' => 0,
884
    'sources_as_content' => 0,
885
    'sources_as_content_to_bibliography' => 0,
886
    'sort_elements' => NO_SORT, // will cause ...
887
    'glue' => ' ',
888
    'element_tag' => 'div',
889
    'special' => array()
890
  );
891

    
892
  $default_theme = variable_get('theme_default', NULL);
893

    
894
  switch ($default_theme) {
895
    case 'garland_cichorieae':
896
      $settings_for_theme = $cichorieae_default;
897
      break;
898
    case 'cyprus':
899
      // cyprus: no longer used in production,
900
      // but is required for selenium tests see class eu.etaxonomy.dataportal.pages.PortalPage
901
      $settings_for_theme = $cyprus_default;
902
      break;
903
    case 'flore_afrique_centrale':
904
    case 'flora_malesiana':
905
    case 'flore_gabon':
906
      $settings_for_theme = $cichorieae_default;
907
      $settings_for_theme[UUID_CITATION]['as_list'] = 'ul';
908
      break;
909
    case 'palmweb_2':
910
      $settings_for_theme = $palmweb_default;
911
      break;
912
    default:
913
      $settings_for_theme = $other_themes_default;
914
  }
915
  // add pseudo feature settings
916
  $settings_for_theme['BIBLIOGRAPHY'] = $default['BIBLIOGRAPHY'];
917

    
918
  // ---- END of DEFAULTS
919

    
920
  $saved_settings = variable_get(FEATURE_BLOCK_SETTINGS, NULL);
921

    
922
  $feature_block_setting = null;
923

    
924
  if (isset($saved_settings[$feature_uuid])) {
925
    $feature_block_setting = $saved_settings[$feature_uuid];
926
  }
927
  else if (isset($settings_for_theme[$feature_uuid])) {
928
    $feature_block_setting = $settings_for_theme[$feature_uuid];
929
  }
930
  else if (isset($settings_for_theme['DEFAULT'])) {
931
    $feature_block_setting = $settings_for_theme['DEFAULT'];
932
  }
933

    
934
  // now merge the default and specific settings
935
  $settings_to_merge = array($default['DEFAULT']);
936
  if(is_array($saved_settings)){
937
    $settings_to_merge[] = $saved_settings['DEFAULT'];
938
  }
939
  if(isset($feature_block_setting)){
940
    $settings_to_merge[] = $feature_block_setting;
941
  }
942
  $feature_block_setting = drupal_array_merge_deep_array($settings_to_merge);
943

    
944
  return $feature_block_setting;
945
}
946

    
947
/**
948
 * returns the current setting for the original source bibliography
949
 *
950
 * Caches internally
951
 *
952
 * @return array
953
 *  the setting for the original source bibliography see BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE:
954
 *   - 'enabled': 1|0
955
 *   - 'key_format': one of 'latin', 'ROMAN', 'roman', 'ALPHA', 'alpha'
956
 */
957
function get_bibliography_settings($clear_cache = false){
958
  static $bibliography_settings = null;
959
  if(!$bibliography_settings || $clear_cache){
960
    $bibliography_settings = get_array_variable_merged(
961
      BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE,
962
      BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT
963
    );
964
  }
965
  return $bibliography_settings;
966
}
967

    
968
/**
969
 * @todo Please document this function.
970
 * @see http://drupal.org/node/1354
971
 */
972
function cdm_dataportal_menu_admin(&$items) {
973
  // Display section on admin/config page.
974
  $items['admin/config/cdm_dataportal'] = array(
975
    'title' => 'CDM Dataportal',
976
    'description' => 'Settings for the CDM DataPortal.',
977
    'position' => 'right',
978
    'weight' => 10,
979
    'page callback' => 'system_admin_menu_block_page',
980
    'access arguments' => array('administer cdm_dataportal'),
981
    'file' => 'system.admin.inc',
982
    'file path' => drupal_get_path('module', 'system'),
983
  );
984
  $items['admin/config/cdm_dataportal/settings'] = array(
985
    'title' => 'Settings',
986
    'description' => 'Settings for the CDM DataPortal.',
987
    'weight' => 0,
988
    'page callback' => 'drupal_get_form',
989
    'page arguments' => array('cdm_settings_general'),
990
    'access arguments' => array('administer cdm_dataportal'),
991
    'type' => MENU_NORMAL_ITEM,
992
  );
993
  $items['admin/config/cdm_dataportal/settings/general'] = array(
994
    'title' => 'General',
995
    'description' => 'General',
996
    'weight' => 0,
997
    'page callback' => 'drupal_get_form',
998
    'page arguments' => array('cdm_settings_general'),
999
    'access arguments' => array('administer cdm_dataportal'),
1000
    'type' => MENU_DEFAULT_LOCAL_TASK,
1001
  );
1002

    
1003
  $items['admin/config/cdm_dataportal/settings/cachesite'] = array(
1004
    'title' => 'Cache',
1005
    'description' => 'Cache',
1006
    'access arguments' => array('administer cdm_dataportal'),
1007
    'page callback' => 'drupal_get_form',
1008
    'page arguments' => array('cdm_settings_cache'),
1009
    'weight' => 10,
1010
    'type' => MENU_LOCAL_TASK,
1011
  );
1012

    
1013
  $items['admin/config/cdm_dataportal/settings/geo'] = array(
1014
    'title' => 'Geo & Map',
1015
    'description' => 'Geo & Map',
1016
    'access arguments' => array('administer cdm_dataportal'),
1017
    'page callback' => 'drupal_get_form',
1018
    'page arguments' => array('cdm_settings_geo'),
1019
    'weight' => 1,
1020
    'type' => MENU_LOCAL_TASK,
1021
  );
1022

    
1023
  $items['admin/config/cdm_dataportal/settings/layout'] = array(
1024
    'title' => 'Layout',
1025
    'description' => 'Configure and adjust the layout of your DataPortal ',
1026
    'access arguments' => array('administer cdm_dataportal'),
1027
    'page callback' => 'drupal_get_form',
1028
    'page arguments' => array('cdm_settings_layout'),
1029
    'weight' => 2,
1030
    'type' => MENU_LOCAL_TASK,
1031
  );
1032

    
1033
  $items['admin/config/cdm_dataportal/settings/layout/taxon'] = array(
1034
    'title' => 'Taxon',
1035
    'description' => 'Configure and adjust the layout of your DataPortal ',
1036
    'access arguments' => array('administer cdm_dataportal'),
1037
    'page callback' => 'drupal_get_form',
1038
    'page arguments' => array('cdm_settings_layout_taxon'),
1039
    'weight' => 1,
1040
    'type' => MENU_LOCAL_TASK,
1041
  );
1042
  /*
1043
  $items[] = array(
1044
  'path' => 'admin/config/cdm_dataportal/layout/synonymy',
1045
  'title' => t('Synonymy'),
1046
  'description' => t('Configure and adjust the layout of your DataPortal '),
1047
  'access' => user_access('administer cdm_dataportal'),
1048
  'callback' => 'drupal_get_form',
1049
  'callback arguments' => array('cdm_settings_layout_synonymy'),
1050
  'weight' => 1,
1051
  'type' => MENU_LOCAL_TASK,
1052
  );
1053

1054
  $items[] = array(
1055
  'path' => 'admin/config/cdm_dataportal/layout/specimens',
1056
  'title' => t('Specimens'),
1057
  'description' => t('Configure and adjust the layout of your DataPortal '),
1058
  'access' => user_access('administer cdm_dataportal'),
1059
  'callback' => 'drupal_get_form',
1060
  'callback arguments' => array('cdm_settings_layout_specimens'),
1061
  'weight' => 1,
1062
  'type' => MENU_LOCAL_TASK,
1063
  );
1064
  */
1065
  $items['admin/config/cdm_dataportal/settings/layout/search'] = array(
1066
    'title' => 'Search',
1067
    'description' => 'Configure and adjust the layout of your DataPortal ',
1068
    'access arguments' => array('administer cdm_dataportal'),
1069
    'page callback' => 'drupal_get_form',
1070
    'page arguments' => array('cdm_settings_layout_search'),
1071
    'weight' => 2,
1072
    'type' => MENU_LOCAL_TASK,
1073
  );
1074

    
1075
  $items['admin/config/cdm_dataportal/settings/layout/media'] = array(
1076
    'title' => 'Media',
1077
    'description' => 'Configure and adjust the layout of your DataPortal ',
1078
    'access arguments' => array('administer cdm_dataportal'),
1079
    'page callback' => 'drupal_get_form',
1080
    'page arguments' => array('cdm_settings_layout_media'),
1081
    'weight' => 3,
1082
    'type' => MENU_LOCAL_TASK,
1083
  );
1084

    
1085
}
1086

    
1087
/**
1088
 * @todo document this function.
1089
 */
1090
function cdm_help_general_cache() {
1091
  $form = array();
1092
  $form['cache_help'] = array(
1093
    '#type' => 'fieldset',
1094
    '#title' => t('Help'),
1095
    '#collapsible' => TRUE,
1096
    '#collapsed' => TRUE,
1097
  );
1098
  $form['cache_help']['test'] = array('#value' => t('probando'));
1099
  return drupal_render($form);
1100
  $res = array();
1101
  $res['default'] = drupal_render($help);
1102
  return $res;
1103
}
1104

    
1105
/**
1106
 * Configures the settings form for the CDM-API module.
1107
 *
1108
 * @return array
1109
 *   Drupal settings form.
1110
 */
1111
function cdm_settings_general() {
1112

    
1113
  $form['cdm_webservice'] = array(
1114
    '#type' => 'fieldset',
1115
    '#title' => t('CDM Server'),
1116
    '#collapsible' => FALSE,
1117
    '#collapsed' => FALSE,
1118
    '#description' => t('The <em>CDM Server</em> exposes data stored in a
1119
        CDM data base to the web via RESTful web services and thus is the source of the data
1120
        to be displayed by a CDM DataPotal.'),
1121
  );
1122

    
1123
  $form['cdm_webservice']['cdm_webservice_url'] = array(
1124
    '#type' => 'textfield',
1125
    '#title' => t('CDM web service URL') . ':',
1126
    '#description' => t('This is the URL to the CDM-Server exposing your data
1127
      e.g. <em>"http://myserver.net/cdmserver/myproject"</em>'),
1128
    '#default_value' => variable_get('cdm_webservice_url', NULL),
1129
  );
1130

    
1131
  $form['cdm_webservice']['cdm_webservice_debug'] = array(
1132
    '#type' => 'markup',
1133
    '#markup' => '<b>Debug CDM Web Service:</b> Debugging web services is possible via the ' . l('CDM web service debug block', 'admin/structure/block/manage/cdm_api/cdm_ws_debug/configure')
1134
      . ' visible only for administrators',
1135
  );
1136

    
1137
  $form['cdm_webservice']['freetext_index'] = array(
1138
    '#type' => 'fieldset',
1139
    '#title' => t('Freetext index'),
1140
    '#collapsible' => FALSE,
1141
    '#collapsed' => FALSE,
1142
  );
1143

    
1144
  // Check the cdmserver port number and display a waring if it is not port 80
1145
  preg_match("#http[s]?://[0-9\p{L}\.]*:([0-9]*)/.*#u", variable_get('cdm_webservice_url', ''), $portNumberMatch, PREG_OFFSET_CAPTURE);
1146
  if (isset($portNumberMatch[1]) && $portNumberMatch[1] != '80') {
1147
    $form['cdm_webservice']['freetext_index']['message'] = array(
1148
      '#markup' => "<div class=\"description\">"
1149
      . t("The CDM web service URL contains a portnumber other than standart HTTP port 80: '!port'
1150
           Due to this the reindex and purge fuctions may not be working if there is a firewall in between you and the CDM Server.
1151
           You may want to contact the maintainer of the according CDM Server in order to solve this problem.",
1152
          array('!port' => $portNumberMatch[1][0])
1153
        )
1154
      . "</div>",
1155
    );
1156
  };
1157

    
1158
  $frontentURL = urlencode(variable_get('cdm_webservice_url', ''));
1159
  $trigger_link_options = array(
1160
    'attributes' => array(
1161
      'class' => 'index-trigger'
1162
    ),
1163
  );
1164
  $form['cdm_webservice']['freetext_index']['operations'] = array(
1165
    '#markup' => "<div>" . t('Operations: !url1 !url2', array(
1166
        '!url1' => l(t("Purge"), cdm_compose_url(CDM_WS_MANAGE_PURGE, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
1167
        '!url2' => l(t("Reindex"), cdm_compose_url(CDM_WS_MANAGE_REINDEX, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
1168
      ))
1169
    . '<div id="index-progress"></div></div>',
1170
  );
1171

    
1172
  $form['cdm_webservice']['freetext_index']['cdm_login'] = array(
1173
    // this must not be stored, it is only used by the _add_js_cdm_ws_progressbar
1174
    '#type' => 'textfield',
1175
    '#title' => t('Login'),
1176
    '#description' => t('Your cdm user credentials in the following form: <code>user:password</code>')
1177
  );
1178
  drupal_add_js('
1179
        jQuery(document).ready(function() {
1180
             jQuery("#edit-cdm-login").change(function (e) {
1181
                var login = jQuery(e.target).val();
1182
                jQuery("#edit-freetext-index .index-trigger").each(function(index){
1183
                   var url = jQuery(this).attr("href");
1184
                   url = url.replace(/:\/\/[^@]+@|:\/\//, "://" + login + "@");
1185
                   jQuery(this).attr("href", url);
1186
                });
1187
            });
1188
        });
1189
      ',
1190
    array(
1191
      'type' => 'inline',
1192
      'scope' => 'footer'
1193
    )
1194
  );
1195
  _add_js_cdm_ws_progressbar(".index-trigger", "#index-progress");
1196

    
1197
  $form['cdm_webservice']['proxy'] = array(
1198
    '#type' => 'fieldset',
1199
    '#title' => t('Proxy'),
1200
    '#collapsible' => TRUE,
1201
    '#collapsed' => TRUE,
1202
  );
1203

    
1204
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] = array(
1205
    '#type' => 'textfield',
1206
    '#title' => t('Proxy URL') . ':',
1207
    '#description' => t('If this proxy url is set the cdm api tries
1208
    to connect the web service over the given proxy server.
1209
    Otherwise proxy usage is deactivated.'),
1210
    '#default_value' => variable_get('cdm_webservice_proxy_url', FALSE),
1211
  );
1212

    
1213
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] = array(
1214
    '#type' => 'textfield',
1215
    '#title' => t('Proxy port') . ':',
1216
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
1217
  );
1218

    
1219
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] = array(
1220
    '#type' => 'textfield',
1221
    '#title' => t('Login') . ':',
1222
    '#default_value' => variable_get('cdm_webservice_proxy_usr', FALSE),
1223
  );
1224

    
1225
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] = array(
1226
    '#type' => 'textfield',
1227
    '#title' => t('Password') . ':',
1228
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', FALSE),
1229
  );
1230

    
1231
  $form['sub_tree_filter'] = array(
1232
    '#type' => 'fieldset',
1233
    '#title' => t('Subtree filter'),
1234
    '#collapsible' => FALSE,
1235
    '#collapsed' => TRUE,
1236
    '#description' => t('The Data Portal can be restricted to the taxa which belong to a specific classification subtree. Other taxa will not be shown or accessible otherwise.'),
1237
  );
1238

    
1239
  $sub_tree_filter_uuid_value = variable_get(CDM_SUB_TREE_FILTER_UUID, FALSE);
1240
  $taxon_node_info = '';
1241
  if($sub_tree_filter_uuid_value){
1242
    $taxon_node_dto = cdm_ws_get(CDM_WS_TAXONNODE, array($sub_tree_filter_uuid_value));
1243
    if($taxon_node_dto){
1244
      $taxon_node_info = " Current taxon node: <strong>" . cdm_tagged_text_to_markup($taxon_node_dto->taggedTitle) . " [" . $taxon_node_dto->treeIndex . "]</strong>";
1245
    }
1246
  }
1247
  $form['sub_tree_filter'][CDM_SUB_TREE_FILTER_UUID] = array(
1248
    '#type' => 'textfield',
1249
    '#title' => t('Taxon Node UUID') . ':',
1250
    '#default_value' => variable_get(CDM_SUB_TREE_FILTER_UUID, FALSE),
1251
    '#description' => "The uuid of the TaxonNode entity to be used as filter." . $taxon_node_info
1252
  );
1253

    
1254
  // TODO: settings are still incomplete, compare with
1255
  // trunk/dataportal/inc/config_default.php.inc.
1256
  $form['taxon_tree'] = array(
1257
    '#type' => 'fieldset',
1258
    '#title' => t('Taxon Tree'),
1259
    '#collapsible' => FALSE,
1260
    '#collapsed' => TRUE,
1261
    '#description' => t('<p>When you explore your collection, you can navigate
1262
      it through a tree structure also called <em>Taxon Tree</em>.</p><p>To be
1263
      able to navigate through your collection the
1264
      <a href="http://drupal.org/handbook/blocks">drupal block</a>
1265
      <em>CDM Taxon Tree</em> should be visible for users. Enable the block at
1266
      <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks
1267
      </a></p>'),
1268
  );
1269

    
1270
  $form['taxon_tree'][CDM_TAXONOMICTREE_UUID] = array(
1271
    '#type' => 'select',
1272
    '#title' => t('Default classification') . ':',
1273
    '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
1274
    '#options' => cdm_get_taxontrees_as_options(),
1275
    '#description' => t('The default taxa classification to be used in the whole portal. 
1276
      This affects most obviously the classification browser and the search in case is is restricted 
1277
      to a specific classification. See also <i>Included Classifications</i> below.'),
1278
  );
1279

    
1280
  $form['taxon_tree'][TAXONTREE_RANKLIMIT] = array(
1281
    '#type' => 'select',
1282
    '#title' => t('Rank of highest displayed taxon') . ':',
1283
     // Before DEFAULT_TAXONTREE_RANKLIMIT_UUID.
1284
    '#default_value' => variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT),
1285
    '#options' => cdm_vocabulary_as_option(UUID_RANK, null, true),
1286
    '#description' => t('This is the rank of the highest displayed taxon in the
1287
      <em>taxon tree</em>. You can select here which rank should be at the top
1288
      level of the tree structure.'),
1289
  );
1290

    
1291
  $classification_uuids = array_keys(cdm_get_taxontrees_as_options());
1292
  $taxontree_includes_default = array_combine($classification_uuids, $classification_uuids);
1293
  $form['taxon_tree'][CDM_TAXONTREE_INCLUDES] = array(
1294
      '#type' => 'checkboxes',
1295
      '#title' => t('Included Classifications') . ':',
1296
      '#default_value' => variable_get(CDM_TAXONTREE_INCLUDES, $taxontree_includes_default),
1297
      '#options' => cdm_get_taxontrees_as_options(),
1298
      '#description' => t('Only the checked classifications will be available in the classification chooser.'),
1299
  );
1300

    
1301
  $form['distribution'] = array(
1302
      '#type' => 'fieldset',
1303
      '#title' => t('Distributions'),
1304
      '#collapsible' => FALSE,
1305
      '#description' => 'This section covers general settings regarding distributions, map related settings are found in the '
1306
          . l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
1307
          '. Further settings regarding the Distribution feature block can be found in the Layout/Taxon tab at two distinct places: '
1308
          . l('Distribution appearance', 'admin/config/cdm_dataportal/settings/layout/taxon', array('fragment' => 'edit-distribution-layout')) .', '
1309
          . l('Taxon profile feature block settings', 'admin/config/cdm_dataportal/settings/layout/taxon', array('fragment' => 'edit-feature-block-settings')) .
1310
          '<p>
1311
          </p>',
1312
  );
1313

    
1314
  $form['distribution'][CDM_DISTRIBUTION_FILTER] = array(
1315
      '#type' => 'fieldset',
1316
      '#title' => 'Distribution filter',
1317
      '#collapsible' => FALSE,
1318
      '#collapsed' => FALSE,
1319
      '#tree' => TRUE,
1320
      '#description' => 'The Distribution filter offers the following options
1321
      <ul>
1322
      <li><strong>Status order preference rule:</strong> In case of multiple distribution status (PresenceAbsenceTermBase) for
1323
        the same area the status with the highest order is preferred, see OrderedTermBase.compareTo(OrderedTermBase).</li>
1324
      <li><strong>Sub area preference rule:</strong>If there is an area with a direct sub area and both areas have the same
1325
        computed status only the information on the sub area should be reported, whereas the super area should be ignored.</li>
1326
      <li><strong>Marked area filter:</strong>Skip distributions for areas having a TRUE Marker with one of the specified MarkerTypes.
1327
        Existing sub-areas of a marked area must also be marked with the same marker type, otherwise the marked
1328
        area acts as a fallback area for the sub areas. An area is a <em>fallback area</em> if it is marked to
1329
        be hidden and if it has at least one of sub area which is not marked to be hidden. The <em>fallback area</em>
1330
        will be show if there is no Distribution for any of the non hidden sub-areas. For more detailed discussion on
1331
        <em>fallback area</em> see https://dev.e-taxonomy.eu/trac/ticket/4408.</li>
1332
      </ul>'
1333
  );
1334

    
1335
  $cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
1336
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['filter_rules'] = array(
1337
      '#type' => 'checkboxes',
1338
      '#title' => 'Filter rules',
1339
      '#default_value' => $cdm_distribution_filter['filter_rules'],
1340
      '#options' => array(
1341
          'statusOrderPreference' => 'Status order preference rule',
1342
          'subAreaPreference' => 'Sub area preference rule'
1343
      ),
1344
  );
1345

    
1346
  $marker_type_options = cdm_terms_by_type_as_option('MarkerType');
1347
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['hiddenAreaMarkerType'] = array(
1348
      '#type' => 'checkboxes',
1349
      '#title' => 'Hide marked area filter',
1350
      '#default_value' => $cdm_distribution_filter['hiddenAreaMarkerType'],
1351
      '#options' => $marker_type_options,
1352
      '#description' => 'Check one or more MarkerTypes to define the "hide marked area" filter .',
1353
  );
1354

    
1355
  $form['aggregation'] = array(
1356
      '#type' => 'fieldset',
1357
      '#title' => t('Aggregation of data'),
1358
      '#collapsible' => FALSE,
1359
      '#description' => 'This section covers the different aspects of aggregating information.
1360
          <p>
1361
          </p>',
1362
  );
1363

    
1364
  $form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
1365
      '#type' => 'checkboxes',
1366
      '#title' => 'Taxon media filter',
1367
      '#default_value' => variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)),
1368
      '#options' => array(
1369
          'includeTaxonDescriptions' => 'Media in taxon descriptions',
1370
          'includeTaxonNameDescriptions' => 'Media in name descriptions',
1371
          'includeOccurrences' => 'Media related to specimens and occurrences',
1372
      ),
1373
      '#description' => 'This filter configures which images should be taken into account.',
1374
  );
1375

    
1376
  $form['aggregation']['notice'] = array(
1377
      '#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
1378
          want to make use of the caching capabilities of the dataportal.',
1379
  );
1380

    
1381
  $form['aggregation']['media_aggregation'] = array(
1382
      '#type' => 'fieldset',
1383
      '#title' => t('Media aggregation'),
1384
      '#collapsible' => FALSE,
1385
      '#collapsed' => TRUE,
1386
      '#description' => t("The media aggregation is also affected by the settigs in \"<strong>Aggregation via taxon relationsships</strong>\" below."),
1387

    
1388
  );
1389
  $form['aggregation']['media_aggregation']['cdm_images_include_children'] = array(
1390
      '#type' => 'select',
1391
      '#title' => t('Aggregation of taxon pictures') . ':',
1392
      '#default_value' => variable_get('cdm_images_include_children', FALSE),
1393
      '#options' => array(
1394
          0 => "Show only pictures of the current taxon",
1395
          1 => "Include pictures of taxonomic children",
1396
      ),
1397
      '#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."),
1398
  );
1399

    
1400
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS] = array(
1401
      '#type' => 'fieldset',
1402
      '#attributes' => array('class' => array('clearfix')),
1403
      '#title' => t('Aggregation via taxon relationsships'),
1404
      '#collapsible' => TRUE,
1405
      '#collapsed' => TRUE,
1406
      '#tree' => TRUE,
1407
      '#description' => t('Information on taxa will be aggregated along the below chosen
1408
          taxon relation ships. This will affect images and occurrences (specimens).
1409
          Taxon relation ships are directed and point form one taxon to another. The taxon
1410
          relationships to be taken into accunt can therefore configured for the direct direction
1411
          and for the inverse.'),
1412
  );
1413

    
1414
  $taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
1415
  $aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
1416

    
1417
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array(
1418
      '#type' => 'checkboxes',
1419
      '#title' => t('Direct'),
1420
      '#options' => $taxonRelationshipTypeOptions,
1421
      '#default_value' => $aggregate_by_taxon_relationships['direct'],
1422
  );
1423
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['invers'] = array(
1424
      '#type' => 'checkboxes',
1425
      '#title' => t('Invers'),
1426
      '#options' => $taxonRelationshipTypeOptions,
1427
      '#default_value' => $aggregate_by_taxon_relationships['invers'],
1428
  );
1429

    
1430
  $form['drupal_integration'] = array(
1431
    '#type' => 'fieldset',
1432
    '#attributes' => array('class'=> array('clearfix')),
1433
    '#title' => t('Drupal integration'),
1434
    '#collapsible' => FALSE,
1435
    '#collapsed' => FALSE,
1436
    '#tree' => FALSE
1437
  );
1438

    
1439
  $form['drupal_integration'][CDM_DRUPAL_NODE_CREATION] = array(
1440
    '#type' => 'checkbox',
1441
    '#title' => 'Create drupal nodes',
1442
    '#default_value' => variable_get(CDM_DRUPAL_NODE_CREATION, FALSE),
1443
    '#description' => 'Content für cdm_dataportal pages is directly retrieved from the 
1444
    CDM webservice configured above. In order to use other drupal modules like the "Comments" module together with the 
1445
    cdm pages it is required that drupal nodes are created and stored in the database.'
1446
  );
1447

    
1448

    
1449

    
1450
  $form['drupal_integration']['drop_all_cdm_nodes_warning_pre'] = array(
1451
    '#markup' => '<h6 style="color:red;">WARNING:</h6>
1452
    <div class="description">Using this button, you will lose all content associated with the cdm drupal nodes which is stored in the drupal data base.</div>',
1453
  );
1454
  $form['drupal_integration']['drop_all_cdm_nodes'] = array(
1455
    '#type' => 'submit',
1456
    '#value' => t('Drop all cdm nodes'),
1457
    '#submit' => array('drop_all_cdm_nodes_submit')
1458
  );
1459

    
1460
  $form['drupal_integration']['drop_all_cdm_nodes_warning_post'] = array(
1461
    '#markup' => '<div class="description">All Drupal nodes created for cdm content can be deleted at once using this button.</div>',
1462
  );
1463

    
1464
    // ----------------------
1465
  $form['cdm_js_devel_mode'] = array(
1466
      '#type' => 'checkbox',
1467
      '#title' => 'Java-script developer mode',
1468
      '#default_value' => variable_get('cdm_js_devel_mode', FALSE),
1469
      '#description' => 'In production envirionments the java script libraries
1470
      the cdm_dataportal is making use of are compressed and optimized. This
1471
      is good for performance but a caveat if you need to debug java-script. When the
1472
      java-script developer mode is enabled the uncompressed and commented developer
1473
      versions of java-script libraries will be used where possible.
1474
      <br/><strong>Do not use this option in production!</strong>'
1475
  );
1476
  // ----------------------
1477
  $form['cdm_debug_mode'] = array(
1478
      '#type' => 'checkbox',
1479
      '#title' => 'CDM page debug mode',
1480
      '#default_value' => variable_get('cdm_debug_mode', FALSE),
1481
      '#description' => 'When CDM page debug mode enabled the start and end of cdm entity page
1482
      creation is logged as well as any http request send via the cdm_api. The log is written to a file in the temporary
1483
      folder configured in the' . l('File system settings', 'admin/config/media/file-system') .
1484
       '. For this site the file is <code> ' . file_directory_temp() . '/drupal_debug.txt</code>
1485
      The log is written by the drupal devel module function <code>dd()</code>.
1486
      <br/><strong>Note:</strong> The start and end of the page creation is currently only logged for taxon pages only.'
1487
  );
1488

    
1489
  // Comment @WA: D7 form api does not support reset buttons,
1490
  // so to mimic the D5 reset button we add one like this.
1491
  $form['actions']['reset'] = array(
1492
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
1493
    '#weight' => 1000,
1494
  );
1495

    
1496
  $form['#submit'][] = 'cdm_settings_general_submit';
1497

    
1498
  return system_settings_form($form);
1499
}
1500

    
1501
/**
1502
 * Submit callback; drops all cdm nodes.
1503
 *
1504
 * @ingroup forms
1505
 */
1506
function drop_all_cdm_nodes_submit($form, &$form_state) {
1507
  cdm_delete_all_cdm_nodes();
1508
  drupal_set_message(t('All cdm nodes dropped.'));
1509
}
1510

    
1511

    
1512
/**
1513
 * LAYOUT settings
1514
 * @return
1515
 *   todo
1516
 */
1517
function cdm_settings_layout() {
1518

    
1519
  $form = array();
1520

    
1521
  $form['about'] = array(
1522
    '#markup' => '<h4>' . t('Portal Layout') . '</h4><p>' . t('This settings contains the general configurations
1523
      layout. If you want to configure the specific sites layout visit the
1524
      respective configuration site for taxon, search or media.') . '</p>',
1525
  );
1526

    
1527
  // ---- footnotes --- //
1528
  $form['footnotes'] = array(
1529
    '#type' => 'fieldset',
1530
    '#title' => t('Footnotes'),
1531
    '#collapsible' => FALSE,
1532
    '#collapsed' => FALSE,
1533
    '#description' => t('Taxa data such authors, synonyms names, descriptions,
1534
      media or distribution areas may have annotations or footnotes. When the
1535
      footnotes are enabled they will be visible (if they exist).'),
1536
  );
1537

    
1538
  $form['footnotes']['cdm_dataportal_all_footnotes'] = array(
1539
    '#type' => 'checkbox',
1540
    '#title' => t('Do not show footnotes'),
1541
    '#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
1542
    '#description' => t('Check this if you do not want to show any footnotes'),
1543
  );
1544

    
1545
  $form['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
1546
    '#type' => 'checkbox',
1547
    '#title' => t('Do not show annotation footnotes'),
1548
    '#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
1549
    '#description' => t('Check this if you do not want to show annotation footnotes'),
1550
  );
1551

    
1552
  $form['annotations'] = array(
1553
    '#type' => 'fieldset',
1554
    '#title' => t('Annotations'),
1555
    '#collapsible' => FALSE,
1556
    '#collapsed' => FALSE,
1557
    '#description' => t('This sections allows configuring global settings regarding annotations and thus will affect annotations dispayed as footnote and others.'),
1558
  );
1559

    
1560
  $annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType');
1561
  // Additional option for the NULL case.
1562
  $annotationTypeOptions['NULL_VALUE'] = t('untyped');
1563
  $annotationsTypesAsFootnotes = variable_get(ANNOTATION_TYPES_VISIBLE, unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
1564
  $form['annotations'][ANNOTATION_TYPES_VISIBLE] = array(
1565
    '#type' => 'checkboxes',
1566
    '#title' => t('Visbility of annotation types'),
1567
    '#description' => t("Only annotations of the selected type will be displayed. You may want to turn 'technical annotations' off."),
1568
    '#options' => $annotationTypeOptions,
1569
    '#default_value' => $annotationsTypesAsFootnotes
1570
  );
1571

    
1572

    
1573
  // ---- original source --- //
1574
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE] = array(
1575
      '#type' => 'fieldset',
1576
      '#tree' => TRUE,
1577
      '#title' => t('Source Citations'),
1578
      '#collapsible' => FALSE,
1579
      '#collapsed' => FALSE,
1580
  );
1581

    
1582
  $bibliography_settings = get_bibliography_settings(true);
1583

    
1584
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['enabled'] = array(
1585
      '#type' => 'checkbox',
1586
      '#title' => t('Original Source in bibliography'),
1587
      '#default_value' => $bibliography_settings['enabled'],
1588
      '#description' => t('Show original source citations in bibliography block, instead of rendering them with other
1589
       annotations in each feature block.<br/><br/>Whether the Original Source reference of a Feature Block is actually put 
1590
       into the bibliography also depends on the settings in the ' .
1591
        l("Taxon profile feature block settings", "settings/layout/taxon") .
1592
        '. For more information please refer to the description on the settings "<em>Sources as content</em>" & "<em>Sources as content to bibliography</em>" in that settings page.'),
1593
  );
1594

    
1595
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['key_format'] = array(
1596
    '#type' => 'select',
1597
    '#title' => t('The format of the key numerals'),
1598
    '#default_value' => $bibliography_settings['key_format'],
1599
    '#options' => array('latin' => 'Latin',
1600
      'ROMAN' => 'Roman (upper case)',
1601
      'roman' => 'Roman (lower case)',
1602
      'ALPHA'=> 'Alphabet (upper case)',
1603
      'alpha' => 'Alphabet (lower case)')
1604
  );
1605

    
1606
  // --- Advanced Search --- //
1607
  $form['asearch'] = array(
1608
      '#type' => 'fieldset',
1609
      '#title' => t('Advanced search'),
1610
      '#collapsible' => FALSE,
1611
      '#collapsed' => FALSE,
1612
  );
1613
  $form['asearch']['cdm_dataportal_show_advanced_search'] = array(
1614
      '#type' => 'checkbox',
1615
      '#title' => t('Show advanced search link'),
1616
      '#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
1617
      '#description' => t('Check this box if the link to advanced search should be show below the search box.'),
1618
  );
1619

    
1620
  // --- Registrations --- //
1621
  $form['registrations'] = array(
1622
    '#type' => 'fieldset',
1623
    '#title' => t('Registrations'),
1624
    '#collapsible' => FALSE,
1625
    '#collapsed' => FALSE,
1626
  );
1627
  $form['registrations']['cdm_registration_presistent_identifier_as_link'] = array(
1628
    '#type' => 'checkbox',
1629
    '#title' => t('Use the persistent http identifier as link'),
1630
    '#default_value' => variable_get('cdm_registration_presistent_identifier_as_link', 0),
1631
    '#description' => t('Switch the portal from using the drupal path <code>registration/{url encoded persistent http identifier}</code> to using the persistent http identifier directly as link.'),
1632
  );
1633

    
1634
  // ---- Taxon Name Rendering --- //
1635
  $form['taxon_name'] = array(
1636
      '#type' => 'fieldset',
1637
      '#title' => t('Taxon name display'),
1638
      '#collapsible' => TRUE,
1639
      '#collapsed' => TRUE,
1640
      '#description' => t('The display of taxon names is configured by two parts.
1641
          The <srong>name render templates</strong> define the parts of the name to be displayed in the different areas of the data portal pages.
1642
          The name parts are defined in the <stong>part definitions</strong>'),
1643
  );
1644

    
1645
  $default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT);
1646
  $default_part_definitions_pre_380_json = json_encode(unserialize(CDM_PART_DEFINITIONS_DEFAULT_PRE_380), JSON_PRETTY_PRINT);
1647
  $default_part_definition_json = json_encode($default_part_definitions, JSON_PRETTY_PRINT);
1648
  $current_part_definition_json = json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions), JSON_PRETTY_PRINT);
1649

    
1650
  $is_custom_part_definition = $default_part_definition_json != $current_part_definition_json;
1651
  if($default_part_definitions_pre_380_json == $current_part_definition_json){
1652
    $which_version_message = '(These are the old default part definition from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)';
1653
  } else if($is_custom_part_definition){
1654
      $which_version_message = '(This are custom part definitions, clearing the text area and and submitting the form will reset it to the default)';
1655
  } else  {
1656
    $which_version_message = '(These are the default part definition.)';
1657
  }
1658

    
1659
  $diff_viewer_markup = '';
1660
  if($is_custom_part_definition){
1661
    $diff_viewer_markup = diff_viewer($default_part_definition_json, $current_part_definition_json);
1662
  }
1663

    
1664
  $which_version_message = '<div style="color:#ff0000; font-weight: bold;">'
1665
    . $which_version_message
1666
    . '</div>'
1667
    . $diff_viewer_markup;
1668

    
1669
  $form['taxon_name'][CDM_PART_DEFINITIONS] = array(
1670
      '#type' => 'textarea',
1671
      '#title' => t('Part definitions'),
1672
      '#element_validate' => array('form_element_validate_json'),
1673
      '#default_value' =>  $current_part_definition_json,
1674
      '#description' => '
1675
          <p>' . $which_version_message . '</p>
1676
          <p>
1677
           The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
1678
          </p>
1679
          <p>
1680
           A full taxon name plus additional information can consist of the following elements:
1681
          <ul>
1682
             <li>name: the taxon name inclugin rank nbut without author</li>
1683
             <li>authors:  The authors of a reference, also used in taxon names</li>
1684
             <li>reference: the nomenclatural reference,</li>
1685
             <li>microreference:  Volume, page number etc.</li>
1686
             <li>status:  The nomenclatural status of a name</li>
1687
             <li>description: name descriptions like protologues etc ...</li>
1688
          </ul>
1689
          </p>
1690
          <p>
1691
           These elements are combined in the part definitions array to from the specific parts to be rendered.
1692
           (The taxon name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example in the following)
1693
           The following parts can be formed and are recognized by the system:
1694
          <ul>
1695
            <li>namePart: the name and rank (for example: "Lapsana communis")</li>
1696
            <li>authorshipPart: the author (for example: "L.")</li>
1697
            <li>nameAuthorPart: the combination of name and author part (for example: "Lapsana communis L.").</li>
1698
               This is useful for zoological names where the authorshipPart belongs to the name and both should</li>
1699
               be combined when a link to the taxon is rendered.</li>
1700
            <li>referencePart: the nomencaltural reference (for example: "Sp. Pl. 1753")</li>
1701
          <li>referenceYearPart: the publication year of the nomencaltural reference (for example: "1753")</li>
1702
            <li>microreferencePart: usually the page number (for example ": 811.")</li>
1703
            <li>statusPart: the nomenclatorical status</li>
1704
            <li>descriptionPart: name descriptions like protologues etc ...</li>
1705
          </ul>
1706
          </p>
1707
          <p>
1708
           Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
1709
           specific parts part definitions:
1710
          <ul>
1711
            <li>BotanicalName</li>
1712
            <li>ZoologicalName</li>
1713
            <li>#DEFAULT: covers ViralNames and other NonViralNames
1714
          </ul>
1715
           An example:
1716
          <pre>
1717
           {
1718
            "ZoologicalName": {
1719
              "namePart": {
1720
                "name": true
1721
              },
1722
              "referencePart": {
1723
                "authors": true
1724
              },
1725
              "microreferencePart": {
1726
                "microreference": true
1727
              },
1728
              "statusPart": {
1729
                "status": true
1730
              },
1731
              "descriptionPart": {
1732
                "description": true
1733
              }
1734
            },
1735
            "BotanicalName": {
1736
              "namePart": {
1737
                "name": true,
1738
                "authors": true
1739
              },
1740
              "referencePart": {
1741
                "reference": true,
1742
                "microreference": true
1743
              },
1744
              "secReferencePart": {
1745
                "secReference": true
1746
              },
1747
              "statusPart": {
1748
                "status": true
1749
              },
1750
              "descriptionPart": {
1751
                "description": true
1752
              }
1753
            }
1754
          }
1755
           </pre>',
1756
  );
1757

    
1758
  $default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
1759
  $default_render_templates_pre_380_json = json_encode(unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380), JSON_PRETTY_PRINT);
1760
  $default_render_templates_json = json_encode($default_render_templates, JSON_PRETTY_PRINT);
1761
  $current_render_templates_json = json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates), JSON_PRETTY_PRINT);
1762
  $is_custom_render_template = $default_render_templates_json != $current_render_templates_json;
1763

    
1764
  if($default_render_templates_pre_380_json == $current_render_templates_json){
1765
    $which_version_message = '(These are the old default render templates from before EDIT platform release 3.8.0, you may want to reset these by clearing the text area and and submitting the form.)';
1766
  } else if($is_custom_render_template){
1767
    $which_version_message = '(These are custom render templates, clearing the text area and and submitting the form will reset it to the default)';
1768
  } else {
1769
    $which_version_message = '(These are the default render templates.)';
1770
  }
1771

    
1772
  $diff_viewer_markup = '';
1773
  if($is_custom_render_template){
1774
    $diff_viewer_markup = diff_viewer($default_render_templates_json, $current_render_templates_json);
1775
  }
1776

    
1777
  $which_version_message = '<div style="color:#ff0000; font-weight: bold;">'
1778
    . $which_version_message
1779
    . '</div>'
1780
    . $diff_viewer_markup;
1781

    
1782
  $form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array(
1783
      '#type' => 'textarea',
1784
      '#title' => t('Name render templates'),
1785
      '#element_validate' => array('form_element_validate_json'),
1786
      '#default_value' =>  $current_render_templates_json,
1787
      '#description' => '
1788
          <p>' . $which_version_message . '</p>
1789
          <p>
1790
          The render templates array contains one or more name render templates to be used within the page areas identified by the
1791
          render path. The render path of taxon names can be made visible by adding the URI query parameter 
1792
          <strong><code>RENDER_PATH=1</code></strong> to the page request.<br />
1793
          The render path is used as key of the array sub subelements whereas the name render template array is set as value.
1794
          The following render Path keys are currently recognized:
1795
          <ul>
1796
            <li>list_of_taxa</li>
1797
            <li>acceptedFor</li>
1798
            <li>homonym</li>
1799
            <li>taxon_page_synonymy</li>
1800
            <li>typedesignations</li>
1801
            <li>taxon_page_title</li>
1802
            <li>polytomousKey</li>
1803
            <li>na: name + authorship</li>
1804
            <li>nar:name + authorship + reference</li>
1805
            <li>#DEFAULT</li>
1806
          </ul>
1807
          A single render template can be used for multiple render paths. In this case the according key of the render templates
1808
          array element should be a comma separated list of render paths, without any whitespace!.
1809
          </p>
1810
          <p>
1811
          A render template is an associative array. The keys of this array are referring to the keys as defined in the part
1812
          definitions array. See <a href="#edit-cdm-part-definitions">Part definitions</a> above for more information.
1813
          <p>
1814
          The value of the render template element must be set to TRUE in order to let this part being rendered.
1815
          For some parts can <strong>links</strong> can be created which lead to the accoring intity page:</br>
1816
          The <strong>namePart</strong>, <strong>nameAuthorPart</strong>, <strong>referencePart</strong> and <strong>secReferencePart</strong> can also hold an associative array with a single
1817
          element: array(\'#uri\' => TRUE). The value of the #uri element will be replaced by the according
1818
          links if the paramters $nameLink or $refenceLink are given to the name render function
1819
          (this is hard coded and cannot be configured here).',
1820
  );
1821

    
1822
  // @WA: D7 form api does not support reset buttons,
1823
  // so to mimic the D5 reset button we add one like this.
1824
  $form['actions']['reset'] = array(
1825
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
1826
    '#weight' => 1000,
1827
  );
1828

    
1829
  $form['#submit'] = array('submit_json_as_php_array');
1830
  // #json_elements especially defined for submit_json_as_php_array()
1831
  $form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
1832
  return system_settings_form($form);
1833
}
1834

    
1835

    
1836
/**
1837
 * @param $form_name
1838
 * @param $form_title
1839
 * @param $collapsed
1840
 * @param string $form_description
1841
 *   The description for the fieldset of the gallery setting.
1842
 * @return mixed
1843
 */
1844
function cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description = '') {
1845
  $form[$form_name] = array(
1846
    '#type' => 'fieldset',
1847
    '#title' => t('@form-title', array('@form-title' => $form_title)),
1848
    '#collapsible' => TRUE,
1849
    '#collapsed' => $collapsed,
1850
    '#tree' => TRUE,
1851
    '#description' => $form_description,
1852
  );
1853

    
1854
  $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
1855
  $gallery_settings = variable_get($form_name, $default_values);
1856
  // $test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
1857
  if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
1858
    /*
1859
    TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
1860
    $form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
1861
    '#type' => 'textfield',
1862
    '#title' => t('Search Page Size'),
1863
    '#default_value' => $test,
1864
    '#description' => t('Number of Names to display per page in search results.')
1865
    );
1866
    */
1867
    $form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
1868
      '#type' => 'checkbox',
1869
      '#title' => t('Show media thumbnails for accepted taxa'),
1870
      '#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
1871
    );
1872

    
1873
    $form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
1874
      '#type' => 'checkbox',
1875
      '#title' => t('Show media thumbnails for synonyms'),
1876
      '#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
1877
      '#description' => '',
1878
    );
1879
  }
1880

    
1881
  // $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
1882
  $form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
1883
    '#type' => 'checkbox',
1884
    '#title' => t('Show captions under thumbnails'),
1885
    '#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
1886
    '#description' => '',
1887
  );
1888

    
1889
  $form[$form_name]['cdm_dataportal_media_maxextend'] = array(
1890
    '#type' => 'textfield',
1891
    '#title' => t('Thumbnail size (max of width or height)') . ':',
1892
    '#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
1893
    '#description' => t('The maximum extend in either dimension, width or height, in pixels for the thumbnail images in the gallery.'),
1894
  );
1895

    
1896
  $form[$form_name]['cdm_dataportal_media_cols'] = array(
1897
    '#type' => 'textfield',
1898
    '#title' => t('Number of columns') . ':',
1899
    '#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
1900
    '#description' => t('Group the thumbnails in columns: select how many
1901
      columns the gallery should display.'),
1902
  );
1903

    
1904
  if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
1905
    $form[$form_name]['cdm_dataportal_media_maxRows'] = array(
1906
      '#type' => 'textfield',
1907
      '#title' => t('Maximum number of rows') . ':',
1908
      '#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
1909
      '#description' => t('You can group the thumbnails in rows, select in how
1910
        many rows should be the thumbnails grouped.<br/><strong>Note:</strong>
1911
        If you want an unlimited number of rows please set to 0.'),
1912
    );
1913
  }
1914

    
1915
  return $form;
1916
}
1917

    
1918
/**
1919
 * @todo document this function.
1920
 */
1921
function cdm_settings_layout_taxon() {
1922
  $collapsed = FALSE;
1923
  $form = array();
1924

    
1925
  $form['#submit'][] = 'cdm_settings_layout_taxon_submit';
1926

    
1927
  // --------- TABBED TAXON ------- //
1928
  $form['taxon_tabs'] = array(
1929
    '#type' => 'fieldset',
1930
    '#title' => t('Taxon tabs'),
1931
    '#collapsible' => TRUE,
1932
    '#collapsed' => TRUE,
1933
    '#description' => 'A taxon page consists of various sections, that is content blocks, each displaying a different kind of information.'
1934
  );
1935

    
1936
  $form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
1937
    '#type' => 'checkbox',
1938
    '#title' => t('Tabbed taxon page'),
1939
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
1940
    '#description' => t('If enabled the sections of a taxon page will be displayed as individual tabs'),
1941
  );
1942

    
1943
  $form['taxon_tabs'][CDM_SYNONYMY_AS_TAB] = array(
1944
    '#type' => 'checkbox',
1945
    '#title' => t('Synonymy as tab'),
1946
    '#default_value' => variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT),
1947
    '#description' => t('The synonymy can be moved to its own tab. This is only applicable when the tabbed taxon page option is activated.'),
1948
    '#disabled' =>  variable_get('cdm_dataportal_taxonpage_tabs', 1) !== 1
1949
  );
1950

    
1951
  $form['taxon_tabs']['cdm_taxonpage_tabs_visibility'] = array(
1952
    '#type' => 'checkboxes',
1953
    '#title' => t('Section/Tab visibility') . ':',
1954
    '#default_value' => variable_get('cdm_taxonpage_tabs_visibility', get_taxon_options_list()),
1955
    '#options' => get_taxon_options_list()
1956
  );
1957

    
1958
  // WEIGHT
1959
  $taxon_tabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
1960
  $form['taxon_tabs'][CDM_TAXONPAGE_TAB_WEIGHT] = array(
1961
    '#title'  => 'Section/Tab order',
1962
    '#type' => 'fieldset',
1963
    '#collapsible' => false,
1964
    '#tree' => true,
1965
    '#description' => 'The weight value defines the order of the section/tab.'
1966
  );
1967
  // Weights range from -delta to +delta, so delta should be at least half
1968
  // of the amount of tabs present.
1969
  $tab_weight_delta = round(count(get_taxon_tabs_list()) / 2) + 1;
1970
  foreach (get_taxon_tabs_list() as $label) {
1971
    $key = strtolower($label); // turn in to string, since we need to use strings as keys
1972
    $form['taxon_tabs'][CDM_TAXONPAGE_TAB_WEIGHT][$key] = array(
1973
        '#title' => $label,
1974
        '#type'  => 'weight',
1975
        '#default_value' => $taxon_tabs_weights[$key],
1976
        '#delta' => $tab_weight_delta
1977
    );
1978
  }
1979

    
1980
  $taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
1981
  $form['taxon_tabs'][CDM_TAXONPAGE_TAB_LABELS] = array(
1982
    '#title'  => 'Section/Tab label override',
1983
    '#type' => 'fieldset',
1984
    '#collapsible' => false,
1985
    '#tree' => true,
1986
    '#description' => 'Setting a label for a section/tab will override the default label. 
1987
      Please enter the label text in the default language of the portal.'
1988
  );
1989
  foreach (get_taxon_tabs_list() as $label) {
1990
    $key = strtolower($label); // turn in to string, since we need to use strings as keys
1991
    $form['taxon_tabs'][CDM_TAXONPAGE_TAB_LABELS][$key] = array(
1992
      '#title' => $label,
1993
      '#type'  => 'textfield',
1994
      '#default_value' => $taxon_tabs_labels[$key]
1995
    );
1996
  }
1997

    
1998
  $form['taxon_tabs']['cdm_dataportal_default_tab'] = array(
1999
    '#type' => 'select',
2000
    '#title' => t('Default tab to display') . ':',
2001
    '#default_value' => variable_get('cdm_dataportal_default_tab', 0),
2002
    '#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
2003
    '#description' => t('<p>Select the default tab to display when visiting a
2004
      taxon page. Only available if Tabbed Taxon Page is enable.</p>
2005
      <strong>Note:</strong> After performing a search and clicking in any
2006
      synonym, the taxon tab to be rendered will be the synonymy of the accepted
2007
      taxon and not the above selected tab.'),
2008
  );
2009

    
2010
  /* ======  TAXON_PROFILE ====== */
2011
  $form['taxon_profile'] = array(
2012
    '#type' => 'fieldset',
2013
    '#title' => t('Taxon profile (tab)'),
2014
    '#description' => t('<p>This section covers the settings related to the taxon
2015
      profile tab, also known as the <strong>"General"</strong> tab.</p>'),
2016
    '#collapsible' => TRUE,
2017
    '#collapsed' => TRUE,
2018
  );
2019

    
2020
  // ---- PROFILE PICTURE ----//
2021

    
2022
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE] = array(
2023
    '#type' => 'fieldset',
2024
    '#tree' => TRUE,
2025
    '#title' => t('Taxon profile picture'),
2026
    '#collapsible' => TRUE,
2027
    '#collapsed' => FALSE,
2028
    '#description' => t('This sections allows configuring the display of the so called taxon profile image which is displayed in the taxon profile tab.'),
2029
  );
2030

    
2031
  //FIXME migrate variables:
2032
  //  cdm_dataportal_show_default_image ---> CDM_TAXON_PROFILE_IMAGE['show']
2033
  // FIXME
2034
  //  enable file module in profile and in update,(a.kohlbecker, 4.9.2014: is this still an open issue?)
2035

    
2036
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
2037

    
2038
  /*
2039
   * 'show' => 1,
2040
   * 'maxextend' => 184,
2041
   * 'media_uri_query' => ''
2042
   * 'custom_placeholder_image_on' => 1,
2043
   * 'custom_placeholder_image_fid' => ''
2044
   */
2045
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['show'] = array(
2046
    '#type' => 'checkbox',
2047
    '#title' => t('Enable profile picture'),
2048
    '#description' => t('Show the profile picture.'),
2049
    '#default_value' => $taxon_profile_image_settings['show'],
2050
  );
2051

    
2052
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['maxextend'] = array(
2053
      '#type' => 'textfield',
2054
      '#tree' => TRUE,
2055
      '#title' => t('Profile picture maximum extend'),
2056
      '#default_value' =>  $taxon_profile_image_settings['maxextend'],
2057
      '#field_suffix' => 'px',
2058
      '#maxlength' => 4,
2059
      '#size' => 4,
2060
      '#description' => t('The maximum extend in either dimension, width or height, of the profile picture in pixels.')
2061
  );
2062

    
2063
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array(
2064
      '#type' => 'textfield',
2065
      '#tree' => TRUE,
2066
      '#title' => t('Additional URI query parameter'),
2067
      '#default_value' =>  $taxon_profile_image_settings['media_uri_query'],
2068
      '#maxlength' => 1024,
2069
      '#size' => 60,
2070
      '#description' => t('Additional query parameters to be used when requesting for the  
2071
            profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.
2072
            The query parameters will be appended to the uri of the media representation part
2073
            as stored in the cdm. The query parameter string must not start with a \'&\' or  \'?\'')
2074
  );
2075

    
2076
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_enabled'] = array(
2077
    '#type' => 'checkbox',
2078
    '#title' => t('Show the placeholder image'),
2079
    '#description' => t("A placeholder image will be shown if no taxon profile picture is available."),
2080
    '#default_value' => $taxon_profile_image_settings['custom_placeholder_enabled']
2081
  );
2082

    
2083
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array(
2084
      '#type' => 'checkbox',
2085
      '#title' => t('Use a custom placeholder image'),
2086
      '#description' => t("This image is shown as replacement if no image of the taxon is available."),
2087
      '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_on']
2088
  );
2089

    
2090
  if($taxon_profile_image_settings['custom_placeholder_image_on'] == 1){
2091
    $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
2092
        '#type' => 'managed_file',
2093
        '#title' => t('Custom placeholder image file'),
2094
        '#progress_indicator' => 'bar',
2095
        '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid'],
2096
    //       '#name' => 'custom_placeholder_image',
2097
        '#upload_location' => 'public://' . CDM_TAXON_PROFILE_IMAGE .'/'
2098
    );
2099

    
2100
    if($taxon_profile_image_settings['custom_placeholder_image_fid']){
2101
      $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
2102
      $url = file_create_url($profile_image_file->uri);
2103
      $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['preview'] = array(
2104
                '#type' => 'item',
2105
                '#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
2106
      );
2107
    }
2108
  } else {
2109
    $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
2110
      '#type' => 'hidden',
2111
      '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid']
2112
    );
2113
  }
2114

    
2115
  $options = cdm_vocabulary_as_option(UUID_RANK, null, true);
2116
  array_unshift($options, '-- DISABLED --');
2117
  $form['taxon_profile']['picture']['image_hide_rank'] = array(
2118
    '#type' => 'select',
2119
    '#title' => t('Hide profile picture for higher ranks') . ':',
2120
    '#default_value' => variable_get('image_hide_rank', '0'),
2121
    '#options' => $options,
2122
    '#description' => t('The taxon profile picture will not be shown for taxa with rank higher that the selected.'),
2123
  );
2124

    
2125
  // -- MEDIA THUMBNAILS -- //
2126
  $form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
2127
  $form_title = 'Taxon Profile Images';
2128
  $form_description = '<p>The different sections 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>';
2129
  $form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
2130

    
2131
  // ---- FEATURE TREE BLOCKS ---- //
2132
  $form['taxon_profile']['feature_blocks'] = array(
2133
    '#type' => 'fieldset',
2134
    '#title' => t('Feature Blocks'),
2135
    '#collapsible' => TRUE,
2136
    '#collapsed' => FALSE,
2137
    '#description' => t("This section covers settings related to the taxon's
2138
      <em>Feature Tree</em>. The <em>feature tree</em> are the taxon's
2139
      features such as description, distribution, common names"),
2140
  );
2141
  $featureTrees = cdm_get_featureTrees_as_options(TRUE);
2142
  $profile_feature_tree = get_profile_feature_tree();
2143
  $profile_feature_tree_uuid = $profile_feature_tree->uuid;
2144
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2145
    $profile_feature_tree_uuid = UUID_DEFAULT_FEATURETREE;
2146
  }
2147
  $form['taxon_profile']['feature_blocks'][CDM_PROFILE_FEATURETREE_UUID] = array(
2148
    '#type' => 'radios',
2149
    '#title' => t('Taxon profile feature tree') . ':',
2150
    '#default_value' => $profile_feature_tree_uuid,
2151
    '#options' =>  $featureTrees['options'],
2152
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2153
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2154
    '#description' => t('The Feature Tree selected here define the feature blocks which are visible in the taxon
2155
      profile page.'
2156
    ),
2157
  );
2158

    
2159
  // ---- FEATURE TREE BLOCKS > LAYOUT PER FEATURE BLOCK ---- //
2160
  $profile_feature_tree = get_profile_feature_tree();
2161

    
2162
  if (isset($profile_feature_tree->root->childNodes)) {
2163

    
2164
    $form_feature_block_layout = array(
2165
      '#type' => 'fieldset',
2166
      '#tree' => true,
2167
      '#title' => t('Taxon profile feature block settings'),
2168
      '#collapsible' => TRUE,
2169
      '#collapsed' => FALSE,
2170
      '#description' => 'This section let\'s you define how each of the feature blocks is displayed.
2171
      A sub form is for each of the features of currently selected feature tree allows to configre each feature block individually.
2172
      The subforms have the following settings in common:<br />
2173
      <h6>List type:</h6><div>Whether the description elements are displayed as list or not. Three different list types are available</div>
2174
      <h6>Link to reference:</h6><div>Render the reference as link, ignored if the element is NOT a DescriptionElementSource</div>
2175
      <h6>Link to name used in source:</h6><div>Whether to show name in source information as link which will point to the according name page</div>
2176
      <h6>Sources as content:</h6><div><strong>If enabled:</strong><br />
2177
            <ol>
2178
            <li>If the element is a CDM TextData instance and if the text is not empty the source references will be
2179
                appended in brackets like "text (source references)". If the original source has name in source
2180
                information it will be appended to the citation string,
2181
                like : "(citation-A, as name-in-source-A; citation-B, as name-in-source-B)"</li>
2182
             <li>if the text of the TextData is empty, the original source citations are the only content
2183
                (e.g. use case CITATION) and are not put into brackets. In this case the nameInSource is
2184
                prepended to the citation string like: "name in source: citation"</li>
2185
            </ol>
2186
            <strong>If disabled:</strong><br />
2187
             Original sources are put into the bibliography(=references) pseudo feature block. If the original source
2188
             citations are the only content, the resulting feature block content would only consist of footnotes.
2189
             In this case the display of the respective feature block is suppressed.</div>
2190
      </dl>
2191
      <h6>Sources as content to bibliography:</h6><div>Only valid if <em>Sources as content</em> is enabled, will cause the sources to be also shown
2192
           in the bibliography. For this to work the bibliography must be enabled the <em>' .l(
2193
            'Layout Settings', 'admin/config/cdm_dataportal/settings/layout', array('fragment'=>'edit-bibliography-for-original-source'))
2194
        . '</em></div>
2195
      <h6>Sort elements:</h6><div>Whether and how to sort the elements
2196
           possible values are the constants SORT_ASC, SORT_DESC, NULL,
2197
           some feature types (Distribution) also support: SORT_HIERARCHICAL</div>
2198
      <h6>Element tag:</h6><div>The tag to be used for creating the elements, only applies if "List type" is set to <em>No list</em>
2199
           possible values are span or div. Developers: The proper inner tag name can be retrieved by the function
2200
           cdm_feature_block_element_tag_name()</div>
2201
       <h6>Element glue:</h6><div>This string is used to concatenate individual items together. The glue is ignored when the items are displayed 
2202
           as list.<b>NOTE:</b>The glue is not yet fully implemented for all features and thus may not work as expected, see '
2203
           . l('#6831', 'https://dev.e-taxonomy.eu/redmine/issues/6831') . '</div>',
2204
    );
2205

    
2206

    
2207
    $feature_list_layout_settings_disabled = FALSE;
2208

    
2209
    // creating helper object to retrieve the default settings
2210
    $featureNode = new stdClass();
2211
    $featureNode->term = new stdClass();
2212
    $featureNode->term->uuid="DEFAULT";
2213
    $featureNode->term->representation_L10n = "Default";
2214
    array_unshift($profile_feature_tree->root->childNodes, $featureNode);
2215

    
2216
    foreach ($profile_feature_tree->root->childNodes as $featureNode) {
2217

    
2218
      if (!$feature_list_layout_settings_disabled && isset($featureNode->term)) {
2219

    
2220
        // $subform_id must not exceed 45 characters, a uuid has 36 characters
2221
        $subform_id = $featureNode->term->uuid;
2222
        $feature_block_setting = get_feature_block_settings($featureNode->term->uuid);
2223

    
2224
//        $settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
2225

    
2226
        $form_feature_block_layout[$subform_id] = array(
2227
          '#type' => 'fieldset',
2228
          '#tree' => TRUE,
2229
          '#title' => $featureNode->term->representation_L10n,
2230
          '#collapsible' => FALSE,
2231
          '#collapsed' => FALSE,
2232
        );
2233
        if($featureNode->term->uuid == "DEFAULT"){
2234
          $form_feature_block_layout[$subform_id]['#description']='These are the defaults which apply to
2235
          all feature blocks for which no specific settings have been defined. for consistency enabling links for <em>source
2236
          references</em> and <em>names in source</em> is only possible in the defaults';
2237
        }
2238

    
2239
        $form_feature_block_layout[$subform_id]['as_list'] = array(
2240
          '#type' => 'select',
2241
          '#title' => 'List type',
2242
          '#default_value' => $feature_block_setting['as_list'],
2243
          '#options' => array(
2244
            'div' => 'not as list',
2245
            'ul' => 'bullet list',
2246
            'ol' => 'numbered list',
2247
            'dl' => 'definition list'
2248
          ),
2249
        );
2250

    
2251
        if($featureNode->term->uuid == "DEFAULT"){
2252
          $form_feature_block_layout[$subform_id]['link_to_reference'] = array(
2253
            '#type' => 'checkbox',
2254
            '#title' => t('Link to reference'),
2255
            '#default_value' => $feature_block_setting['link_to_reference'],
2256
          );
2257

    
2258
          $form_feature_block_layout[$subform_id]['link_to_name_used_in_source'] = array(
2259
            '#type' => 'checkbox',
2260
            '#title' => 'Link to name used in source',
2261
            '#default_value' => $feature_block_setting['link_to_name_used_in_source'],
2262
          );
2263
        }
2264

    
2265
        $form_feature_block_layout[$subform_id]['sources_as_content'] = array(
2266
          '#type' => 'checkbox',
2267
          '#title' => 'Sources as content',
2268
          '#default_value' => $feature_block_setting['sources_as_content'],
2269
        );
2270

    
2271
        $form_feature_block_layout[$subform_id]['sources_as_content_to_bibliography'] = array(
2272
          '#type' => 'checkbox',
2273
          '#title' => 'Put sources also as content to bibliography',
2274
          '#default_value' => $feature_block_setting['sources_as_content_to_bibliography'],
2275
        );
2276

    
2277
        $form_feature_block_layout[$subform_id]['sort_elements'] = array(
2278
          '#type' => 'select',
2279
          '#title' => t('Sort elements'),
2280
          '#default_value' => $feature_block_setting['sort_elements'],
2281
          '#options' => array(
2282
            NO_SORT => 'No sorting',
2283
            SORT_ASC => 'Ascending',
2284
            SORT_DESC => 'Descending',
2285
            SORT_HIERARCHICAL => 'Hierarchical'
2286
          ),
2287
          '#description' => 'NOT YET FULLY USED! only in preparation (works partially for distributions)
2288
          <dl>
2289
          <dr><dt>No sorting</dt><dd>Sorting undefined</dd></dr>
2290
          <dr><dt>Ascending</dt><dd>Alphabetically in ascending order</dd></dr>
2291
          <dr><dt>Descending</dt><dd>Alphabetically in descending order</dd></dr>
2292
          <dr><dt>Hierarchical</dt><dd>Use the order of items and their hierarchy. This is not possible for all feature and item types.</dd></dr>
2293
          </dl>',
2294
        );
2295

    
2296
        $form_feature_block_layout[$subform_id]['element_tag'] = array(
2297
          '#type' => 'select',
2298
          '#title' => t('Element tag'),
2299
          '#options' => array(
2300
            'span' => 'span',
2301
            'div' => 'div',
2302
            'p' => 'p'
2303
          ),
2304
          '#default_value' => $feature_block_setting['element_tag'],
2305
        );
2306
        $form_feature_block_layout[$subform_id]['glue'] = array(
2307
          '#type' => 'textfield',
2308
          '#title' => t('Element glue'),
2309
          '#default_value' => $feature_block_setting['glue'],
2310
          '#size' => 10
2311
      );
2312

    
2313
      }
2314
      $form['taxon_profile']['feature_blocks'][FEATURE_BLOCK_SETTINGS] = $form_feature_block_layout;
2315
    }
2316
  }
2317

    
2318
  // ---- STRUCTURED DESCRIPTION FEATURE TREE ---- //
2319
  $form['taxon_profile']['structured_description_featuretree'] = array(
2320
    '#type' => 'fieldset',
2321
    '#title' => t('Structured Description Feature Tree'),
2322
    '#collapsible' => TRUE,
2323
    '#collapsed' => FALSE,
2324
  );
2325
  $featureTrees = cdm_get_featureTrees_as_options();
2326
  $profile_feature_tree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
2327
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2328
    $profile_feature_tree_uuid = NULL;
2329
  }
2330
  $form['taxon_profile']['structured_description_featuretree'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
2331
    '#type' => 'radios',
2332
    '#title' => t('Natural language representation of structured descriptions') . ':',
2333
    '#default_value' => $profile_feature_tree_uuid,
2334
    '#options' => $featureTrees['options'],
2335
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2336
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2337
    '#description' => t('Taxon descriptions can be stored in a highly structured
2338
      form. The feature tree selected here will be used to generate textual
2339
      representation in natural language.'
2340
    ),
2341
  );
2342

    
2343

    
2344

    
2345
  // ---- DISTRIBUTION LAYOUT ---- //
2346
  $form['taxon_profile']['distribution_layout'] = array(
2347
    '#title' => t('Distribution'),
2348
    '#collapsible' => TRUE,
2349
    '#collapsed' => FALSE,
2350
    '#type' => 'fieldset',
2351
    '#description' => 'This section covers general settings regarding the textual representation of distributions and the visibility of the map.
2352
        Map settings regarding the geometry, layers, etc are found in the '
2353
      . l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
2354
      '. Further settings regarding the distribution feature block can be found in above in this tab at '
2355
      . l(
2356
        'Taxon profile feature block settings', 'admin/config/cdm_dataportal/settings/layout/taxon',
2357
        array('fragment' => 'edit-feature-block-settings')
2358
      )
2359
      . ' More general settings regrading the filtering of Distributions are found at '
2360
      . l('Distribution appearance', 'admin/config/cdm_dataportal/settings', array('fragment' => 'edit-distribution'))
2361
      . '. (These settings here will be merged in future releases into the feature block settings)',
2362

    
2363
  );
2364

    
2365
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_MAP_VISIBILITY] = _cdm_map_visibility_setting('distribution');
2366

    
2367
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED] = array(
2368
    '#type' => 'checkbox',
2369
    '#title' => t('Condensed distribution'),
2370
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED, 0),
2371
    '#description' => 'This option enables the display of a very compact representation
2372
    of the distribution which includes also information on the status.',
2373
  );
2374

    
2375
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED_RECIPE] = array(
2376
    '#type' => 'select',
2377
    '#title' => t('Condensed distribution recipe'),
2378
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED_RECIPE, DISTRIBUTION_CONDENSED_RECIPE_DEFAULT),
2379
    '#options' => array('EuroPlusMed' => 'Euro+Med', 'FloraCuba' => 'Flora of Cuba'),
2380
    '#description' => 'Recipe for creating the condensed distribution.',
2381
  );
2382

    
2383
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED_INFO_PATH] = array(
2384
    '#type' => 'textfield',
2385
    '#title' => t('Condensed distribution info path'),
2386
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED_INFO_PATH, DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT),
2387
    '#description' => 'By default the help page ' .l(DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT, DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT)
2388
      . ' is used as target for the info link which is shown at the end of the condensed distribution string.',
2389
  );
2390

    
2391

    
2392
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_ORDER_MODE] = array(
2393
    '#type' => 'radios',
2394
    '#title' => t('Display mode') . ':',
2395
    '#default_value' => variable_get(DISTRIBUTION_ORDER_MODE, DISTRIBUTION_ORDER_MODE_DEFAULT),
2396
    '#options' => array(
2397
      'FLAT_ALPHA' => t('Flat list'),
2398
      'TREE' => t('Hierarchically ordered'),
2399
    ),
2400
    '#description' => 'Taxon distribution information is displayed with
2401
    focus on the area of the distribution. The list of areas can either be shown
2402
    as flat list ordered alphabetically or in the hierarchical of the parent
2403
    area and subarea relationship. Fall back areas areas with no Distribution data
2404
    are hidden from the area hierarchy so that their sub areas will move one level up.
2405
    See ' . l('Distribution appearance', 'admin/config/cdm_dataportal/settings', array('fragment' => 'edit-distribution')) .
2406
    ' for details on the <em>Marked area filter</em>.',
2407
  );
2408

    
2409
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE] = array(
2410
    '#type' => 'fieldset',
2411
    '#tree' => true,
2412
    '#title' => t('Distribution hierarchy style')
2413
  );
2414

    
2415
  $hierarchy_styles = get_array_variable_merged(DISTRIBUTION_HIERARCHY_STYLE, DISTRIBUTION_HIERARCHY_STYLE_DEFAULT);
2416
  foreach(array_keys($hierarchy_styles) as $level) {
2417
    $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE][$level] = array(
2418
      '#type' => 'fieldset',
2419
      '#tree' => true,
2420
      '#title' => t('@area-level', array('@area-level' => drupal_ucfirst((str_replace('_', ' ', $level))))),
2421
      '#attributes' => array('class' => array('fieldset-float'))
2422
    );
2423
    foreach ($hierarchy_styles[$level] as $key => $value) {
2424
      $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE][$level][$key] = array(
2425
        '#type' => 'textfield',
2426
        '#title' => t('@area-level-style', array('@area-level-style' => drupal_ucfirst((str_replace('_', ' ', $key))))),
2427
        '#default_value' => $hierarchy_styles[$level][$key],
2428
        '#maxlength' => 4,
2429
        '#size' => 4
2430
      );
2431
    }
2432
  }
2433

    
2434
  $level_options = cdm_vocabulary_as_option(UUID_NAMED_AREA_LEVEL, NULL, FALSE, NULL, CDM_ORDER_BY_ORDER_INDEX_ASC);
2435
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_TREE_OMIT_LEVELS] = array(
2436
    '#type' => 'checkboxes',
2437
    '#title' => 'Omit area levels',
2438
    '#options' => $level_options,
2439
    '#default_value' => variable_get(DISTRIBUTION_TREE_OMIT_LEVELS, array()),
2440
    '#description' => 'This option ins only applicable when distributions are hierachically orderd (see option above)!
2441
    Areas which belong to the selected area levels will be hidden in the portal.',
2442
  );
2443

    
2444
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] = array(
2445
    '#type' => 'checkbox',
2446
    '#title' => t('Show TextData elements on top of the map'),
2447
    '#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
2448
    '#description' => t('Check this if you want to appear all <code>TextData</code>
2449
      elements on top of the map. Otherwise all <code>TextData</code>
2450
      distribution elements will be listed below the other area elements.
2451
      This option is useful if you need to have descriptive texts for each
2452
      distribution map.'),
2453
  );
2454

    
2455
  $form['taxon_profile'][DISTRIBUTION_STATUS_COLORS] = array(
2456
      '#type' => 'textarea',
2457
      '#title' => t('Custom status colors'),
2458
      '#element_validate' => array('form_element_validate_json'),
2459
      '#default_value' => variable_get(DISTRIBUTION_STATUS_COLORS, ''),
2460
      '#description' => t('<strong>EXPERIMENTAL!</strong><br/>This may be changed in the next release without notification.
2461
          A json map object with StatusTerm.idInVocabulary as key and a hex color as value. e.g: <code>{"n":"#ff0000","p":"#00ff00"}</code>.
2462
          reference list of the idInVocabulary values of absence and presence terms:
2463
<pre>
2464
Presence Term
2465
p        present
2466
pd        present: doubtfully present
2467
n        native
2468
nq        native: presence questionable
2469
nd        native: doubtfully native
2470
c        cultivated
2471
i        introduced
2472
iq        introduced: presence questionable
2473
id        introduced: doubtfully introduced (perhaps cultivated only)
2474
ip        introduced: uncertain degree of naturalisation
2475
ia        introduced: adventitious (casual)
2476
in        introduced: naturalized
2477
ic        introduced: cultivated
2478
e        endemic for the relevant area
2479
na        naturalised
2480
iv        invasive
2481

2482
AbsenceTerm
2483
a        absent
2484
f        reported in error
2485
nf        native: reported in error
2486
if        introduced: reported in error
2487
cf        cultivated: reported in error
2488
ne        native: formerly native
2489
ie        introduced: formerly introduced
2490

2491
</pre>'),
2492
  );
2493

    
2494

    
2495
  /* ====== SYNONYMY ====== */
2496
  $form['taxon_synonymy'] = array(
2497
    '#type' => 'fieldset',
2498
    '#title' => t('Taxon synonymy (tab)'),
2499
    '#collapsible' => TRUE,
2500
    '#collapsed' => TRUE,
2501
    '#description' => t('This section covers the settings related to the taxon
2502
      <strong>synonymy</strong> tab.'),
2503
  );
2504

    
2505
  $form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
2506
    '#type' => 'checkbox',
2507
    '#title' => t('Accepted taxon on top of the synonymy'),
2508
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
2509
    '#description' => t('If checked, the first homotypic taxon is a repetition
2510
      of the accepted taxon most likely with the full nomenclatural reference, 
2511
      depending on the ' . l('Name render templates', 'admin/config/cdm_dataportal/settings/layout') . '.'),
2512
  );
2513

    
2514
  $form['taxon_synonymy'][CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE] = array(
2515
    '#type' => 'checkbox',
2516
    '#title' => t('Secundum referenence as separate line above the accepted taxon.'),
2517
    '#default_value' => variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE, 0),
2518
    '#description' => t('You may want to remove the <code>"secReferencePart": true,</code> entry from <code>"accepted_taxon.taxon_page_synonymy"{</code> the in the '
2519
      . l('Name render templates', 'admin/config/cdm_dataportal/settings/layout')
2520
      . ' (Only applicable when the "Show accepted taxon on top of the synonymy" option above is enabled.)'),
2521
    '#disabled' =>  !variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE)
2522
  );
2523

    
2524
  $form['taxon_synonymy'][CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL] = array(
2525
    '#type' => 'textfield',
2526
    '#description' => 'Label for the secundum referenence.',
2527
    '#default_value' => variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL, CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL_DEFAULT),
2528
    '#disabled' =>  !variable_get('cdm_dataportal_nomref_in_title', 0)
2529
    );
2530

    
2531
  $form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
2532
    '#type' => 'checkbox',
2533
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when
2534
      coming from a synonym link.'),
2535
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
2536
    '#description' => t('Check this if after doing a search and clicking on a
2537
      synonym you want to see the "accept of" text for the accepted synonym.'),
2538
  );
2539

    
2540
  /* === currently unused ===
2541
  $nameRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
2542
  $form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array(
2543
    '#type' => 'checkboxes',
2544
    '#title' => t('Display name relationships') . ':',
2545
    '#default_value' => variable_get('name_relationships_to_show', 0),
2546
    '#options' => $nameRelationshipTypeOptions,
2547
    '#description' => t('Select the name relationships you want to show for the
2548
      accepted taxa.'),
2549
  );
2550
 */
2551

    
2552
  $form['taxon_synonymy']['taxon_relations'] = array(
2553
    '#type' => 'fieldset',
2554
    '#title' => t('Taxon relationships'),
2555
    '#collapsible' => FALSE,
2556
    '#collapsed' => FALSE
2557
  );
2558

    
2559
  $form['taxon_synonymy']['taxon_relations'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
2560
    '#type' => 'checkbox',
2561
    '#title' => t('Show taxon relations ships of accepted taxon'),
2562
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
2563
    '#description' => t('If this option is enabled the synonymy will show the
2564
      below selected taxon relationships of accepted taxa.'),
2565
  );
2566

    
2567
  $taxon_relationship_type_options = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
2568
  $taxon_relationship_type_defaults = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
2569
  $form['taxon_synonymy']['taxon_relations'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
2570
    '#type' => 'checkboxes',
2571
    '#title' => t('Taxon relationship types') . ':',
2572
    '#description' => t('Only taxon relationships of the selected type will be
2573
      displayed'),
2574
    '#options' => $taxon_relationship_type_options,
2575
    '#default_value' => $taxon_relationship_type_defaults,
2576
    '#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
2577
  );
2578

    
2579
  $form['taxon_synonymy']['name_relations'] = array(
2580
    '#type' => 'fieldset',
2581
    '#title' => t('Name relationships'),
2582
    '#collapsible' => FALSE,
2583
    '#collapsed' => FALSE
2584
  );
2585

    
2586
  $name_relationship_type_options = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
2587
  $form['taxon_synonymy']['name_relations'][CDM_NAME_RELATIONSHIP_TYPES] = array(
2588
    '#type' => 'checkboxes',
2589
    '#title' => t('Name relationship types') . ':',
2590
    '#description' => t('Only name relationships of the selected type will be
2591
      displayed'),
2592
    '#options' => $name_relationship_type_options,
2593
    '#default_value' => variable_get(CDM_NAME_RELATIONSHIP_TYPES, unserialize(CDM_NAME_RELATIONSHIP_TYPES_DEFAULT)),
2594
  );
2595

    
2596
  // ====== SPECIMENS ====== //
2597
  $form['taxon_specimens'] = array(
2598
    '#type' => 'fieldset',
2599
    '#title' => t('Taxon specimens (tab)'),
2600
    '#collapsible' => TRUE,
2601
    '#collapsed' => TRUE,
2602
    '#description' => t('This section covers the settings related to the taxon
2603
      <strong>specimens</strong> tab.'),
2604
  );
2605

    
2606
  $form['taxon_specimens'][SPECIMEN_MAP_VISIBILITY]  = _cdm_map_visibility_setting('specimen');
2607

    
2608
  $form['taxon_specimens']['cdm_dataportal_compressed_specimen_derivate_table'] = array(
2609
    '#type' => 'checkbox',
2610
    '#title' => t('Show specimen derivatives in a compressed table'),
2611
    '#default_value' => variable_get('cdm_dataportal_compressed_specimen_derivate_table', CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE),
2612
    '#description' => t('If checked, the specimen will be listed in a table. Every row represents
2613
    a collection and it can be expanded to get an overview of the specimens and their derivates.'),
2614
  );
2615

    
2616
  $form['taxon_specimens']['cdm_dataportal_compressed_specimen_derivate_table_page_size'] = array(
2617
      '#type' => 'textfield',
2618
      '#title' => t('Number of records per page') . ':',
2619
      '#default_value' => variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size', CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_PAGE_SIZE),
2620
  );
2621

    
2622
    $form['taxon_specimens']['cdm_dataportal_specimen_derivate_tree'] = array(
2623
        '#type' => 'checkbox',
2624
        '#title' => t('Show specimen derivatives in a tree view'),
2625
        '#default_value' => variable_get('cdm_dataportal_specimen_derivate_tree', CDM_DATAPORTAL_SPECIMEN_DERIVATE_TREE),
2626
        '#description' => t('If checked, the specimen will be listed in a tree view.'),
2627
    );
2628

    
2629

    
2630
    $featureTrees = cdm_get_featureTrees_as_options(TRUE);
2631
  $profile_feature_tree_uuid = variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
2632
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2633
    $profile_feature_tree_uuid = UUID_DEFAULT_FEATURETREE;
2634
  }
2635
  $form['taxon_specimens']['feature_trees'][CDM_OCCURRENCE_FEATURETREE_UUID] = array(
2636
    '#type' => 'radios',
2637
    '#title' => t('Specimen description feature tree') . ':',
2638
    '#default_value' => $profile_feature_tree_uuid,
2639
    '#options' =>  $featureTrees['options'],
2640
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2641
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2642
    '#description' => t('Select the feature tree to be used for displaying specimen descriptions. Click "Show Details" to see the Feature Tree elements.'
2643
    ),
2644
  );
2645

    
2646
  $form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
2647
  $form_title = t('Specimen media');
2648
  $form_description = t('Specimens may have media which is displayed at the
2649
     Specimen tab/section as a gallery. It is possible to configure the
2650
     thumbnails gallery here, however for configuring how a single media should
2651
     be displayed please go to !url.</p>',
2652
     array(
2653
       '!url' => l(t('Layout -> Media'), 'admin/config/cdm_dataportal/settings/layout/media'),
2654
     ));
2655
  $form['taxon_specimens'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
2656

    
2657
  // --- MEDIA GALLERY ---- //
2658
  $form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
2659
  $form_title = 'Media gallery (tab)';
2660
  $form_description = '<p>This section covers the settings related to the taxon <strong>images</strong> tab.
2661
   Taxa may have media (usually images) and they are displayed as thumbnails. It is possible to configure
2662
   the thumbnails gallery here, however for configuring how a single media should be displayed please go to
2663
   <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a></p>
2664
   <p><strong>Note:</strong> These settings are only taken into account when the standard
2665
   gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a>.</p>';
2666
  $form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
2667

    
2668
  // Comment @WA: D7 form api does not support reset buttons,
2669
  // so to mimic the D5 reset button we add one like this.
2670
  $form['actions']['reset'] = array(
2671
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2672
    '#weight' => 1000,
2673
  );
2674
  return system_settings_form($form);
2675
}
2676

    
2677
/**
2678
 * Creates a form element for the constants DISTRIBUTION_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY.
2679
 *
2680
 * @param $map_id
2681
 * @param $form
2682
 * @return mixed
2683
 */
2684
function _cdm_map_visibility_setting($map_id)
2685
{
2686
  return array(
2687
    '#type' => 'select',
2688
    '#title' => t(ucfirst($map_id) . ' map visibility'),
2689
    '#default_value' => variable_get(constant(strtoupper($map_id) . '_MAP_VISIBILITY'), constant(strtoupper($map_id) . '_MAP_VISIBILITY_DEFAULT')),
2690
    '#options' => array('always' => 'always', 'automatic' => 'automatic', 'never' => 'never'),
2691
    '#description' => "The visibility of the map can managed <b>automatically</b> depending on whether there is data to show or not. 
2692
        The map also can forced to show up <b>always</b> or <b>never</b>."
2693
  );
2694
}
2695

    
2696
/**
2697
 * @todo document this function.
2698
 */
2699
function cdm_settings_layout_search() {
2700

    
2701
  $form = array();
2702

    
2703
  $form['#submit'][] = 'cdm_settings_layout_search_submit';
2704

    
2705
  $form['search_settings'] = array(
2706
    '#type' => 'fieldset',
2707
    '#title' => t('Taxa Search'),
2708
    '#collapsible' => FALSE,
2709
    '#collapsed' => FALSE,
2710
    '#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
2711
         the block <em>CDM Taxon Search</em> should be enabled and visible for users
2712
         where they can write the text to be searched. You can find Drupal block configuration
2713
         site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p> '),
2714
  );
2715

    
2716
  $form['search_settings'][SIMPLE_SEARCH_IGNORE_CLASSIFICATION] = array(
2717
      '#type' => 'checkbox',
2718
      '#title' => t('Ignore the chosen classification in simple search'),
2719
      '#default_value' => variable_get(SIMPLE_SEARCH_IGNORE_CLASSIFICATION, 0),
2720
      '#description' => t('The simple search, which can be executed via the search block,
2721
          will by default search on the classification selected in the classification browser
2722
          selector. Set the tick if you want your portal to search on all classifications.'),
2723
  );
2724

    
2725
  $form['search_settings'][SIMPLE_SEARCH_USE_LUCENE_BACKEND] = array(
2726
    '#type' => 'checkbox',
2727
    '#title' => t('Run simple search with free-text search backend.'),
2728
    '#default_value' => variable_get(SIMPLE_SEARCH_USE_LUCENE_BACKEND, 0),
2729
    '#description' => t('The simple search uses by default another search
2730
      backend as the advances search. By checking this option the simple search can be
2731
      configured to also use the free-text search backend.'),
2732
  );
2733

    
2734
  $form['search_settings'][SIMPLE_SEARCH_AUTO_SUGGEST] = array(
2735
    '#type' => 'checkbox',
2736
    '#title' => t('(EXPERIMENTAL) Enable auto-suggest for taxon search'),
2737
    '#default_value' => variable_get(SIMPLE_SEARCH_AUTO_SUGGEST, 0),
2738
    '#description' => t('If enabled, the taxon search field will suggest taxon names while typing in a search query.
2739
    This function works on indexed taxon names. If you experience any delay maybe you have to reindex (see above).'),
2740
  );
2741

    
2742
  $form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
2743
    '#type' => 'textfield',
2744
    '#title' => t('Results per page') . ':',
2745
    '#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
2746
    '#description' => t('Number of results to display per page.'),
2747
  );
2748

    
2749
  $form['search_settings'][SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX] = array(
2750
    '#type' => 'checkbox',
2751
    '#title' => t('Show the') .  ' <i>' . t('Display image thumbnails') . '</i>' . t('button') . ':',
2752
    '#default_value' => variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT),
2753
    '#description' => t('The search results page will offer a button to toggle the display of image thumbnails.'),
2754
  );
2755

    
2756
  $search_mode_default = get_array_variable_merged(CDM_SEARCH_TAXA_MODE, CDM_SEARCH_TAXA_MODE_DEFAULT);
2757
  $form['search_settings']['cdm_search_taxa_mode'] = array(
2758
      '#type' => 'checkboxes',
2759
      '#title' => 'Search mode',
2760
      '#description' => 'The taxon search can operate in different modes in order to find only taxa, synonyms,
2761
          taxa by its common name and even taxa which have been used as misappied names. The settings made here will affect the default
2762
          for the advance search form and the behaviour of the simple search form which always will behave according to the
2763
          defaults set here.',
2764
      '#options' => drupal_map_assoc(array_keys(unserialize(CDM_SEARCH_TAXA_MODE_DEFAULT))),
2765
      '#default_value' => $search_mode_default
2766
      );
2767

    
2768
  $form['search_settings'][CDM_SEARCH_AREA_FILTER_PRESET] = array(
2769
    '#type' => 'textarea',
2770
    '#title' => t('area_filter_preset') . ':',
2771
    '#default_value' => variable_get(CDM_SEARCH_AREA_FILTER_PRESET, ''), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2772

    
2773
    '#description' => t('Area uuids, comma separated, no whitespace. EXPERIMENTAL!!!!'),
2774
  );
2775

    
2776
    $form['blast_search_settings'] = array(
2777
        '#type' => 'fieldset',
2778
        '#title' => t('Blast Search'),
2779
        '#collapsible' => TRUE,
2780
        '#collapsed' => TRUE,
2781
        '#description' => t('<p>To perform blast searchs
2782
         the block <em>CDM Taxon Search</em> should be enabled and visible for users
2783
         where they can write the text to be searched. You can find Drupal block configuration
2784
         site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p>
2785
         <p>To perform a blast search a blast database for the cdm instance is needed.</p> '),
2786
    );
2787

    
2788
    $form['blast_search_settings'][CDM_BLAST] = array(
2789
        '#type' => 'checkbox',
2790
        '#title' => t('Activate Blast search') . ':',
2791
        '#default_value' => variable_get(CDM_BLAST, 0), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2792

    
2793
        '#description' => t('Activate the blast search for this portal, this works only with an existing blast database!'),
2794
    );
2795
    $form['blast_search_settings'][CDM_WS_PORTAL_BLAST] = array(
2796
        '#type' => 'textfield',
2797
        '#title' => t('Webservice URL for blast search') . ':',
2798
        '#default_value' => variable_get(CDM_WS_PORTAL_BLAST, 'http://127.0.0.1:9001/api/sequence'), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2799

    
2800
        '#description' => t('Enter the webservice URL for blast search'),
2801
    );
2802

    
2803
  // --- SEARCH TAXA GALLERY ---- //
2804
  $items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
2805
  $collapsed = FALSE;
2806
  $form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
2807
  $form_title = 'Taxa Search thumbnails';
2808
  $form_description = 'Search results may show thumbnails. ';
2809
  $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
2810

    
2811
  // Comment @WA: D7 form api does not support reset buttons,
2812
  // so to mimic the D5 reset button we add one like this.
2813
  $form['actions']['reset'] = array(
2814
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2815
    '#weight' => 1000,
2816
  );
2817
  return system_settings_form($form);
2818
}
2819

    
2820
/**
2821
 * @todo document this function.
2822
 */
2823
function cdm_settings_layout_media() {
2824

    
2825
  $form = array();
2826

    
2827
  $form['media_settings'] = array(
2828
    '#type' => 'fieldset',
2829
    '#title' => t('Media settings'),
2830
    '#collapsible' => FALSE,
2831
    '#collapsed' => FALSE,
2832
    '#description' => 'This section covers layout settings for media pages.'
2833
      . 'Further media related settings may be found under the taxon layout settings and on the general settings.',
2834
  );
2835

    
2836
  $form['media_settings']['image_gallery_viewer'] = array(
2837
    '#type' => 'select',
2838
    '#title' => t('Image viewer') . ':',
2839
    '#default_value' => variable_get('image_gallery_viewer', 'default'),
2840
    '#options' => array(
2841
      'default' => t('Standard image viewer'),
2842
      'fsi' => t('FSI viewer (requires FSI server!)'),
2843
    ),
2844
  );
2845

    
2846
  // --- STANDARD_IMAGE_VIEWER ---- //
2847
  if(variable_get('image_gallery_viewer', 'default') == 'default') {
2848
    $form['media_settings'][CDM_STANDARD_IMAGE_VIEWER] = array(
2849
      '#type' => 'fieldset',
2850
      '#tree' => true,
2851
      '#title' => t('Standard image viewer settings'),
2852
      '#collapsible' => FALSE,
2853
      '#collapsed' => FALSE,
2854
      );
2855

    
2856
    $cdm_standard_image_viewer_settings = get_array_variable_merged(CDM_STANDARD_IMAGE_VIEWER, CDM_STANDARD_IMAGE_VIEWER_DEFAULT);
2857
    $form['media_settings'][CDM_STANDARD_IMAGE_VIEWER]['media_representation_details_enabled'] = array (
2858
      '#type' => 'checkbox',
2859
      '#title' => 'Show media representations',
2860
      '#default_value' => $cdm_standard_image_viewer_settings['media_representation_details_enabled']
2861

    
2862
    );
2863
  }
2864

    
2865

    
2866
  // @WA: D7 form api does not support reset buttons,
2867
  // so to mimic the D5 reset button we add one like this.
2868
  $form['actions']['reset'] = array(
2869
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2870
    '#weight' => 1000,
2871
  );
2872
  return system_settings_form($form);
2873
}
2874

    
2875
/**
2876
 * GEOSERVICE and Map settings.
2877
 */
2878
function cdm_settings_geo($form, &$form_state) {
2879

    
2880
  $current_geoserver_settings = get_edit_map_service_settings();
2881
  $map_distribution = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
2882

    
2883

    
2884
  $form = array();
2885

    
2886
  $dummy_distribution_query = NULL;
2887
  if($map_distribution['map_type'] != 1){
2888
    // we need to apply a dummy query since the map service requires for image maps
2889
    // at least as and ad to be defined
2890
    $dummy_distribution_query = "as=a:339966&ad=tdwg1:a:1,2,3,4,5,6,7,8,9";
2891
  }
2892

    
2893
  $form['map_preview'] = array(
2894
      '#type' => 'fieldset',
2895
      '#tree' => FALSE,
2896
      '#title' => t('Map preview'),
2897
      '#collapsible' => FALSE,
2898
      '#description' => 'The preview of the map'
2899
       . ($dummy_distribution_query != null ?
2900
           ' may not be accurate in case of image maps, please check the map display in the taxon pages.':
2901
           '.<br/>Hold down Strg and drag with your mouse to select a bbox to zoom to. <br/>The bbox of the visible area of the map is always displayed below the map.')
2902
  );
2903
  $form['map_preview']['openlayers_map'] = compose_map('settings-preview', NULL, $dummy_distribution_query, NULL, array(
2904
    'move' => "this.cdmOpenlayersMap.printInfo",
2905
    '#execute' => "this.cdmOpenlayersMap.printInfo"
2906
  ), true // resizable
2907
  );
2908

    
2909
  /*
2910
  $form['map_preview']['map'] = compose_map(NULL, $dummy_distribution_query, NULL, array(), 0 // force image map
2911
  );
2912
  */
2913

    
2914
  /*
2915
   * GEO SERVER
2916
   */
2917
  $form['edit_map_server'] = array(
2918
    '#type' => 'fieldset',
2919
    '#tree' => true,
2920
    '#title' => t('EDIT map service'),
2921
    '#collapsible' => TRUE,
2922
    '#collapsed' => TRUE,
2923
    '#description' => t('Configuration and selection of your geo server.
2924
      The Geo Server is responsible for generating the maps.'),
2925
  );
2926

    
2927
  $form['edit_map_server']['base_uri'] = array(
2928
    '#type' => 'select',
2929
    '#title' => t('EDIT map service') . ':',
2930
    '#default_value' => $current_geoserver_settings['base_uri'],
2931
    '#options' => unserialize(EDIT_MAPSERVER_URI),
2932
    '#description' => t('Select the EDIT map server you want to use within your data portal.'),
2933
  );
2934
  $form['edit_map_server']['version'] = array(
2935
      '#type' => 'select',
2936
      '#title' => t('Version') . ':',
2937
      '#default_value' => $current_geoserver_settings['version'],
2938
      '#options' => unserialize(EDIT_MAPSERVER_VERSION),
2939
      '#description' => t('The version of the EDIT map services'),
2940
  );
2941

    
2942
  /*
2943
   * MAP SETTINGS
2944
   */
2945

    
2946
  $form[CDM_MAP_DISTRIBUTION] = array(
2947
    '#type' => 'fieldset',
2948
    '#tree' => TRUE,
2949
    '#title' => t('Maps settings'),
2950
    '#collapsible' => TRUE,
2951
    '#collapsed' => TRUE,
2952
    '#description' => t('General configuration for all map types.'),
2953
  );
2954

    
2955
  $form[CDM_MAP_DISTRIBUTION]['map_type'] = array(
2956
    '#type' => 'radios',
2957
    '#title' => 'Map types',
2958
    '#options' => array(
2959
      1 => "OpenLayers dynamic map viewer",
2960
      0 => "Plain image",
2961
    ),
2962
    '#default_value' => $map_distribution['map_type'],
2963
    '#description' => 'Two different map types are available :
2964
      <ul><li><em>OpenLayers</em>: Display the maps in an interactive viewer
2965
      which allows zooming and panning. If enabled you can configure the default layer
2966
      (background of your maps) below.</li>
2967
      <li><em>Plain image</em>: The map will be static non interactive
2968
      image.</li></ul>',
2969
  );
2970
  $open_layers_is_enabled = $map_distribution['map_type'] == 1;
2971

    
2972
  /*
2973
   * settings for the distribution map are used also for specimens map!!!!
2974
   */
2975

    
2976
  $form[CDM_MAP_DISTRIBUTION]['aspect_ratio'] = array(
2977
      '#type' => 'textfield',
2978
      '#title' => 'Aspect ratio',
2979
      '#default_value' => $map_distribution['aspect_ratio'],
2980
      '#maxlength' => 4,
2981
      '#size' => 4,
2982
      '#element_validate' => array('element_validate_number'),
2983
      '#description' => 'The ratio of width to height of the map. Instead of expressing the aspect ratio as usually as
2984
      two numbers separated by a colon (x:y), this field requires a the value which is the result of the division of the
2985
      width by the height:</br>
2986
      <pre>aspect ratio = w / h</pre>
2987
      For a landscape oriented map with an aspect ratio of 2:1 use <strong>2</strong> as value,</br>
2988
      for a square map use <strong>1</strong>.',
2989
  );
2990

    
2991
  $form[CDM_MAP_DISTRIBUTION]['bbox'] = array(
2992
    '#type' => 'textfield',
2993
    '#title' => 'Bounding box',
2994
    '#default_value' => $map_distribution['bbox'],
2995
    '#description' => t('The bounding box (left, bottom, right, top) in degree defines the area to be initially displayed in maps.
2996
      Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong>
2997
      to let the map <strong>automatically zoom</strong> to the bounds enclosing the shown data.</p>
2998
      <strong>TIP:</strong> You can use the map preview above to choose the <span class="map-extent-bbox"><strong>map extent bbox</strong> in <strong class="degree-value"">degree</strong></span> from the map.
2999
      (Maybe you need to change the map base layer to OpeLayers.)
3000
      Hold down Strg and drag with your mouse to select a bbox to zoom to. The bbox of the visible area of the map is always displayed
3001
      below the map from where you can copy the bbox string.</p>'),
3002
  );
3003

    
3004
  $form[CDM_MAP_DISTRIBUTION]['maxZoom'] = array(
3005
    '#type' => 'select',
3006
    '#title' => 'Max zoom level',
3007
    '#default_value' => $map_distribution['maxZoom'],
3008
    '#options' => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
3009
  );
3010

    
3011
  $form[CDM_MAP_DISTRIBUTION]['show_labels'] = array(
3012
    '#type' => 'checkbox',
3013
    '#title' => 'Display area labels',
3014
    '#default_value' => $map_distribution['show_labels'],
3015
    '#description' => t('The map will show name labels of the areas'),
3016
  );
3017

    
3018
  $form[CDM_MAP_DISTRIBUTION]['caption'] = array(
3019
    '#type' => 'textfield',
3020
    '#title' => 'Map caption',
3021
    '#default_value' => $map_distribution['caption'],
3022
    '#description' => t('The caption will be shown below the map.'),
3023
  );
3024

    
3025
  $form[CDM_MAP_DISTRIBUTION]['distribution_opacity'] = array(
3026
    '#type' => 'textfield',
3027
    '#title' => 'Distribution layer opacity',
3028
    '#default_value' => $map_distribution['distribution_opacity'],
3029
    '#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions
3030
    (the countries or regions) will fully visible, while a value near to 0.0 will be not much visible.'),
3031
  );
3032

    
3033
  // --- Plain Image Settings --- //
3034
  $form[CDM_MAP_DISTRIBUTION]['image_map'] = array(
3035
    '#type' => 'fieldset',
3036
    '#title' => 'Plain image map settings',
3037
    '#tree' => TRUE,
3038
    '#collapsible' => TRUE,
3039
    '#collapsed' => $open_layers_is_enabled,
3040
    '#description' => 'The settings in this section are still expertimental
3041
      and can only be used with the EDIT map service version 1.1 or above.',
3042
  );
3043
  $edit_mapserver_version = get_edit_map_service_version_number();
3044
  if ($edit_mapserver_version < 1.1) {
3045
    $form[CDM_MAP_DISTRIBUTION]['image_map']['#description'] = '<div class="messages warning">'
3046
      . t("The chosen EDIT map service version (@edit-mapserver-version) is too low, it must be at least 1.1",
3047
        array('@edit_mapserver_version' => '$edit_mapserver_version')) . '</div>'
3048
      . $form[CDM_MAP_DISTRIBUTION]['image_map']['#description'];
3049
  }
3050

    
3051
  $form[CDM_MAP_DISTRIBUTION]['image_map']['width'] = array(
3052
    '#type' => 'textfield',
3053
    '#title' => 'Width',
3054
    '#default_value' => $map_distribution['image_map']['width'],
3055
    '#maxlength' => 4,
3056
    '#size' => 4,
3057
    '#description' => 'Width of the map. The height is calculated from the <strong>Aspect ratio</strong> set in the section above. ',
3058
  );
3059

    
3060
  $form[CDM_MAP_DISTRIBUTION]['image_map']['base_layer'] = array(
3061
    '#type' => 'textfield',
3062
    '#title' => 'Background layer',
3063
    '#default_value' => $map_distribution['image_map']['base_layer'],
3064
    '#description' => t('Background layer. For available layers inspect !url1 or !url2.', array(
3065
      '!url1' => l('deegree-csw', 'http://edit.africamuseum.be:8080/deegree-csw/md_search.jsp'),
3066
      '!url2' => l('geoserver layers', 'http://edit.africamuseum.be/geoserver/web/'),
3067
    )),
3068
  );
3069

    
3070
  $form[CDM_MAP_DISTRIBUTION]['image_map']['bg_color'] = array(
3071
    '#type' => 'textfield',
3072
    '#title' => 'Background color',
3073
    '#default_value' => $map_distribution['image_map']['bg_color'],
3074
  );
3075

    
3076
  $form[CDM_MAP_DISTRIBUTION]['image_map']['layer_style'] = array(
3077
    '#type' => 'textfield',
3078
    '#title' => 'Background layer style',
3079
     // Only line color by now.
3080
    '#default_value' => $map_distribution['image_map']['layer_style'],
3081
    '#description' => 'Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}',
3082
  );
3083

    
3084
  $form[CDM_MAP_DISTRIBUTION]['image_map']['projection'] = array(
3085
      '#type' => 'textfield',
3086
      '#title' => 'Projection',
3087
      '#default_value' => drupal_array_get_nested_value($map_distribution, array('image_map', 'projection')),
3088
      '#description' => 'Spatial Reference System (SRS) identifier ) optional ( Defines projections in WMS GetMap request.
3089
        Using EPSG:4326 (WGS84 lat/long) is the default but can be changed
3090
        on-the-fly to different UTM and much more zone specific. Examples: EPSG:4326, EPSG:900913, EPSG:3857, EPSG:7777777',
3091
  );
3092

    
3093

    
3094
  // --- OpenLayers Settings --- //
3095
  $form[CDM_MAP_DISTRIBUTION]['openlayers'] = array(
3096
    '#type' => 'fieldset',
3097
    '#title' => 'OpenLayers settings',
3098
    '#tree' => TRUE,
3099
    '#collapsible' => TRUE,
3100
    '#collapsed' => !$open_layers_is_enabled,
3101
    '#description' => '',
3102
  );
3103

    
3104

    
3105
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['display_outside_max_extent'] = array(
3106
      '#type' => 'checkbox',
3107
      '#title' => 'Display outside max extent',
3108
      '#default_value' => $map_distribution['openlayers']['display_outside_max_extent'],
3109
      '#description' => t('Allows the map to display parts of the layers which are outside
3110
         the max extent if the aspect ratio of the map and of the baselayer
3111
         are not equal.'),
3112
  );
3113

    
3114

    
3115
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['show_layer_switcher'] = array(
3116
      '#type' => 'checkbox',
3117
      '#title' => 'Show Layer Switcher',
3118
      '#default_value' => $map_distribution['openlayers']['show_layer_switcher'],
3119
      '#description' => 'The Layer Switcher control displays a table of contents
3120
      for the map.  This allows the user interface to switch between
3121
      base layers and to show or hide overlays.  By default the switcher is
3122
      shown minimized on the right edge of the map, the user may expand it
3123
      by clicking on the handle.',
3124
  );
3125

    
3126
  if (!$open_layers_is_enabled) {
3127
    $form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'] = '<div class="messages warning">'
3128
        . 'The Openlayers viewer is currently not enabled! (see section Maps settings above )</div>'
3129
        . $form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'];
3130
  }
3131

    
3132
  // The default layer must always be enabled
3133
  $preferred_layer = $map_distribution['openlayers']['base_layers']['PREFERRED'];
3134
  $map_distribution['openlayers']['base_layers'][$preferred_layer] = $preferred_layer;
3135

    
3136
  $baselayer_options = array(
3137
    /*
3138
   NOTICE: must correspond to the layers defined in
3139
   js/openlayers_,ap.js#getLayersByName()
3140
   */
3141
    'osgeo_vmap0' => "Metacarta Vmap0 (OSGeo server) - instable!", // EPSG:4326: EPSG:900913
3142
    'metacarta_vmap0' => "Metacarta Vmap0 (MetaCarta Labs server)  - instable!", // EPSG:4326, EPSG:900913
3143
    'mapproxy_vmap0' => "Metacarta Vmap0 (OSGeo server) - via fast EDIT MapProxy",
3144
    'mapproxy_etopo1' => "ETOPO1 Global Relief Model - via fast EDIT MapProxy",
3145
    'edit-etopo1' => "ETOPO1 Global Relief Model",
3146
    // all others EPSG:900913
3147
    'mapnik' => 'OpenStreetMap (mapnik)',
3148
    'stamen_terrain' => 'Stamen Terrain',
3149
    'open_topomap' => 'OpenTopoMap',
3150
    // map quest is no longer free. it is required to sign up for a test plan.
3151
    // 'mapquest_open' => "MapQuest",
3152
    // 'mapquest_sat' => "MapQuest Sattelite",
3153
    'groadmap' => 'Google Roadmap',
3154
    'gsatellite' => 'Google Satellite',
3155
    'ghybrid' => 'Google Hybrid',
3156
    'gterrain' => 'Google Terrain',
3157
//     'veroad' => 'Virtual Earth Roads',
3158
//     'veaer' => 'Virtual Earth Aerial',
3159
//     'vehyb' => 'Virtual Earth Hybrid',
3160
    // 'yahoo' => 'Yahoo Street',
3161
    // 'yahoosat' => 'Yahoo Satellite',
3162
    // 'yahoohyb' => 'Yahoo Hybrid',
3163
     'custom_wms_base_layer_1' => 'Custom WMS base layer (needs to be manually configured below!)',
3164
  );
3165

    
3166
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['base_layers'] = array(
3167
    '#type' => 'checkboxes_preferred',
3168
    '#title' => 'Base Layers',
3169
    '#options' => $baselayer_options,
3170
    '#default_value' =>  $map_distribution['openlayers']['base_layers'],
3171
    '#description' => 'Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.',
3172
  );
3173

    
3174
  $google_maps_api_key = null;
3175
  if(isset($map_distribution['openlayers']['google_maps_api_key'])){
3176
    $google_maps_api_key = $map_distribution['openlayers']['google_maps_api_key'];
3177
  }
3178
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['google_maps_api_key'] = array(
3179
    '#type' => 'textfield',
3180
    '#title' => 'Google Maps API Key',
3181
    '#default_value' => $google_maps_api_key,
3182
    '#description' => 'In order to use any of the Google map layers you need to provide 
3183
        your <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">Google Maps API Key</a>. ',
3184
  );
3185

    
3186
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer'] = wms_layer_settings(
3187
    $map_distribution['openlayers']['custom_wms_base_layer'],
3188
    'Custom WMS base layer',
3189
    'Here you an define a custom wms layer as additional base layer. You need to enable this layer in the base layers section above.',
3190
    true // add projection settings
3191
    );
3192

    
3193
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['wms_overlay_layer'] = wms_layer_settings(
3194
    $map_distribution['openlayers']['wms_overlay_layer'],
3195
    'WMS overlay layer',
3196
    'Here you an define a wms layer which will overlay all other layers in the map viewer. 
3197
                You can actually combine multiple layers for this overlay. 
3198
                For details please refer to the wms query parameter <code>Layers</code> .'
3199
  );
3200

    
3201
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['wms_overlay_layer']['is_enabled'] = array(
3202
    '#type' => 'checkbox',
3203
    '#title' => 'Enable overlay layer',
3204
    '#weight' => -100,
3205
    '#default_value' => $map_distribution['openlayers']['wms_overlay_layer']['is_enabled'] === 1  ? 1 : 0
3206
  );
3207

    
3208
  /*
3209
   * Map Legend