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