Project

General

Profile

Download (147 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
<?php
2
/**
3
 * @file
4
 * CDM Dataportal settings.
5
 */
6
7 b2b9e057 Andreas Kohlbecker
8 642b323b Andreas Kohlbecker
  // TODO Genus UUID.
9
10 aaa81689 Andreas Kohlbecker
  define('TAXONTREE_RANKLIMIT', 'cdm_taxontree_ranklimit');
11
  define('TAXONTREE_RANKLIMIT_DEFAULT', 0);
12 642b323b Andreas Kohlbecker
  define('CDM_TAXONOMICTREE_UUID', 'cdm_taxonomictree_uuid');
13
  define('CDM_TAXONTREE_INCLUDES', 'taxontree_includes');
14
15
  define('NO_SORT', -1);
16
  define('SORT_HIERARCHICAL', 9);
17
18
  define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
19 1d69a96c Andreas Kohlbecker
20
  define('SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT', 1);
21
  define('SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX', 'search_results_show_thumbnail_checkbox');
22
23 642b323b Andreas Kohlbecker
  define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
24
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE', 0);
25 2e82a602 Patrick Plitzner
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_PAGE_SIZE', 50);
26 35bea66c Patrick Plitzner
  define('CDM_DATAPORTAL_TAXON_AUTO_SUGGEST', 0);
27 642b323b Andreas Kohlbecker
  define('CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_SHOW_DETERMINED_AS', 1);
28
  define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
29
  define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
30
  define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
31
  define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
32
33
  /* annotationTypeKeys */
34 7ca5ef1e Andreas Kohlbecker
  $annotationTypeKeys = array_keys(cdm_vocabulary_as_option(UUID_ANNOTATION_TYPE));
35 642b323b Andreas Kohlbecker
  if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
36
    $annotationTypeKeys = array_flip($annotationTypeKeys);
37
38
    // Technical annotation are off by default.
39
    unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
40
    $annotationTypeKeys = array_flip($annotationTypeKeys);
41
    // Additional value for the NULL case.
42
    $annotationTypeKeys[] = 'NULL_VALUE';
43
  }
44
  define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
45 6657531f Andreas Kohlbecker
46 642b323b Andreas Kohlbecker
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE', 'bibliography_for_original_source');
47
  define('BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT', serialize(array(
48
    'enabled' => 0,
49
    'key_format' => 'ALPHA'
50
  )));
51 f19f47fa Andreas Kohlbecker
52 642b323b Andreas Kohlbecker
  /* taxonRelationshipTypes */
53
  define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(array(UUID_MISAPPLIED_NAME_FOR, UUID_INVALID_DESIGNATION_FOR)));
54 6657531f Andreas Kohlbecker
55 6280e639 Andreas Kohlbecker
56 1ce9afb7 Patric Plitzner
57 642b323b Andreas Kohlbecker
    /* ---- MAP SETTING CONSTANTS ---- */
58
  /**
59
   * @var array of URIs eg. http://edit.africamuseum.be"
60
   *   An options array
61
   */
62
  define('EDIT_MAPSERVER_URI', serialize(
63
      array(
64
        'http://edit.africamuseum.be'=>'Primary (http://edit.africamuseum.be)',
65
        'http://edit.br.fgov.be'=>'Secondary (http://edit.br.fgov.be)',
66
      )
67 ba706bf0 Andreas Kohlbecker
    )
68 642b323b Andreas Kohlbecker
  );
69
  define('EDIT_MAPSERVER_PATH', '/edit_wp5');
70
  /**
71
   * @var array of versions eg. "v1.2"
72
   *   An options array
73
   */
74
  define('EDIT_MAPSERVER_VERSION', serialize(
75
      array(
76 fb9c2a03 Andreas Kohlbecker
//        'v1' => 'v1' ,           // no longer recommended
77
//        'v1.1' => 'v1.1',        // no longer recommended
78
//        'v1.2_dev' => 'v1.2_dev',// no longer recommended
79 642b323b Andreas Kohlbecker
        'v1.2' => 'v1.2',
80 fb9c2a03 Andreas Kohlbecker
        'v1.3_dev' => 'v1.3_dev (not recommended)',
81
        'v1.4_dev' => 'v1.4_dev (experimental features)'
82 642b323b Andreas Kohlbecker
      )
83 f19f47fa Andreas Kohlbecker
    )
84 642b323b Andreas Kohlbecker
  );
85
  define('EDIT_MAPSERVER_URI_DEFAULT', 'http://edit.africamuseum.be');
86
  define('EDIT_MAPSERVER_VERSION_DEFAULT', 'v1.2');
87 6657531f Andreas Kohlbecker
88 642b323b Andreas Kohlbecker
    // --- Taxon profile settings --- /
89
  define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
90
  define('CDM_TAXON_PROFILE_IMAGE', 'cdm_taxon_profile_image');
91
  define('CDM_TAXON_PROFILE_IMAGE_DEFAULT', serialize(
92
      array(
93
          'show' => 0,
94
          'maxextend' => 184,
95
          'media_uri_query' => '',
96 ca47ea76 Andreas Kohlbecker
          'custom_placeholder_enabled' => 1,
97 642b323b Andreas Kohlbecker
          'custom_placeholder_image_on' => 0,
98
          'custom_placeholder_image_fid' => ''
99
      )
100 9c92cd84 Andreas Kohlbecker
    )
101 642b323b Andreas Kohlbecker
  );
102 ba706bf0 Andreas Kohlbecker
103 846c0606 Andreas Kohlbecker
104
define('FEATURE_BLOCK_SETTINGS', 'feature_block_settings');
105
106
define('DISTRIBUTION_CONDENSED', 'distribution_condensed');
107
define('DISTRIBUTION_CONDENSED_INFO_PATH', 'distribution_condensed_info_path');
108
define('DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT', 'cdm_dataportal/help/condensed_distribution');
109
define('DISTRIBUTION_CONDENSED_RECIPE', 'distribution_condensed_recipe');
110
define('DISTRIBUTION_CONDENSED_RECIPE_DEFAULT', 'EuroPlusMed');
111
112
define('DISTRIBUTION_STATUS_COLORS', 'distribution_status_colors');
113
define('DISTRIBUTION_ORDER_MODE', 'distribution_order_mode');
114
define('DISTRIBUTION_ORDER_MODE_DEFAULT', 'TREE');
115
define('DISTRIBUTION_TREE_OMIT_LEVELS', 'distribution_tree_omit_levels');
116 c6ee8193 Andreas Kohlbecker
117 6657531f Andreas Kohlbecker
/**
118 b54cbda1 Andreas Kohlbecker
 * Returns the array of implemented taxon page tabs.
119
 * The array has fixed integer keys which must not be changed.
120 6657531f Andreas Kohlbecker
 */
121
function get_taxon_tabs_list() {
122
  return array(
123
    0 => 'General',
124
    1 => 'Synonymy',
125
    2 => 'Images',
126
    3 => 'Specimens',
127
    4 => 'Keys',
128 7663cd0b Andreas Kohlbecker
    5 => 'Experts',
129 6657531f Andreas Kohlbecker
  );
130
}
131
132 4feeabc7 Andreas Kohlbecker
define('CDM_TAXONPAGE_TAB_WEIGHT', 'cdm_taxonpage_tab_weight');
133 b54cbda1 Andreas Kohlbecker
define('CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT', serialize(
134 d9763fd3 Andreas Kohlbecker
  array(
135
    'general' => '-3',
136
    'synonymy' => '-2',
137
    'images' => '0',
138
    'specimens' => '1',
139
    'keys' => '3',
140
    'experts' => '5',
141
    )
142 b54cbda1 Andreas Kohlbecker
));
143
144 4feeabc7 Andreas Kohlbecker
145
// CDM_TAXONPAGE_TAB_LABELS_DEFAULT
146
define('CDM_TAXONPAGE_TAB_LABELS', 'cdm_taxonpage_tab_labels');
147
define('CDM_TAXONPAGE_TAB_LABELS_DEFAULT', serialize(
148
  array(
149
    'general' => null,
150
    'synonymy' => null,
151
    'images' => null,
152
    'specimens' => null,
153
    'keys' => null,
154
    'experts' => null,
155
  )
156
));
157
158 6657531f Andreas Kohlbecker
$taxon_tab_options = get_taxon_tabs_list();
159
$taxon_tab_options[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX] = 'Last visited tab';
160
161
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
162
163
/**
164
 * @todo document this function.
165
 */
166
function get_taxon_options_list() {
167
  $taxon_tab_options = array_flip(get_taxon_tabs_list());
168
  foreach ($taxon_tab_options as $key => $value) {
169 7cc085da Andreas Kohlbecker
    $taxon_tab_options[$key] = t('@key', array('@key' => $key));
170 6657531f Andreas Kohlbecker
  }
171
  return $taxon_tab_options;
172
173
}
174
175 0f5f1c12 Andreas Kohlbecker
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions');
176
define('CDM_PART_DEFINITIONS_DEFAULT', serialize(
177 f19f47fa Andreas Kohlbecker
  array(
178
      'ZoologicalName' => array(
179 501347df Andreas Kohlbecker
        'namePart' => array('name' => TRUE),
180 f19f47fa Andreas Kohlbecker
        'nameAuthorPart' => array('name' => TRUE),
181
        'referencePart' => array('authors' => TRUE),
182
        'microreferencePart' => array('microreference' => TRUE),
183 e24d373b Andreas Kohlbecker
        'secReferencePart' => array('secReference' => TRUE,),
184 f19f47fa Andreas Kohlbecker
        'statusPart' => array('status' => TRUE),
185
        'descriptionPart' => array('description' => TRUE),
186
      ),
187 0f5f1c12 Andreas Kohlbecker
      'BotanicalName'=> array(
188
        'namePart' => array('name' => TRUE),
189
        'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
190
        'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
191 43998144 Andreas Kohlbecker
        'secReferencePart' => array('secReference' => TRUE,),
192 51b04faf Andreas Kohlbecker
        'referenceYearPart' => array('reference.year' => TRUE),
193 0f5f1c12 Andreas Kohlbecker
        'statusPart' => array('status' => TRUE),
194
        'descriptionPart' => array('description' => TRUE),
195 f19f47fa Andreas Kohlbecker
      ),
196
     '#DEFAULT' => array(
197
        'namePart' => array(
198
            'name' => TRUE
199 501347df Andreas Kohlbecker
        ),
200
        'nameAuthorPart' => array(
201
            'name' => TRUE,
202
            'authors' => TRUE
203 f19f47fa Andreas Kohlbecker
        ),
204 43998144 Andreas Kohlbecker
       'referencePart' => array(
205
         'reference' => TRUE
206 f19f47fa Andreas Kohlbecker
        ),
207 43998144 Andreas Kohlbecker
       'secReferencePart' => array(
208
         'secReference' => TRUE,
209
       ),
210
       'microreferencePart' => array(
211
          'microreference' => TRUE,
212 f19f47fa Andreas Kohlbecker
        ),
213 43998144 Andreas Kohlbecker
       'statusPart' => array(
214
          'status' => TRUE,
215 f19f47fa Andreas Kohlbecker
        ),
216 43998144 Andreas Kohlbecker
       'descriptionPart' => array(
217
          'description' => TRUE,
218 f19f47fa Andreas Kohlbecker
        ),
219
      )
220 0f5f1c12 Andreas Kohlbecker
    )
221
  )
222
);
223 1a01f6dd Andreas Kohlbecker
  define('CDM_PART_DEFINITIONS_DEFAULT_PRE_380', serialize(
224
    array(
225
      'ZoologicalName' => array(
226
        'namePart' => array('name' => TRUE),
227
        'nameAuthorPart' => array('name' => TRUE),
228
        'referencePart' => array('authors' => TRUE),
229
        'microreferencePart' => array('microreference' => TRUE),
230
        'statusPart' => array('status' => TRUE),
231
        'descriptionPart' => array('description' => TRUE),
232
      ),
233
      'BotanicalName'=> array(
234
        'namePart' => array('name' => TRUE),
235
        'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
236
        'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
237
        'referenceYearPart' => array('reference.year' => TRUE),
238
        'statusPart' => array('status' => TRUE),
239
        'descriptionPart' => array('description' => TRUE),
240
      ),
241
      '#DEFAULT' => array(
242
        'namePart' => array(
243
          'name' => TRUE
244
        ),
245
        'nameAuthorPart' => array(
246
          'name' => TRUE,
247
          'authors' => TRUE
248
        ),
249
        'referencePart' => array(
250
          'reference' => TRUE
251
        ),
252
        'microreferencePart' => array(
253
          'microreference' => TRUE,
254
        ),
255
        'statusPart' => array(
256
          'status' => TRUE,
257
        ),
258
        'descriptionPart' => array(
259
          'description' => TRUE,
260
        ),
261
      )
262
    )
263
  )
264
  );
265
266 f19f47fa Andreas Kohlbecker
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates');
267 0f5f1c12 Andreas Kohlbecker
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize(
268 e24d373b Andreas Kohlbecker
  array (
269
    'taxon_page_title,polytomousKey'=> array(
270 1a01f6dd Andreas Kohlbecker
        'namePart' => array('#uri' => TRUE),
271
      ),
272 e24d373b Andreas Kohlbecker
    'not_in_current_classification' => array(
273
     'nameAuthorPart' => TRUE,
274
     'referencePart' => TRUE,
275
     'statusPart' => TRUE,
276
     'secReferencePart' => TRUE,
277
    ),
278
    'taxon_page_synonymy,accepted_taxon.taxon_page_synonymy'=> array(
279
      'nameAuthorPart' => array('#uri' => TRUE),
280
      'referencePart' => TRUE,
281
      'statusPart' => TRUE,
282
      'descriptionPart' => TRUE,
283
    ),
284 df6226aa Andreas Kohlbecker
    'related_taxon.other_taxon_relationship.taxon_relationships.taxon_page_synonymy'=> array(
285 e24d373b Andreas Kohlbecker
      'nameAuthorPart' => array('#uri' => TRUE),
286
      'referencePart' => TRUE,
287
      'statusPart' => TRUE,
288
      'secReferencePart' => TRUE,
289
      'descriptionPart' => TRUE,
290
    ),
291 df6226aa Andreas Kohlbecker
    'related_taxon.misapplied_name_for.taxon_relationships.taxon_page_synonymy' => array(
292
      'nameAuthorPart' => array('#uri' => TRUE),
293
      'referencePart' => TRUE,
294
      'statusPart' => TRUE,
295
      /* no sec ref in this case, misapplied names are
296
       * de-duplicated and the sec ref is shown as footnote */
297
      'descriptionPart' => TRUE,
298
    ),
299 e24d373b Andreas Kohlbecker
    'homonym'=> array(
300 1a01f6dd Andreas Kohlbecker
        'nameAuthorPart' => array('#uri' => TRUE),
301
        'referenceYearPart' => TRUE,
302 c97cae85 Andreas Kohlbecker
        'statusPart' => TRUE,
303 e24d373b Andreas Kohlbecker
    ),
304
    'acceptedFor,typedesignations,list_of_taxa' => array(
305 1a01f6dd Andreas Kohlbecker
        'nameAuthorPart' => array('#uri' => TRUE),
306
        'referencePart' => TRUE,
307
      ),
308 e24d373b Andreas Kohlbecker
    '#DEFAULT' => array(
309 1a01f6dd Andreas Kohlbecker
        'nameAuthorPart' => array('#uri' => TRUE),
310
        'referencePart' => TRUE,
311 e24d373b Andreas Kohlbecker
     )
312
  )
313
));
314
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380', serialize(
315
  array (
316
    'taxon_page_title,polytomousKey'=> array(
317
      'namePart' => array('#uri' => TRUE),
318
    ),
319
    'taxon_page_synonymy,related_taxon'=> array(
320
      'nameAuthorPart' => array('#uri' => TRUE),
321
      'referencePart' => TRUE,
322
      'statusPart' => TRUE,
323
      'descriptionPart' => TRUE,
324
    ),
325
    'homonym'=> array(
326
      'nameAuthorPart' => array('#uri' => TRUE),
327
      'referenceYearPart' => TRUE,
328
    ),
329
    'acceptedFor,typedesignations,list_of_taxa' => array(
330
      'nameAuthorPart' => array('#uri' => TRUE),
331
      'referencePart' => TRUE,
332
    ),
333
    '#DEFAULT' => array(
334
      'nameAuthorPart' => array('#uri' => TRUE),
335
      'referencePart' => TRUE,
336 1a01f6dd Andreas Kohlbecker
    )
337 e24d373b Andreas Kohlbecker
  )
338
));
339 0f5f1c12 Andreas Kohlbecker
340 6280e639 Andreas Kohlbecker
define('CDM_SEARCH_TAXA_MODE','cdm_search_taxa_mode');
341
define('CDM_SEARCH_TAXA_MODE_DEFAULT', serialize(
342
    // to unset a default enntry set the value to 0
343
    array(
344
      'doTaxa'=>'doTaxa',
345
      'doSynonyms' => 'doSynonyms',
346
      'doTaxaByCommonNames' => 'doTaxaByCommonNames',
347
      'doMisappliedNames' => 'doMisappliedNames'
348
    )
349
  )
350
);
351
352 072122ee Andreas Kohlbecker
define('CDM_SEARCH_AREA_FILTER_PRESET', 'cdm_search_area_filter_preset');
353
354 2d0d855a Andreas Kohlbecker
define('SIMPLE_SEARCH_USE_LUCENE_BACKEND', 'simple_search_use_lucene_backend');
355 90a6166e Andreas Kohlbecker
define('SIMPLE_SEARCH_IGNORE_CLASSIFICATION', 'simple_search_ignore_classification');
356 2d0d855a Andreas Kohlbecker
357 6280e639 Andreas Kohlbecker
/* Gallery variables. */
358
$gallery_settings = array(
359
    "cdm_dataportal_show_taxon_thumbnails" => 1,
360
    "cdm_dataportal_show_synonym_thumbnails" => 0,
361
    "cdm_dataportal_show_thumbnail_captions" => 1,
362
    "cdm_dataportal_media_maxextend" => 120,
363
    "cdm_dataportal_media_cols" => 3,
364
    "cdm_dataportal_media_maxRows" => 1,
365
);
366
367 6657531f Andreas Kohlbecker
define('TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT', serialize(get_taxon_options_list()));
368
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
369
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
370
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
371
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
372
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
373
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
374
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
375
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
376
// define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
377
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
378
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
379 6421984d Andreas Kohlbecker
380 30f78c59 Andreas Kohlbecker
/**
381
 * The drupal variable key for the array containing the uuids of the taxon relationship types to display in
382
 * the snonymy.
383
 *
384
 * @var string
385
 */
386 6657531f Andreas Kohlbecker
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
387 6421984d Andreas Kohlbecker
388
define('CDM_NAME_RELATIONSHIP_TYPES', 'cdm_name_relationship_types');
389
define('CDM_NAME_RELATIONSHIP_TYPES_DEFAULT', serialize(
390
    array(
391 e4ccc0a0 Andreas Kohlbecker
      UUID_NAMERELATIONSHIPTYPE_LATER_HOMONYM => UUID_NAMERELATIONSHIPTYPE_LATER_HOMONYM,
392
      UUID_NAMERELATIONSHIPTYPE_TREATED_AS_LATER_HOMONYM => UUID_NAMERELATIONSHIPTYPE_TREATED_AS_LATER_HOMONYM,
393
      UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR => UUID_NAMERELATIONSHIPTYPE_BLOCKING_NAME_FOR
394 6421984d Andreas Kohlbecker
    )
395
  )
396
);
397
398 30f78c59 Andreas Kohlbecker
/**
399
 * The drupal variable for the configuration of the information aggregation along
400
 * the taxon relation ships. The mapped arrayis associative and holds two elements:
401
 *    - direct: the uuids of the taxon relationship types to take into account in invers
402
 *      direction.
403
 *    - invers: the uuids of the taxon relationship types to take into account in direct
404
 *      direction.
405
 *
406
 * @var String
407
 */
408
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS', 'cdm_aggregate_by_taxon_relationships');
409
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT', serialize(
410
    array(
411
        'direct'=>array(),
412
        'invers'=>array()
413
     )
414
   ));
415 6657531f Andreas Kohlbecker
define('CDM_PROFILE_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
416 bfb2b81a Andreas Kohlbecker
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
417 6657531f Andreas Kohlbecker
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
418
419 aa63dfb4 Andreas Kohlbecker
define('CDM_DISTRIBUTION_FILTER', 'cdm_distribution_filter');
420
define('CDM_DISTRIBUTION_FILTER_DEFAULT', serialize(
421
      array(
422
      'filter_rules' => array(
423
        'statusOrderPreference' => 0,
424
        'subAreaPreference' => 0,
425
      ),
426 6fbf1bd3 Andreas Kohlbecker
      'hiddenAreaMarkerType' => array()
427 aa63dfb4 Andreas Kohlbecker
     )
428
));
429
430 38dd933d Andreas Kohlbecker
define('DISTRIBUTION_HIERARCHY_STYLE', 'distribution_hierarchy_style');
431
define('DISTRIBUTION_HIERARCHY_STYLE_DEFAULT', serialize(array(
432
  "level_0" => array(
433
    'label_suffix' => ':',
434 3de12c0d Andreas Kohlbecker
    'status_glue' => '',
435 38dd933d Andreas Kohlbecker
    'item_glue' => ' ',
436
    'item_group_prefix' => '',
437
    'item_group_postfix' => ''
438
  ),
439
  "level_1" => array(
440 3de12c0d Andreas Kohlbecker
    'label_suffix' => '',
441
    'status_glue' => '‒ ', // '&#8210; '
442 38dd933d Andreas Kohlbecker
    'item_glue' => '; ',
443
    'item_group_prefix' => ', ',
444
    'item_group_postfix' => ''
445
  ),
446
  "level_2" => array(
447 3de12c0d Andreas Kohlbecker
    'label_suffix' => '',
448
    'status_glue' => '‒ ', // '&#8210; '
449 38dd933d Andreas Kohlbecker
    'item_glue' => ', ',
450
    'item_group_prefix' => ' (',
451
    'item_group_postfix' => ')'
452
  )
453
)));
454 aa63dfb4 Andreas Kohlbecker
455 378bc1ce Andreas Kohlbecker
/**
456
 * Constant for the drupal variable key distribution_map_visibility
457
 *
458
 * possible values:
459
 *  - never
460
 *  - automatic
461
 *  - always
462
 */
463
define('DISTRIBUTION_MAP_VISIBILITY', 'distribution_map_visibility');
464
define('DISTRIBUTION_MAP_VISIBILITY_DEFAULT', 'automatic');
465
466
/**
467
 * Constant for the drupal variable key specimen_map_visibility
468
 *
469
 * possible values:
470
 *  - never
471
 *  - automatic
472
 *  - always
473
 */
474
define('SPECIMEN_MAP_VISIBILITY', 'specimen_map_visibility');
475
define('SPECIMEN_MAP_VISIBILITY_DEFAULT', 'automatic');
476
477 a950f2f9 Andreas Kohlbecker
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
478
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
479
    array(
480
        'includeTaxonDescriptions' => 'includeTaxonDescriptions',
481
        'includeOccurrences' => 0,
482
        'includeTaxonNameDescriptions' => 0
483
     )
484
  ));
485
486 cc3c9807 Andreas Kohlbecker
define('CDM_MAP_DISTRIBUTION', 'cdm_map_distribution');
487
define('CDM_MAP_DISTRIBUTION_DEFAULT', serialize(array(
488
  // needs to be merged with user setting by drupal_array_merge_deep()
489 b4503332 Andreas Kohlbecker
  // 'width' => 512, // optimum size for OSM layers is 512
490
  // 'height' => 512 / 2, // optimum size for OSM layers 256
491
  'aspect_ratio' => 2,
492 cc3c9807 Andreas Kohlbecker
  'bbox' => '', // empty to allow automatic zooming to extend
493
  'show_labels' => FALSE,
494
  'caption' => '',
495
  'distribution_opacity' => '0.5',
496
  'map_type' => 1, //  1 = 'openlayers', 0 = 'image'
497
  'image_map' => array(
498
    'base_layer' => '', // none, formerly this was cyprusdivs
499
    'bg_color' => '1874CD',
500
    'layer_style' => 'ffffff,606060,,',
501
  ),
502
  'openlayers' => array(
503
    'base_layers' =>  array(
504
      // A layer MUST NOT BE SET in the defaults,
505
      // otherwise it can not be overidden by the user settings:
506 5cef0b6d Andreas Kohlbecker
      // 'mapproxy_vmap0' => 'mapproxy_vmap0',
507 cc3c9807 Andreas Kohlbecker
      // it is sufficient to define the preferred layer,
508
      // since it will automatically be enabled:
509 5cef0b6d Andreas Kohlbecker
      'PREFERRED' => 'mapproxy_vmap0'),
510 fb9c2a03 Andreas Kohlbecker
    'custom_wms_base_layer' => array(
511
      'name' => NULL,
512
      'url' => NULL,
513
      'params' =>  NULL,
514
      'projection' => NULL,
515
      'proj4js_def' => NULL,
516
      'max_extent' => NULL,
517
      'units' => NULL
518
    ),
519 2bbc28c8 Andreas Kohlbecker
    'show_layer_switcher' => TRUE,
520 2b83cc8b Andreas Kohlbecker
    'display_outside_max_extent' => FALSE,
521
    'google_maps_api_key' => NULL,
522 cc3c9807 Andreas Kohlbecker
  ),
523
  'legend' => array(
524
    'show' => TRUE,
525
    'opacity' => '0.5',
526
    'font_size' => 10,
527
    'font_style' => FALSE,
528
    'icon_width' => 35,
529
    'icon_height' => 15
530
  )
531
)));
532
533
/**
534
 * Merges the named array variable with the array of defaults.
535
 *
536 5611d467 Andreas Kohlbecker
 * IMPORTANT: The array keys must be strings. When the keys are integers
537
 * the merging will not take place for these entities. Number keyed entities
538 b54cbda1 Andreas Kohlbecker
 * are just appended to the result array.
539
 *
540 cc3c9807 Andreas Kohlbecker
 * @param string $variable_name
541
 *     The variable name
542
 * @param string | array $default
543
 *     The array containing the default values either as array or serialized as string.
544 5611d467 Andreas Kohlbecker
 *     Unserialization is cared for if necessary
545 cc3c9807 Andreas Kohlbecker
 * @return array
546 5611d467 Andreas Kohlbecker
 *     The merged array as returned by drupal_array_merge_deep()
547 8c962983 Andreas Kohlbecker
 *
548 0f7c9d15 Andreas Kohlbecker
 * TODO compare with mixed_variable_get() duplicate functions? => result use this function instead of mixed_variable_get()
549
 * TODO force $default being an array
550 cc3c9807 Andreas Kohlbecker
 */
551
function get_array_variable_merged($variable_name, $default){
552
553
    // unserialize if nessecary
554
    if(!is_array($default)){
555
      $default = unserialize($default);
556
    }
557
    $variable = variable_get($variable_name, array());
558 b54cbda1 Andreas Kohlbecker
    $result = drupal_array_merge_deep($default, $variable);
559
    return $result;
560 cc3c9807 Andreas Kohlbecker
}
561
562 6657531f Andreas Kohlbecker
/**
563
 * @todo document this function.
564
 */
565
function getGallerySettings($gallery_config_form_name) {
566 cc3c9807 Andreas Kohlbecker
  return get_array_variable_merged($gallery_config_form_name, CDM_DATAPORTAL_GALLERY_SETTINGS);
567 6657531f Andreas Kohlbecker
}
568
569
/**
570
 * Returns the string representation of the default tab.
571
 *
572
 * @param bool $returnTabIndex
573
 *   Defaults to FALSE, if set true this function will return the index number
574
 *   of the default tab. (used to supply default values to form elements).
575
 */
576
function get_default_taxon_tab($returnTabIndex = FALSE) {
577
578
  global $user;
579
  $values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
580
  $user_tab_active = 'cdm_dataportal_' . $user->uid . '_default_tab_active';
581
  $user_tab = 'cdm_dataportal_' . $user->uid . '_default_tab';
582
  // Get the user value if the used has chosen to overwrite the system settings.
583
  $user_tab_on = variable_get($user_tab_active, FALSE);
584
  if ($user_tab_on) {
585
    $user_value = variable_get($user_tab, 0);
586
    $index_value = $user_value;
587
    // Get the system value.
588
  }
589
  else {
590
    $system_value = variable_get('cdm_dataportal_default_tab', 0);
591
    $index_value = $system_value;
592
  }
593
594
  // Return the index value or the string representation.
595
  if ($returnTabIndex) {
596
    return $index_value;
597
  }
598
  else {
599
    return ($values[$index_value]);
600 22f5e82d Andreas Kohlbecker
  }
601 6657531f Andreas Kohlbecker
}
602
603 22f5e82d Andreas Kohlbecker
604 f3a04cfa Andreas Kohlbecker
  /**
605 8c962983 Andreas Kohlbecker
   * Provides the feature block settings for a specific feature which matches the $feature_uuid parameter.
606 f3a04cfa Andreas Kohlbecker
   *
607 8c962983 Andreas Kohlbecker
   * In case specifically configured settings array, like these which are stored in the drupal variables, is missing
608
   * one or more fields these fields are taken from the default. That is the specific settings are always merges
609
   * with the default.
610 f3a04cfa Andreas Kohlbecker
   *
611
   * Note: These settings only apply to feature blocks which do not have a special rendering
612 abacccbf Andreas Kohlbecker
   * the specially handled features (e.g.: Distribution, CommonNames) may make use of the
613 f3a04cfa Andreas Kohlbecker
   * 'special' element of the settings
614
   *
615
   * @param $feature_uuid
616
   *   The uuid string representation of the feature to return the settings for
617
   *
618
   * @return array
619
   *  an associative array of settings, with the following fields:
620
   *    - as_list: string
621 c651d3b1 Andreas Kohlbecker
   *        this setting will be used in compose_feature_block_wrap_elements() as $enclosing_tag
622 f3a04cfa Andreas Kohlbecker
   *        possible values are:
623
   *          div: not as list,
624
   *          ul: as bullet list,
625
   *          ol: as numbered list,
626
   *          dl: as definition list
627 08a339ec Andreas Kohlbecker
   *        The tag used for the inner element, thus depends on the value of this field. The
628
   *        inner tag name can be retrieved by the function cdm_feature_block_element_tag_name()
629 f3a04cfa Andreas Kohlbecker
   *    - link_to_reference: boolean,
630
   *        render the reference as link, ignored if the element is NOT a DescriptionElementSource
631
   *    - link_to_name_used_in_source": boolean
632
   *        whether to show name is source information as link which will point to the according name page
633
   *    - sources_as_content (boolean)
634 642b323b Andreas Kohlbecker
   *        TRUE (int: 1):
635 159cd9bb Andreas Kohlbecker
   *          1. If element is of the CDM type TextData and the text is not empty the source references will be
636 44d445c0 Andreas Kohlbecker
   *             appended in brackets like "text (source references)". If the original source has name in source
637
   *             information it will be appended to the citation string,
638
   *             like : "(citation, as name in source; citation, as name in source)"
639
   *          2. if the text of the TextData is empty, the original source citations are the only content
640
   *             (e.g. use case CITATION) and are not put into brackets. In this case the nameInSource is
641
   *             prepended to the citation string like: "name in source: citation"
642 642b323b Andreas Kohlbecker
   *        FALSE (int: 0):
643 dcf17487 Andreas Kohlbecker
   *          Original sources are put into the bibliography(=references) pseudo feature block. If the original source
644 159cd9bb Andreas Kohlbecker
   *          citations are the only content, the resulting feature block content would only consist of footnotes.
645
   *          In this case the display of the respective feature block is suppressed.
646 dcf17487 Andreas Kohlbecker
   *          TODO if the bibliography is not enabled the sources will be treated as footnotes like annotations,
647
   *               in future however they will in this case be shown in a separate references section for each
648
   *               feature block.
649 f3a04cfa Andreas Kohlbecker
   *    - sources_as_content_to_bibliography  (boolean)
650
   *        Only valid if sources_as_content == TRUE, will cause the sources to be also shown
651 159cd9bb Andreas Kohlbecker
   *        in the bibliography.
652 f3a04cfa Andreas Kohlbecker
   *    - sort_elements
653
   *        whether and how to sort the elements
654 dcf17487 Andreas Kohlbecker
   *        possible values are the constants SORT_ASC, SORT_DESC, NULL,
655 642b323b Andreas Kohlbecker
   *        some feature types (Distribution) also support: SORT_HIERARCHICAL (
656
   *        TODO option to exclude levels, put in special?,
657 c651d3b1 Andreas Kohlbecker
   *        TODO make use of this setting in compose_feature_block_wrap_elements())
658 f3a04cfa Andreas Kohlbecker
   *    - element_tag
659
   *        specifies the tag to be used for creating the elements, only applies if "as_list" == 'div'
660 f2e44165 Andreas Kohlbecker
   *        possible values are span | div. the proper inner tag name can be retrieved by the function
661
   *        cdm_feature_block_element_tag_name()
662 f3a04cfa Andreas Kohlbecker
   *    - special: array()
663
   *        an array with further settings, this field can be used for special
664
   *        settings for specialized rendering like for distributions
665
   *  }
666
   *
667
   */
668 642b323b Andreas Kohlbecker
  function get_feature_block_settings($feature_uuid = 'DEFAULT') {
669 f3a04cfa Andreas Kohlbecker
    // the default must conform to the default parameter values of
670 c651d3b1 Andreas Kohlbecker
    // compose_feature_block_wrap_elements() : $glue = '', $sort = FALSE, $enclosing_tag = 'ul'
671 0ef9a709 Andreas Kohlbecker
    // compose_description_element_text_data() : asListElement = NULL
672 f3a04cfa Andreas Kohlbecker
673
    // see #3257 (implement means to define the features to show up in the taxonprofile and in the specimen descriptions)
674
675 642b323b Andreas Kohlbecker
    // ---- DEFAULTS settings
676
677 6776a5bc Andreas Kohlbecker
    // only needed as final option, when the settings are not having a default
678 f3a04cfa Andreas Kohlbecker
    $default = array(
679 6776a5bc Andreas Kohlbecker
      'DEFAULT' => array(
680 6882da59 Andreas Kohlbecker
        'as_list' => 'div',
681 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
682
        'link_to_name_used_in_source' => 1,
683 8c962983 Andreas Kohlbecker
        'sources_as_content' => 0,
684 642b323b Andreas Kohlbecker
        'sources_as_content_to_bibliography' => 0,
685
        'sort_elements' => NO_SORT,
686 6776a5bc Andreas Kohlbecker
        'glue' => '',
687 642b323b Andreas Kohlbecker
        'element_tag' => NULL
688 6776a5bc Andreas Kohlbecker
      )
689
    );
690
691
    // will be used as preset in the settings
692
    $other_themes_default = array(
693 f3a04cfa Andreas Kohlbecker
      'DEFAULT' => array(
694 6882da59 Andreas Kohlbecker
        'as_list' => 'div',
695 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
696
        'link_to_name_used_in_source' => 1,
697
        'sources_as_content' => 0,
698
        'sources_as_content_to_bibliography' => 0,
699
        'sort_elements' => NO_SORT,
700 f3a04cfa Andreas Kohlbecker
        'glue' => '',
701 642b323b Andreas Kohlbecker
        'element_tag' => NULL
702 f3a04cfa Andreas Kohlbecker
      ),
703
      UUID_CITATION => array(
704
        'as_list' => 'div',
705 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
706
        'link_to_name_used_in_source' => 0,
707
        'sources_as_content' => 1,
708
        'sources_as_content_to_bibliography' => 0,
709 dcf17487 Andreas Kohlbecker
        'sort_elements' => SORT_ASC,
710 f3a04cfa Andreas Kohlbecker
        'glue' => '',
711 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
712 dcf17487 Andreas Kohlbecker
      ),
713
      UUID_DISTRIBUTION => array(
714
        'as_list' => 'div', // currently ignored
715 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
716
        'link_to_name_used_in_source' => 0,
717
        'sources_as_content' => 0,
718
        'sources_as_content_to_bibliography' => 0,
719
        'sort_elements' => NO_SORT, // will cause ...
720 dcf17487 Andreas Kohlbecker
        'glue' => '',
721 642b323b Andreas Kohlbecker
        'element_tag' => 'div',
722
        'special' => array()
723 dcf17487 Andreas Kohlbecker
      ),
724 f2e44165 Andreas Kohlbecker
      UUID_COMMON_NAME => array(
725 6a3b101a Andreas Kohlbecker
        'as_list' => 'div',
726 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
727
        'link_to_name_used_in_source' => 1,
728
        'sources_as_content' => 0,
729
        'sources_as_content_to_bibliography' => 0,
730
        'sort_elements' => NO_SORT,
731 f2e44165 Andreas Kohlbecker
        'glue' => '',
732 642b323b Andreas Kohlbecker
        'element_tag' => 'span'
733 f2e44165 Andreas Kohlbecker
      ),
734 f3a04cfa Andreas Kohlbecker
    );
735
736 642b323b Andreas Kohlbecker
    // ---- Special DEFAULTS for existing portals
737
    // TODO:
738
    // this can be removed once the feature block
739
    // settings have been deployed for the first time to these portals
740
741 f3a04cfa Andreas Kohlbecker
    $cichorieae_default = array(
742
      'DEFAULT' => array(
743
        'as_list' => 'div',
744 642b323b Andreas Kohlbecker
        'link_to_reference' => 1,
745
        'link_to_name_used_in_source' => 1,
746
        'sources_as_content' => 1,
747
        'sources_as_content_to_bibliography' => 0,
748
        'sort_elements' => NO_SORT,
749 f3a04cfa Andreas Kohlbecker
        'glue' => '',
750 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
751 f3a04cfa Andreas Kohlbecker
      ),
752
      UUID_CITATION => array(
753
        'as_list' => 'div',
754 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
755
        'link_to_name_used_in_source' => 0,
756
        'sources_as_content' => 1,
757
        'sources_as_content_to_bibliography' => 0,
758 dcf17487 Andreas Kohlbecker
        'sort_elements' => SORT_ASC,
759 f3a04cfa Andreas Kohlbecker
        'glue' => '',
760 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
761 f3a04cfa Andreas Kohlbecker
      ),
762
      UUID_CHROMOSOMES_NUMBERS => array(
763
        'as_list' => 'ul',
764 642b323b Andreas Kohlbecker
        'link_to_reference' => 1,
765
        'link_to_name_used_in_source' => 1,
766
        'sources_as_content' => 1,
767
        'sources_as_content_to_bibliography' => 0,
768
        'sort_elements' => NO_SORT,
769 f3a04cfa Andreas Kohlbecker
        'glue' => '',
770 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
771 f3a04cfa Andreas Kohlbecker
      ),
772
      UUID_CHROMOSOMES => array(
773
        'as_list' => 'ul',
774 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
775
        'link_to_name_used_in_source' => 1,
776
        'sources_as_content' => 1,
777
        'sources_as_content_to_bibliography' => 0,
778
        'sort_elements' => NO_SORT,
779 f3a04cfa Andreas Kohlbecker
        'glue' => '',
780 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
781 f3a04cfa Andreas Kohlbecker
      ),
782 f2e44165 Andreas Kohlbecker
      UUID_COMMON_NAME => array(
783
        'as_list' => 'div',
784 642b323b Andreas Kohlbecker
        'link_to_reference' => 0,
785
        'link_to_name_used_in_source' => 1,
786
        'sources_as_content' => 0,
787
        'sources_as_content_to_bibliography' => 0,
788
        'sort_elements' => NO_SORT,
789 f2e44165 Andreas Kohlbecker
        'glue' => '',
790 642b323b Andreas Kohlbecker
        'element_tag' => 'span'
791 f2e44165 Andreas Kohlbecker
      ),
792 f3a04cfa Andreas Kohlbecker
    );
793
794
    $palmweb_default = array(
795
      'DEFAULT' => array(
796
        'as_list' => 'ul',
797 642b323b Andreas Kohlbecker
        'link_to_reference' => 1,
798
        'link_to_name_used_in_source' => 1,
799
        'sources_as_content' => 1,
800
        'sources_as_content_to_bibliography' => 1,
801
        'sort_elements' => NO_SORT,
802 f3a04cfa Andreas Kohlbecker
        'glue' => '',
803 642b323b Andreas Kohlbecker
        'element_tag' => NULL
804 f3a04cfa Andreas Kohlbecker
      ),
805
      UUID_CITATION => array(
806
        'as_list' => 'ul',
807 642b323b Andreas Kohlbecker
        'link_to_reference' => 1,
808
        'link_to_name_used_in_source' => 1,
809
        'sources_as_content' => 0,
810
        'sources_as_content_to_bibliography' => 1,
811 dcf17487 Andreas Kohlbecker
        'sort_elements' => SORT_ASC,
812 f3a04cfa Andreas Kohlbecker
        'glue' => '',
813 642b323b Andreas Kohlbecker
        'element_tag' => 'div'
814 a009927b Andreas Kohlbecker
      ),
815
      UUID_DISTRIBUTION => array(
816
        'as_list' => 'div', // currently ignored
817 642b323b Andreas Kohlbecker
        'link_to_reference' => 1,
818
        'link_to_name_used_in_source' => 1,
819
        'sources_as_content' => 1, // FIXME seems to have no effect see Acanthophoenix rousselii (palmae)
820
        'sources_as_content_to_bibliography' => 1,
821
        'sort_elements' => NO_SORT, // will cause ...
822 a009927b Andreas Kohlbecker
        'glue' => '',
823 642b323b Andreas Kohlbecker
        'element_tag' => 'div',
824
        'special' => array()
825 a009927b Andreas Kohlbecker
      ),
826 f3a04cfa Andreas Kohlbecker
    );
827
828 6776a5bc Andreas Kohlbecker
    $cyprus_default = $cichorieae_default;
829 642b323b Andreas Kohlbecker
    $cyprus_default[UUID_DISTRIBUTION] = array(
830 6776a5bc Andreas Kohlbecker
      'as_list' => 'div', // currently ignored
831 642b323b Andreas Kohlbecker
      'link_to_reference' => 0,
832
      'link_to_name_used_in_source' => 0,
833
      'sources_as_content' => 0,
834
      'sources_as_content_to_bibliography' => 0,
835
      'sort_elements' => NO_SORT, // will cause ...
836 6776a5bc Andreas Kohlbecker
      'glue' => '',
837 642b323b Andreas Kohlbecker
      'element_tag' => 'div',
838
      'special' => array()
839 6776a5bc Andreas Kohlbecker
    );
840
841 f3a04cfa Andreas Kohlbecker
    $default_theme = variable_get('theme_default', NULL);
842
843 642b323b Andreas Kohlbecker
    switch ($default_theme) {
844 f3a04cfa Andreas Kohlbecker
      case 'garland_cichorieae':
845 6776a5bc Andreas Kohlbecker
        $settings_for_theme = $cichorieae_default;
846
        break;
847 f3a04cfa Andreas Kohlbecker
      case 'cyprus':
848
        // cyprus: no longer used in production,
849
        // but is required for selenium tests see class eu.etaxonomy.dataportal.pages.PortalPage
850 6776a5bc Andreas Kohlbecker
        $settings_for_theme = $cyprus_default;
851 f3a04cfa Andreas Kohlbecker
        break;
852
      case 'flore_afrique_centrale':
853
      case 'flora_malesiana':
854
      case 'flore_gabon':
855
        $settings_for_theme = $cichorieae_default;
856
        $settings_for_theme[UUID_CITATION]['as_list'] = 'ul';
857
        break;
858
      case 'palmweb_2':
859
        $settings_for_theme = $palmweb_default;
860
        break;
861
      default:
862 642b323b Andreas Kohlbecker
        $settings_for_theme = $other_themes_default;
863 f3a04cfa Andreas Kohlbecker
    }
864 642b323b Andreas Kohlbecker
    // ---- END of DEFAULTS
865 c367b0ab Andreas Kohlbecker
866 642b323b Andreas Kohlbecker
    $saved_settings = variable_get(FEATURE_BLOCK_SETTINGS, NULL);
867
868 57d513cb Andreas Kohlbecker
    $feature_block_setting = null;
869 642b323b Andreas Kohlbecker
870
    if (isset($saved_settings[$feature_uuid])) {
871
      $feature_block_setting = $saved_settings[$feature_uuid];
872
    }
873
    else if (isset($settings_for_theme[$feature_uuid])) {
874
      $feature_block_setting = $settings_for_theme[$feature_uuid];
875 f3a04cfa Andreas Kohlbecker
    }
876 642b323b Andreas Kohlbecker
    else if (isset($settings_for_theme['DEFAULT'])) {
877
      $feature_block_setting = $settings_for_theme['DEFAULT'];
878
    }
879
880 57d513cb Andreas Kohlbecker
    // now merge the default and specific settings
881
    $settings_to_merge = array($default['DEFAULT']);
882
    if(is_array($saved_settings)){
883
      $settings_to_merge[] = $saved_settings['DEFAULT'];
884
    }
885
    if(isset($feature_block_setting)){
886
      $settings_to_merge[] = $feature_block_setting;
887
    }
888
    $feature_block_setting = drupal_array_merge_deep_array($settings_to_merge);
889 642b323b Andreas Kohlbecker
890
    return $feature_block_setting;
891 1ce9afb7 Patric Plitzner
}
892 22f5e82d Andreas Kohlbecker
  /**
893 5611d467 Andreas Kohlbecker
 * returns the current setting for the original source bibliography
894
 *
895
 * Caches internally
896
 *
897
 * @return array
898
 *  the setting for the original source bibliography see BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE:
899
 *   - 'enabled': 1|0
900
 *   - 'key_format': one of 'latin', 'ROMAN', 'roman', 'ALPHA', 'alpha'
901
 */
902 800ff2b0 Andreas Kohlbecker
function get_bibliography_settings($clear_cache = false){
903 5611d467 Andreas Kohlbecker
  static $bibliography_settings = null;
904 800ff2b0 Andreas Kohlbecker
  if(!$bibliography_settings || $clear_cache){
905 f3a04cfa Andreas Kohlbecker
    $bibliography_settings = get_array_variable_merged(
906
      BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE,
907
      BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE_DEFAULT
908
    );
909 5611d467 Andreas Kohlbecker
  }
910
  return $bibliography_settings;
911
}
912
913 6657531f Andreas Kohlbecker
/**
914
 * @todo Please document this function.
915
 * @see http://drupal.org/node/1354
916
 */
917
function cdm_dataportal_menu_admin(&$items) {
918
  // Display section on admin/config page.
919
  $items['admin/config/cdm_dataportal'] = array(
920
    'title' => 'CDM Dataportal',
921
    'description' => 'Settings for the CDM DataPortal.',
922
    'position' => 'right',
923
    'weight' => 10,
924
    'page callback' => 'system_admin_menu_block_page',
925 e014414c Andreas Kohlbecker
    'access arguments' => array('administer cdm_dataportal'),
926 6657531f Andreas Kohlbecker
    'file' => 'system.admin.inc',
927
    'file path' => drupal_get_path('module', 'system'),
928
  );
929
  $items['admin/config/cdm_dataportal/settings'] = array(
930
    'title' => 'Settings',
931
    'description' => 'Settings for the CDM DataPortal.',
932
    'weight' => 0,
933
    'page callback' => 'drupal_get_form',
934
    'page arguments' => array('cdm_settings_general'),
935
    'access arguments' => array('administer cdm_dataportal'),
936
    'type' => MENU_NORMAL_ITEM,
937
  );
938
  $items['admin/config/cdm_dataportal/settings/general'] = array(
939
    'title' => 'General',
940
    'description' => 'General',
941
    'weight' => 0,
942
    'page callback' => 'drupal_get_form',
943
    'page arguments' => array('cdm_settings_general'),
944
    'access arguments' => array('administer cdm_dataportal'),
945
    'type' => MENU_DEFAULT_LOCAL_TASK,
946
  );
947
948
  $items['admin/config/cdm_dataportal/settings/cachesite'] = array(
949
    'title' => 'Cache',
950
    'description' => 'Cache',
951
    'access arguments' => array('administer cdm_dataportal'),
952
    'page callback' => 'drupal_get_form',
953
    'page arguments' => array('cdm_settings_cache'),
954
    'weight' => 10,
955
    'type' => MENU_LOCAL_TASK,
956
  );
957
958
  $items['admin/config/cdm_dataportal/settings/geo'] = array(
959
    'title' => 'Geo & Map',
960
    'description' => 'Geo & Map',
961
    'access arguments' => array('administer cdm_dataportal'),
962
    'page callback' => 'drupal_get_form',
963
    'page arguments' => array('cdm_settings_geo'),
964
    'weight' => 1,
965
    'type' => MENU_LOCAL_TASK,
966
  );
967
968
  $items['admin/config/cdm_dataportal/settings/layout'] = array(
969
    'title' => 'Layout',
970
    'description' => 'Configure and adjust the layout of your DataPortal ',
971
    'access arguments' => array('administer cdm_dataportal'),
972
    'page callback' => 'drupal_get_form',
973
    'page arguments' => array('cdm_settings_layout'),
974
    'weight' => 2,
975
    'type' => MENU_LOCAL_TASK,
976
  );
977
978
  $items['admin/config/cdm_dataportal/settings/layout/taxon'] = array(
979
    'title' => 'Taxon',
980
    'description' => 'Configure and adjust the layout of your DataPortal ',
981
    'access arguments' => array('administer cdm_dataportal'),
982
    'page callback' => 'drupal_get_form',
983
    'page arguments' => array('cdm_settings_layout_taxon'),
984
    'weight' => 1,
985
    'type' => MENU_LOCAL_TASK,
986
  );
987
  /*
988
  $items[] = array(
989
  'path' => 'admin/config/cdm_dataportal/layout/synonymy',
990
  'title' => t('Synonymy'),
991
  'description' => t('Configure and adjust the layout of your DataPortal '),
992
  'access' => user_access('administer cdm_dataportal'),
993
  'callback' => 'drupal_get_form',
994
  'callback arguments' => array('cdm_settings_layout_synonymy'),
995
  'weight' => 1,
996
  'type' => MENU_LOCAL_TASK,
997
  );
998
999
  $items[] = array(
1000
  'path' => 'admin/config/cdm_dataportal/layout/specimens',
1001
  'title' => t('Specimens'),
1002
  'description' => t('Configure and adjust the layout of your DataPortal '),
1003
  'access' => user_access('administer cdm_dataportal'),
1004
  'callback' => 'drupal_get_form',
1005
  'callback arguments' => array('cdm_settings_layout_specimens'),
1006
  'weight' => 1,
1007
  'type' => MENU_LOCAL_TASK,
1008
  );
1009
  */
1010
  $items['admin/config/cdm_dataportal/settings/layout/search'] = array(
1011
    'title' => 'Search',
1012
    'description' => 'Configure and adjust the layout of your DataPortal ',
1013
    'access arguments' => array('administer cdm_dataportal'),
1014
    'page callback' => 'drupal_get_form',
1015
    'page arguments' => array('cdm_settings_layout_search'),
1016
    'weight' => 2,
1017
    'type' => MENU_LOCAL_TASK,
1018
  );
1019
1020
  $items['admin/config/cdm_dataportal/settings/layout/media'] = array(
1021
    'title' => 'Media',
1022
    'description' => 'Configure and adjust the layout of your DataPortal ',
1023
    'access arguments' => array('administer cdm_dataportal'),
1024
    'page callback' => 'drupal_get_form',
1025
    'page arguments' => array('cdm_settings_layout_media'),
1026
    'weight' => 3,
1027
    'type' => MENU_LOCAL_TASK,
1028
  );
1029 947c6a8d Andreas Kohlbecker
1030 6657531f Andreas Kohlbecker
}
1031
1032
/**
1033
 * @todo document this function.
1034
 */
1035
function cdm_help_general_cache() {
1036
  $form = array();
1037
  $form['cache_help'] = array(
1038
    '#type' => 'fieldset',
1039
    '#title' => t('Help'),
1040
    '#collapsible' => TRUE,
1041
    '#collapsed' => TRUE,
1042
  );
1043
  $form['cache_help']['test'] = array('#value' => t('probando'));
1044
  return drupal_render($form);
1045
  $res = array();
1046
  $res['default'] = drupal_render($help);
1047
  return $res;
1048
}
1049
1050
/**
1051
 * Configures the settings form for the CDM-API module.
1052
 *
1053
 * @return array
1054
 *   Drupal settings form.
1055
 */
1056
function cdm_settings_general() {
1057
1058
  $form['cdm_webservice'] = array(
1059
    '#type' => 'fieldset',
1060
    '#title' => t('CDM Server'),
1061
    '#collapsible' => FALSE,
1062
    '#collapsed' => FALSE,
1063 9438ad3a Andreas Kohlbecker
    '#description' => t('The <em>CDM Server</em> exposes data stored in a
1064
        CDM data base to the web via RESTful web services and thus is the source of the data
1065
        to be displayed by a CDM DataPotal.'),
1066 6657531f Andreas Kohlbecker
  );
1067
1068
  $form['cdm_webservice']['cdm_webservice_url'] = array(
1069
    '#type' => 'textfield',
1070
    '#title' => t('CDM web service URL') . ':',
1071
    '#description' => t('This is the URL to the CDM-Server exposing your data
1072 d1eb0a8c Andreas Kohlbecker
      e.g. <em>"http://myserver.net/cdmserver/myproject"</em>'),
1073 6657531f Andreas Kohlbecker
    '#default_value' => variable_get('cdm_webservice_url', NULL),
1074
  );
1075
1076
  $form['cdm_webservice']['cdm_webservice_debug'] = array(
1077 17c3d760 Andreas Kohlbecker
    '#type' => 'markup',
1078 d1e3ac25 Andreas Kohlbecker
    '#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')
1079
      . ' visible only for administrators',
1080 6657531f Andreas Kohlbecker
  );
1081
1082
  $form['cdm_webservice']['freetext_index'] = array(
1083
    '#type' => 'fieldset',
1084
    '#title' => t('Freetext index'),
1085
    '#collapsible' => FALSE,
1086
    '#collapsed' => FALSE,
1087
  );
1088
1089
  // Check the cdmserver port number and display a waring if it is not port 80
1090
  preg_match("#http[s]?://[0-9\p{L}\.]*:([0-9]*)/.*#u", variable_get('cdm_webservice_url', ''), $portNumberMatch, PREG_OFFSET_CAPTURE);
1091
  if (isset($portNumberMatch[1]) && $portNumberMatch[1] != '80') {
1092
    $form['cdm_webservice']['freetext_index']['message'] = array(
1093
      '#markup' => "<div class=\"description\">"
1094 7cc085da Andreas Kohlbecker
      . t("The CDM web service URL contains a portnumber other than standart HTTP port 80: '!port'
1095
           Due to this the reindex and purge fuctions may not be working if there is a firewall in between you and the CDM Server.
1096
           You may want to contact the maintainer of the according CDM Server in order to solve this problem.",
1097
          array('!port' => $portNumberMatch[1][0])
1098
        )
1099 6657531f Andreas Kohlbecker
      . "</div>",
1100
    );
1101
  };
1102
1103
  $frontentURL = urlencode(variable_get('cdm_webservice_url', ''));
1104
  $trigger_link_options = array(
1105
    'attributes' => array(
1106
      'class' => 'index-trigger',
1107
    ),
1108
  );
1109
  $form['cdm_webservice']['freetext_index']['operations'] = array(
1110
    '#markup' => "<div>" . t('Operations: !url1 !url2', array(
1111
        '!url1' => l(t("Purge"), cdm_compose_url(CDM_WS_MANAGE_PURGE, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
1112
        '!url2' => l(t("Reindex"), cdm_compose_url(CDM_WS_MANAGE_REINDEX, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
1113
      ))
1114
    . '<div id="index-progress"></div></div>',
1115
  );
1116
  _add_js_cdm_ws_progressbar(".index-trigger", "#index-progress");
1117
1118 35bea66c Patrick Plitzner
    $form['cdm_webservice']['freetext_index']['cdm_dataportal_taxon_auto_suggest'] = array(
1119
        '#type' => 'checkbox',
1120 6a5d84e2 Patrick Plitzner
        '#title' => t('(EXPERIMENTAL) Enable auto-suggest for taxon search'),
1121 35bea66c Patrick Plitzner
        '#default_value' => variable_get('cdm_dataportal_taxon_auto_suggest', CDM_DATAPORTAL_TAXON_AUTO_SUGGEST),
1122
        '#description' => t('If enabled, the taxon search field will suggest taxon names while typing in a search query.
1123
        This function works on indexed taxon names. If you experience any delay maybe you have to reindex (see above).'),
1124
    );
1125
1126 6657531f Andreas Kohlbecker
  $form['cdm_webservice']['proxy'] = array(
1127
    '#type' => 'fieldset',
1128
    '#title' => t('Proxy'),
1129
    '#collapsible' => TRUE,
1130
    '#collapsed' => TRUE,
1131
  );
1132
1133
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] = array(
1134
    '#type' => 'textfield',
1135
    '#title' => t('Proxy URL') . ':',
1136
    '#description' => t('If this proxy url is set the cdm api tries
1137
    to connect the web service over the given proxy server.
1138
    Otherwise proxy usage is deactivated.'),
1139
    '#default_value' => variable_get('cdm_webservice_proxy_url', FALSE),
1140
  );
1141
1142
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] = array(
1143
    '#type' => 'textfield',
1144
    '#title' => t('Proxy port') . ':',
1145
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
1146
  );
1147
1148
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] = array(
1149
    '#type' => 'textfield',
1150
    '#title' => t('Login') . ':',
1151
    '#default_value' => variable_get('cdm_webservice_proxy_usr', FALSE),
1152
  );
1153
1154
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] = array(
1155
    '#type' => 'textfield',
1156
    '#title' => t('Password') . ':',
1157
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', FALSE),
1158
  );
1159
1160
  // TODO: settings are still incomplete, compare with
1161
  // trunk/dataportal/inc/config_default.php.inc.
1162 9438ad3a Andreas Kohlbecker
  $form['taxon_tree'] = array(
1163 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
1164
    '#title' => t('Taxon Tree'),
1165
    '#collapsible' => FALSE,
1166
    '#collapsed' => TRUE,
1167
    '#description' => t('<p>When you explore your collection, you can navigate
1168
      it through a tree structure also called <em>Taxon Tree</em>.</p><p>To be
1169
      able to navigate through your collection the
1170
      <a href="http://drupal.org/handbook/blocks">drupal block</a>
1171
      <em>CDM Taxon Tree</em> should be visible for users. Enable the block at
1172
      <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks
1173
      </a></p>'),
1174
  );
1175
1176 9438ad3a Andreas Kohlbecker
  $form['taxon_tree'][CDM_TAXONOMICTREE_UUID] = array(
1177 6657531f Andreas Kohlbecker
    '#type' => 'select',
1178
    '#title' => t('Available classifications') . ':',
1179
    '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
1180
    '#options' => cdm_get_taxontrees_as_options(),
1181
    '#description' => t('Select the default taxa classification for your
1182
      <em>taxon tree</em>, the other classifications will be also available but
1183
      with a manual user change.'),
1184
  );
1185
1186 aaa81689 Andreas Kohlbecker
  $form['taxon_tree'][TAXONTREE_RANKLIMIT] = array(
1187 6657531f Andreas Kohlbecker
    '#type' => 'select',
1188
    '#title' => t('Rank of highest displayed taxon') . ':',
1189
     // Before DEFAULT_TAXONTREE_RANKLIMIT_UUID.
1190 aaa81689 Andreas Kohlbecker
    '#default_value' => variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT),
1191 6657531f Andreas Kohlbecker
    '#options' => cdm_rankVocabulary_as_option(),
1192
    '#description' => t('This is the rank of the highest displayed taxon in the
1193
      <em>taxon tree</em>. You can select here which rank should be at the top
1194
      level of the tree structure.'),
1195
  );
1196
1197 26fb3778 Andreas Kohlbecker
  $classification_uuids = array_keys(cdm_get_taxontrees_as_options());
1198
  $taxontree_includes_default = array_combine($classification_uuids, $classification_uuids);
1199
  $form['taxon_tree'][CDM_TAXONTREE_INCLUDES] = array(
1200
      '#type' => 'checkboxes',
1201
      '#title' => t('Included Classifications') . ':',
1202
      '#default_value' => variable_get(CDM_TAXONTREE_INCLUDES, $taxontree_includes_default),
1203
      '#options' => cdm_get_taxontrees_as_options(),
1204
      '#description' => t('Only the checked classifications will be avaliable in the classification chooser.'),
1205
  );
1206
1207 aa63dfb4 Andreas Kohlbecker
  $form['distribution'] = array(
1208
      '#type' => 'fieldset',
1209
      '#title' => t('Distributions'),
1210
      '#collapsible' => FALSE,
1211
      '#description' => 'This section covers general settings regarding distributions, map related settings are found in the '
1212
          . l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
1213 562a6ac4 Andreas Kohlbecker
          '. Further settings regarding the Distribution feature block can be found in the Layout/Taxon tab at two distinct places: '
1214
          . l('Distribution appearance', 'admin/config/cdm_dataportal/settings/layout/taxon', array('fragment' => 'edit-distribution-layout')) .', '
1215
          . l('Taxon profile feature block settings', 'admin/config/cdm_dataportal/settings/layout/taxon', array('fragment' => 'edit-feature-block-settings')) .
1216 aa63dfb4 Andreas Kohlbecker
          '<p>
1217
          </p>',
1218
  );
1219
1220
  $form['distribution'][CDM_DISTRIBUTION_FILTER] = array(
1221
      '#type' => 'fieldset',
1222
      '#title' => 'Distribution filter',
1223
      '#collapsible' => FALSE,
1224
      '#collapsed' => FALSE,
1225
      '#tree' => TRUE,
1226
      '#description' => 'The Distribution filter offers the following options
1227
      <ul>
1228 0eef1621 Andreas Kohlbecker
      <li><strong>Status order preference rule:</strong> In case of multiple distribution status (PresenceAbsenceTermBase) for
1229
        the same area the status with the highest order is preferred, see OrderedTermBase.compareTo(OrderedTermBase).</li>
1230
      <li><strong>Sub area preference rule:</strong>If there is an area with a direct sub area and both areas have the same
1231
        computed status only the information on the sub area should be reported, whereas the super area should be ignored.</li>
1232
      <li><strong>Marked area filter:</strong>Skip distributions for areas having a TRUE Marker with one of the specified MarkerTypes.
1233
        Existing sub-areas of a marked area must also be marked with the same marker type, otherwise the marked
1234
        area acts as a fallback area for the sub areas. An area is a <em>fallback area</em> if it is marked to
1235
        be hidden and if it has at least one of sub area which is not marked to be hidden. The <em>fallback area</em>
1236
        will be show if there is no Distribution for any of the non hidden sub-areas. For more detailed discussion on
1237
        <em>fallback area</em> see https://dev.e-taxonomy.eu/trac/ticket/4408.</li>
1238 aa63dfb4 Andreas Kohlbecker
      </ul>'
1239
  );
1240
1241
  $cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
1242
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['filter_rules'] = array(
1243
      '#type' => 'checkboxes',
1244
      '#title' => 'Filter rules',
1245
      '#default_value' => $cdm_distribution_filter['filter_rules'],
1246
      '#options' => array(
1247
          'statusOrderPreference' => 'Status order preference rule',
1248
          'subAreaPreference' => 'Sub area preference rule'
1249
      ),
1250
  );
1251
1252 7ca5ef1e Andreas Kohlbecker
  $marker_type_options = cdm_terms_by_type_as_option('MarkerType');
1253 6fbf1bd3 Andreas Kohlbecker
  $form['distribution'][CDM_DISTRIBUTION_FILTER]['hiddenAreaMarkerType'] = array(
1254 aa63dfb4 Andreas Kohlbecker
      '#type' => 'checkboxes',
1255
      '#title' => 'Hide marked area filter',
1256 6fbf1bd3 Andreas Kohlbecker
      '#default_value' => $cdm_distribution_filter['hiddenAreaMarkerType'],
1257 aa63dfb4 Andreas Kohlbecker
      '#options' => $marker_type_options,
1258
      '#description' => 'Check one or more MarkerTypes to define the "hide marked area" filter .',
1259
  );
1260
1261 f19f47fa Andreas Kohlbecker
  $form['aggregation'] = array(
1262
      '#type' => 'fieldset',
1263
      '#title' => t('Aggregation of data'),
1264
      '#collapsible' => FALSE,
1265 aa63dfb4 Andreas Kohlbecker
      '#description' => 'This section covers the different aspects of aggregating information.
1266 9438ad3a Andreas Kohlbecker
          <p>
1267 f19f47fa Andreas Kohlbecker
          </p>',
1268 9438ad3a Andreas Kohlbecker
  );
1269
1270 ccde8251 Andreas Kohlbecker
  $form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
1271
      '#type' => 'checkboxes',
1272
      '#title' => 'Taxon media filter',
1273
      '#default_value' => variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)),
1274
      '#options' => array(
1275
          'includeTaxonDescriptions' => 'Media in taxon descriptions',
1276
          'includeTaxonNameDescriptions' => 'Media in name descriptions',
1277
          'includeOccurrences' => 'Media related to specimens and occurrences',
1278
      ),
1279
      '#description' => 'This filter configures which images should be taken into account.',
1280
  );
1281
1282
  $form['aggregation']['notice'] = array(
1283 3a874294 Andreas Kohlbecker
      '#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
1284 ccde8251 Andreas Kohlbecker
          want to make use of the caching capabilities of the dataportal.',
1285
  );
1286
1287 f19f47fa Andreas Kohlbecker
  $form['aggregation']['media_aggregation'] = array(
1288
      '#type' => 'fieldset',
1289
      '#title' => t('Media aggregation'),
1290
      '#collapsible' => FALSE,
1291 9438ad3a Andreas Kohlbecker
      '#collapsed' => TRUE,
1292 f19f47fa Andreas Kohlbecker
      '#description' => t("The media aggregation is also affected by the settigs in \"<strong>Aggregation via taxon relationsships</strong>\" below."),
1293
1294 9438ad3a Andreas Kohlbecker
  );
1295 f19f47fa Andreas Kohlbecker
  $form['aggregation']['media_aggregation']['cdm_images_include_children'] = array(
1296
      '#type' => 'select',
1297
      '#title' => t('Aggregation of taxon pictures') . ':',
1298
      '#default_value' => variable_get('cdm_images_include_children', FALSE),
1299
      '#options' => array(
1300
          0 => "Show only pictures of the current taxon",
1301
          1 => "Include pictures of taxonomic children",
1302
      ),
1303
      '#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."),
1304 9438ad3a Andreas Kohlbecker
  );
1305
1306 f19f47fa Andreas Kohlbecker
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS] = array(
1307 30f78c59 Andreas Kohlbecker
      '#type' => 'fieldset',
1308 38dd933d Andreas Kohlbecker
      '#attributes' => array('class' => array('clearfix')),
1309 9438ad3a Andreas Kohlbecker
      '#title' => t('Aggregation via taxon relationsships'),
1310 30f78c59 Andreas Kohlbecker
      '#collapsible' => TRUE,
1311
      '#collapsed' => TRUE,
1312 f19f47fa Andreas Kohlbecker
      '#tree' => TRUE,
1313 30f78c59 Andreas Kohlbecker
      '#description' => t('Information on taxa will be aggregated along the below chosen
1314
          taxon relation ships. This will affect images and occurrences (specimens).
1315
          Taxon relation ships are directed and point form one taxon to another. The taxon
1316
          relationships to be taken into accunt can therefore configured for the direct direction
1317 f19f47fa Andreas Kohlbecker
          and for the inverse.'),
1318
  );
1319
1320 7ca5ef1e Andreas Kohlbecker
  $taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
1321 30f78c59 Andreas Kohlbecker
  $aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
1322 f19f47fa Andreas Kohlbecker
1323
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array(
1324
      '#type' => 'checkboxes',
1325
      '#title' => t('Direct'),
1326
      '#options' => $taxonRelationshipTypeOptions,
1327
      '#default_value' => $aggregate_by_taxon_relationships['direct'],
1328 30f78c59 Andreas Kohlbecker
  );
1329 f19f47fa Andreas Kohlbecker
  $form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['invers'] = array(
1330
      '#type' => 'checkboxes',
1331
      '#title' => t('Invers'),
1332
      '#options' => $taxonRelationshipTypeOptions,
1333
      '#default_value' => $aggregate_by_taxon_relationships['invers'],
1334 30f78c59 Andreas Kohlbecker
  );
1335
1336 06c2b3e2 Andreas Kohlbecker
  $form['drupal_integration'] = array(
1337
    '#type' => 'fieldset',
1338 38dd933d Andreas Kohlbecker
    '#attributes' => array('class'=> array('clearfix')),
1339 06c2b3e2 Andreas Kohlbecker
    '#title' => t('Drupal integration'),
1340
    '#collapsible' => FALSE,
1341
    '#collapsed' => FALSE,
1342
    '#tree' => FALSE
1343
  );
1344
1345
  $form['drupal_integration'][CDM_DRUPAL_NODE_CREATION] = array(
1346
    '#type' => 'checkbox',
1347
    '#title' => 'Create drupal nodes',
1348
    '#default_value' => variable_get(CDM_DRUPAL_NODE_CREATION, FALSE),
1349 944d793a Andreas Kohlbecker
    '#description' => 'Content für cdm_dataportal pages is directly retrieved from the 
1350 06c2b3e2 Andreas Kohlbecker
    CDM webservice configured above. In order to use other drupal modules like the "Comments" module together with the 
1351
    cdm pages it is required that drupal nodes are created and stored in the database.'
1352
  );
1353
1354
1355
1356
  $form['drupal_integration']['drop_all_cdm_nodes_warning_pre'] = array(
1357
    '#markup' => '<h6 style="color:red;">WARNING:</h6>
1358
    <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>',
1359
  );
1360
  $form['drupal_integration']['drop_all_cdm_nodes'] = array(
1361
    '#type' => 'submit',
1362
    '#value' => t('Drop all cdm nodes'),
1363
    '#submit' => array('drop_all_cdm_nodes_submit')
1364
  );
1365
1366
  $form['drupal_integration']['drop_all_cdm_nodes_warning_post'] = array(
1367
    '#markup' => '<div class="description">All Drupal nodes created for cdm content can be deleted at once using this button.</div>',
1368
  );
1369
1370
    // ----------------------
1371 5ea8b301 Andreas Kohlbecker
  $form['cdm_js_devel_mode'] = array(
1372
      '#type' => 'checkbox',
1373
      '#title' => 'Java-script developer mode',
1374
      '#default_value' => variable_get('cdm_js_devel_mode', FALSE),
1375
      '#description' => 'In production envirionments the java script libraries
1376
      the cdm_dataportal is making use of are compressed and optimized. This
1377
      is good for performance but a caveat if you need to debug java-script. When the
1378
      java-script developer mode is enabled the uncompressed and commented developer
1379
      versions of java-script libraries will be used where possible.
1380
      <br/><strong>Do not use this option in production!</strong>'
1381
  );
1382 2dd59bb5 Andreas Kohlbecker
  // ----------------------
1383
  $form['cdm_debug_mode'] = array(
1384
      '#type' => 'checkbox',
1385
      '#title' => 'CDM page debug mode',
1386
      '#default_value' => variable_get('cdm_debug_mode', FALSE),
1387
      '#description' => 'When CDM page debug mode enabled the start and end of cdm entity page
1388 b5deb531 Andreas Kohlbecker
      creation is logged as well as any http request send via the cdm_api. The log is written to a file in the temporary
1389
      folder configured in the' . l('File system settings', 'admin/config/media/file-system') .
1390
       '. For this site the file is <code> ' . file_directory_temp() . '/drupal_debug.txt</code>
1391 2dd59bb5 Andreas Kohlbecker
      The log is written by the drupal devel module function <code>dd()</code>.
1392 b5deb531 Andreas Kohlbecker
      <br/><strong>Note:</strong> The start and end of the page creation is currently only logged for taxon pages only.'
1393 2dd59bb5 Andreas Kohlbecker
  );
1394 5ea8b301 Andreas Kohlbecker
1395 6657531f Andreas Kohlbecker
  // Comment @WA: D7 form api does not support reset buttons,
1396
  // so to mimic the D5 reset button we add one like this.
1397
  $form['actions']['reset'] = array(
1398
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
1399
    '#weight' => 1000,
1400
  );
1401
1402 22eb20d7 Andreas Kohlbecker
  $form['#submit'][] = 'cdm_settings_general_submit';
1403
1404 6657531f Andreas Kohlbecker
  return system_settings_form($form);
1405
}
1406
1407 06c2b3e2 Andreas Kohlbecker
/**
1408
 * Submit callback; drops all cdm nodes.
1409
 *
1410
 * @ingroup forms
1411
 */
1412
function drop_all_cdm_nodes_submit($form, &$form_state) {
1413
  cdm_delete_all_cdm_nodes();
1414
  drupal_set_message(t('All cdm nodes dropped.'));
1415
}
1416
1417 6657531f Andreas Kohlbecker
1418
/**
1419
 * LAYOUT settings
1420 cf839840 Andreas Kohlbecker
 * @return
1421 6657531f Andreas Kohlbecker
 *   todo
1422
 */
1423
function cdm_settings_layout() {
1424
1425
  $form = array();
1426 0f5f1c12 Andreas Kohlbecker
1427
  $form['about'] = array(
1428
    '#markup' => '<h4>' . t('Portal Layout') . '</h4><p>' . t('This settings contains the general configurations
1429 6657531f Andreas Kohlbecker
      layout. If you want to configure the specific sites layout visit the
1430 0f5f1c12 Andreas Kohlbecker
      respective configuration site for taxon, search or media.') . '</p>',
1431 6657531f Andreas Kohlbecker
  );
1432
1433
  // ---- footnotes --- //
1434 0f5f1c12 Andreas Kohlbecker
  $form['footnotes'] = array(
1435 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
1436
    '#title' => t('Footnotes'),
1437
    '#collapsible' => FALSE,
1438
    '#collapsed' => FALSE,
1439
    '#description' => t('Taxa data such authors, synonyms names, descriptions,
1440
      media or distribution areas may have annotations or footnotes. When the
1441
      footnotes are enabled they will be visible (if they exist).'),
1442
  );
1443
1444 0f5f1c12 Andreas Kohlbecker
  $form['footnotes']['cdm_dataportal_all_footnotes'] = array(
1445 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
1446
    '#title' => t('Do not show footnotes'),
1447
    '#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
1448
    '#description' => t('Check this if you do not want to show any footnotes'),
1449
  );
1450
1451 0f5f1c12 Andreas Kohlbecker
  $form['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
1452 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
1453 10055120 Andreas Kohlbecker
    '#title' => t('Do not show annotation footnotes'),
1454 6657531f Andreas Kohlbecker
    '#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
1455
    '#description' => t('Check this if you do not want to show annotation footnotes'),
1456
  );
1457
1458 7ca5ef1e Andreas Kohlbecker
  $annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType');
1459 6657531f Andreas Kohlbecker
  // Additional option for the NULL case.
1460
  $annotationTypeOptions['NULL_VALUE'] = t('untyped');
1461 0f5f1c12 Andreas Kohlbecker
  $form['footnotes']['annotations_types_as_footnotes'] = array(
1462 6657531f Andreas Kohlbecker
    '#type' => 'checkboxes',
1463
    '#title' => t('Annotation types as footnotes'),
1464
    '#description' => t("Only annotations of the selected type will be displayed
1465
       as footnotes. You may want to turn 'technical annotations' off."),
1466
    '#options' => $annotationTypeOptions,
1467
  );
1468
  $annotationsTypesAsFootnotes = variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
1469
  if (!empty($annotationsTypesAsFootnotes)) {
1470 0f5f1c12 Andreas Kohlbecker
    $form['footnotes']['annotations_types_as_footnotes']['#default_value'] = $annotationsTypesAsFootnotes;
1471 6657531f Andreas Kohlbecker
  }
1472
1473 5611d467 Andreas Kohlbecker
  // ---- original source --- //
1474
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE] = array(
1475
      '#type' => 'fieldset',
1476
      '#tree' => TRUE,
1477
      '#title' => t('Source Citations'),
1478
      '#collapsible' => FALSE,
1479
      '#collapsed' => FALSE,
1480
  );
1481 f19f47fa Andreas Kohlbecker
1482 800ff2b0 Andreas Kohlbecker
  $bibliography_settings = get_bibliography_settings(true);
1483 5611d467 Andreas Kohlbecker
1484 800ff2b0 Andreas Kohlbecker
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['enabled'] = array(
1485 5611d467 Andreas Kohlbecker
      '#type' => 'checkbox',
1486
      '#title' => t('Original Source in bibliography'),
1487
      '#default_value' => $bibliography_settings['enabled'],
1488
      '#description' => t('Show original source citations in bibliography block, instead of rendering them with other
1489
       annotations in each feature block.'),
1490
  );
1491
1492
  $form[BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE]['key_format'] = array(
1493
    '#type' => 'select',
1494
    '#title' => t('The format of the key numerals'),
1495
    '#default_value' => $bibliography_settings['key_format'],
1496
    '#options' => array('latin' => 'Latin',
1497
      'ROMAN' => 'Roman (upper case)',
1498
      'roman' => 'Roman (lower case)',
1499
      'ALPHA'=> 'Alphabet (upper case)',
1500
      'alpha' => 'Alphabet (lower case)')
1501
  );
1502 f19f47fa Andreas Kohlbecker
1503
  // --- Advanced Search --- //
1504
  $form['asearch'] = array(
1505 1ce9afb7 Patric Plitzner
      '#type' => 'fieldset',
1506
      '#title' => t('Advanced search'),
1507
      '#collapsible' => FALSE,
1508
      '#collapsed' => FALSE,
1509 f19f47fa Andreas Kohlbecker
  );
1510
  $form['asearch']['cdm_dataportal_show_advanced_search'] = array(
1511 1ce9afb7 Patric Plitzner
      '#type' => 'checkbox',
1512
      '#title' => t('Show advanced search link'),
1513
      '#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
1514
      '#description' => t('Check this box if the link to advanced search should be show below the search box.'),
1515 f19f47fa Andreas Kohlbecker
  );
1516
1517
  // ---- Taxon Name Rendering --- //
1518
  $form['taxon_name'] = array(
1519
      '#type' => 'fieldset',
1520
      '#title' => t('Taxon name display'),
1521
      '#collapsible' => TRUE,
1522
      '#collapsed' => TRUE,
1523 7cc085da Andreas Kohlbecker
      '#description' => t('The display of taxon names is configured by two parts.
1524
          The <srong>name render templates</strong> define the parts of the name to be displayed in the different areas of the data portal pages.
1525
          The name parts are defined in the <stong>part definitions</strong>'),
1526 0f5f1c12 Andreas Kohlbecker
  );
1527
1528 78292e72 Andreas Kohlbecker
  $default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT);
1529 b2b9e057 Andreas Kohlbecker
  $default_part_definitions_pre_380_json = json_encode(unserialize(CDM_PART_DEFINITIONS_DEFAULT_PRE_380), JSON_PRETTY_PRINT);
1530
  $default_part_definition_json = json_encode($default_part_definitions, JSON_PRETTY_PRINT);
1531
  $current_part_definition_json = json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions), JSON_PRETTY_PRINT);
1532 1a01f6dd Andreas Kohlbecker
1533 b2b9e057 Andreas Kohlbecker
  $is_custom_part_definition = $default_part_definition_json != $current_part_definition_json;
1534 2eaa13b4 Andreas Kohlbecker
  if($default_part_definitions_pre_380_json == $current_part_definition_json){
1535 b2b9e057 Andreas Kohlbecker
    $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.)';
1536
  } else if($is_custom_part_definition){
1537
    $which_version_message = '(This are custom part definitions, clearing the text area and and submitting the form will reset it to the default)';
1538 2eaa13b4 Andreas Kohlbecker
  } else  {
1539 1a01f6dd Andreas Kohlbecker
    $which_version_message = '(These are the default part definition.)';
1540
  }
1541
1542 b2b9e057 Andreas Kohlbecker
  $diff_viewer_markup = '';
1543
  if($is_custom_part_definition){
1544
    $diff_viewer_markup = diff_viewer($default_part_definition_json, $current_part_definition_json);
1545
  }
1546
1547
  $which_version_message = '<div style="color:#ff0000; font-weight: bold;">'
1548
    . $which_version_message
1549
    . '</div>'
1550
    . $diff_viewer_markup;
1551
1552 0f5f1c12 Andreas Kohlbecker
  $form['taxon_name'][CDM_PART_DEFINITIONS] = array(
1553
      '#type' => 'textarea',
1554
      '#title' => t('Part definitions'),
1555
      '#element_validate' => array('form_element_validate_json'),
1556 43998144 Andreas Kohlbecker
      '#default_value' =>  $current_part_definition_json,
1557 0f5f1c12 Andreas Kohlbecker
      '#description' => '
1558 1a01f6dd Andreas Kohlbecker
          <p>' . $which_version_message . '</p>
1559 0f5f1c12 Andreas Kohlbecker
          <p>
1560
           The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
1561
          </p>
1562
          <p>
1563
           A full taxon name plus additional information can consist of the following elements:
1564
          <ul>
1565
             <li>name: the taxon name inclugin rank nbut without author</li>
1566
             <li>authors:  The authors of a reference, also used in taxon names</li>
1567
             <li>reference: the nomenclatural reference,</li>
1568
             <li>microreference:  Volume, page number etc.</li>
1569
             <li>status:  The nomenclatural status of a name</li>
1570
             <li>description: name descriptions like protologues etc ...</li>
1571
          </ul>
1572
          </p>
1573
          <p>
1574
           These elements are combined in the part definitions array to from the specific parts to be rendered.
1575
           (The taxon name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example in the following)
1576 51b04faf Andreas Kohlbecker
           The following parts can be formed and are recognized by the system:
1577 0f5f1c12 Andreas Kohlbecker
          <ul>
1578 51b04faf Andreas Kohlbecker
            <li>namePart: the name and rank (for example: "Lapsana communis")</li>
1579
            <li>authorshipPart: the author (for example: "L.")</li>
1580
            <li>nameAuthorPart: the combination of name and author part (for example: "Lapsana communis L.").</li>
1581 0f5f1c12 Andreas Kohlbecker
               This is useful for zoological names where the authorshipPart belongs to the name and both should</li>
1582
               be combined when a link to the taxon is rendered.</li>
1583 51b04faf Andreas Kohlbecker
            <li>referencePart: the nomencaltural reference (for example: "Sp. Pl. 1753")</li>
1584
          <li>referenceYearPart: the publication year of the nomencaltural reference (for example: "1753")</li>
1585
            <li>microreferencePart: usually the page number (for example ": 811.")</li>
1586 0f5f1c12 Andreas Kohlbecker
            <li>statusPart: the nomenclatorical status</li>
1587
            <li>descriptionPart: name descriptions like protologues etc ...</li>
1588
          </ul>
1589
          </p>
1590
          <p>
1591
           Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
1592
           specific parts part definitions:
1593
          <ul>
1594
            <li>BotanicalName</li>
1595
            <li>ZoologicalName</li>
1596
            <li>#DEFAULT: covers ViralNames and other NonViralNames
1597
          </ul>
1598
           An example:
1599
          <pre>
1600
           {
1601
            "ZoologicalName": {
1602
              "namePart": {
1603
                "name": true
1604
              },
1605
              "referencePart": {
1606 b5519d3a Andreas Kohlbecker
                "authors": true
1607 0f5f1c12 Andreas Kohlbecker
              },
1608
              "microreferencePart": {
1609
                "microreference": true
1610
              },
1611
              "statusPart": {
1612
                "status": true
1613
              },
1614
              "descriptionPart": {
1615
                "description": true
1616
              }
1617
            },
1618
            "BotanicalName": {
1619
              "namePart": {
1620
                "name": true,
1621
                "authors": true
1622
              },
1623
              "referencePart": {
1624
                "reference": true,
1625
                "microreference": true
1626
              },
1627 43998144 Andreas Kohlbecker
              "secReferencePart": {
1628
                "secReference": true
1629
              },
1630 0f5f1c12 Andreas Kohlbecker
              "statusPart": {
1631
                "status": true
1632
              },
1633
              "descriptionPart": {
1634
                "description": true
1635
              }
1636
            }
1637
          }
1638
           </pre>',
1639
  );
1640
1641 78292e72 Andreas Kohlbecker
  $default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
1642 b2b9e057 Andreas Kohlbecker
  $default_render_templates_pre_380_json = json_encode(unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT_PRE_380), JSON_PRETTY_PRINT);
1643
  $default_render_templates_json = json_encode($default_render_templates, JSON_PRETTY_PRINT);
1644
  $current_render_templates_json = json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates), JSON_PRETTY_PRINT);
1645
  $is_custom_render_template = $default_render_templates_json != $current_render_templates_json;
1646 1a01f6dd Andreas Kohlbecker
1647 2eaa13b4 Andreas Kohlbecker
  if($default_render_templates_pre_380_json == $current_render_templates_json){
1648 b2b9e057 Andreas Kohlbecker
    $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.)';
1649
  } else if($is_custom_render_template){
1650
    $which_version_message = '(These are custom render templates, clearing the text area and and submitting the form will reset it to the default)';
1651 1a01f6dd Andreas Kohlbecker
  } else {
1652
    $which_version_message = '(These are the default render templates.)';
1653
  }
1654
1655 b2b9e057 Andreas Kohlbecker
  $diff_viewer_markup = '';
1656
  if($is_custom_render_template){
1657
    $diff_viewer_markup = diff_viewer($default_render_templates_json, $current_render_templates_json);
1658
  }
1659
1660
  $which_version_message = '<div style="color:#ff0000; font-weight: bold;">'
1661
    . $which_version_message
1662
    . '</div>'
1663
    . $diff_viewer_markup;
1664
1665 f19f47fa Andreas Kohlbecker
  $form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array(
1666
      '#type' => 'textarea',
1667 0f5f1c12 Andreas Kohlbecker
      '#title' => t('Name render templates'),
1668 f19f47fa Andreas Kohlbecker
      '#element_validate' => array('form_element_validate_json'),
1669 1a01f6dd Andreas Kohlbecker
      '#default_value' =>  $current_render_templates_json,
1670 0f5f1c12 Andreas Kohlbecker
      '#description' => '
1671 1a01f6dd Andreas Kohlbecker
          <p>' . $which_version_message . '</p>
1672 0f5f1c12 Andreas Kohlbecker
          <p>
1673
          The render templates array contains one or more name render templates to be used within the page areas identified by the
1674 f695daf4 Andreas Kohlbecker
          render path. The render path of taxon names can be made visible by adding the URI query parameter 
1675
          <strong><code>RENDER_PATH=1</code></strong> to the page request.<br />
1676
          The render path is used as key of the array sub subelements whereas the name render template array is set as value.
1677
          The following render Path keys are currently recognized:
1678 0f5f1c12 Andreas Kohlbecker
          <ul>
1679 51b04faf Andreas Kohlbecker
            <li>list_of_taxa</li>
1680
            <li>acceptedFor</li>
1681
            <li>homonym</li>
1682 0f5f1c12 Andreas Kohlbecker
            <li>taxon_page_synonymy</li>
1683
            <li>typedesignations</li>
1684
            <li>taxon_page_title</li>
1685
            <li>polytomousKey</li>
1686
            <li>na: name + authorship</li>
1687
            <li>nar:name + authorship + reference</li>
1688
            <li>#DEFAULT</li>
1689
          </ul>
1690
          A single render template can be used for multiple render paths. In this case the according key of the render templates
1691
          array element should be a comma separated list of render paths, without any whitespace!.
1692
          </p>
1693
          <p>
1694
          A render template is an associative array. The keys of this array are referring to the keys as defined in the part
1695
          definitions array. See <a href="#edit-cdm-part-definitions">Part definitions</a> above for more information.
1696
          <p>
1697
          The value of the render template element must be set to TRUE in order to let this part being rendered.
1698 43998144 Andreas Kohlbecker
          For some parts can <strong>links</strong> can be created which lead to the accoring intity page:</br>
1699
          The <strong>namePart</strong>, <strong>nameAuthorPart</strong>, <strong>referencePart</strong> and <strong>secReferencePart</strong> can also hold an associative array with a single
1700 0f5f1c12 Andreas Kohlbecker
          element: array(\'#uri\' => TRUE). The value of the #uri element will be replaced by the according
1701
          links if the paramters $nameLink or $refenceLink are given to the name render function
1702 f19f47fa Andreas Kohlbecker
          (this is hard coded and cannot be configured here).',
1703 6657531f Andreas Kohlbecker
  );
1704
1705
  // @WA: D7 form api does not support reset buttons,
1706
  // so to mimic the D5 reset button we add one like this.
1707
  $form['actions']['reset'] = array(
1708
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
1709
    '#weight' => 1000,
1710
  );
1711 f19f47fa Andreas Kohlbecker
1712 0f5f1c12 Andreas Kohlbecker
  $form['#submit'] = array('submit_json_as_php_array');
1713
  // #json_elements especially defined for submit_json_as_php_array()
1714
  $form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
1715 6657531f Andreas Kohlbecker
  return system_settings_form($form);
1716
}
1717
1718
1719 b2b9e057 Andreas Kohlbecker
1720
  /**
1721 6657531f Andreas Kohlbecker
 * @todo Please document this function.
1722
 * @see http://drupal.org/node/1354
1723
 */
1724
function cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description = '') {
1725
  $form[$form_name] = array(
1726
    '#type' => 'fieldset',
1727 7cc085da Andreas Kohlbecker
    '#title' => t('@form-title', array('@form-title' => $form_title)),
1728 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
1729
    '#collapsed' => $collapsed,
1730
    '#tree' => TRUE,
1731 7cc085da Andreas Kohlbecker
    '#description' => t('@$form-description', array('@$form-description' => $form_description)),
1732 6657531f Andreas Kohlbecker
  );
1733
1734
  $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
1735
  $gallery_settings = variable_get($form_name, $default_values);
1736
  // $test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
1737
  if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
1738
    /*
1739
    TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
1740
    $form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
1741
    '#type' => 'textfield',
1742
    '#title' => t('Search Page Size'),
1743
    '#default_value' => $test,
1744
    '#description' => t('Number of Names to display per page in search results.')
1745
    );
1746
    */
1747
    $form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
1748
      '#type' => 'checkbox',
1749
      '#title' => t('Show media thumbnails for accepted taxa'),
1750
      '#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
1751
    );
1752
1753
    $form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
1754
      '#type' => 'checkbox',
1755
      '#title' => t('Show media thumbnails for synonyms'),
1756
      '#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
1757
      '#description' => '',
1758
    );
1759
  }
1760
1761
  // $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
1762
  $form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
1763
    '#type' => 'checkbox',
1764
    '#title' => t('Show captions under thumbnails'),
1765
    '#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
1766
    '#description' => '',
1767
  );
1768
1769
  $form[$form_name]['cdm_dataportal_media_maxextend'] = array(
1770
    '#type' => 'textfield',
1771
    '#title' => t('Thumbnail size') . ':',
1772
    '#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
1773
    '#description' => t('Select the size of each individual thumbnail.'),
1774
  );
1775
1776
  if ($form_name != CDM_DATAPORTAL_MEDIA_GALLERY_NAME) {
1777
    $form[$form_name]['cdm_dataportal_media_cols'] = array(
1778
      '#type' => 'textfield',
1779
      '#title' => t('Number of columns') . ':',
1780
      '#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
1781
      '#description' => t('Group the thumbnails in columns: select how many
1782
        columns the gallery should display.'),
1783
    );
1784
  }
1785
1786
  if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
1787
    $form[$form_name]['cdm_dataportal_media_maxRows'] = array(
1788
      '#type' => 'textfield',
1789
      '#title' => t('Maximum number of rows') . ':',
1790
      '#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
1791
      '#description' => t('You can group the thumbnails in rows, select in how
1792
        many rows should be the thumbnails grouped.<br/><strong>Note:</strong>
1793
        If you want an unlimited number of rows please set to 0.'),
1794
    );
1795
  }
1796
1797
  return $form;
1798
}
1799
1800
/**
1801
 * @todo document this function.
1802
 */
1803
function cdm_settings_layout_taxon() {
1804
  $collapsed = FALSE;
1805
  $form = array();
1806
1807 7df1be04 Andreas Kohlbecker
  $form['#submit'][] = 'cdm_settings_layout_taxon_submit';
1808
1809 6657531f Andreas Kohlbecker
  // --------- TABBED TAXON ------- //
1810
  $form['taxon_tabs'] = array(
1811
    '#type' => 'fieldset',
1812
    '#title' => t('Taxon tabs'),
1813
    '#collapsible' => TRUE,
1814 6421984d Andreas Kohlbecker
    '#collapsed' => TRUE,
1815 6657531f Andreas Kohlbecker
    '#description' => t('If tabbed taxon page is enabled the taxon profile will
1816
      be splitted in four diferent tabs; General, Synonymy, Images and
1817
      Specimens. If the taxon has no information for any of the tabs/sections
1818
      such tab will be not displayed.'),
1819
  );
1820
1821
  $form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
1822
    '#type' => 'checkbox',
1823
    '#title' => t('Tabbed taxon page'),
1824
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
1825
    '#description' => t('<p>If selected split the taxon page into individual
1826
      tabs for description, images, synonymy and specimens. If not the taxon
1827
      data is rendered as a long single page without tabs.</p>'),
1828
  );
1829
1830
  $form['taxon_tabs']['cdm_taxonpage_tabs_visibility'] = array(
1831
    '#type' => 'checkboxes',
1832
    '#title' => t('Tabs visibility options') . ':',
1833
    '#default_value' => variable_get('cdm_taxonpage_tabs_visibility', get_taxon_options_list()),
1834
    '#options' => get_taxon_options_list(),
1835
    '#description' => t('Enable or disable Tabs in the Tabbed page display'),
1836
  );
1837
1838 b54cbda1 Andreas Kohlbecker
  // WEIGHT
1839 4feeabc7 Andreas Kohlbecker
  $taxon_tabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
1840
  $form['taxon_tabs'][CDM_TAXONPAGE_TAB_WEIGHT] = array(
1841
    '#title'  => 'Tabs order',
1842 2a61a296 Andreas Kohlbecker
    '#type' => 'fieldset',
1843
    '#collapsible' => false,
1844 4feeabc7 Andreas Kohlbecker
    '#tree' => true,
1845
    '#description' => 'The weight value defines the order of the tabs or of the respective content block on the 
1846
        taxon page when it is the tabless mode.'
1847 b54cbda1 Andreas Kohlbecker
  );
1848
  // Weights range from -delta to +delta, so delta should be at least half
1849
  // of the amount of tabs present.
1850
  $tab_weight_delta = round(count(get_taxon_tabs_list()) / 2) + 1;
1851
  foreach (get_taxon_tabs_list() as $label) {
1852
    $key = strtolower($label); // turn in to string, since we need to use strings as keys
1853 4feeabc7 Andreas Kohlbecker
    $form['taxon_tabs'][CDM_TAXONPAGE_TAB_WEIGHT][$key] = array(
1854 b54cbda1 Andreas Kohlbecker
        '#title' => $label,
1855
        '#type'  => 'weight',
1856 4feeabc7 Andreas Kohlbecker
        '#default_value' => $taxon_tabs_weights[$key],
1857 b54cbda1 Andreas Kohlbecker
        '#delta' => $tab_weight_delta
1858
    );
1859
  }
1860
1861 4feeabc7 Andreas Kohlbecker
  $taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
1862
  $form['taxon_tabs'][CDM_TAXONPAGE_TAB_LABELS] = array(
1863
    '#title'  => 'Tab label override',
1864 2a61a296 Andreas Kohlbecker
    '#type' => 'fieldset',
1865
    '#collapsible' => false,
1866 4feeabc7 Andreas Kohlbecker
    '#tree' => true,
1867
    '#description' => 'Setting a label for a tab will override the default label.'
1868
  );
1869
  foreach (get_taxon_tabs_list() as $label) {
1870
    $key = strtolower($label); // turn in to string, since we need to use strings as keys
1871
    $form['taxon_tabs'][CDM_TAXONPAGE_TAB_LABELS][$key] = array(
1872
      '#title' => $label,
1873
      '#type'  => 'textfield',
1874
      '#default_value' => $taxon_tabs_labels[$key]
1875
    );
1876
  }
1877
1878 6657531f Andreas Kohlbecker
  $form['taxon_tabs']['cdm_dataportal_default_tab'] = array(
1879
    '#type' => 'select',
1880
    '#title' => t('Default tab to display') . ':',
1881
    '#default_value' => variable_get('cdm_dataportal_default_tab', 0),
1882
    '#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
1883
    '#description' => t('<p>Select the default tab to display when visiting a
1884
      taxon page. Only available if Tabbed Taxon Page is enable.</p>
1885
      <strong>Note:</strong> After performing a search and clicking in any
1886
      synonym, the taxon tab to be rendered will be the synonymy of the accepted
1887
      taxon and not the above selected tab.'),
1888
  );
1889
1890
  /* ======  TAXON_PROFILE ====== */
1891
  $form['taxon_profile'] = array(
1892
    '#type' => 'fieldset',
1893
    '#title' => t('Taxon profile (tab)'),
1894 9438ad3a Andreas Kohlbecker
    '#description' => t('<p>This section covers the settings related to the taxon
1895 6657531f Andreas Kohlbecker
      profile tab, also known as the <strong>"General"</strong> tab.</p>'),
1896
    '#collapsible' => TRUE,
1897 6421984d Andreas Kohlbecker
    '#collapsed' => TRUE,
1898 6657531f Andreas Kohlbecker
  );
1899
1900
  // ---- PROFILE PICTURE ----//
1901 9c92cd84 Andreas Kohlbecker
1902
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE] = array(
1903 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
1904 9c92cd84 Andreas Kohlbecker
    '#tree' => TRUE,
1905 9438ad3a Andreas Kohlbecker
    '#title' => t('Taxon profile picture'),
1906 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
1907
    '#collapsed' => FALSE,
1908 9438ad3a Andreas Kohlbecker
    '#description' => t('This sections allows configuring the display of the so called taxon profile image which is displayed in the taxon profile tab.'),
1909 6657531f Andreas Kohlbecker
  );
1910
1911 9c92cd84 Andreas Kohlbecker
  //FIXME migrate variables:
1912
  //  cdm_dataportal_show_default_image ---> CDM_TAXON_PROFILE_IMAGE['show']
1913
  // FIXME
1914 9aff46e4 Andreas Kohlbecker
  //  enable file module in profile and in update,(a.kohlbecker, 4.9.2014: is this still an open issue?)
1915 9c92cd84 Andreas Kohlbecker
1916
  $taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
1917 9506fd1f Andreas Kohlbecker
1918 9c92cd84 Andreas Kohlbecker
  /*
1919
   * 'show' => 1,
1920
   * 'maxextend' => 184,
1921 053a92ec Andreas Kohlbecker
   * 'media_uri_query' => ''
1922 9c92cd84 Andreas Kohlbecker
   * 'custom_placeholder_image_on' => 1,
1923
   * 'custom_placeholder_image_fid' => ''
1924
   */
1925
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['show'] = array(
1926 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
1927 6421984d Andreas Kohlbecker
    '#title' => t('Enable profile picture'),
1928
    '#description' => t('Show the profile picture.'),
1929 9c92cd84 Andreas Kohlbecker
    '#default_value' => $taxon_profile_image_settings['show'],
1930 6657531f Andreas Kohlbecker
  );
1931
1932 9c92cd84 Andreas Kohlbecker
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['maxextend'] = array(
1933 d9c55e6c Andreas Kohlbecker
      '#type' => 'textfield',
1934
      '#tree' => TRUE,
1935 6421984d Andreas Kohlbecker
      '#title' => t('Profile picture maximum extend'),
1936 9c92cd84 Andreas Kohlbecker
      '#default_value' =>  $taxon_profile_image_settings['maxextend'],
1937 d9c55e6c Andreas Kohlbecker
      '#field_suffix' => 'px',
1938
      '#maxlength' => 4,
1939
      '#size' => 4,
1940 7cc085da Andreas Kohlbecker
      '#description' => t('The maximum extend in either dimension, width or height, of the profile picture in pixels.')
1941 d9c55e6c Andreas Kohlbecker
  );
1942
1943 053a92ec Andreas Kohlbecker
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array(
1944
      '#type' => 'textfield',
1945
      '#tree' => TRUE,
1946
      '#title' => t('Additional URI query parameter'),
1947
      '#default_value' =>  $taxon_profile_image_settings['media_uri_query'],
1948
      '#maxlength' => 1024,
1949
      '#size' => 60,
1950 7cc085da Andreas Kohlbecker
      '#description' => t('Additional query parameters to be used when requesting for the  
1951
            profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.
1952
            The query parameters will be appended to the uri of the media representation part
1953
            as stored in the cdm. The query parameter string must not start with a \'&\' or  \'?\'')
1954 053a92ec Andreas Kohlbecker
  );
1955
1956 ca47ea76 Andreas Kohlbecker
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_enabled'] = array(
1957
    '#type' => 'checkbox',
1958
    '#title' => t('Show the placeholder image'),
1959
    '#description' => t("If not taxon profile picture is available a placeholder image is shown instead."),
1960
    '#default_value' => $taxon_profile_image_settings['custom_placeholder_enabled']
1961
  );
1962
1963 9c92cd84 Andreas Kohlbecker
  $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array(
1964
      '#type' => 'checkbox',
1965
      '#title' => t('Use a custom placeholder image'),
1966 7df1be04 Andreas Kohlbecker
      '#description' => t("This image is shown as replacement if no image of the taxon is available."),
1967 9c92cd84 Andreas Kohlbecker
      '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_on']
1968 7df1be04 Andreas Kohlbecker
  );
1969
1970 9c92cd84 Andreas Kohlbecker
  if($taxon_profile_image_settings['custom_placeholder_image_on'] == 1){
1971
    $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
1972
        '#type' => 'managed_file',
1973
        '#title' => t('Custom placeholder image file'),
1974
        '#progress_indicator' => 'bar',
1975
        '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid'],
1976
    //       '#name' => 'custom_placeholder_image',
1977
        '#upload_location' => 'public://' . CDM_TAXON_PROFILE_IMAGE .'/'
1978
    );
1979
1980
    if($taxon_profile_image_settings['custom_placeholder_image_fid']){
1981
      $profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
1982
      $url = file_create_url($profile_image_file->uri);
1983
      $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['preview'] = array(
1984
                '#type' => 'item',
1985
                '#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
1986
      );
1987
    }
1988
  } else {
1989
    $form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
1990 642b323b Andreas Kohlbecker
      '#type' => 'hidden',
1991
      '#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid']
1992 9c92cd84 Andreas Kohlbecker
    );
1993
  }
1994
1995 6657531f Andreas Kohlbecker
  $options = cdm_rankVocabulary_as_option();
1996
  array_unshift($options, '-- DISABLED --');
1997
  $form['taxon_profile']['picture']['image_hide_rank'] = array(
1998
    '#type' => 'select',
1999 9438ad3a Andreas Kohlbecker
    '#title' => t('Hide profile picture for higher ranks') . ':',
2000 6657531f Andreas Kohlbecker
    '#default_value' => variable_get('image_hide_rank', '0'),
2001
    '#options' => $options,
2002 9438ad3a Andreas Kohlbecker
    '#description' => t('The taxon profile picture will not be shown for taxa with rank higher that the selected.'),
2003 6657531f Andreas Kohlbecker
  );
2004
2005
  // -- MEDIA THUMBNAILS -- //
2006
  $form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
2007
  $form_title = 'Taxon Profile Images';
2008
  $form_description = '<p>The different section in the taxon  profile can have images associated with them. These images are displayed in a gallery of thumbnails wich can be configuered here:</p>';
2009
  $form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
2010
2011 642b323b Andreas Kohlbecker
  // ---- FEATURE TREE BLOCKS ---- //
2012
  $form['taxon_profile']['feature_blocks'] = array(
2013 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
2014 642b323b Andreas Kohlbecker
    '#title' => t('Feature Blocks'),
2015 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
2016
    '#collapsed' => FALSE,
2017
    '#description' => t("This section covers settings related to the taxon's
2018
      <em>Feature Tree</em>. The <em>feature tree</em> are the taxon's
2019 642b323b Andreas Kohlbecker
      features such as description, distribution, common names"),
2020 6657531f Andreas Kohlbecker
  );
2021
  $featureTrees = cdm_get_featureTrees_as_options(TRUE);
2022 642b323b Andreas Kohlbecker
  $profile_feature_tree = get_profile_feature_tree();
2023
  $profile_feature_tree_uuid = $profile_feature_tree->uuid;
2024
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2025
    $profile_feature_tree_uuid = UUID_DEFAULT_FEATURETREE;
2026 854e1d99 Andreas Kohlbecker
  }
2027 642b323b Andreas Kohlbecker
  $form['taxon_profile']['feature_blocks'][CDM_PROFILE_FEATURETREE_UUID] = array(
2028 6657531f Andreas Kohlbecker
    '#type' => 'radios',
2029 642b323b Andreas Kohlbecker
    '#title' => t('Taxon profile feature tree') . ':',
2030
    '#default_value' => $profile_feature_tree_uuid,
2031 6657531f Andreas Kohlbecker
    '#options' =>  $featureTrees['options'],
2032 3f485c6d Andreas Kohlbecker
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2033
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2034 642b323b Andreas Kohlbecker
    '#description' => t('The Feature Tree selected here define the feature blocks which are visible in the taxon
2035
      profile page.'
2036 6657531f Andreas Kohlbecker
    ),
2037
  );
2038
2039 642b323b Andreas Kohlbecker
  // ---- FEATURE TREE BLOCKS > LAYOUT PER FEATURE BLOCK ---- //
2040
  $profile_feature_tree = get_profile_feature_tree();
2041
2042
  if (isset($profile_feature_tree->root->childNodes)) {
2043 6657531f Andreas Kohlbecker
2044 642b323b Andreas Kohlbecker
    $form_feature_block_layout = array(
2045
      '#type' => 'fieldset',
2046
      '#tree' => true,
2047
      '#title' => t('Taxon profile feature block settings'),
2048 6657531f Andreas Kohlbecker
      '#collapsible' => TRUE,
2049
      '#collapsed' => FALSE,
2050 642b323b Andreas Kohlbecker
      '#description' => 'This section let\'s you define how each of the feature blocks is displayed.
2051
      A sub form is for each of the features of currently selected feature tree allows to configre each feature block individually.
2052
      The subforms have the following settings in common:<br />
2053
      <h6>List type:</h6><div>Whether the description elements are displayed as list or not. Three different list types are available</div>
2054
      <h6>Link to reference:</h6><div>Render the reference as link, ignored if the element is NOT a DescriptionElementSource</div>
2055
      <h6>Link to name used in source:</h6><div>Whether to show name is source information as link which will point to the according name page</div>
2056
      <h6>Sources as content:</h6><div><strong>If enabled:</strong><br />
2057
            <ol>
2058
            <li>If element is of the CDM type TextData and the text is not empty the source references will be
2059
                appended in brackets like "text (source references)". If the original source has name in source
2060
                information it will be appended to the citation string,
2061
                like : "(citation, as name in source; citation, as name in source)"</li>
2062
             <li>if the text of the TextData is empty, the original source citations are the only content
2063
                (e.g. use case CITATION) and are not put into brackets. In this case the nameInSource is
2064
                prepended to the citation string like: "name in source: citation"</li>
2065
            </ol>
2066
            <strong>If disabled:</strong><br />
2067
             Original sources are put into the bibliography(=references) pseudo feature block. If the original source
2068
             citations are the only content, the resulting feature block content would only consist of footnotes.
2069
             In this case the display of the respective feature block is suppressed.</div>
2070
      </dl>
2071
      <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
2072 0686f307 Andreas Kohlbecker
           in the bibliography. For this to work the bibliography must be enabled the <em>' .l(
2073
            'Layout Settings', 'admin/config/cdm_dataportal/settings/layout', array('fragment'=>'edit-bibliography-for-original-source'))
2074
        . '</em></div>
2075 642b323b Andreas Kohlbecker
      <h6>Sort elements:</h6><div>Whether and how to sort the elements
2076
           possible values are the constants SORT_ASC, SORT_DESC, NULL,
2077
           some feature types (Distribution) also support: SORT_HIERARCHICAL</div>
2078
      <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>
2079
           possible values are span or div. Developers: The proper inner tag name can be retrieved by the function
2080
           cdm_feature_block_element_tag_name()</div>',
2081 6657531f Andreas Kohlbecker
    );
2082
2083 642b323b Andreas Kohlbecker
2084
    $feature_list_layout_settings_disabled = FALSE;
2085 8c962983 Andreas Kohlbecker
2086
    // creating helper object to retrieve the default settings
2087
    $featureNode = new stdClass();
2088
    $featureNode->feature = new stdClass();
2089
    $featureNode->feature->uuid="DEFAULT";
2090
    $featureNode->feature->representation_L10n = "Default";
2091
    array_unshift($profile_feature_tree->root->childNodes, $featureNode);
2092
2093 642b323b Andreas Kohlbecker
    foreach ($profile_feature_tree->root->childNodes as $featureNode) {
2094 6657531f Andreas Kohlbecker
2095
      if (!$feature_list_layout_settings_disabled && isset($featureNode->feature)) {
2096
2097 642b323b Andreas Kohlbecker
        // $subform_id must not exceed 45 characters, a uuid has 36 characters
2098
        $subform_id = $featureNode->feature->uuid;
2099
        $feature_block_setting = get_feature_block_settings($featureNode->feature->uuid);
2100 6657531f Andreas Kohlbecker
2101 642b323b Andreas Kohlbecker
//        $settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
2102
2103
        $form_feature_block_layout[$subform_id] = array(
2104
          '#type' => 'fieldset',
2105 6657531f Andreas Kohlbecker
          '#tree' => TRUE,
2106 642b323b Andreas Kohlbecker
          '#title' => $featureNode->feature->representation_L10n,
2107 6657531f Andreas Kohlbecker
          '#collapsible' => FALSE,
2108
          '#collapsed' => FALSE,
2109
        );
2110 8c962983 Andreas Kohlbecker
        if($featureNode->feature->uuid == "DEFAULT"){
2111
          $form_feature_block_layout[$subform_id]['#description']='These are the defaults which apply to
2112
          all feature blocks for which no specific settings have been defined. for consistency enabling links for <em>source
2113
          references</em> and <em>names in source</em> is only possible in the defaults';
2114
        }
2115 6657531f Andreas Kohlbecker
2116 642b323b Andreas Kohlbecker
        $form_feature_block_layout[$subform_id]['as_list'] = array(
2117
          '#type' => 'select',
2118
          '#title' => 'List type',
2119
          '#default_value' => $feature_block_setting['as_list'],
2120
          '#options' => array(
2121
            'div' => 'not as list',
2122
            'ul' => 'bullet list',
2123
            'ol' => 'numbered list',
2124
            'dl' => 'definition list'
2125
          ),
2126
        );
2127
2128 8c962983 Andreas Kohlbecker
        if($featureNode->feature->uuid == "DEFAULT"){
2129
          $form_feature_block_layout[$subform_id]['link_to_reference'] = array(
2130
            '#type' => 'checkbox',
2131
            '#title' => t('Link to reference'),
2132
            '#default_value' => $feature_block_setting['link_to_reference'],
2133
          );
2134 642b323b Andreas Kohlbecker
2135 8c962983 Andreas Kohlbecker
          $form_feature_block_layout[$subform_id]['link_to_name_used_in_source'] = array(
2136
            '#type' => 'checkbox',
2137
            '#title' => 'Link to name used in source',
2138
            '#default_value' => $feature_block_setting['link_to_name_used_in_source'],
2139
          );
2140
        }
2141 6657531f Andreas Kohlbecker
2142 642b323b Andreas Kohlbecker
        $form_feature_block_layout[$subform_id]['sources_as_content'] = array(
2143
          '#type' => 'checkbox',
2144
          '#title' => 'Sources as content',
2145
          '#default_value' => $feature_block_setting['sources_as_content'],
2146 6657531f Andreas Kohlbecker
        );
2147
2148 642b323b Andreas Kohlbecker
        $form_feature_block_layout[$subform_id]['sources_as_content_to_bibliography'] = array(
2149
          '#type' => 'checkbox',
2150 8c962983 Andreas Kohlbecker
          '#title' => 'Put sources also as content to bibliography',
2151 642b323b Andreas Kohlbecker
          '#default_value' => $feature_block_setting['sources_as_content_to_bibliography'],
2152 6657531f Andreas Kohlbecker
        );
2153
2154 642b323b Andreas Kohlbecker
        $form_feature_block_layout[$subform_id]['sort_elements'] = array(
2155
          '#type' => 'select',
2156
          '#title' => t('Sort elements'),
2157
          '#default_value' => $feature_block_setting['sort_elements'],
2158
          '#options' => array(
2159
            NO_SORT => 'No sorting',
2160
            SORT_ASC => 'Ascending',
2161
            SORT_DESC => 'Descending',
2162 3eccfdb9 Andreas Kohlbecker
            SORT_HIERARCHICAL => 'Hierarchical'
2163 642b323b Andreas Kohlbecker
          ),
2164 3eccfdb9 Andreas Kohlbecker
          '#description' => 'NOT YET FULLY USED! only in preparation (works partially for distributions)
2165
          <dl>
2166
          <dr><dt>No sorting</dt><dd>Sorting undefined</dd></dr>
2167
          <dr><dt>Ascending</dt><dd>Alphabetically in ascending order</dd></dr>
2168
          <dr><dt>Descending</dt><dd>Alphabetically in descending order</dd></dr>
2169
          <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>
2170
          </dl>',
2171 6657531f Andreas Kohlbecker
        );
2172
2173 642b323b Andreas Kohlbecker
        $form_feature_block_layout[$subform_id]['element_tag'] = array(
2174
          '#type' => 'select',
2175
          '#title' => t('Element tag'),
2176
          '#options' => array(
2177
            'span' => 'span',
2178
            'div' => 'div'
2179
          ),
2180
          '#default_value' => $feature_block_setting['element_tag'],
2181
        );
2182 6657531f Andreas Kohlbecker
      }
2183 642b323b Andreas Kohlbecker
      $form['taxon_profile']['feature_blocks'][FEATURE_BLOCK_SETTINGS] = $form_feature_block_layout;
2184 6657531f Andreas Kohlbecker
    }
2185
  }
2186
2187 642b323b Andreas Kohlbecker
  // ---- STRUCTURED DESCRIPTION FEATURE TREE ---- //
2188
  $form['taxon_profile']['structured_description_featuretree'] = array(
2189
    '#type' => 'fieldset',
2190
    '#title' => t('Structured Description Feature Tree'),
2191
    '#collapsible' => TRUE,
2192
    '#collapsed' => FALSE,
2193
  );
2194
  $featureTrees = cdm_get_featureTrees_as_options();
2195
  $profile_feature_tree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
2196
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2197
    $profile_feature_tree_uuid = NULL;
2198
  }
2199
  $form['taxon_profile']['structured_description_featuretree'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
2200
    '#type' => 'radios',
2201
    '#title' => t('Natural language representation of structured descriptions') . ':',
2202
    '#default_value' => $profile_feature_tree_uuid,
2203
    '#options' => $featureTrees['options'],
2204
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2205
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2206
    '#description' => t('Taxon descriptions can be stored in a highly structured
2207
      form. The feature tree selected here will be used to generate textual
2208
      representation in natural language.'
2209
    ),
2210
  );
2211
2212
2213
2214 6657531f Andreas Kohlbecker
  // ---- DISTRIBUTION LAYOUT ---- //
2215
  $form['taxon_profile']['distribution_layout'] = array(
2216
    '#title' => t('Distribution'),
2217
    '#collapsible' => TRUE,
2218
    '#collapsed' => FALSE,
2219
    '#type' => 'fieldset',
2220 378bc1ce Andreas Kohlbecker
    '#description' => 'This section covers general settings regarding the textual representation of distributions and the visibility of the map.
2221
        Map settings regarding the geometry, layers, etc are found in the '
2222 562a6ac4 Andreas Kohlbecker
      . l('geo & map tab', 'admin/config/cdm_dataportal/settings/geo') .
2223
      '. Further settings regarding the distribution feature block can be found in above in this tab at '
2224
      . l(
2225
        'Taxon profile feature block settings', 'admin/config/cdm_dataportal/settings/layout/taxon',
2226
        array('fragment' => 'edit-feature-block-settings')
2227
      )
2228
      . ' More general settings regrading the filtering of Distributions are found at '
2229
      . l('Distribution appearance', 'admin/config/cdm_dataportal/settings', array('fragment' => 'edit-distribution'))
2230
      . '. (These settings here will be merged in future releases into the feature block settings)',
2231
2232 6657531f Andreas Kohlbecker
  );
2233
2234 378bc1ce Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_MAP_VISIBILITY] = _cdm_map_visibility_setting('distribution');
2235
2236 bda17f32 Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED] = array(
2237
    '#type' => 'checkbox',
2238
    '#title' => t('Condensed distribution'),
2239
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED, 0),
2240
    '#description' => 'This option enables the display of a very compact representation
2241
    of the distribution which includes also information on the status.',
2242
  );
2243
2244 846c0606 Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED_RECIPE] = array(
2245
    '#type' => 'select',
2246
    '#title' => t('Condensed distribution recipe'),
2247
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED_RECIPE, DISTRIBUTION_CONDENSED_RECIPE_DEFAULT),
2248
    '#options' => array('EuroPlusMed' => 'Euro+Med', 'FloraCuba' => 'Flora of Cuba'),
2249
    '#description' => 'Recipe for creating the condensed distribution.',
2250
  );
2251
2252 6858b474 Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_CONDENSED_INFO_PATH] = array(
2253
    '#type' => 'textfield',
2254
    '#title' => t('Condensed distribution info path'),
2255
    '#default_value' => variable_get(DISTRIBUTION_CONDENSED_INFO_PATH, DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT),
2256
    '#description' => 'By default the help page ' .l(DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT, DISTRIBUTION_CONDENSED_INFO_PATH_DEFAULT)
2257
      . ' is used as target for the info link which is shown at the end of the condensed distribution string.',
2258
  );
2259
2260 bda17f32 Andreas Kohlbecker
2261 f5bc56a0 Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_ORDER_MODE] = array(
2262 6657531f Andreas Kohlbecker
    '#type' => 'radios',
2263 c359043a Andreas Kohlbecker
    '#title' => t('Display mode') . ':',
2264 97ac3d38 Andreas Kohlbecker
    '#default_value' => variable_get(DISTRIBUTION_ORDER_MODE, DISTRIBUTION_ORDER_MODE_DEFAULT),
2265 6657531f Andreas Kohlbecker
    '#options' => array(
2266 f5bc56a0 Andreas Kohlbecker
      'FLAT_ALPHA' => t('Flat list'),
2267
      'TREE' => t('Hierarchically ordered'),
2268 6657531f Andreas Kohlbecker
    ),
2269 0eef1621 Andreas Kohlbecker
    '#description' => 'Taxon distribution information is displayed with
2270 f5bc56a0 Andreas Kohlbecker
    focus on the area of the distribution. The list of areas can either be shown
2271 0eef1621 Andreas Kohlbecker
    as flat list ordered alphabetically or in the hierarchical of the parent
2272
    area and subarea relationship. Fall back areas areas with no Distribution data
2273
    are hidden from the area hierarchy so that their sub areas will move one level up.
2274
    See ' . l('Distribution appearance', 'admin/config/cdm_dataportal/settings', array('fragment' => 'edit-distribution')) .
2275 40420110 Andreas Kohlbecker
    ' for details on the <em>Marked area filter</em>.',
2276 6657531f Andreas Kohlbecker
  );
2277
2278 38dd933d Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE] = array(
2279
    '#type' => 'fieldset',
2280
    '#tree' => true,
2281
    '#title' => t('Distribution hierarchy style')
2282
  );
2283
2284
  $hierarchy_styles = get_array_variable_merged(DISTRIBUTION_HIERARCHY_STYLE, DISTRIBUTION_HIERARCHY_STYLE_DEFAULT);
2285
  foreach(array_keys($hierarchy_styles) as $level) {
2286
    $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE][$level] = array(
2287
      '#type' => 'fieldset',
2288
      '#tree' => true,
2289 7cc085da Andreas Kohlbecker
      '#title' => t('@area-level', array('@area-level' => drupal_ucfirst((str_replace('_', ' ', $level))))),
2290 38dd933d Andreas Kohlbecker
      '#attributes' => array('class' => array('fieldset-float'))
2291
    );
2292
    foreach ($hierarchy_styles[$level] as $key => $value) {
2293
      $form['taxon_profile']['distribution_layout'][DISTRIBUTION_HIERARCHY_STYLE][$level][$key] = array(
2294
        '#type' => 'textfield',
2295 7cc085da Andreas Kohlbecker
        '#title' => t('@area-level-style', array('@area-level-style' => drupal_ucfirst((str_replace('_', ' ', $key))))),
2296 38dd933d Andreas Kohlbecker
        '#default_value' => $hierarchy_styles[$level][$key],
2297
        '#maxlength' => 4,
2298
        '#size' => 4
2299
      );
2300
    }
2301
  }
2302
2303 b3b63fc8 Andreas Kohlbecker
  $level_options = cdm_vocabulary_as_option(UUID_NAMED_AREA_LEVEL, NULL, FALSE, NULL, CDM_ORDER_BY_ORDER_INDEX_ASC);
2304 f5bc56a0 Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_TREE_OMIT_LEVELS] = array(
2305
    '#type' => 'checkboxes',
2306
    '#title' => 'Omit area levels',
2307
    '#options' => $level_options,
2308
    '#default_value' => variable_get(DISTRIBUTION_TREE_OMIT_LEVELS, array()),
2309 284fb36d Andreas Kohlbecker
    '#description' => 'This option ins only applicable when distributions are hierachically orderd (see option above)!
2310
    Areas which belong to the selected area levels will be hidden in the portal.',
2311 f5bc56a0 Andreas Kohlbecker
  );
2312
2313 6657531f Andreas Kohlbecker
  $form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] = array(
2314
    '#type' => 'checkbox',
2315
    '#title' => t('Show TextData elements on top of the map'),
2316
    '#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
2317
    '#description' => t('Check this if you want to appear all <code>TextData</code>
2318
      elements on top of the map. Otherwise all <code>TextData</code>
2319
      distribution elements will be listed below the other area elements.
2320
      This option is useful if you need to have descriptive texts for each
2321
      distribution map.'),
2322
  );
2323
2324 c6ee8193 Andreas Kohlbecker
  $form['taxon_profile'][DISTRIBUTION_STATUS_COLORS] = array(
2325
      '#type' => 'textarea',
2326
      '#title' => t('Custom status colors'),
2327
      '#element_validate' => array('form_element_validate_json'),
2328
      '#default_value' => variable_get(DISTRIBUTION_STATUS_COLORS, ''),
2329
      '#description' => t('<strong>EXPERIMENTAL!</strong><br/>This may be changed in the next release without notification.
2330
          A json map object with StatusTerm.idInVocabulary as key and a hex color as value. e.g: <code>{"n":"#ff0000","p":"#00ff00"}</code>.
2331 eb961cb9 Andreas Kohlbecker
          reference list of the idInVocabulary values of absence and presence terms:
2332 c6ee8193 Andreas Kohlbecker
<pre>
2333 eb961cb9 Andreas Kohlbecker
Presence Term
2334
p	present
2335
pd	present: doubtfully present
2336
n	native
2337
nq	native: presence questionable
2338
nd	native: doubtfully native
2339
c	cultivated
2340
i	introduced
2341
iq	introduced: presence questionable
2342
id	introduced: doubtfully introduced (perhaps cultivated only)
2343
ip	introduced: uncertain degree of naturalisation
2344
ia	introduced: adventitious (casual)
2345
in	introduced: naturalized
2346
ic	introduced: cultivated
2347
e	endemic for the relevant area
2348
na	naturalised
2349
iv	invasive
2350
2351
AbsenceTerm
2352
a	absent
2353
f	reported in error
2354
nf	native: reported in error
2355
if	introduced: reported in error
2356
cf	cultivated: reported in error
2357
ne	native: formerly native
2358
ie	introduced: formerly introduced
2359
2360 c6ee8193 Andreas Kohlbecker
</pre>'),
2361
  );
2362
2363 6657531f Andreas Kohlbecker
2364
  /* ====== SYNONYMY ====== */
2365
  $form['taxon_synonymy'] = array(
2366
    '#type' => 'fieldset',
2367
    '#title' => t('Taxon synonymy (tab)'),
2368
    '#collapsible' => TRUE,
2369
    '#collapsed' => TRUE,
2370
    '#description' => t('This section covers the settings related to the taxon
2371 501347df Andreas Kohlbecker
      <strong>synonymy</strong> tab.'),
2372 6657531f Andreas Kohlbecker
  );
2373
2374
  $form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
2375
    '#type' => 'checkbox',
2376
    '#title' => t('Show accepted taxon on top of the synonymy'),
2377
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
2378
    '#description' => t('If checked, the first homotypic taxon is a repetition
2379
      of the accepted taxon most likely with the full nomenclatural reference
2380
      (depending on the currently chosen theme).'),
2381
  );
2382
2383
  $form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
2384
    '#type' => 'checkbox',
2385
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when
2386
      coming from a synonym link.'),
2387
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
2388
    '#description' => t('Check this if after doing a search and clicking on a
2389
      synonym you want to see the "accept of" text for the accepted synonym.'),
2390
  );
2391
2392 24058570 Andreas Kohlbecker
  /* === currently unused ===
2393 7ca5ef1e Andreas Kohlbecker
  $nameRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
2394 5014bf09 Andreas Kohlbecker
  $form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array(
2395 6657531f Andreas Kohlbecker
    '#type' => 'checkboxes',
2396
    '#title' => t('Display name relationships') . ':',
2397
    '#default_value' => variable_get('name_relationships_to_show', 0),
2398
    '#options' => $nameRelationshipTypeOptions,
2399
    '#description' => t('Select the name relationships you want to show for the
2400
      accepted taxa.'),
2401
  );
2402 24058570 Andreas Kohlbecker
 */
2403 6657531f Andreas Kohlbecker
2404 6421984d Andreas Kohlbecker
  $form['taxon_synonymy']['taxon_relations'] = array(
2405
    '#type' => 'fieldset',
2406
    '#title' => t('Taxon relationships'),
2407
    '#collapsible' => FALSE,
2408
    '#collapsed' => FALSE
2409
  );
2410
2411
  $form['taxon_synonymy']['taxon_relations'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
2412 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
2413
    '#title' => t('Show taxon relations ships of accepted taxon'),
2414
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
2415
    '#description' => t('If this option is enabled the synonymy will show the
2416
      below selected taxon relationships of accepted taxa.'),
2417
  );
2418
2419 7ca5ef1e Andreas Kohlbecker
  $taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
2420 6421984d Andreas Kohlbecker
  $form['taxon_synonymy']['taxon_relations'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
2421 6657531f Andreas Kohlbecker
    '#type' => 'checkboxes',
2422
    '#title' => t('Taxon relationship types') . ':',
2423
    '#description' => t('Only taxon relationships of the selected type will be
2424
      displayed'),
2425
    '#options' => $taxonRelationshipTypeOptions,
2426
    '#default_value' => variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
2427
    '#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
2428
  );
2429
2430 6421984d Andreas Kohlbecker
  $form['taxon_synonymy']['name_relations'] = array(
2431
    '#type' => 'fieldset',
2432
    '#title' => t('Name relationships'),
2433
    '#collapsible' => FALSE,
2434
    '#collapsed' => FALSE
2435
  );
2436
2437 7ca5ef1e Andreas Kohlbecker
  $taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
2438 6421984d Andreas Kohlbecker
  $form['taxon_synonymy']['name_relations'][CDM_NAME_RELATIONSHIP_TYPES] = array(
2439
    '#type' => 'checkboxes',
2440
    '#title' => t('Name relationship types') . ':',
2441
    '#description' => t('Only name relationships of the selected type will be
2442
      displayed'),
2443
    '#options' => $taxonRelationshipTypeOptions,
2444
    '#default_value' => variable_get(CDM_NAME_RELATIONSHIP_TYPES, unserialize(CDM_NAME_RELATIONSHIP_TYPES_DEFAULT)),
2445
  );
2446
2447 6657531f Andreas Kohlbecker
  // ====== SPECIMENS ====== //
2448
  $form['taxon_specimens'] = array(
2449
    '#type' => 'fieldset',
2450
    '#title' => t('Taxon specimens (tab)'),
2451
    '#collapsible' => TRUE,
2452
    '#collapsed' => TRUE,
2453
    '#description' => t('This section covers the settings related to the taxon
2454
      <strong>specimens</strong> tab.'),
2455
  );
2456
2457 378bc1ce Andreas Kohlbecker
  $form['taxon_specimens'][SPECIMEN_MAP_VISIBILITY]  = _cdm_map_visibility_setting('specimen');
2458
2459
  $form['taxon_specimens']['cdm_dataportal_compressed_specimen_derivate_table'] = array(
2460
    '#type' => 'checkbox',
2461
    '#title' => t('Show specimen derivatives in a compressed table'),
2462
    '#default_value' => variable_get('cdm_dataportal_compressed_specimen_derivate_table', CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE),
2463
    '#description' => t('If checked, the specimen will be listed in a table. Every row represents
2464
    a collection and it can be expanded to get an overview of the specimens and their derivates.'),
2465
  );
2466
2467 2e82a602 Patrick Plitzner
    $form['taxon_specimens']['cdm_dataportal_compressed_specimen_derivate_table_page_size'] = array(
2468
        '#type' => 'textfield',
2469
        '#title' => t('Number of records per page') . ':',
2470
        '#default_value' => variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size', CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_PAGE_SIZE),
2471
    );
2472
2473 378bc1ce Andreas Kohlbecker
  $form['taxon_specimens']['cdm_dataportal_compressed_specimen_derivate_table_show_determined_as'] = array(
2474
    '#type' => 'checkbox',
2475
    '#title' => t('Show "Associated with" in specimen table.'),
2476
    '#default_value' => variable_get('cdm_dataportal_compressed_specimen_derivate_table_show_determined_as', CDM_DATAPORTAL_COMPRESSED_SPECIMEN_DERIVATE_TABLE_SHOW_DETERMINED_AS)
2477
  );
2478 1ce9afb7 Patric Plitzner
2479 854e1d99 Andreas Kohlbecker
  $featureTrees = cdm_get_featureTrees_as_options(TRUE);
2480 642b323b Andreas Kohlbecker
  $profile_feature_tree_uuid = variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
2481
  if(!isset($featureTrees['options'][$profile_feature_tree_uuid])) {
2482
    $profile_feature_tree_uuid = UUID_DEFAULT_FEATURETREE;
2483 f19f47fa Andreas Kohlbecker
  }
2484
  $form['taxon_specimens']['feature_trees'][CDM_OCCURRENCE_FEATURETREE_UUID] = array(
2485 378bc1ce Andreas Kohlbecker
    '#type' => 'radios',
2486
    '#title' => t('Specimen description feature tree') . ':',
2487
    '#default_value' => $profile_feature_tree_uuid,
2488
    '#options' =>  $featureTrees['options'],
2489
    '#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
2490
    '#options_suffixes' => $featureTrees['treeRepresentations'],
2491
    '#description' => t('Select the feature tree to be used for displaying specimen descriptions. Click "Show Details" to see the Feature Tree elements.'
2492
    ),
2493 bfb2b81a Andreas Kohlbecker
  );
2494
2495 6657531f Andreas Kohlbecker
  $form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
2496
  $form_title = t('Specimen media');
2497
  $form_description = t('Specimens may have media which is displayed at the
2498
     Specimen tab/section as a gallery. It is possible to configure the
2499
     thumbnails gallery here, however for configuring how a single media should
2500
     be displayed please go to !url.</p>',
2501
     array(
2502
       '!url' => l(t('Layout -> Media'), 'admin/config/cdm_dataportal/settings/layout/media'),
2503
     ));
2504
  $form['taxon_specimens'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
2505
2506
  // --- MEDIA GALLERY ---- //
2507
  $form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
2508
  $form_title = 'Media gallery (tab)';
2509 43034365 Patrick Plitzner
  $form_description = '<p>This section covers the settings related to the taxon <strong>images</strong> tab.
2510
   Taxa may have media (usually images) and they are displayed as thumbnails. It is possible to configure
2511 6657531f Andreas Kohlbecker
   the thumbnails gallery here, however for configuring how a single media should be displayed please go to
2512
   <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a></p>
2513
   <p><strong>Note:</strong> These settings are only taken into account when the standard
2514
   gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a>.</p>';
2515
  $form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
2516
2517
  // Comment @WA: D7 form api does not support reset buttons,
2518
  // so to mimic the D5 reset button we add one like this.
2519
  $form['actions']['reset'] = array(
2520
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2521
    '#weight' => 1000,
2522
  );
2523
  return system_settings_form($form);
2524
}
2525
2526 378bc1ce Andreas Kohlbecker
/**
2527
 * Creates a form element for the constants DISTRIBUTION_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY.
2528
 *
2529
 * @param $map_id
2530
 * @param $form
2531
 * @return mixed
2532
 */
2533
function _cdm_map_visibility_setting($map_id)
2534
{
2535
  return array(
2536
    '#type' => 'select',
2537
    '#title' => t(ucfirst($map_id) . ' map visibility'),
2538
    '#default_value' => variable_get(constant(strtoupper($map_id) . '_MAP_VISIBILITY'), constant(strtoupper($map_id) . '_MAP_VISIBILITY_DEFAULT')),
2539
    '#options' => array('always' => 'always', 'automatic' => 'automatic', 'never' => 'never'),
2540
    '#description' => "The visibility of the map can managed <b>automatically</b> depending on whether there is data to show or not. 
2541
        The map also can forced to show up <b>always</b> or <b>never</b>."
2542
  );
2543
}
2544
2545 6657531f Andreas Kohlbecker
/**
2546
 * @todo document this function.
2547
 */
2548
function cdm_settings_layout_search() {
2549
2550
  $form = array();
2551
2552 c5ed6357 Andreas Kohlbecker
  $form['#submit'][] = 'cdm_settings_layout_search_submit';
2553
2554 6657531f Andreas Kohlbecker
  $form['search_settings'] = array(
2555
    '#type' => 'fieldset',
2556
    '#title' => t('Taxa Search'),
2557 61b6ee11 Andreas Kohlbecker
    '#collapsible' => FALSE,
2558
    '#collapsed' => FALSE,
2559 6657531f Andreas Kohlbecker
    '#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
2560
         the block <em>CDM Taxon Search</em> should be enabled and visible for users
2561
         where they can write the text to be searched. You can find Drupal block configuration
2562
         site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p> '),
2563
  );
2564
2565 90a6166e Andreas Kohlbecker
  $form['search_settings'][SIMPLE_SEARCH_IGNORE_CLASSIFICATION] = array(
2566 f19f47fa Andreas Kohlbecker
      '#type' => 'checkbox',
2567
      '#title' => t('Ignore the chosen classification in simple search'),
2568 90a6166e Andreas Kohlbecker
      '#default_value' => variable_get(SIMPLE_SEARCH_IGNORE_CLASSIFICATION, 0),
2569 61b6ee11 Andreas Kohlbecker
      '#description' => t('The simple search, which can be executed via the search block,
2570 90a6166e Andreas Kohlbecker
          will by default search on the classification selected in the classification browser
2571
          selector. Set the tick if you want your portal to search on all classifications.'),
2572 61b6ee11 Andreas Kohlbecker
  );
2573
2574 2d0d855a Andreas Kohlbecker
  $form['search_settings'][SIMPLE_SEARCH_USE_LUCENE_BACKEND] = array(
2575
    '#type' => 'checkbox',
2576
    '#title' => t('Run simple search with free-text search backend.'),
2577 90a6166e Andreas Kohlbecker
    '#default_value' => variable_get(SIMPLE_SEARCH_USE_LUCENE_BACKEND, 0),
2578 2d0d855a Andreas Kohlbecker
    '#description' => t('The simple search uses by default another search
2579
      backend as the advances search. By checking this option the simple search can be
2580
      configured to also use the free-text search backend.'),
2581
  );
2582
2583 6657531f Andreas Kohlbecker
  $form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
2584
    '#type' => 'textfield',
2585
    '#title' => t('Results per page') . ':',
2586
    '#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
2587
    '#description' => t('Number of results to display per page.'),
2588
  );
2589
2590 1d69a96c Andreas Kohlbecker
  $form['search_settings'][SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX] = array(
2591
    '#type' => 'checkbox',
2592 c278f2a0 Andreas Kohlbecker
    '#title' => t('Show the') .  ' <i>' . t('Display image thumbnails') . '</i>' . t('button') . ':',
2593 1d69a96c Andreas Kohlbecker
    '#default_value' => variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT),
2594
    '#description' => t('The search results page will offer a button to toggle the display of image thumbnails.'),
2595
  );
2596
2597 6280e639 Andreas Kohlbecker
  $search_mode_default = get_array_variable_merged(CDM_SEARCH_TAXA_MODE, CDM_SEARCH_TAXA_MODE_DEFAULT);
2598
  $form['search_settings']['cdm_search_taxa_mode'] = array(
2599
      '#type' => 'checkboxes',
2600
      '#title' => 'Search mode',
2601
      '#description' => 'The taxon search can operate in different modes in order to find only taxa, synonyms,
2602
          taxa by its common name and even taxa which have been used as misappied names. The settings made here will affect the default
2603
          for the advance search form and the behaviour of the simple search form which always will behave according to the
2604
          defaults set here.',
2605
      '#options' => drupal_map_assoc(array_keys(unserialize(CDM_SEARCH_TAXA_MODE_DEFAULT))),
2606
      '#default_value' => $search_mode_default
2607
      );
2608 6657531f Andreas Kohlbecker
2609 072122ee Andreas Kohlbecker
  $form['search_settings'][CDM_SEARCH_AREA_FILTER_PRESET] = array(
2610 f4cc620d Andreas Kohlbecker
    '#type' => 'textarea',
2611 072122ee Andreas Kohlbecker
    '#title' => t('area_filter_preset') . ':',
2612
    '#default_value' => variable_get(CDM_SEARCH_AREA_FILTER_PRESET, ''), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2613
2614
    '#description' => t('Area uuids, comma separated, no whitespace. EXPERIMENTAL!!!!'),
2615
  );
2616
2617 6657531f Andreas Kohlbecker
  // --- SEARCH TAXA GALLERY ---- //
2618
  $items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
2619
  $collapsed = FALSE;
2620
  $form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
2621
  $form_title = 'Taxa Search thumbnails';
2622
  $form_description = 'Search results may show thumbnails. ';
2623
  $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
2624
2625
  // Comment @WA: D7 form api does not support reset buttons,
2626
  // so to mimic the D5 reset button we add one like this.
2627
  $form['actions']['reset'] = array(
2628
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2629
    '#weight' => 1000,
2630
  );
2631
  return system_settings_form($form);
2632
}
2633
2634
/**
2635
 * @todo document this function.
2636
 */
2637
function cdm_settings_layout_media() {
2638
2639
  $form = array();
2640
2641
  $form['media_settings'] = array(
2642
    '#type' => 'fieldset',
2643 a950f2f9 Andreas Kohlbecker
    '#title' => t('Media settings'),
2644
    '#collapsible' => FALSE,
2645 6657531f Andreas Kohlbecker
    '#collapsed' => FALSE,
2646 ccde8251 Andreas Kohlbecker
    '#description' => 'This section covers layout settings for media pages.'
2647
      . 'Further media related settings may be found under the taxon layout settings and on the general settings.',
2648 6657531f Andreas Kohlbecker
  );
2649
2650
  $form['media_settings']['image_gallery_viewer'] = array(
2651
    '#type' => 'select',
2652
    '#title' => t('Image viewer') . ':',
2653
    '#default_value' => variable_get('image_gallery_viewer', 'default'),
2654
    '#options' => array(
2655
      'default' => t('Standard image viewer'),
2656
      'fsi' => t('FSI viewer (requires FSI server!)'),
2657
    ),
2658
  );
2659
2660
  // --- MEDIA GALLERY ---- //
2661
  $form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
2662
  $form_title = 'Standard viewer';
2663
  $form_description = '<p>Configure the standard image viewer.</p><p><strong>Note:</strong> the image viewer should selected otherwise settings are not taking into account.</p>';
2664
  // $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
2665
  $form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
2666
2667
  // @WA: D7 form api does not support reset buttons,
2668
  // so to mimic the D5 reset button we add one like this.
2669
  $form['actions']['reset'] = array(
2670
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
2671
    '#weight' => 1000,
2672
  );
2673
  return system_settings_form($form);
2674
}
2675
2676
/**
2677
 * GEOSERVICE and Map settings.
2678
 */
2679 1d39ec64 w.addink
function cdm_settings_geo($form, &$form_state) {
2680 6657531f Andreas Kohlbecker
2681 cc3c9807 Andreas Kohlbecker
  $current_geoserver_settings = get_edit_map_service_settings();
2682
  $map_distribution = get_array_variable_merged(CDM_MAP_DISTRIBUTION, CDM_MAP_DISTRIBUTION_DEFAULT);
2683 ff965d76 Andreas Kohlbecker
2684 cc3c9807 Andreas Kohlbecker
2685 6657531f Andreas Kohlbecker
  $form = array();
2686
2687 cc3c9807 Andreas Kohlbecker
  $dummy_distribution_query = NULL;
2688
  if($map_distribution['map_type'] != 1){
2689 ff965d76 Andreas Kohlbecker
    // we need to apply a dummy query since the map service requires for image maps
2690 cc3c9807 Andreas Kohlbecker
    // at least as and ad to be defined
2691
    $dummy_distribution_query = "as=a:339966&ad=tdwg1:a:1,2,3,4,5,6,7,8,9";
2692
  }
2693 087bb473 Andreas Kohlbecker
2694 d2fd2a4c Andreas Kohlbecker
  $form['map_preview'] = array(
2695
      '#type' => 'fieldset',
2696
      '#tree' => FALSE,
2697
      '#title' => t('Map preview'),
2698
      '#collapsible' => FALSE,
2699 cc3c9807 Andreas Kohlbecker
      '#description' => 'The preview of the map'
2700 2bbc28c8 Andreas Kohlbecker
       . ($dummy_distribution_query != null ?
2701 ff965d76 Andreas Kohlbecker
           ' may not be accurate in case of image maps, please check the map display in the taxon pages.':
2702 d5661a4c Andreas Kohlbecker
           '.<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.')
2703 d2fd2a4c Andreas Kohlbecker
  );
2704 4c21ffdb Andreas Kohlbecker
  $form['map_preview']['openlayers_map'] = compose_map('settings-preview', NULL, $dummy_distribution_query, NULL, array(
2705 653e9c6b Andreas Kohlbecker
    'move' => "this.cdmOpenlayersMap.printInfo",
2706
    '#execute' => "this.cdmOpenlayersMap.printInfo"
2707
  ), true // resizable
2708 d2fd2a4c Andreas Kohlbecker
  );
2709 087bb473 Andreas Kohlbecker
2710 6f718d1b Andreas Kohlbecker
  /*
2711
  $form['map_preview']['map'] = compose_map(NULL, $dummy_distribution_query, NULL, array(), 0 // force image map
2712
  );
2713
  */
2714 cc3c9807 Andreas Kohlbecker
2715 6657531f Andreas Kohlbecker
  /*
2716 d2fd2a4c Andreas Kohlbecker
   * GEO SERVER
2717
   */
2718 ba706bf0 Andreas Kohlbecker
  $form['edit_map_server'] = array(
2719 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
2720 ba706bf0 Andreas Kohlbecker
    '#tree' => true,
2721
    '#title' => t('EDIT map service'),
2722 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
2723
    '#collapsed' => TRUE,
2724
    '#description' => t('Configuration and selection of your geo server.
2725
      The Geo Server is responsible for generating the maps.'),
2726
  );
2727
2728 f19f47fa Andreas Kohlbecker
  $form['edit_map_server']['base_uri'] = array(
2729 6657531f Andreas Kohlbecker
    '#type' => 'select',
2730 ba706bf0 Andreas Kohlbecker
    '#title' => t('EDIT map service') . ':',
2731
    '#default_value' => $current_geoserver_settings['base_uri'],
2732
    '#options' => unserialize(EDIT_MAPSERVER_URI),
2733
    '#description' => t('Select the EDIT map server you want to use within your data portal.'),
2734 6657531f Andreas Kohlbecker
  );
2735 f19f47fa Andreas Kohlbecker
  $form['edit_map_server']['version'] = array(
2736
      '#type' => 'select',
2737
      '#title' => t('Version') . ':',
2738
      '#default_value' => $current_geoserver_settings['version'],
2739
      '#options' => unserialize(EDIT_MAPSERVER_VERSION),
2740
      '#description' => t('The version of the EDIT map services'),
2741 6657531f Andreas Kohlbecker
  );
2742
2743
  /*
2744 d2fd2a4c Andreas Kohlbecker
   * MAP SETTINGS
2745
   */
2746 cc3c9807 Andreas Kohlbecker
2747
  $form[CDM_MAP_DISTRIBUTION] = array(
2748 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
2749 cc3c9807 Andreas Kohlbecker
    '#tree' => TRUE,
2750 6657531f Andreas Kohlbecker
    '#title' => t('Maps settings'),
2751
    '#collapsible' => TRUE,
2752
    '#collapsed' => TRUE,
2753
    '#description' => t('General configuration for all map types.'),
2754
  );
2755
2756 6f718d1b Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['map_type'] = array(
2757
    '#type' => 'radios',
2758
    '#title' => 'Map types',
2759
    '#options' => array(
2760
      1 => "OpenLayers dynamic map viewer",
2761
      0 => "Plain image",
2762
    ),
2763
    '#default_value' => $map_distribution['map_type'],
2764
    '#description' => 'Two different map types are available :
2765
      <ul><li><em>OpenLayers</em>: Display the maps in an interactive viewer
2766
      which allows zooming and panning. If enabled you can configure the default layer
2767
      (background of your maps) below.</li>
2768
      <li><em>Plain image</em>: The map will be static non interactive
2769
      image.</li></ul>',
2770
  );
2771
  $open_layers_is_enabled = $map_distribution['map_type'] == 1;
2772
2773 cc3c9807 Andreas Kohlbecker
  /*
2774
   * settings for the distribution map are used also for specimens map!!!!
2775
   */
2776
2777 b4503332 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['aspect_ratio'] = array(
2778 cc3c9807 Andreas Kohlbecker
      '#type' => 'textfield',
2779 b4503332 Andreas Kohlbecker
      '#title' => 'Aspect ratio',
2780
      '#default_value' => $map_distribution['aspect_ratio'],
2781 cc3c9807 Andreas Kohlbecker
      '#maxlength' => 4,
2782
      '#size' => 4,
2783 ff965d76 Andreas Kohlbecker
      '#element_validate' => array('element_validate_number'),
2784 b4503332 Andreas Kohlbecker
      '#description' => 'The ratio of width to height of the map. Instead of expressing the aspect ratio as usually as
2785
      two numbers separated by a colon (x:y), this field requires a the value which is the result of the division of the
2786
      width by the height:</br>
2787
      <pre>aspect ratio = w / h</pre>
2788
      For a landscape oriented map with an aspect ratio of 2:1 use <strong>2</strong> as value,</br>
2789
      for a square map use <strong>1</strong>.',
2790 cc3c9807 Andreas Kohlbecker
  );
2791 6657531f Andreas Kohlbecker
2792 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['bbox'] = array(
2793 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2794 cc3c9807 Andreas Kohlbecker
    '#title' => 'Bounding box',
2795
    '#default_value' => $map_distribution['bbox'],
2796 b4503332 Andreas Kohlbecker
    '#description' => t('The bounding box (left, bottom, right, top) in degree defines the area to be initially displayed in maps.
2797 6657531f Andreas Kohlbecker
      Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong>
2798 2bbc28c8 Andreas Kohlbecker
      to let the map <strong>automatically zoom</strong> to the bounds enclosing the shown data.</p>
2799 087bb473 Andreas Kohlbecker
      <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.
2800 b4503332 Andreas Kohlbecker
      (Maybe you need to change the map base layer to OpeLayers.)
2801 d5661a4c Andreas Kohlbecker
      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
2802 2bbc28c8 Andreas Kohlbecker
      below the map from where you can copy the bbox string.</p>'),
2803 6657531f Andreas Kohlbecker
  );
2804
2805 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['show_labels'] = array(
2806 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
2807 cc3c9807 Andreas Kohlbecker
    '#title' => 'Display area labels',
2808
    '#default_value' => $map_distribution['show_labels'],
2809
    '#description' => t('The map will show name labels of the areas'),
2810 6657531f Andreas Kohlbecker
  );
2811
2812 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['caption'] = array(
2813 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2814 cc3c9807 Andreas Kohlbecker
    '#title' => 'Map caption',
2815
    '#default_value' => $map_distribution['caption'],
2816
    '#description' => t('The caption will be shown below the map.'),
2817 6657531f Andreas Kohlbecker
  );
2818
2819 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['distribution_opacity'] = array(
2820 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2821 cc3c9807 Andreas Kohlbecker
    '#title' => 'Distribution layer opacity',
2822
    '#default_value' => $map_distribution['distribution_opacity'],
2823 b4503332 Andreas Kohlbecker
    '#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions
2824
    (the countries or regions) will fully visible, while a value near to 0.0 will be not much visible.'),
2825 6657531f Andreas Kohlbecker
  );
2826
2827
  // --- Plain Image Settings --- //
2828 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map'] = array(
2829 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
2830 cc3c9807 Andreas Kohlbecker
    '#title' => 'Plain image map settings',
2831
    '#tree' => TRUE,
2832 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
2833 cc3c9807 Andreas Kohlbecker
    '#collapsed' => $open_layers_is_enabled,
2834
    '#description' => 'The settings in this section are still expertimental
2835
      and can only be used with the EDIT map service version 1.1 or above.',
2836 6657531f Andreas Kohlbecker
  );
2837 ba706bf0 Andreas Kohlbecker
  $edit_mapserver_version = get_edit_map_service_version_number();
2838 6657531f Andreas Kohlbecker
  if ($edit_mapserver_version < 1.1) {
2839 7cc085da Andreas Kohlbecker
    $form[CDM_MAP_DISTRIBUTION]['image_map']['#description'] = '<div class="messages warning">'
2840
      . t("The chosen EDIT map service version (@edit-mapserver-version) is too low, it must be at least 1.1",
2841
        array('@edit_mapserver_version' => '$edit_mapserver_version')) . '</div>'
2842 cc3c9807 Andreas Kohlbecker
      . $form[CDM_MAP_DISTRIBUTION]['image_map']['#description'];
2843 6657531f Andreas Kohlbecker
  }
2844
2845 b4503332 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map']['width'] = array(
2846
    '#type' => 'textfield',
2847
    '#title' => 'Width',
2848
    '#default_value' => $map_distribution['image_map']['width'],
2849
    '#maxlength' => 4,
2850
    '#size' => 4,
2851 50791e51 Andreas Kohlbecker
    '#description' => 'Width of the map. The height is calculated from the <strong>Aspect ratio</strong> set in the section above. ',
2852 b4503332 Andreas Kohlbecker
  );
2853
2854 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map']['base_layer'] = array(
2855 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2856 cc3c9807 Andreas Kohlbecker
    '#title' => 'Background layer',
2857
    '#default_value' => $map_distribution['image_map']['base_layer'],
2858 6657531f Andreas Kohlbecker
    '#description' => t('Background layer. For available layers inspect !url1 or !url2.', array(
2859 cc3c9807 Andreas Kohlbecker
      '!url1' => l('deegree-csw', 'http://edit.africamuseum.be:8080/deegree-csw/md_search.jsp'),
2860
      '!url2' => l('geoserver layers', 'http://edit.africamuseum.be/geoserver/web/'),
2861 6657531f Andreas Kohlbecker
    )),
2862
  );
2863
2864 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map']['bg_color'] = array(
2865 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2866 cc3c9807 Andreas Kohlbecker
    '#title' => 'Background color',
2867
    '#default_value' => $map_distribution['image_map']['bg_color'],
2868 6657531f Andreas Kohlbecker
  );
2869
2870 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map']['layer_style'] = array(
2871 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
2872 cc3c9807 Andreas Kohlbecker
    '#title' => 'Background layer style',
2873 6657531f Andreas Kohlbecker
     // Only line color by now.
2874 cc3c9807 Andreas Kohlbecker
    '#default_value' => $map_distribution['image_map']['layer_style'],
2875
    '#description' => 'Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}',
2876 6657531f Andreas Kohlbecker
  );
2877
2878 4bef194f Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['image_map']['projection'] = array(
2879
      '#type' => 'textfield',
2880
      '#title' => 'Projection',
2881
      '#default_value' => drupal_array_get_nested_value($map_distribution, array('image_map', 'projection')),
2882
      '#description' => 'Spatial Reference System (SRS) identifier ) optional ( Defines projections in WMS GetMap request.
2883
        Using EPSG:4326 (WGS84 lat/long) is the default but can be changed
2884
        on-the-fly to different UTM and much more zone specific. Examples: EPSG:4326, EPSG:900913, EPSG:3857, EPSG:7777777',
2885
  );
2886
2887 6657531f Andreas Kohlbecker
2888
  // --- OpenLayers Settings --- //
2889 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers'] = array(
2890 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
2891 cc3c9807 Andreas Kohlbecker
    '#title' => 'OpenLayers settings',
2892
    '#tree' => TRUE,
2893 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
2894 cc3c9807 Andreas Kohlbecker
    '#collapsed' => !$open_layers_is_enabled,
2895 6657531f Andreas Kohlbecker
    '#description' => '',
2896
  );
2897
2898 2bbc28c8 Andreas Kohlbecker
2899
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['display_outside_max_extent'] = array(
2900
      '#type' => 'checkbox',
2901
      '#title' => 'Display outside max extent',
2902
      '#default_value' => $map_distribution['openlayers']['display_outside_max_extent'],
2903
      '#description' => t('Allows the map to display parts of the layers which are outside
2904
         the max extent if the aspect ratio of the map and of the baselayer
2905
         are not equal.'),
2906
  );
2907
2908 570f0e73 Andreas Kohlbecker
2909 2bbc28c8 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['show_layer_switcher'] = array(
2910
      '#type' => 'checkbox',
2911
      '#title' => 'Show Layer Switcher',
2912
      '#default_value' => $map_distribution['openlayers']['show_layer_switcher'],
2913
      '#description' => 'The Layer Switcher control displays a table of contents
2914
      for the map.  This allows the user interface to switch between
2915
      base layers and to show or hide overlays.  By default the switcher is
2916
      shown minimized on the right edge of the map, the user may expand it
2917
      by clicking on the handle.',
2918
  );
2919
2920 cc3c9807 Andreas Kohlbecker
  if (!$open_layers_is_enabled) {
2921
    $form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'] = '<div class="messages warning">'
2922
        . 'The Openlayers viewer is currently not enabled! (see section Maps settings above )</div>'
2923
        . $form[CDM_MAP_DISTRIBUTION]['openlayers']['#description'];
2924 6657531f Andreas Kohlbecker
  }
2925
2926 ff965d76 Andreas Kohlbecker
  // The default layer must always be enabled
2927
  $preferred_layer = $map_distribution['openlayers']['base_layers']['PREFERRED'];
2928
  $map_distribution['openlayers']['base_layers'][$preferred_layer] = $preferred_layer;
2929
2930 6657531f Andreas Kohlbecker
  $baselayer_options = array(
2931
    /*
2932
   NOTICE: must correspond to the layers defined in
2933
   js/openlayers_,ap.js#getLayersByName()
2934
   */
2935 1f3c62f9 Andreas Kohlbecker
    'osgeo_vmap0' => "Metacarta Vmap0 (OSGeo server) - instable!", // EPSG:4326: EPSG:900913
2936
    'metacarta_vmap0' => "Metacarta Vmap0 (MetaCarta Labs server)  - instable!", // EPSG:4326, EPSG:900913
2937
    'mapproxy_vmap0' => "Metacarta Vmap0 (OSGeo server) - via fast EDIT MapProxy",
2938
    'mapproxy_etopo1' => "ETOPO1 Global Relief Model - via fast EDIT MapProxy",
2939 6657531f Andreas Kohlbecker
    'edit-etopo1' => "ETOPO1 Global Relief Model",
2940 1f3c62f9 Andreas Kohlbecker
    // all others EPSG:900913
2941 6657531f Andreas Kohlbecker
    'mapnik' => 'OpenStreetMap',
2942 2bbc28c8 Andreas Kohlbecker
    'mapquest_open' => "MapQuest",
2943
    'mapquest_sat' => "MapQuest Sattelite",
2944 2b83cc8b Andreas Kohlbecker
    'groadmap' => 'Google Roadmap',
2945
    'gsatellite' => 'Google Satellite',
2946 f619ffbf Andreas Kohlbecker
    'ghybrid' => 'Google Hybrid',
2947 2b83cc8b Andreas Kohlbecker
    'gterrain' => 'Google Terrain',
2948 cc3c9807 Andreas Kohlbecker
//     'veroad' => 'Virtual Earth Roads',
2949
//     'veaer' => 'Virtual Earth Aerial',
2950
//     'vehyb' => 'Virtual Earth Hybrid',
2951 6657531f Andreas Kohlbecker
    // 'yahoo' => 'Yahoo Street',
2952
    // 'yahoosat' => 'Yahoo Satellite',
2953
    // 'yahoohyb' => 'Yahoo Hybrid',
2954 2bbc28c8 Andreas Kohlbecker
     'custom_wms_base_layer_1' => 'Custom WMS base layer (needs to be manually configured below!)',
2955 6657531f Andreas Kohlbecker
  );
2956
2957 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['base_layers'] = array(
2958 6657531f Andreas Kohlbecker
    '#type' => 'checkboxes_preferred',
2959 cc3c9807 Andreas Kohlbecker
    '#title' => 'Base Layers',
2960 6657531f Andreas Kohlbecker
    '#options' => $baselayer_options,
2961 cc3c9807 Andreas Kohlbecker
    '#default_value' =>  $map_distribution['openlayers']['base_layers'],
2962
    '#description' => 'Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.',
2963 6657531f Andreas Kohlbecker
  );
2964
2965 2b83cc8b Andreas Kohlbecker
  $google_maps_api_key = null;
2966
  if(isset($map_distribution['openlayers']['google_maps_api_key'])){
2967
    $google_maps_api_key = $map_distribution['openlayers']['google_maps_api_key'];
2968
  }
2969
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['google_maps_api_key'] = array(
2970
    '#type' => 'textfield',
2971
    '#title' => 'Google Maps API Key',
2972
    '#default_value' => $google_maps_api_key,
2973
    '#description' => 'In order to use any of the Google map layers you need to provide 
2974
        your <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">Google Maps API Key</a>. ',
2975
  );
2976
2977 2bbc28c8 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer'] = array(
2978
      '#type' => 'fieldset',
2979
      '#title' => 'Custom WMS base layer',
2980
      '#tree' => TRUE,
2981
      '#collapsible' => FALSE,
2982
      '#collapsed' => FALSE,
2983
      '#description' => 'Here you an define a custom wms layer as additional base layer.',
2984
  );
2985
2986
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['name'] = array(
2987
      '#type' => 'textfield',
2988
      '#title' => 'Layer name',
2989
      // Only line color by now.
2990
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['name'],
2991
      '#description' => 'A arbitrary name for the layer.',
2992
  );
2993
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['url'] = array(
2994
      '#type' => 'textfield',
2995
      '#title' => 'WMS url',
2996
      // Only line color by now.
2997
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['url'],
2998 ff965d76 Andreas Kohlbecker
      '#description' => 'Base url for the WMS (e.g.  http://edit.africamuseum.be/geoserver/topp/wms, http://wms.jpl.nasa.gov/wms.cgi)'
2999 2bbc28c8 Andreas Kohlbecker
  );
3000
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['params'] = array(
3001
      '#type' => 'textarea',
3002
      '#title' => 'WMS parameters',
3003
      '#element_validate' => array('form_element_validate_json'),
3004
      // Only line color by now.
3005
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['params'],
3006 570f0e73 Andreas Kohlbecker
      '#description' => 'An javasript object with key/value pairs representing the GetMap query string parameters and parameter values, entered in valid JSON. For example:
3007
<pre> {
3008
  "Layers": "topp:em_tiny_jan2003",
3009
  "Format": "image/png",
3010
  "BGCOLOR": "0xe0faff"
3011
}
3012
</pre>'
3013 2bbc28c8 Andreas Kohlbecker
  );
3014
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['projection'] = array(
3015
      '#type' => 'textfield',
3016
      '#title' => 'Projection',
3017
      // Only line color by now.
3018
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['projection'],
3019
      '#description' => 'The desired projection for the layer (e.g. EPSG:4326, EPSG:900913, EPSG:3857)'
3020
  );
3021 e3026d72 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['proj4js_def'] = array(
3022
      '#type' => 'textfield',
3023 14339c2a Andreas Kohlbecker
      '#maxlength' => 256,
3024 e3026d72 Andreas Kohlbecker
      '#title' => 'proj4js definition',
3025
      // Only line color by now.
3026
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['proj4js_def'],
3027
      '#description' => 'The <a href="http://trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js">proj4js definition</a> for the projection named above.
3028
            The definitions for
3029
            EPSG:102067, EPSG:102757, EPSG:102758, EPSG:21781, EPSG:26591, EPSG:26912, EPSG:27200, EPSG:27563, EPSG:3857,
3030
            EPSG:41001, EPSG:4139, EPSG:4181, EPSG:42304, EPSG:4272, EPSG:4302, EPSG:900913
3031
            are already predefined and must be added here again.  If your dont know the defintion of your desired projection,
3032
            go to  <a href="http://spatialreference.org/">http://spatialreference.org/</a>, search for your projection and
3033
            choose to display the proj4js definition string.
3034 7f71136d Andreas Kohlbecker
            <h5>Quick Reference on the commion proj4js definition parameters:</h5>
3035
            <pre>
3036
+a         Semimajor radius of the ellipsoid axis
3037
+alpha     ? Used with Oblique Mercator and possibly a few others
3038
+axis      Axis orientation (new in 4.8.0)
3039
+b         Semiminor radius of the ellipsoid axis
3040
+datum     Datum name (see `proj -ld`)
3041
+ellps     Ellipsoid name (see `proj -le`)
3042
+k         Scaling factor (old name)
3043
+k_0       Scaling factor (new name)
3044
+lat_0     Latitude of origin
3045
+lat_1     Latitude of first standard parallel
3046
+lat_2     Latitude of second standard parallel
3047
+lat_ts    Latitude of true scale
3048
+lon_0     Central meridian
3049
+lonc      ? Longitude used with Oblique Mercator and possibly a few others
3050
+lon_wrap  Center longitude to use for wrapping (see below)
3051
+nadgrids  Filename of NTv2 grid file to use for datum transforms (see below)
3052
+no_defs   Don\'t use the /usr/share/proj/proj_def.dat defaults file
3053
+over      Allow longitude output outside -180 to 180 range, disables wrapping (see below)
3054
+pm        Alternate prime meridian (typically a city name, see below)
3055
+proj      Projection name (see `proj -l`)
3056
+south     Denotes southern hemisphere UTM zone
3057
+to_meter  Multiplier to convert map units to 1.0m
3058
+towgs84   3 or 7 term datum transform parameters (see below)
3059
+units     meters, US survey feet, etc.
3060
+vto_meter vertical conversion to meters.
3061
+vunits    vertical units.
3062
+x_0       False easting
3063
+y_0       False northing
3064
+zone      UTM zone
3065
            </pre>
3066
          For the full reference please refer to <a href="http://trac.osgeo.org/proj/wiki/GenParms">http://trac.osgeo.org/proj/wiki/GenParms</a>.'
3067 e3026d72 Andreas Kohlbecker
  );
3068 2bbc28c8 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['max_extent'] = array(
3069
      '#type' => 'textfield',
3070
      '#title' => 'Maximum extent',
3071
      // Only line color by now.
3072
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['max_extent'],
3073 14339c2a Andreas Kohlbecker
      '#description' => 'The maximum extent of the map as bounding box (left, bottom, right, top) in the units of the map.'
3074 2bbc28c8 Andreas Kohlbecker
  );
3075
  $form[CDM_MAP_DISTRIBUTION]['openlayers']['custom_wms_base_layer']['units'] = array(
3076
      '#type' => 'textfield',
3077
      '#title' => 'Units',
3078
      '#default_value' => $map_distribution['openlayers']['custom_wms_base_layer']['units'],
3079
      '#description' => 'The layer map units.  Defaults to null.  Possible values are ‘degrees’ (or ‘dd’), ‘m’, ‘ft’, ‘km’, ‘mi’, ‘inches’.  Normally taken from the projection.  Only required if both map and layers do not define a projection, or if they define a projection which does not define units.'
3080 6657531f Andreas Kohlbecker
  );
3081
3082 cc3c9807 Andreas Kohlbecker
  /*
3083
   * Map Legend
3084
   */
3085
  $form[CDM_MAP_DISTRIBUTION]['legend'] = array(
3086 6657531f Andreas Kohlbecker
    '#type' => 'fieldset',
3087 cc3c9807 Andreas Kohlbecker
    '#title' => 'Map legend',
3088
    '#tree' => TRUE,
3089 6657531f Andreas Kohlbecker
    '#collapsible' => TRUE,
3090
    '#collapsed' => TRUE,
3091 cc3c9807 Andreas Kohlbecker
    '#description' => 'Configure the maps legend.',
3092 6657531f Andreas Kohlbecker
  );
3093
3094 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['show'] = array(
3095 6657531f Andreas Kohlbecker
    '#type' => 'checkbox',
3096 cc3c9807 Andreas Kohlbecker
    '#title' => 'Display a map legend',
3097
    '#default_value' => $map_distribution['legend']['show'],
3098
    '#description' => 'Check this if you like a legend to be displayed with the maps.',
3099 6657531f Andreas Kohlbecker
  );
3100
3101 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['opacity'] = array(
3102 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
3103 cc3c9807 Andreas Kohlbecker
    '#title' => 'Legend opacity',
3104
    '#default_value' => $map_distribution['legend']['opacity'],
3105
    '#description' => 'Valid values range from 0.0 to 1.0. Value 1.0 means the legend will be fully visible, while a value near
3106
                         to 0.0 will be not much visible.',
3107 6657531f Andreas Kohlbecker
  );
3108
3109 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['font_size'] = array(
3110 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
3111 cc3c9807 Andreas Kohlbecker
    '#title' => 'Font size',
3112
    '#default_value' => $map_distribution['legend']['font_size'],
3113
    '#description' => 'Font size in pixels.',
3114 6657531f Andreas Kohlbecker
  );
3115
3116
  $fontStyles = array(
3117
    0 => "plane",
3118
    1 => "italic",
3119
  );
3120 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['font_style'] = array(
3121 6657531f Andreas Kohlbecker
    '#type' => 'select',
3122 cc3c9807 Andreas Kohlbecker
    '#title' => 'Available font styles',
3123
    '#default_value' => $map_distribution['legend']['font_style'],
3124 6657531f Andreas Kohlbecker
    '#options' => $fontStyles,
3125 cc3c9807 Andreas Kohlbecker
    '#description' => 'Select a font style for the map legend.',
3126 6657531f Andreas Kohlbecker
  );
3127
3128 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['icon_width'] = array(
3129 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
3130 cc3c9807 Andreas Kohlbecker
    '#title' => 'Icon width',
3131
    '#default_value' => $map_distribution['legend']['icon_width'],
3132
    '#description' => 'Legend icon width in pixels.',
3133 6657531f Andreas Kohlbecker
  );
3134 cc3c9807 Andreas Kohlbecker
  $form[CDM_MAP_DISTRIBUTION]['legend']['icon_height'] = array(
3135 6657531f Andreas Kohlbecker
    '#type' => 'textfield',
3136 cc3c9807 Andreas Kohlbecker
    '#title' => 'Icon height',
3137
    '#default_value' => $map_distribution['legend']['icon_height'],
3138
    '#description' => 'Legend icon height in pixels.',
3139 6657531f Andreas Kohlbecker
  );
3140
3141
  // @WA: D7 form api does not support reset buttons,
3142
  // so to mimic the D5 reset button we add one like this.
3143
  $form['actions']['reset'] = array(
3144
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
3145
    '#weight' => 1000,
3146
  );
3147 1d39ec64 w.addink
3148 6657531f Andreas Kohlbecker
  return system_settings_form($form);
3149
}
3150
3151 ff965d76 Andreas Kohlbecker
3152 6657531f Andreas Kohlbecker
/**
3153
 * @todo document this function.
3154
 */
3155
function cdm_settings_cache() {
3156
3157
  $form = array();
3158
3159
  $form['cache_settings'] = array(
3160
    '#type' => 'fieldset',
3161
    '#title' => t('Cache Settings'),
3162
    '#collapsible' => FALSE,
3163
    '#collapsed' => FALSE,
3164
    '#description' => t('<p>When caching is enabled all single taxon sites are
3165
      stored in an internal drupal cache doing the portal response of taxa pages
3166
      faster. This is possible because the sites are loaded from the cache and
3167
      are not created from scratch.</p>'),
3168
  );
3169
3170
  $form['cache_settings']['cdm_webservice_cache'] = array(
3171
    '#type' => 'checkbox',
3172
    '#title' => t('<strong>Enable caching</strong>'),
3173
    '#options' => cdm_help_general_cache(),
3174
    '#default_value' => variable_get('cdm_webservice_cache', 1),
3175
    '#description' => t('<p>Enable drupal to load taxa pages from the cache.</p>
3176
       <p><strong>Note:</strong> If taxa are modified by the editor or any other
3177
       application the changes will be not visible till the cache is erased.
3178
       Therefore developers should deactived this feature when they are working
3179
       on the CDM Dataportal Module.</p>'),
3180
  );
3181
3182
  $form['cache_settings']['cdm_run_cache'] = array(
3183
    '#markup' => cdm_view_cache_site(),
3184
  );
3185
3186
  // @WA: D7 form api does not support reset buttons,
3187
  // so to mimic the D5 reset button we add one like this.
3188
  $form['actions']['reset'] = array(
3189
    '#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
3190
    '#weight' => 1000,
3191
  );
3192
  return system_settings_form($form);
3193
}
3194
3195
/**
3196
 * Walk and cache all taxon pages.
3197
 */
3198
function cdm_view_cache_site() {
3199
3200
  $out = '';
3201
3202
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cache_all_taxa.js');
3203
3204
  $request_params = array();
3205 7d828d59 Andreas Kohlbecker
  $request_params['class'] = "Taxon";
3206 6657531f Andreas Kohlbecker
3207 7d828d59 Andreas Kohlbecker
  $cdm_ws_page_taxa_url = cdm_compose_url(CDM_WS_TAXON . ".json", NULL, queryString($request_params));
3208
  $cdm_ws_page_taxa_url = uri_uriByProxy($cdm_ws_page_taxa_url);
3209
  $cdm_ws_page_taxa_url = rtrim($cdm_ws_page_taxa_url, '/');
3210 6657531f Andreas Kohlbecker
3211
  $out .= t('<p><strong>Cache all taxon pages</strong></p>');
3212
  $out .= '<p>When you launch the cache process the cache is filled and ready to be enabled.<br/>
3213
  Remember that when you load the taxa from the cache last changes on taxa will be not visible till you erase
3214
  the cache and fill it again.</p>';
3215
  $out .= '<p>Before  running the cache bot you have to empty the cache manually.</p>';
3216
3217
  $out .= '<div>' . t('This caching process may take long time and could cause heavy load on your server') . '</div>';
3218
  $out .= '<div id="progress"></div>';
3219
3220
  // Comment @WA: A form within a form is not valid html and not needed here.
3221
  // Also, it would be recommended just to include this part of the form in the
3222
  // rest of the form array in cdm_settings_cache().
3223
  // $out .= '<form id="cache_site">';
3224 0516e3d0 Andreas Kohlbecker
  $out .= '<input type="hidden" name="pageTaxaUrl" value="' . $cdm_ws_page_taxa_url . '"/>';
3225 7d828d59 Andreas Kohlbecker
  $out .= '<input type="hidden" name="taxonPageUrl" value="' . url('cdm_dataportal/taxon/') . '"/>';
3226 6657531f Andreas Kohlbecker
  $out .= '<input type="button" name="start" value="' . t('Start') . '"/>';
3227
  $out .= '<input type="button" name="stop" value="' . t('Stop') . '"/>';
3228
  // $out .= '</form>';
3229
  $out .= '</div>';
3230
  /*
3231
  foreach($taxonPager->records as $taxon){
3232
    cdm_dataportal_taxon_view($uuid);
3233
  }
3234
  */
3235
  return $out;
3236
}
3237
3238 7df1be04 Andreas Kohlbecker
3239
function cdm_settings_layout_taxon_submit($form, &$form_state){
3240 9c92cd84 Andreas Kohlbecker
  if (isset($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'])) {
3241
    $file = file_load($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid']);
3242
    if(is_object($file)){
3243
      $file->status = FILE_STATUS_PERMANENT;
3244
      file_save($file);
3245
      file_usage_add($file, 'cdm_dataportal', CDM_TAXON_PROFILE_IMAGE, 0);
3246
    }
3247 7df1be04 Andreas Kohlbecker
  }
3248 d5403dc4 Andreas Kohlbecker
  // rebuild the menu if the show tabs setting has changed, otherwise the change will not have a consistent effect
3249
  if(variable_get('cdm_dataportal_taxonpage_tabs', 1) != $form_state['values']['cdm_dataportal_taxonpage_tabs']){
3250
    // we first need to set the variable to persist the changes setting
3251
    variable_set('cdm_dataportal_taxonpage_tabs', $form_state['values']['cdm_dataportal_taxonpage_tabs']);
3252
    menu_rebuild();
3253
  }
3254 7df1be04 Andreas Kohlbecker
}
3255
3256 c5ed6357 Andreas Kohlbecker
function cdm_settings_layout_search_submit($form, &$form_state){
3257
  // the visibility of media thumbnails also affects the ui of the search results
3258
  // so reset the according session variable
3259
  //    1. in order to give the user immediate
3260
  //       feedback on potential setting changes
3261
  //    2. let refresh the default if it has changed
3262
  if (isset($_SESSION['pageoption']['searchtaxa']['showThumbnails'])) {
3263
    unset($_SESSION['pageoption']['searchtaxa']['showThumbnails']);
3264
  }
3265
}
3266
3267 6657531f Andreas Kohlbecker
/**
3268 d1eb0a8c Andreas Kohlbecker
 * Form validation handler for cdm_settings_general
3269 6657531f Andreas Kohlbecker
 *
3270 22eb20d7 Andreas Kohlbecker
 * @param $form
3271
 * @param $form_state
3272 6657531f Andreas Kohlbecker
 */
3273 d1eb0a8c Andreas Kohlbecker
function cdm_settings_general_validate($form, &$form_state) {
3274 6657531f Andreas Kohlbecker
3275
  if (!str_endsWith($form_state['values']['cdm_webservice_url'], '/')) {
3276
    $form_state['values']['cdm_webservice_url'] .= '/';
3277
  }
3278
3279 d1eb0a8c Andreas Kohlbecker
}
3280
3281 22eb20d7 Andreas Kohlbecker
/**
3282
 * Form submit handler for settings general.
3283
 *
3284
 * tasks performed:
3285
 *  - clear the [cdm][taxonomictree_uuid] session variable since this taxonomictree_uuid might no longer bee valid
3286
 *
3287
 * @param $form
3288
 * @param $form_state
3289
 */
3290
function cdm_settings_general_submit($form, &$form_state){
3291
  // clear the [cdm][taxonomictree_uuid] session variable since this taxonomictree_uuid might no longer bee valid
3292
  unset($_SESSION['cdm']['taxonomictree_uuid']);
3293
}
3294
3295 d1eb0a8c Andreas Kohlbecker
/**
3296
 * Form validation handler for cdm_settings_cache
3297
 */
3298 847bb49e Andreas Kohlbecker
function cdm_settings_cache_validate($form, &$form_state) {
3299 6657531f Andreas Kohlbecker
  if ($form_state['values']['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)) {
3300
    cache_clear_all(NULL, 'cache_cdm_ws');
3301
    // Better clear secref_cache since I can not be sure if the cache has not
3302
    // be used during this response.
3303
    cdm_api_secref_cache_clear();
3304
  }
3305 d1eb0a8c Andreas Kohlbecker
3306 6657531f Andreas Kohlbecker
}
3307
3308
/**
3309 ba706bf0 Andreas Kohlbecker
 * Returns an associative array of the currently chosen settings for the EDIT map service or the defaults as
3310
 * specified in EDIT_MAPSERVER_URI_DEFAULT and EDIT_MAPSERVER_VERSION_DEFAULT:
3311
 *  - base_uri: the protocol and host part , e.g.: http://edit.africamuseum.be
3312
 *  - version: the version, e.g.: v1.1
3313
 *
3314
 * @return array
3315
 *    An associative array of the currently chosen settings for the EDIT map service or the defaults.
3316 6657531f Andreas Kohlbecker
 */
3317 ba706bf0 Andreas Kohlbecker
function get_edit_map_service_settings() {
3318
3319
  $settings = variable_get('edit_map_server', array(
3320
      'base_uri' => EDIT_MAPSERVER_URI_DEFAULT,
3321
      'version' => EDIT_MAPSERVER_VERSION_DEFAULT
3322
      )
3323
  );
3324 6657531f Andreas Kohlbecker
3325 ba706bf0 Andreas Kohlbecker
  return $settings;
3326 6657531f Andreas Kohlbecker
}
3327
3328
/**
3329 ba706bf0 Andreas Kohlbecker
 * Returns the full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
3330
 *
3331
 * @return string
3332
 *   The full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
3333
 */
3334
function get_edit_map_service_full_uri() {
3335
  $settings = get_edit_map_service_settings();
3336
  return $settings['base_uri'] . EDIT_MAPSERVER_PATH .  '/' . $settings['version'];
3337
}
3338
3339
3340
/**
3341
 * Returns the version number of the currently selected edit mapserver as a float
3342 6657531f Andreas Kohlbecker
 *
3343
 * @return float
3344
 *   The version number of the currently selected edit mapserver as a float.
3345
 *   Returns 0 on error.
3346
 */
3347 ba706bf0 Andreas Kohlbecker
function get_edit_map_service_version_number() {
3348 6657531f Andreas Kohlbecker
3349 ba706bf0 Andreas Kohlbecker
  $pattern = '/v([\d\.]+).*$/';
3350 6657531f Andreas Kohlbecker
3351 ba706bf0 Andreas Kohlbecker
  $settings = get_edit_map_service_settings();
3352
  preg_match($pattern, $settings['version'], $matches, PREG_OFFSET_CAPTURE);
3353 6657531f Andreas Kohlbecker
  if (isset($matches[1])) {
3354
    // Convert string to float.
3355
    $version = 1 + $matches[1][0] - 1;
3356
    return $version;
3357
  }
3358
  else {
3359
    // Report error.
3360 ba706bf0 Andreas Kohlbecker
    drupal_set_message(t(" Invalid EDIT map service version number: '!version'",
3361
        array(
3362
          '!version' => $settings['version'],
3363
          'warning')
3364
        )
3365
      );
3366 6657531f Andreas Kohlbecker
    return 0;
3367
  }
3368
}
3369
3370 30f78c59 Andreas Kohlbecker
/**
3371 ba706bf0 Andreas Kohlbecker
 * Returns the array of selected items in a options array
3372 30f78c59 Andreas Kohlbecker
 *
3373
 * @param array $options
3374
 *   An options array as generated by a form element like checkoxes, select ...,
3375
 */
3376
function get_selection($options) {
3377
  $selection = array();
3378
  foreach ($options as $key=>$val) {
3379
    if (!empty($val)) {
3380
      $selection[] = $val;
3381
    }
3382
  }
3383
  return $selection;
3384
}
3385
3386 bfb2b81a Andreas Kohlbecker
3387 6657531f Andreas Kohlbecker
/**
3388
 * Implements hook_element_info().
3389
 *
3390 14feebe9 Andreas Kohlbecker
 * Allows modules to declare their own Form API element types and specify their default values.
3391
 *
3392
 * @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_element_info/7
3393 6657531f Andreas Kohlbecker
 */
3394
function cdm_dataportal_element_info() {
3395
  $type['checkboxes_preferred'] = array(
3396
    '#input' => TRUE,
3397 14feebe9 Andreas Kohlbecker
    '#process' => array('checkboxes_preferred_expand'),
3398 6657531f Andreas Kohlbecker
    '#after_build' => array('checkboxes_preferred_after_build'),
3399
    '#theme' => array('checkboxes_preferred'),
3400
    // '#theme_wrapper' => array('form_element'),
3401
  );
3402
  return $type;
3403
}
3404
3405
/**
3406 14feebe9 Andreas Kohlbecker
 * #process callback function for the custom form element type 'checkbox_preferred'
3407
 *
3408
 *
3409 6657531f Andreas Kohlbecker
 */
3410 14feebe9 Andreas Kohlbecker
function checkboxes_preferred_expand($element, &$form_state, $form) {
3411
3412
  // First of all create checkboxes for each of the elements
3413 6657531f Andreas Kohlbecker
  $element = form_process_checkboxes($element);
3414
3415 cc3c9807 Andreas Kohlbecker
  // compose the element name
3416
  $parents = array();
3417
  array_deep_copy($element['#parents'], $parents);
3418
  $parents[count($parents) -1 ] .= '_preferred';
3419
  $element_name = $parents[0];
3420
  for ($i=1; $i < count($parents); $i++){
3421
    $element_name .= '[' . $parents[$i] . ']';
3422
  }
3423
3424 6657531f Andreas Kohlbecker
  $children = element_children($element);
3425
3426
  $element['table_start'] = array(
3427
    '#markup' => '<table class="checkboxes_preferred"><tr><th></th><th>' . t('Enabled') . '</th><th>' . t('Default') . '</th></tr>',
3428
    '#weight' => -1,
3429
  );
3430
3431 14feebe9 Andreas Kohlbecker
  // prepare first part each of the table rows which contains the row label
3432 6657531f Andreas Kohlbecker
  $weight = 0;
3433
  foreach ($children as $key) {
3434
    $odd_even = $weight % 4 == 0 ? 'odd' : 'even';
3435
    $element[$key]['#weight'] = $weight;
3436 7cc085da Andreas Kohlbecker
    $element[$key]['#prefix'] = '<tr class="' . $odd_even . '"><td>' . t('@row-label', array('@row-label' => $element['#options'][$key])) . '</td><td>';
3437 6657531f Andreas Kohlbecker
    $element[$key]['#suffix'] = '</td>';
3438
    unset($element[$key]['#title']);
3439
    $weight += 2;
3440
  }
3441
  $weight = 0;
3442
3443 14feebe9 Andreas Kohlbecker
  // add a radio button to each of the checkboxes, the
3444
  // check boxes have already been created at the beginning
3445
  // of this function
3446 6657531f Andreas Kohlbecker
  if (count($element['#options']) > 0) {
3447
    foreach ($element['#options'] as $key => $choice) {
3448
      if (!isset($element[$key . '_preferred'])) {
3449
        $element[$key . '_preferred'] = array(
3450
          '#type' => 'radio',
3451 cc3c9807 Andreas Kohlbecker
          '#name' => $element_name,
3452 6657531f Andreas Kohlbecker
          '#return_value' => check_plain($key),
3453
          '#default_value' => empty($element['#default_value_2']) ? NULL : $element['#default_value_2'],
3454
          '#attributes' => $element['#attributes'],
3455 1d39ec64 w.addink
          '#parents' => $element['#parents'],
3456 6657531f Andreas Kohlbecker
          // '#spawned' => TRUE,
3457
          '#weight' => $weight + 1,
3458 14feebe9 Andreas Kohlbecker
          '#prefix' => '<td>',        // add a prefix to start a new table cell
3459
          '#suffix' => '</td></tr>',  // add a prefix to close the tabel row
3460 6657531f Andreas Kohlbecker
        );
3461
      }
3462
      $weight += 2;
3463
    }
3464
  }
3465
3466 14feebe9 Andreas Kohlbecker
  // end the table
3467 6657531f Andreas Kohlbecker
  $element['table_end'] = array(
3468
    '#markup' => '</table>',
3469
    '#weight' => $weight++,
3470
  );
3471
3472
  return $element;
3473
}
3474
3475
/**
3476
 * Theme function for the custom form field 'checkboxes_preferred'.
3477
 */
3478
function theme_checkboxes_preferred($variables) {
3479
  $element = $variables['element'];
3480
  $out = '<div id="edit-baselayers-wrapper" class="form-item">';
3481
  $out .= '<label for="edit-baselayers">' . $element['#title'] . '</label>';
3482
  $out .= drupal_render_children($element);
3483
  $out .= '<div class="description">' . $element['#description'] . '</div>';
3484
  $out .= '</div>';
3485
  return $out;
3486
}
3487
3488
/**
3489 14feebe9 Andreas Kohlbecker
 * Callback for checkboxes preferred for widget which will
3490
 * be called after the form or element is built. The call
3491
 * back is configured in the form element by setting it as
3492
 * #after_build parameter.
3493
 *
3494
 * @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#after_build
3495
 *
3496 cc3c9807 Andreas Kohlbecker
 * @param $element
3497 14feebe9 Andreas Kohlbecker
 *   Nested array of form elements that comprise the form.
3498
 * @param $form_state
3499
 *   A keyed array containing the current state of the form.
3500 cc3c9807 Andreas Kohlbecker
 *   This includes the current persistent storage data for the form.
3501
 *   Additional information, like the sanitized $_POST data,
3502
 *   is also accumulated here in $form_state['input']
3503 14feebe9 Andreas Kohlbecker
 *
3504
 * @return the modified form array
3505 6657531f Andreas Kohlbecker
 */
3506 cc3c9807 Andreas Kohlbecker
function checkboxes_preferred_after_build($element, &$form_state) {
3507 6657531f Andreas Kohlbecker
3508 cc3c9807 Andreas Kohlbecker
  $parent_id = $element['#parents'][count($element['#parents']) - 1];
3509 6657531f Andreas Kohlbecker
3510
  if ($_POST && count($_POST) > 0) {
3511 cc3c9807 Andreas Kohlbecker
    // TODO use  $form_state['input'] instead of POST !!!
3512 6657531f Andreas Kohlbecker
    // First pass of form processing.
3513 cc3c9807 Andreas Kohlbecker
    $parents = array();
3514
    array_deep_copy($element['#parents'], $parents);
3515
    $parents[count($parents) - 1] .= '_preferred';
3516
    $preferred_layer = drupal_array_get_nested_value($_POST, $parents);
3517
    $element['#value']['PREFERRED'] = $preferred_layer;
3518
//     $form_state[$parent_id] = $element['#value'];
3519
//     $form_state['values']['baselayers'] = $element['#value'];
3520
    $form_state_element_values = &drupal_array_get_nested_value($form_state['values'], $element['#parents']);
3521
    $form_state_element_values = $element['#value'];
3522 6657531f Andreas Kohlbecker
  }
3523
  else {
3524
    // Second pass of form processing.
3525 cc3c9807 Andreas Kohlbecker
    $preferred_layer = $element['#value']['PREFERRED'];
3526 6657531f Andreas Kohlbecker
  }
3527
3528
  // Also set the chosen value (not sure if this is good Drupal style ....).
3529 cc3c9807 Andreas Kohlbecker
  foreach ($children = element_children($element) as $key) {
3530
    if (!empty($element[$key]['#type']) && $element[$key]['#type'] == 'radio') {
3531
      $element[$key]['#value'] = $preferred_layer;
3532 6657531f Andreas Kohlbecker
    }
3533
  }
3534
  // The default layer must always be enabled.
3535 cc3c9807 Andreas Kohlbecker
  $element[$preferred_layer]['#value'] = $preferred_layer;
3536 6657531f Andreas Kohlbecker
3537 cc3c9807 Andreas Kohlbecker
  return $element;
3538 6657531f Andreas Kohlbecker
}
3539 0f5f1c12 Andreas Kohlbecker
3540 3f485c6d Andreas Kohlbecker
function radios_prepare_options_suffix(&$elements){
3541
3542
  $childrenKeys = element_children($elements);
3543
  foreach($childrenKeys as $key){
3544
    if(!is_array($elements[$key]['#theme_wrappers'])){
3545
      $elements[$key]['#theme_wrappers'] = array();
3546
    }
3547
    if(isset($elements['#options_suffixes'][$key])){
3548
      $elements[$key]['#theme_wrappers'][] = 'radio_options_suffix';
3549
      $elements[$key]['#options_suffix'] = $elements['#options_suffixes'][$key];
3550
    }
3551
  }
3552
  return $elements;
3553
3554
}
3555
3556
/**
3557
 * TODO
3558
 * @param unknown $variables
3559
 */
3560
function theme_radio_options_suffix($variables) {
3561
  $element = $variables['element'];
3562
  if(isset($element['#options_suffix'])) {
3563
    $element['#children'] .= $element['#options_suffix'];
3564
  }
3565
  return $element['#children'];
3566
}
3567
3568
3569 0f5f1c12 Andreas Kohlbecker
/**
3570
 * Element validate callback for text field and arrays containing json.
3571
 *
3572
 * @param $element
3573
 *   The form element to validate
3574
 * @param $form_state
3575
 *   A keyed array containing the current state of the form.
3576 cc3c9807 Andreas Kohlbecker
 * @param $form
3577
 *   Nested array of form elements that comprise the form.
3578 0f5f1c12 Andreas Kohlbecker
 */
3579
function form_element_validate_json($element, &$form_state, $form) {
3580
   if (!empty($element['#value'])) {
3581
     json_decode($element['#value']);
3582
     if(json_last_error() != JSON_ERROR_NONE){
3583 7cc085da Andreas Kohlbecker
       form_error($element,
3584
         t('The form element %title contains invalid JSON. You can check the syntax with ', array('%title' => $element['#title']))
3585
         . l('JSONLint', 'http://jsonlint.com/')
3586
       );
3587 0f5f1c12 Andreas Kohlbecker
     }
3588
   }
3589
}
3590
3591
/**
3592
 * Form submission handler for textareas and textfields containing JSON.
3593
 *
3594
 * The contained JSON will be converted into an php array
3595 2bbc28c8 Andreas Kohlbecker
 * or object and will be stored in the variables as such.
3596 0f5f1c12 Andreas Kohlbecker
 *
3597
 * @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#submit
3598
 *
3599
 * @param $form
3600
 *   Nested array of form elements that comprise the form.
3601
 * @param $form_state
3602
 *   A keyed array containing the current state of the form.
3603
 *
3604
 */
3605
function submit_json_as_php_array($form, &$form_state) {
3606
  if (is_array($form['#json_elements'])) {
3607
    foreach ($form['#json_elements'] as $element){
3608 80370786 Andreas Kohlbecker
      if (trim($form_state['values'][$element])) {
3609
        $form_state['values'][$element] = (array) json_decode($form_state['values'][$element]);
3610
      } else {
3611
        $form_state['values'][$element] = NULL;
3612
      }
3613 0f5f1c12 Andreas Kohlbecker
    }
3614
  }
3615
}