Project

General

Profile

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