Project

General

Profile

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