Project

General

Profile

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