Project

General

Profile

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