Project

General

Profile

Download (60.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
define('DEFAULT_TAXONTREE_RANKLIMIT', '1b11c34c-48a8-4efa-98d5-84f7f66ef43a');//TODO Genus UUID
4
define('CDM_TAXONOMICTREE_UUID', 'cdm_taxonomictree_uuid');
5

    
6
define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
7
define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
8
define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
9
define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
10
define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
11
define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 4);
12

    
13
/* annotationTypeKeys */
14
$annotationTypeKeys = array_keys( cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE) );
15
if(in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
16
  $annotationTypeKeys = array_flip($annotationTypeKeys);
17
  // technical annotation are off by default
18
  unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
19
  $annotationTypeKeys = array_flip($annotationTypeKeys);
20
}
21
define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
22

    
23
/* taxonRelationshipTypes */
24
define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(array(UUID_MISAPPLIED_NAME_FOR, UUID_INVALID_DESIGNATION_FOR)));
25

    
26

    
27
/* gallery variables */
28
$gallery_settings = array(
29
    "cdm_dataportal_show_taxon_thumbnails" => 1,
30
    "cdm_dataportal_show_synonym_thumbnails" => 0,
31
    "cdm_dataportal_show_thumbnail_captions" => 1,
32
    "cdm_dataportal_media_maxextend" => 120,
33
    "cdm_dataportal_media_cols" => 3,
34
    "cdm_dataportal_media_maxRows" => 1);
35

    
36

    
37
$taxon_tab_options = array(
38
  0 => 'General',
39
  1 => 'Synonymy',
40
  2 => 'Images',
41
  3 => 'Specimens',
42
  CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX => 'Last visited tab',
43
);
44

    
45
define('EDIT_MAPSERVER_V1_URI', 'http://edit.br.fgov.be/edit_wp5/v1');
46
define('EDIT_MAPSERVER_V11_URI', 'http://edit.br.fgov.be/edit_wp5/v1.1');
47
define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
48

    
49
// --- Taxon profile settings --- /
50
define (LAYOUT_SETTING_PREFIX, 'layout_');
51
define (FEATURE_TREE_LAYOUT_DEFAULTS, serialize(
52
    array(
53
    'enabled'=> false,
54
    'enclosingTag' => 'ul',
55
    'entryEnclosingTag' => 'li',
56
    'glue' => ' '
57
    )
58
  ));
59

    
60

    
61
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
62
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
63
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
64
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
65
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
66
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
67
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
68
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
69
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
70
//define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
71
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
72
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
73
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
74
define('CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
75
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
76

    
77
function getGallerySettings($gallery_config_form_name){
78
  $default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
79
  return variable_get($gallery_config_form_name, $default_values);
80
}
81

    
82
function get_default_taxon_tab($index = false) {
83

    
84
  global $user;
85
  $values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
86
  $user_tab_active = 'cdm_dataportal_' .$user->uid . '_default_tab_active';
87
  $user_tab = 'cdm_dataportal_' .$user->uid . '_default_tab';
88
  //get the user value
89
  $user_tab_on = variable_get($user_tab_active, false);
90
  if($user_tab_on){
91
    $user_value = variable_get($user_tab, 0);
92
    $index_value = $user_value;
93
  //get the system value
94
  }else{
95
    $system_value = variable_get('cdm_dataportal_default_tab', 0);
96
    $index_value = $system_value;
97
  }
98
  if (!index){
99
     return ($values[$index_value]);
100
  }else{
101
     return $index_value;
102
  }
103

    
104

    
105
  switch ($value){
106
    case 0:
107
      $res = 'General';
108
      break;
109
    case 1:
110
      $res = 'Synonymy';
111
      break;
112
    case 2:
113
      $res = 'Images';
114
      break;
115
    case 3:
116
      $res = 'Specimens';
117
      break;
118
    case 4:
119
      $res = 'last_visited_tab';
120
      break;
121
    default:
122
      $res = 'General';
123
  }
124
  return $res;
125
}
126

    
127
function cdm_dataportal_menu_admin($may_cache, &$items){
128

    
129
  if (!$may_cache) {
130

    
131
    $items[] = array(
132
      'path' => 'admin/settings/cdm_dataportal',
133
      'title' => t('CDM Dataportal'),
134
      'description' => t('Setting for the CDM DataPortal'),
135
      'access' => user_access('administer cdm_dataportal'),
136
      'callback' => 'drupal_get_form',
137
      'callback arguments' => array('cdm_settings_general'),
138
      'type' => MENU_NORMAL_ITEM,
139
    );
140

    
141
    $items[] = array(
142
      'path' => 'admin/settings/cdm_dataportal/general',
143
      'title' => t('General'),
144
      'description' => t('Setting for the CDM DataPortal'),
145
      'access' => user_access('administer cdm_dataportal'),
146
      'callback' => 'drupal_get_form',
147
      'callback arguments' => array('cdm_settings_general'),
148
      'weight' => 0,
149
      'type' => MENU_LOCAL_TASK,
150
    );
151

    
152
    $items[] = array(
153
      'path' => 'admin/settings/cdm_dataportal/cachesite',
154
      'title' => t('Cache'),
155
      'description' => t('Cache'),
156
      'access' => user_access('administer cdm_dataportal'),
157
      'callback' => 'drupal_get_form',
158
      'callback arguments' => array('cdm_settings_cache'),
159
      'weight' => 10,
160
      'type' => MENU_LOCAL_TASK,
161
    );
162

    
163
    $items[] = array(
164
      'path' => 'admin/settings/cdm_dataportal/geo',
165
      'title' => t('Geo & Map'),
166
      'description' => t('Geo & Map'),
167
      'access' => user_access('administer cdm_dataportal'),
168
      'callback' => 'drupal_get_form',
169
      'callback arguments' => array('cdm_settings_geo'),
170
      'weight' => 1,
171
      'type' => MENU_LOCAL_TASK,
172
    );
173

    
174
    $items[] = array(
175
      'path' => 'admin/settings/cdm_dataportal/layout',
176
      'title' => t('Layout'),
177
      'description' => t('Configure and adjust the layout of your DataPortal '),
178
      'access' => user_access('administer cdm_dataportal'),
179
      'callback' => 'drupal_get_form',
180
      'callback arguments' => array('cdm_settings_layout'),
181
      'weight' => 2,
182
      'type' => MENU_LOCAL_TASK,
183
    );
184

    
185
    $items[] = array(
186
      'path' => 'admin/settings/cdm_dataportal/layout/taxon',
187
      'title' => t('Taxon'),
188
      'description' => t('Configure and adjust the layout of your DataPortal '),
189
      'access' => user_access('administer cdm_dataportal'),
190
      'callback' => 'drupal_get_form',
191
      'callback arguments' => array('cdm_settings_layout_taxon'),
192
      'weight' => 1,
193
      'type' => MENU_LOCAL_TASK,
194
    );
195
/*
196
    $items[] = array(
197
      'path' => 'admin/settings/cdm_dataportal/layout/synonymy',
198
      'title' => t('Synonymy'),
199
      'description' => t('Configure and adjust the layout of your DataPortal '),
200
      'access' => user_access('administer cdm_dataportal'),
201
      'callback' => 'drupal_get_form',
202
      'callback arguments' => array('cdm_settings_layout_synonymy'),
203
      'weight' => 1,
204
      'type' => MENU_LOCAL_TASK,
205
    );
206

    
207
    $items[] = array(
208
      'path' => 'admin/settings/cdm_dataportal/layout/specimens',
209
      'title' => t('Specimens'),
210
      'description' => t('Configure and adjust the layout of your DataPortal '),
211
      'access' => user_access('administer cdm_dataportal'),
212
      'callback' => 'drupal_get_form',
213
      'callback arguments' => array('cdm_settings_layout_specimens'),
214
      'weight' => 1,
215
      'type' => MENU_LOCAL_TASK,
216
    );
217
*/
218
    $items[] = array(
219
      'path' => 'admin/settings/cdm_dataportal/layout/search',
220
      'title' => t('Search'),
221
      'description' => t('Configure and adjust the layout of your DataPortal '),
222
      'access' => user_access('administer cdm_dataportal'),
223
      'callback' => 'drupal_get_form',
224
      'callback arguments' => array('cdm_settings_layout_search'),
225
      'weight' => 2,
226
      'type' => MENU_LOCAL_TASK,
227
    );
228

    
229
    $items[] = array(
230
      'path' => 'admin/settings/cdm_dataportal/layout/media',
231
      'title' => t('Media'),
232
      'description' => t('Configure and adjust the layout of your DataPortal '),
233
      'access' => user_access('administer cdm_dataportal'),
234
      'callback' => 'drupal_get_form',
235
      'callback arguments' => array('cdm_settings_layout_media'),
236
      'weight' => 3,
237
      'type' => MENU_LOCAL_TASK,
238
    );
239
/*   Path to banners configuration (DEFAULT THEME)
240
    $items[] = array(
241
      'path' => 'admin/settings/cdm_dataportal/layout/theme',
242
      'title' => t('Theme'),
243
      'description' => t('Configure the drupal theme of your DataPortal '),
244
      'access' => user_access('administer cdm_dataportal'),
245
      'callback' => 'drupal_get_form',
246
      'callback arguments' => array('cdm_dataportal_theming_form'),
247
      'weight' => 4,
248
      'type' => MENU_LOCAL_TASK,
249
        );
250
*/
251
  }
252

    
253

    
254
}
255

    
256
function cdm_help_general_cache(){
257
  $form = array();
258
  $form['cache_help'] = array(
259
    '#type' => 'fieldset',
260
  '#title' => t('Help'),
261
  '#collapsible' => TRUE,
262
  '#collapsed' => TRUE,
263
  );
264
  $form['cache_help']['test'] = array('#value' => t('probando'));
265
  return drupal_render($form);
266
  $res = array();
267
  $res['default'] = drupal_render($help);
268
  return $res;
269
}
270

    
271
/**
272
 * Configures the settings form for the CDM-API module.
273
 *
274
 * @return Array Drupal settings form
275
 */
276
function cdm_settings_general(){
277

    
278
  $form['cdm_webservice'] = array(
279
      '#type' => 'fieldset',
280
      '#title' => t('CDM Server'),
281
      '#collapsible' => FALSE,
282
      '#collapsed' => FALSE,
283
    '#description' => t('<em>CDM Server</em> makes possible the dialogue with
284
                         <em>CDM Data Portal</em> thanks to his web services.'),
285
  );
286

    
287
  $form['cdm_webservice']['cdm_webservice_url'] =  array(
288
    '#type' => 'textfield',
289
    '#title'         => t('CDM web service URL'),
290
    '#description'   => t('This is the ip address of the location of the CDM Web Server which contains
291
                           your collection database. The address must follow the format <em>"http://X:Y/Z"</em>
292
                           where "<em>X</em>" is the ip address of the machine where the server is running, "<em>Y</em>" is
293
                           the port number where the server is listening and "<em>Z</em>" the name of the database
294
                           where your collection is, e.g. <em>"http://160.45.63.201:8080/palmae"</em>'),
295
    '#default_value' => variable_get('cdm_webservice_url', NULL),
296
  );
297

    
298
  /** MOVED TO DATAPORTAL
299
  $form['cdm_webservice']['taxontree_ranklimit'] =  array(
300
    '#type'          => 'select',
301
    '#title'         => t('Rank of highest displayed taxon'),
302
    '#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT), //before DEFAULT_TAXONTREE_RANKLIMIT_UUID
303
    '#options'       => cdm_rankVocabulary_as_option(),
304
    '#description'   => t('The rank of the highest displayed taxon in the <em>taxontree</em>. When you explore
305
                           your collection, you can navigate it through a tree structure (<em>taxontree</em>). You can
306
                           select here which rank should be at the top level of the tree structure.'),
307
  );
308
  */
309
/*
310
  $form['cdm_webservice']['cdm_webservice_cache'] =  array(
311
    '#type' => 'checkbox',
312
    '#title'         => t('<b>Enable caching</b>'),
313
  '#options'     => cdm_help_general_cache(),
314
    '#default_value' => variable_get('cdm_webservice_cache', 1),
315
    '#description'   => t('When caching is enabled all single taxon sites are stored in an internal drupal cache doing
316
                           the portal response of taxa sites faster. This is possible because the sites are loaded from
317
                           the cache and are not created from scratch.
318
                           You can manage and find more information about the cache at the <a href="./?q=admin/settings/cdm_dataportal/cachesite">cache configuration site</a>.<br>' .
319
                         '<b>Note:</b> If taxa are modified by the editor or any other application the changes will be not
320
                         visible till the cache is erased. Therefore developers should deactived this feature when they
321
                         are working on the CDM Dataportal Module')
322
    );
323
*/
324
    $form['cdm_webservice']['cdm_webservice_debug'] =  array(
325
    '#type' => 'checkbox',
326
    '#title'         => t('<b>Debug CDM Web Service</b>'),
327
    '#default_value' => variable_get('cdm_webservice_debug', 1),
328
    '#description'   => t('When enabled is possible to see which web services from CDM Server have been called and its
329
                           results. A black box will appear at the top of the web site with the information.<br>' .
330
                          '<b>Note:</b> this is meanly a feature for developers.')
331
    );
332

    
333
    $form['cdm_webservice']['proxy'] = array(
334
      '#type' => 'fieldset',
335
      '#title' => t('Proxy'),
336
      '#collapsible' => TRUE,
337
      '#collapsed' => TRUE
338
    );
339

    
340
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] =  array(
341
    '#type' => 'textfield',
342
    '#title'         => t('Proxy URL'),
343
    '#description'   => t('If this proxy url is set the cdm api tries
344
    to connect the web service over the given proxy server.
345
    Otherwise proxy usage is deactivated.'),
346
    '#default_value' => variable_get('cdm_webservice_proxy_url', false),
347
    );
348

    
349
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] =  array(
350
    '#type' => 'textfield',
351
    '#title'         => t('Proxy port'),
352
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
353
    );
354

    
355
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] =  array(
356
    '#type' => 'textfield',
357
    '#title'         => t('Login'),
358
    '#default_value' => variable_get('cdm_webservice_proxy_usr', false),
359
    );
360

    
361
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] =  array(
362
    '#type' => 'textfield',
363
    '#title'         => t('Password'),
364
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', false),
365
    );
366

    
367
    //TODO: settings are still incomplete, compare with trunk/dataportal/inc/config_default.php.inc
368
    $form['cdm_dataportal'] = array(
369
      '#type' => 'fieldset',
370
      '#title' => t('Taxon Tree'),
371
      '#collapsible' => FALSE,
372
      '#collapsed' => TRUE,
373
      '#description' => t('<p>When you explore your collection, you can navigate it through a
374
                           tree structure also called <em>Taxon Tree</em>.</p><p>To be able to navigate through
375
                           your collection the
376
                           <a href="http://drupal.org/handbook/blocks">drupal block</a>
377
                           <em>CDM Taxon Tree</em> should be visible for users. Enable the block at
378
                           <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p>'),
379
    );
380

    
381
    $form['cdm_dataportal'][CDM_TAXONOMICTREE_UUID] = array(
382
      '#type' => 'select',
383
      '#title'         => t('Available classifications'),
384
      '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, false),
385
      '#options' => cdm_get_taxontrees_as_options(),
386
      '#description'   => t('Select the default taxa classification for your <em>taxon tree</em>,
387
                             the other classifications will be also available but with a manual user change.')
388
    );
389

    
390
    $form['cdm_dataportal']['taxontree_ranklimit'] =  array(
391
    '#type'          => 'select',
392
    '#title'         => t('Rank of highest displayed taxon'),
393
    '#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT), //before DEFAULT_TAXONTREE_RANKLIMIT_UUID
394
    '#options'       => cdm_rankVocabulary_as_option(),
395
    '#description'   => t('This is the rank of the highest displayed taxon in the <em>taxon tree</em>. You can
396
                           select here which rank should be at the top level of the tree structure.'),
397
  );
398

    
399
    return system_settings_form($form);
400
}
401

    
402

    
403
/**
404
 * LAYOUT settings
405
 * @return unknown_type
406
 */
407
function cdm_settings_layout(){
408

    
409
  //drupal_goto('admin/settings/cdm_dataportal/layout/taxon');
410
  $form = array();
411
/*
412
  // -- tabbed pages -- //
413
  $form['cdm_dataportal_taxonpage_tabs'] = array(
414
    '#type' => 'checkbox',
415
    '#title' => t('Tabbed taxon page'),
416
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
417
    '#description' => t('If selected split the taxon page into individual tabs for description, images, synonymy. If not the taxon data is renderized as a long single page without tabs.')
418
  );
419
*/
420
  $form['gen_layout'] = array(
421
    '#type' => 'fieldset',
422
      '#title' => t('Portal Layout'),
423
        '#collapsible' => FALSE,
424
        '#collapsed' => FALSE,
425
      '#description' => t('This settings contains the general configurations layout. If you want to configure the specific sites layout visit the respective configuration site for taxon, search or media.'),
426
  );
427

    
428
  //---- footnotes ---//
429
  $form['gen_layout']['footnotes'] = array(
430
      '#type' => 'fieldset',
431
      '#title' => t('Footnotes'),
432
      '#collapsible' => FALSE,
433
      '#collapsed' => FALSE,
434
    '#description' => t('Taxa data such authors, synonyms names, descriptions, media or distribution areas may have annotations or footnotes. When the footnotes are enabled
435
                         they will be visible (if they exist).'),
436
  );
437

    
438
  $form['gen_layout']['footnotes']['cdm_dataportal_all_footnotes'] = array(
439
      '#type' => 'checkbox',
440
      '#title' => t('Do not show footnotes'),
441
      '#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
442
      '#description' => t('Check this if you do not want to show any footnotes')
443
  );
444

    
445
  $form['gen_layout']['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
446
      '#type' => 'checkbox',
447
      '#title' => t('Do not show annotations footnotes'),
448
      '#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
449
      '#description' => t('Check this if you do not want to show annotation footnotes')
450
  );
451

    
452
  $annotationTypeOptions = cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE);
453
  $form['gen_layout']['footnotes']['annotations_types_as_footnotes'] = array(
454
      '#type' => 'checkboxes',
455
      '#title' => t('Annotation types as footnotes'),
456
      '#description' => t('Only annotations of the selected type will be displayed as footnotes. You may want to turn \'technical annotations\' off. Untyped annotations will always be displayed.'),
457
      '#options' => $annotationTypeOptions,
458
      '#default_value' => variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT))
459

    
460
  );
461

    
462
  //--- Advanced Search ---//
463
  $form['gen_layout']['asearch'] = array(
464
      '#type' => 'fieldset',
465
      '#title' => t('Advanced search'),
466
      '#collapsible' => FALSE,
467
      '#collapsed' => FALSE,
468
    );
469
    $form['gen_layout']['asearch']['cdm_dataportal_show_advanced_search'] = array(
470
      '#type' => 'checkbox',
471
      '#title' => t('Show advanced search link'),
472
      '#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
473
      '#description' => t('Check this box if the link to advanced search should be show below the search box.'),
474
    );
475

    
476
  return system_settings_form($form);
477
}
478

    
479
function cdm_dataportal_theming_form (){
480
    //--- Theme ---//
481
/*
482
    $form['cdm_dataportal_theming'] = array(
483
      '#type' => 'fieldset',
484
      '#title' => t('Theme Images'),
485
      '#collapsible' => FALSE,
486
      '#collapsed' => FALSE,
487
    );
488
*/
489
  $form = array('#attributes' => array('enctype' => 'multipart/form-data'));
490

    
491
    $form['cdm_dataportal_theming_right_image'] = array(
492
        '#type' => 'file',
493
        '#title' => t('Select top right image'),
494
        '#description' => t('Maximum dimensions are %dimensions and the maximum size is %size kB.',
495
                            array('%dimensions' =>  '250x250', '%size' => '30')),
496
    );
497
    $form['cdm_dataportal_theming_middle_image'] = array(
498
        '#type' => 'file',
499
        '#title' => t('Select top middle image'),
500
    );
501
    $form['test'] = array(
502
        '#type' => 'textfield',
503
        '#title' => t('test')
504
    );
505

    
506
    //$form['gen_layout']['theme']['#submit'][] = 'settings_validate_theme_pictures';
507
    $form['cdm_dataportal_theming']['submit'] = array(
508
      '#type' => 'submit',
509
      '#value' => t('Submit')
510
    );
511

    
512
    return $form;
513
}
514

    
515
function cdm_dataportal_theming_form_submit (&$form, &$form_values){
516
  $validators = array();
517
  //destination path where the files/banners will be saved
518
  $dest = absolute_path_to_drupal() . '/' . path_to_theme() . '/images/banners';
519
  $dest = str_replace('/', DIRECTORY_SEPARATOR, $dest);
520
  //drupal_set_message($dest);
521

    
522
  //check if directory exists
523
  if (!file_exists($dest)){
524
        if(!mkdir($dest, 0777, true)){//TODO: add rights, which rights should I add?
525
            drupal_set_message('Fail uploading the files; the directory '
526
                               . $dest . ' could not be created.',
527
                               'warning');
528
        }
529
  }
530
  //check if files already exist
531
  //if (file_exists($dest)) {
532
  //}
533

    
534
  //save the files
535
    $file = file_check_upload('cdm_dataportal_theming_middle_image');
536
    if ($file){
537
        $file = file_save_upload($file, 'files');
538
        drupal_set_message($file->filepath);
539
        file_move($file->filepath, $dest);
540
    }else{
541
      drupal_set_message('Fail uploading the file, the file is not accepted.', 'warning');
542
    }
543
  //use banners in the selected theme
544
    //if (!copy($file, $file.'.bak')) {
545
    //    print ("failed to copy $file...<br>\n");
546
    //}
547

    
548
    //use the banners as default theme
549
}
550
/*
551
function cdm_settings_layout_synonymy(){
552
  / * ====== SYNONYMY ====== * /
553
  $form['synonymy'] = array(
554
      '#type' => 'fieldset',
555
      '#title' => t('Synonymy'),
556
      '#collapsible' => TRUE,
557
      '#collapsed' => TRUE,
558
      '#description' => t('This section covers the settings related to the taxon <b>synonymy</b> tab.'),
559
  );
560

    
561
  $form['synonymy']['cdm_dataportal_nomref_in_title'] = array(
562
    '#type' => 'checkbox',
563
    '#title' => t('Show accepted taxon on top of the synonymy'),
564
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
565
    '#description' => t('If checked, the first homotypic taxon is a repetition of the accepted taxon most likely
566
                        with the full nomenclatural reference (depending on the currently chosen theme).')
567
  );
568

    
569
  $form['synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
570
    '#type' => 'checkbox',
571
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when coming from a synonym link.'),
572
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
573
    '#description' => t('Check this if after doing a search and clicking on a synonym you want to see the "accept of" text for the accepted synonym.')
574
  );
575

    
576
  $form['synonymy']['name_relationships']['name_relationships_to_show'] = array(
577
    '#type' => 'checkboxes',
578
    '#title' => t('Display name relationships'),
579
    '#default_value' => variable_get('name_relationships_to_show', 0),
580
    '#options' => $nameRelationshipTypeOptions,
581
    '#description' => t('Select the name relationships you want to show for the accepted taxa.'),
582
  );
583

    
584
  $form['synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
585
    '#type' => 'checkbox',
586
    '#title' => t('Show taxon relations ships of accepted taxon'),
587
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
588
    '#description' => t('If this option is enabled the synonymy will show the below selected taxon relationships of accepted taxa.')
589
  );
590

    
591
  $taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE);
592
  $form['synonymy'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
593
      '#type' => 'checkboxes',
594
      '#title' => t('Taxon relationship types'),
595
      '#description' => t('Only taxon relationships of the selected type will be displayed'),
596
      '#options' => $taxonRelationshipTypeOptions,
597
      '#default_value' => variable_get('CDM_TAXON_RELATIONSHIP_TYPES', unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
598
      '#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)
599
  );
600

    
601
  return system_settings_form($form);
602

    
603
}
604
*/
605

    
606
function cdm_settings_layout_taxon(){
607
  $collapsed = false;
608
  $form = array();
609

    
610
  //--------- TABBED TAXON -------//
611
  $form['taxon_tabs'] = array(
612
    '#type' => 'fieldset',
613
      '#title' => t('Taxon tabs'),
614
      '#collapsible' => TRUE,
615
      '#collapsed' => FALSE,
616
    '#description' => t('If tabbed taxon page is enabled the taxon profile will be splitted in four diferent tabs;
617
             General, Synonymy, Images and Specimens. If the taxon has no information for any of the tabs/sections such tab will be not displayed.'),
618
  );
619

    
620
    $form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
621
    '#type' => 'checkbox',
622
    '#title' => t('Tabbed taxon page'),
623
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
624
    '#description' => t('<p>If selected split the taxon page into individual tabs for description, images, synonymy and specimens.
625
                            If not the taxon data is renderized as a long single page without tabs.</p>')
626
  );
627

    
628
  $form['taxon_tabs']['cdm_dataportal_detault_tab'] =  array(
629
      '#type'          => 'select',
630
      '#title'         => t('Default tab to display'),
631
      '#default_value' => variable_get('cdm_dataportal_detault_tab', 0),
632
      '#options'       => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
633
      '#description'   => t('<p>Select the default tab to display when visiting a taxon page. Only available if Tabbed Taxon Page is enable.</p>
634
              <strong>Note:</strong> After performing a search and clicking in any synonym, the taxon tab
635
              to be renderized will be the synonymy of the accepted taxon and not the above selected tab.'),
636
  );
637

    
638
  $form['cdm_dataportal_show_back_to_search_results'] = array(
639
      '#type' => 'checkbox',
640
        '#title' => t('Show <em>Back to search results</em> link at the taxon site.'),
641
        '#default_value' => variable_get('cdm_dataportal_show_back_to_search_results', 1),
642
        '#description' => t('<p>If checked the link to search results is rendererized at the top of the taxon site. Clicking on the link the last search performed is renderized again.</p>')
643
  );
644

    
645
  /* ======  TAXON_PROFILE ====== */
646

    
647
  $form['taxon_profile'] = array(
648
      '#type' => 'fieldset',
649
      '#title' => t('Taxon profile (tab)'),
650
      '#description' => t('<p>This section covers the setting related to the taxon profile tab, also known as the <strong>"General"</strong> tab.</p>'),
651
      '#collapsible' => TRUE,
652
      '#collapsed' => TRUE,
653
  );
654

    
655

    
656
  // ---- PROFILE PICTURE ----//
657
  $form['taxon_profile']['picture'] = array(
658
      '#type' => 'fieldset',
659
      '#title' => t('Profile Picture'),
660
      '#collapsible' => TRUE,
661
      '#collapsed' => FALSE,
662
    '#description' => t('Select a profile picture for taxa. Like a facebook of plants.'),
663
  );
664

    
665
  $form['taxon_profile']['picture']['cdm_dataportal_show_default_image'] = array(
666
      '#type' => 'checkbox',
667
      '#title' => t('Enable profil picture'),
668
      '#default_value' => variable_get('cdm_dataportal_show_default_image', false),
669
      '#description'   => t('Show the profil picture.')
670
  );
671

    
672
  $options = cdm_rankVocabulary_as_option();
673
  array_unshift($options, '-- DISABLED --');
674
  $form['taxon_profile']['picture']['image_hide_rank'] =  array(
675
      '#type'          => 'select',
676
      '#title'         => t('Hide picture for taxa above'),
677
      '#default_value' => variable_get('image_hide_rank', '0'),
678
      '#options'       => $options,
679
      '#description'   => t('Select which rank of pictures should not have a profil picture.'),
680
  );
681
  //show picture
682
  $selectShowMedia = array(0 => "Show only taxon pictures",
683
  1 => "Show taxon and child taxa pictures");
684

    
685
  $form['taxon_profile']['picture']['cdm_dataportal_show_media'] = array(
686
      '#type' => 'select',
687
      '#title' => t('Available picture files'),
688
      '#default_value' => variable_get('cdm_dataportal_show_media', false),
689
      '#options' => $selectShowMedia,
690
      '#description'   => t('Show the profil pictures current taxon\'s children.')
691
  );
692

    
693
  //-- MEDIA THUMBNAILS --//
694
  $form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
695
  $form_title = 'Taxon Profile Images';
696
  $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>';
697
  $form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
698

    
699
  // ---- FEATURE TREE ---- //
700
  $form['taxon_profile']['taxon_profile'] = array(
701
  '#type' => 'fieldset',
702
     '#title' => t('Features'),
703
     '#collapsible' => TRUE,
704
     '#collapsed' => FALSE,
705
  '#description' => t('This section covers settings related to the taxon\'s <em>Feature Tree</em>. The <em>feature tree</em> are the taxon\'s
706
                        features such description, distribution, common names, etc. that drupal will render at his taxon profile page.'),
707
  );
708

    
709
  $form['taxon_profile']['feature_trees'][CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID] = array(
710
      '#type' => 'radios',
711
      '#title'         => t('Taxon profile sections'),
712
      '#default_value' => variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE),
713
      '#options' => cdm_get_featureTrees_as_options(TRUE),
714
      '#description'   => t('Select the Feature Tree to be displayed at the taxon profile. Click "Show Details" to see the Feature Tree elemets.'
715
      )
716
  );
717

    
718
  $form['taxon_profile']['feature_trees'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
719
    '#type' => 'radios',
720
    '#title'         => t('Natural language representation of structured descriptions'),
721
    '#default_value' => variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, null),
722
    '#options' => cdm_get_featureTrees_as_options(),
723
    '#description'   => t('Taxon descriptions can be stored in a highly structured form.'.
724
      ' The feature tree selected here will be used to generate textual representation in natural language.'
725
      //.' If there is no applicable FeatureTree you can create a new one using the <a href="">FeatureTreeManager</a>'
726
    )
727
  );
728

    
729
  //---- LAYOUT PER FEATURE ---- //
730
  $feature_tree = cdm_ws_get(CDM_WS_FEATURETREES, variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE));
731

    
732
  if( isset($feature_tree->root->children) ){
733

    
734
    $form_feature_list_layout = array(
735
      '#title' => t('Taxon profile layout'),
736
      '#collapsible' => TRUE,
737
      '#collapsed' => FALSE,
738
      '#type' => 'fieldset',
739
      '#description' => t('Will be availbale in a future release.'),
740
    );
741

    
742
    $feature_list_layout_settings_disabled = true;
743
    foreach( $feature_tree->root->children as $featureNode ){
744

    
745

    
746
      if( !$feature_list_layout_settings_disabled && isset($featureNode->feature) ) {
747

    
748
        $subform_id = LAYOUT_SETTING_PREFIX . $featureNode->feature->uuid; // must not exceed 45 characters !!!
749

    
750
        $settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
751

    
752

    
753
        $form_feature_list_layout[$subform_id] = array(
754
          '#tree' => TRUE,
755
           '#title' => $featureNode->feature->representation_L10n,
756
          '#collapsible' => FALSE,
757
          '#collapsed' => FALSE,
758
          '#type' => 'fieldset',
759
          '#description' => t('')
760
        );
761

    
762
        $form_feature_list_layout[$subform_id]['enabled'] = array(
763
          '#type' => 'checkbox',
764
           '#title' => t('Enable'),
765
          '#default_value' => $settings['enabled'],
766
          '#description' => t('Enable user defined layout for this feature')
767
        );
768

    
769
        $form_feature_list_layout[$subform_id]['enclosingTag'] = array(
770
          '#type' => 'textfield',
771
           '#title' => t('Enclosing tag'),
772
          '#disabled' => !$settings['enabled'],
773
          '#default_value' => $settings['enclosingTag'],
774
          '#description' => t('Default is: ') . "'<code>" . $systemDefaults['enclosingTag'] . "</code>'"
775
        );
776

    
777
        $form_feature_list_layout[$subform_id]['entryEnclosingTag'] = array(
778
          '#type' => 'textfield',
779
           '#title' => t('Entry enclosing tag'),
780
          '#disabled' => !$settings['enabled'],
781
          '#default_value' => $settings['entryEnclosingTag'],
782
          '#description' => t('Default is: ') . "'<code>". $systemDefaults['entryEnclosingTag'] ."</code>'"
783
        );
784

    
785
        $form_feature_list_layout[$subform_id]['glue'] = array(
786
          '#type' => 'textfield',
787
           '#title' => t('Glue'),
788
          '#disabled' => !$settings['enabled'],
789
          '#default_value' => $settings['glue'],
790
          '#description' => t('Default is: ') . "'<code>" . $systemDefaults['glue'] . "</code>'"
791
        );
792

    
793
      }
794

    
795
      $form['taxon_profile']['feature_list_layout'] = $form_feature_list_layout;
796
    }
797
  }
798

    
799

    
800
  //---- DISTRIBUTION LAYOUT ---- //
801

    
802
  $form['taxon_profile']['distribution_layout'] = array(
803
    '#title' => t('Distribution'),
804
    '#collapsible' => TRUE,
805
    '#collapsed' => FALSE,
806
    '#type' => 'fieldset',
807
    '#description' => t('Select if you want to sort or not the distribution text located below the distribution map.'),
808
  );
809

    
810
  $form['taxon_profile']['distribution_layout']['distribution_sort'] =  array(
811
  '#type'          => 'radios',
812
  '#title'         => t('Sort'),
813
  '#default_value' => variable_get('distribution_sort', 'NO_SORT'),
814
  '#options' => array(
815
      'NO_SORT' => t('Standard (No sort)'),
816
      'HIDE_TDWG2' => t('Sorted without TDWG Level 2'),
817
    ));
818

    
819
   $form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] =  array(
820
  '#type'          => 'checkbox',
821
  '#title'         => t('Show TextData elements on top of the map'),
822
  '#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
823
  '#description' => t('Check this if you want to appear all <code>TextData</code> elements on top of the map.
824
    Otherwise all <code>TextData</code> distribution elements will be listed below the other area elements.
825
    This option is useful if you need to have descriptive texts for each distribution map.'),
826
  );
827

    
828

    
829
/* ====== SYNONYMY ====== */
830
  $form['taxon_synonymy'] = array(
831
      '#type' => 'fieldset',
832
      '#title' => t('Taxon synonymy (tab)'),
833
      '#collapsible' => TRUE,
834
      '#collapsed' => TRUE,
835
      '#description' => t('This section covers the settings related to the taxon <b>synonymy</b> tab.####'),
836
  );
837

    
838
  $form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
839
    '#type' => 'checkbox',
840
    '#title' => t('Show accepted taxon on top of the synonymy'),
841
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
842
    '#description' => t('If checked, the first homotypic taxon is a repetition of the accepted taxon most likely
843
                        with the full nomenclatural reference (depending on the currently chosen theme).')
844
  );
845

    
846
  $form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
847
    '#type' => 'checkbox',
848
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when coming from a synonym link.'),
849
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
850
    '#description' => t('Check this if after doing a search and clicking on a synonym you want to see the "accept of" text for the accepted synonym.')
851
  );
852

    
853
  $nameRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
854
  $form['synonymy']['name_relationships']['name_relationships_to_show'] = array(
855
    '#type' => 'checkboxes',
856
    '#title' => t('Display name relationships'),
857
    '#default_value' => variable_get('name_relationships_to_show', 0),
858
    '#options' => $nameRelationshipTypeOptions,
859
    '#description' => t('Select the name relationships you want to show for the accepted taxa.'),
860
  );
861

    
862

    
863
 $form['synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
864
    '#type' => 'checkbox',
865
    '#title' => t('Show taxon relations ships of accepted taxon'),
866
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
867
    '#description' => t('If this option is enabled the synonymy will show the below selected taxon relationships of accepted taxa.')
868
  );
869

    
870
   $taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE);
871
  $form['synonymy'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
872
      '#type' => 'checkboxes',
873
      '#title' => t('Taxon relationship types'),
874
      '#description' => t('Only taxon relationships of the selected type will be displayed'),
875
      '#options' => $taxonRelationshipTypeOptions,
876
      '#default_value' => variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
877
      '#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)
878
  );
879

    
880
  // ====== SPECIMENS ====== //
881
  $form['taxon_specimens'] = array(
882
      '#type' => 'fieldset',
883
      '#title' => t('Taxon specimens (tab)'),
884
      '#collapsible' => TRUE,
885
      '#collapsed' => TRUE,
886
      '#description' => t('This section covers the settings related to the taxon <b>specimens</b> tab.'),
887
  );
888
  $form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
889
  $form_title = 'Specimen media';
890
  $form_description = 'Specimens may have media which is displayed at the Specimen tab/section as a gallery.
891
   It is possible to configure the thumbnails gallery here, however for configuring how a single media should
892
   be displayed please go to <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a></p>';
893
  $form['taxon_specimens'][] =
894
    cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
895

    
896

    
897
  // --- MEDIA GALLERY ---- //
898
  $form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
899
  $form_title = 'Media gallery (tab)';
900
  $form_description = '<p>This section covers the settings related to the taxon <strong>media</strong> tab.
901
   Taxa may have media (usually images) and they are as thumbnails displayed. It is possible to configure
902
   the thumbnails gallery here, however for configuring how a single media should be displayed please go to
903
   <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a></p>
904
   <p><strong>Note:</strong> These settings are only taken into account when the standard
905
   gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -&gt; Media</a>.</p>';
906
  $form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
907

    
908

    
909
  return system_settings_form($form);
910
}
911

    
912
function cdm_settings_layout_search(){
913

    
914
  $form = array();
915

    
916
  $form['search_settings'] = array(
917
    '#type' => 'fieldset',
918
    '#title' => t('Taxa Search'),
919
    '#collapsible' => TRUE,
920
    '#collapsed' => TRUE,
921
    '#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
922
         the block <em>CDM Taxon Search</em> should be enabled and visible for users
923
         where they can write the text to be searched. You can find Drupal block configuration
924
         site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p> '),
925
  );
926

    
927
  $form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
928
    '#type' => 'textfield',
929
    '#title' => t('Results per page'),
930
    '#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
931
    '#description' => t('Number of results to display per page.')
932
  );
933

    
934
  // --- SEARCH TAXA GALLERY ---- //
935
  $items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
936
  $collapsed = FALSE;
937
  $form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
938
  $form_title = 'Taxa Search thumbnails';
939
  $form_description = 'Search results may show thumbnails. ';
940
  $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
941

    
942
  return system_settings_form($form);
943
}
944

    
945
function cdm_settings_layout_media(){
946

    
947
  $form = array();
948

    
949
  $form['media_settings'] = array(
950
      '#type' => 'fieldset',
951
      '#title' => t('Media display settings'),
952
      '#collapsible' => TRUE,
953
      '#collapsed' => FALSE,
954
    '#description' => t('This section covers the settings related to the taxa media, that is how each single media should be displayed.'),
955
      );
956

    
957
  $form['media_settings']['image_gallery_viewer'] =  array(
958
    '#type'          => 'select',
959
    '#title'         => t('Image viewer'),
960
    '#default_value' => variable_get('image_gallery_viewer', 'default'),
961
    '#options' => array('default' => t('Standard image viewer'),
962
                        'fsi' => t('FSI viewer (requires FSI server!)')),
963
  );
964

    
965
  // --- MEDIA GALLERY ---- //
966
  $form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
967
  $form_title = 'Standard viewer';
968
  $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>';
969
  //$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
970
  $form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
971

    
972

    
973
  return system_settings_form($form);
974
}
975

    
976

    
977
/**
978
 * GEOSERVICE and Map settings
979
 * @return unknown_type
980
 */
981
function cdm_settings_geo(){
982

    
983
  $form = array();
984

    
985
  /*
986
   * GEO SERVER
987
   */
988

    
989
  $form['geoserver'] = array(
990
    '#type' => 'fieldset',
991
    '#title' => t('Geo Server Settings'),
992
    '#collapsible' => TRUE,
993
    '#collapsed' => TRUE,
994
    '#description' => t('Configuration and selection of your geo server. The Geo Server is the responsible for generating the maps.'),
995
  );
996

    
997
  $form['geoserver']['edit_map_server'] = array(
998
    '#type' => 'select',
999
    '#title' => t('Geoservice access point URL'),
1000
    '#default_value' => variable_get('edit_map_server', EDIT_MAPSERVER_V1_URI),
1001
    '#options' => array(
1002
        EDIT_MAPSERVER_V1_URI => 'EDIT Map Server v1',
1003
        EDIT_MAPSERVER_V11_URI => 'EDIT Map Server v1.1',
1004
        /*
1005
        'http://edit.br.fgov.be/edit_wp5/v1/' => 'EDIT Map Server - Mirror 1',
1006
        'http://edit.br.fgov.be/edit_wp5/v1/' => 'EDIT Map Server - Mirror 2',
1007
         */
1008
        'ALTERNATIVE' => '-- Alternative URL --'
1009
        ),
1010
    '#description' => t('Select the Map Server you want the data portal to connect.'
1011
         . 'If you want to introduce a custom address just select the Alternative URL value and fill the field Geoservice'
1012
         . 'Access Point - Alternative URL with the custem ip address.')
1013
    );
1014

    
1015
    $form['geoserver']['edit_map_server_alternative'] = array(
1016
      '#type' => 'textfield',
1017
      '#title' => t('Geoservice access point - alternative URL'),
1018
      '#default_value' => variable_get('edit_map_server_alternative', ''),
1019
      '#description' => t('Alternative URL of a EDIT Map Service to be used by this portal. You must choose the option <i>-- Alternative URL --</i> in the chooser abofe to enable this url.')
1020
    );
1021

    
1022

    
1023
  /*
1024
   *  MAP SETTINGS
1025
   */
1026

    
1027
    $form['map_settings'] = array(
1028
      '#type' => 'fieldset',
1029
      '#title' => t('Maps settings'),
1030
      '#collapsible' => TRUE,
1031
      '#collapsed' => TRUE,
1032
      '#description' => t('Configuration of the renderized maps.'),
1033
     );
1034

    
1035
    $form['map_settings']['cdm_dataportal_geoservice_display_width'] = array(
1036
      '#type' => 'textfield',
1037
      '#title' => t('Maps size'),
1038
      '#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
1039
      '#description' => t('Choose the size of your Maps. A value of 500 means the size will be 500x500, a value of 300 means the size will be 300x300.')
1040
    );
1041

    
1042
    $form['map_settings']['cdm_dataportal_geoservice_bounding_box'] = array(
1043
      '#type' => 'textfield',
1044
      '#title' => t('Fixed bounding box'),
1045
      '#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
1046
      '#description' => t('Define surrounding of area to be displayed in maps. Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong> to let the map <strong>automatically zoom</strong> to the distribution area.')
1047
    );
1048

    
1049
    $form['map_settings']['cdm_dataportal_geoservice_labels_on'] = array(
1050
      '#type' => 'checkbox',
1051
      '#title' => '<b>'.t('Display area labels').'</b>',
1052
      '#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
1053
      '#description' => t('Check this if you like area names to be displayed in the maps. DOES IT WORKS???? ')
1054
    );
1055

    
1056
    $form['map_settings']['cdm_dataportal_geoservice_map_caption'] = array(
1057
      '#type' => 'textfield',
1058
      '#title' => t('Map caption'),
1059
      '#default_value' => variable_get('cdm_dataportal_geoservice_map_caption', ''),
1060
      '#description' => t('Define a caption for the map.')
1061
    );
1062

    
1063
    $form['map_settings']['cdm_dataportal_geoservice_distributionOpacity'] = array(
1064
      '#type' => 'textfield',
1065
      '#title' => t('Distribution layer opacity'),
1066
      '#default_value' => variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5'),
1067
      '#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions (the countries or regions) will
1068
                           fully visible, while a value near to 0.0 will be not much visible.')
1069
    );
1070

    
1071
    $form['map_settings']['cdm_dataportal_map_openlayers'] = array(
1072
      '#type' => 'radios',
1073
      '#title' => '<b>'.t('Map Viewer').'</b>',
1074
      '#options' => array(1 => "OpenLayers dynamic mapviewer", 0 => "Plain image" ),
1075
      '#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
1076
      '#description' => t('You can choose from two different map viewers:<ul><li><em>OpenLayers</em> displays the maps in an interactive viewer which allows zooming and panning. If not enabled the maps will consist
1077
                           on a static image. If enabled you can configure the default layer (background of your maps) below. Only one of
1078
                           them will be renderized.</li><li><em>Plain image</em> displays the map as a plain non interactive image</li></ul>')
1079
    );
1080

    
1081
    $openLayersEnabled = variable_get('cdm_dataportal_map_openlayers', 1) === 1;
1082

    
1083

    
1084
    // --- Plain Image Settings --- //
1085

    
1086
    $form['map_image'] = array(
1087
      '#type' => 'fieldset',
1088
      '#title' => t('Plain image map settings'),
1089
      '#collapsible' => TRUE,
1090
      '#collapsed' => $openLayersEnabled,
1091
      '#description' => 'The settings in this section are still expertimental '
1092
        .'and can onyl be used with the EDIT map service version 1.1 or above.'
1093
    );
1094

    
1095
    $edit_mapserver_version = getEDITMapServiceVersionNumber();
1096
    if ($edit_mapserver_version < 1.1) {
1097
      $form['map_image']['#description'] = '<div class="messages warning">' . t("The selected EDIT map service version has to small version number: $edit_mapserver_version") . '</div>'
1098
      . $form['map_image']['#description'];
1099
    }
1100

    
1101
    $form['map_image']['map_base_layer'] = array(
1102
      '#type' => 'textfield',
1103
      '#title' => t('Background layer'),
1104
      '#default_value' => variable_get('map_base_layer', 'cyprusdivs'),
1105
      '#description' => t('Background layer. for available layers inspect')
1106
        . l(" deegree-csw ",  "http://edit2.br.fgov.be:8080/deegree-csw/md_search.jsp") . t('or')
1107
        . l(" geoserver layers ", "http://edit.br.fgov.be:8080/geoserver/rest/layers")
1108
    );
1109

    
1110
    $form['map_image']['map_bg_color'] = array(
1111
      '#type' => 'textfield',
1112
      '#title' => t('Background color'),
1113
      '#default_value' => variable_get('map_bg_color', '1874CD')
1114
    );
1115

    
1116
    $form['map_image']['map_base_layer_style'] = array(
1117
      '#type' => 'textfield',
1118
      '#title' => t('Background layer area style'),
1119
      '#default_value' => variable_get('map_base_layer_style', 'ffffff,606060,,'), // only line color by now
1120
      '#description' => t('Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}')
1121
    );
1122

    
1123

    
1124
    // --- OpenLayers Settings --- //
1125

    
1126
    $form['openlayers'] = array(
1127
      '#type' => 'fieldset',
1128
      '#title' => t('OpenLayers settings'),
1129
      '#collapsible' => TRUE,
1130
      '#collapsed' => !$openLayersEnabled,
1131
      '#description' => ''
1132
    );
1133

    
1134
    if( !$openLayersEnabled ){
1135
      $form['openlayers']['#description'] = '<div class="messages warning">' . t("The Openlayers viewer is curretnly not enabled! (see section Maps settings above )") . '</div>'
1136
      . $form['openlayers']['#description'];
1137
    }
1138

    
1139
    $baselayer_options = array(
1140
      /*
1141
       * NOTICE: must correspond to the layers defined in js/openlayers_,ap.js#getLayersByName()
1142
       */
1143
      'osgeo_vmap0' => "OpenLayers World", // EPSG:4326
1144
      'metacarta_vmap0' => "Metacarta Vmap0" , // EPSG:4326, EPSG:900913
1145
       // all others EPSG:900913
1146
      'edit-vmap0_world_basic' => 'EDIT Vmap0',
1147
      'edit-etopo1' => "ETOPO1 Global Relief Model",
1148
      'osmarender' => 'OpenStreetMap',
1149
      //'oam' => 'OpenAerialMap', // currently unavailable
1150
      'gmap' => 'Google Streets',
1151
      'gsat' => 'Google Satellite',
1152
      'ghyb' => 'Google Hybrid',
1153
      'veroad' => 'Virtual Earth Roads',
1154
      'veaer' => 'Virtual Earth Aerial',
1155
      'vehyb' => 'Virtual Earth Hybrid'
1156
       //  ,
1157
       //    'yahoo' => 'Yahoo Street',
1158
       //    'yahoosat' => 'Yahoo Satellite',
1159
       //    'yahoohyb' => 'Yahoo Hybrid'
1160
    );
1161

    
1162
    $form['openlayers']['baselayers'] = array(
1163
      '#type' => 'checkboxes_preferred',
1164
      '#title' => t('Baser Layers'),
1165
      '#options' => $baselayer_options,
1166
      '#default_value' => variable_get('baselayers', array('metacarta_vmap0' => "metacarta_vmap0", 'PREFERRED' => 'metacarta_vmap0')),
1167
      '#description' => t('Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.')
1168
     );
1169

    
1170
  // cdm_dataportal_geoservice_showLayerSwitcher
1171
  $form['openlayers']['cdm_dataportal_geoservice_showLayerSwitcher'] = array(
1172
    '#type' => 'checkbox',
1173
    '#title' => '<b>'.t('Show Layer Switcher').'</b>',
1174
    '#default_value' => variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE),
1175
    '#description' => t('The Layer Switcher control displays a table of contents for the map.  This allows the user interface to switch between BaseLasyers and to show or hide Overlays.  By default the switcher is shown minimized on the right edge of the map, the user may expand it by clicking on the handle.')
1176
  );
1177

    
1178
  $localhostkey = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
1179
  $gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
1180
  $form['openlayers']['gmap_api_key'] = array(
1181
    '#type' => 'textfield',
1182
    '#title' => t('Gogle maps API key'),
1183
    '#default_value' => variable_get('gmap_api_key', $gmap_api_key),
1184
    '#description' => t('If you want to use the Google Maps Layer a key is needed. If you need a key visit <a href="http://code.google.com/intl/en/apis/maps/signup.html">google maps api key</a>.<br>
1185
         <b>Note:</b> The following key: <code>'.$localhostkey.'</code> is the default key for the localhost (127.0.0.1). The key in use is the one above this text.')
1186
   );
1187

    
1188
  $form['cdm_dataportal_geoservice_map_legend'] = array(
1189
     '#type' => 'fieldset',
1190
     '#title' => t('Map legend'),
1191
     '#collapsible' => TRUE,
1192
     '#collapsed' => TRUE,
1193
     '#description' => t('Configure the maps legend.')
1194
  );
1195

    
1196
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_on'] = array(
1197
    '#type' => 'checkbox',
1198
    '#title' => '<b>'.t('Display a map legend').'</b>',
1199
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
1200
    '#description' => t('Check this if you like a legend to be displayed with the maps.')
1201
  );
1202

    
1203
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legendOpacity'] = array(
1204
    '#type' => 'textfield',
1205
    '#title' => t('Legend opacity'),
1206
    '#default_value' => variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5'),
1207
    '#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the legend will be fully visible, while a value near
1208
                         to 0.0 will be not much visible.')
1209
  );
1210

    
1211
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_size'] = array(
1212
    '#type' => 'textfield',
1213
    '#title' => t('Font size'),
1214
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_size', 10),
1215
    '#description' => t('Font size in pixels.')
1216
  );
1217

    
1218
  $fontStyles = array(0 => "plane", 1 => "italic");
1219
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_style'] = array(
1220
    '#type' => 'select',
1221
    '#title' => t('Available font styles'),
1222
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_style', false),
1223
    '#options' => $fontStyles,
1224
    '#description'   => t('Select a font style for the map legend.')
1225
  );
1226

    
1227
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_width'] = array(
1228
    '#type' => 'textfield',
1229
    '#title' => t('Legend icon width'),
1230
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_width', 35),
1231
    '#description' => t('Legend icon width in pixels.')
1232
  );
1233
  $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_height'] = array(
1234
    '#type' => 'textfield',
1235
    '#title' => t('Legend icon height'),
1236
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_height', 15),
1237
    '#description' => t('Legend icon height in pixels.')
1238
  );
1239

    
1240
        return system_settings_form($form);
1241
}
1242

    
1243

    
1244
function cdm_settings_cache(){
1245

    
1246
  $form = array();
1247

    
1248
  $form['cache_settings'] = array(
1249
      '#type' => 'fieldset',
1250
      '#title' => t('Cache Settings'),
1251
      '#collapsible' => FALSE,
1252
      '#collapsed' => FALSE,
1253
    '#description' => t('<p>When caching is enabled all single taxon sites are stored in an internal drupal cache doing
1254
                           the portal response of taxa pages faster. This is possible because the sites are loaded from
1255
                           the cache and are not created from scratch.</p>'),
1256
      );
1257

    
1258
  $form['cache_settings']['cdm_webservice_cache'] =  array(
1259
    '#type'          => 'checkbox',
1260
    '#title'         => t('<strong>Enable caching</strong>'),
1261
  '#options'     => cdm_help_general_cache(),
1262
    '#default_value' => variable_get('cdm_webservice_cache', 1),
1263
    '#description'   => t('<p>Enable drupal to load taxa pages from the cache.</p>' .
1264
                         '<p><strong>Note:</strong> If taxa are modified by the editor or any other application the changes will be not
1265
                         visible till the cache is erased. Therefore developers should deactived this feature when they
1266
                         are working on the CDM Dataportal Module.</p>')
1267
    );
1268

    
1269
  $form['cache_settings']['cdm_run_cache'] = array(
1270
    '#value' => cdm_view_cache_site()
1271
  );
1272

    
1273
  return system_settings_form($form);
1274
}
1275

    
1276
/**
1277
 * @return walk and cache all taxon pages
1278
 */
1279
function cdm_view_cache_site(){
1280

    
1281
  $out = '';
1282

    
1283
  _add_js_progressbar();
1284
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cache_all_taxa.js');
1285

    
1286
  $request_params = array();
1287
  $request_params['query'] = '%';
1288
  $request_params['tree'] = variable_get('cdm_taxonomictree_uuid', false); //cache only the dafault classification
1289
  $request_params['doTaxa'] = 1;
1290
  $request_params['doSynonyms'] = 0;
1291
  $request_params['doTaxaByCommonNames'] = 0;
1292

    
1293
  $search_url = cdm_compose_url(CDM_WS_PORTAL_TAXON_FIND . ".json", null, queryString($request_params));
1294
  $search_url = uri_uriByProxy($search_url);
1295
  $taxon_page_url = url('cdm_dataportal/taxon/');
1296

    
1297

    
1298
  $out .= t('<p><strong>Cache all taxon pages</strong></p>');
1299
  $out .= '<p>When you lunch the cache process the cache is filled and ready to be enabled.<br/>
1300
  Remember that when you load the taxa from the cache last changes on taxa will be not visible till you erase
1301
  the cache and fill it again.</p>';
1302
  $out .= '<p>Before  running the cache bot you have to empty the cache manually</p>';
1303

    
1304
  $out .= '<form id="cache_site">';
1305
  $out .= '<div>'.t('This caching process may take long time and could cause heavy load on your server').'</div>';
1306
  $out .= '<div id="progress"></div>';
1307
  $out .= '<input type="hidden" name="searchTaxaUrl" value="'.$search_url.'"/>';
1308
  $out .= '<input type="hidden" name="taxonPageUrl" value="'.$taxon_page_url.'"/>';
1309
  $out .= '<input type="button" name="start" value="'.t('Start').'"/>';
1310
  $out .= '<input type="button" name="stop" value="'.t('Stop').'"/>';
1311
  $out .= '</form>';
1312
  $out .= '</div>';
1313
  //  foreach($taxonPager->records as $taxon){
1314
  //    cdm_dataportal_taxon_view($uuid);
1315
  //  }
1316

    
1317
  return $out;
1318
}
1319

    
1320

    
1321
/**
1322
 * Implementation of hook_validate()
1323
 *
1324
 * @param $element
1325
 */
1326
function cdm_settings_validate($form_id, $form_values){
1327

    
1328
  if (!str_endsWith($form_values['cdm_webservice_url'], '/')) {
1329
    //form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
1330
    $form_values['cdm_webservice_url'] .= '/';
1331
  }
1332

    
1333
  if($form_values['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)){
1334
    cache_clear_all(NULL, 'cache_cdm_ws');
1335
    // better clear secref_cache since i can not be sure if the cache has not be used during this response
1336
    cdm_api_secref_cache_clear();
1337
  }
1338

    
1339
}
1340

    
1341
function getEDITMapServiceURI(){
1342

    
1343
  if(variable_get('edit_map_server', false) == 'ALTERNATIVE'){
1344
    return (variable_get('edit_map_server_alternative', false));
1345
  } else if(variable_get('edit_map_server', false)) {
1346
    return variable_get('edit_map_server', false);
1347
  } else {
1348
    return EDIT_MAPSERVER_V1_URI;
1349
  }
1350

    
1351
}
1352

    
1353
/**
1354
 *
1355
 * @return float the version number of the currently selected edit mapserver as a float. Returns 0 on error
1356
 */
1357
function getEDITMapServiceVersionNumber() {
1358

    
1359
      $pattern = '/v(\d+\.\d+)/';
1360

    
1361
      $url = getEDITMapServiceURI();
1362
      preg_match($pattern, $url, $matches, PREG_OFFSET_CAPTURE, 3);
1363
      if( isset($matches[1]) ){
1364
        $version = 1 + $matches[1][0] -1; // convert string to float
1365
        return $version;
1366
      } else {
1367
        // report error
1368
        drupal_set_message(" Invalid version number in EDIT map service URL: '" + variable_get('edit_map_server', EDIT_MAPSERVER_V1_URI) + "'", "waring");
1369
        return 0;
1370
      }
1371
}
1372

    
1373
/**
1374
 * Implementation of hook_elements()
1375
 *
1376
 * see http://drupal.org/node/37862 for an example
1377
 */
1378
function cdm_dataportal_elements() {
1379
  $type['checkboxes_preferred'] = array(
1380
    '#input' => TRUE,
1381
    '#process' => array('expand_checkboxes_preferred' => array()),
1382
    '#after_build' => array('checkboxes_preferred_after_build')
1383
  );
1384
  return $type;
1385
}
1386

    
1387
/**
1388
 * #process function for the custom form element type 'checkbox_preferred'
1389
 */
1390
function expand_checkboxes_preferred($element){
1391

    
1392
  // first of all create the checkboxes
1393
  $element = expand_checkboxes($element);
1394

    
1395
  $children = element_children($element);
1396
  $element['table_start'] = array(
1397
    '#value' => '<table class="checkboxes_preferred"><tr><th></th><th>'.t('Enabled').'</th><th>'.t('Default').'</th></tr>',
1398
    '#weight'=>-1
1399
  );
1400
  $weight = 0;
1401
  foreach ($children as $key) {
1402
    $odd_even = $weight % 4 == 0 ? 'odd' : 'even';
1403
    $element[$key]['#weight'] = $weight;
1404
    $element[$key]['#prefix'] = '<tr class="'.$odd_even.'"><td>'.t($element['#options'][$key]).'</td><td>';
1405
    $element[$key]['#suffix'] = '</td>';
1406
    unset($element[$key]['#title']);
1407
    $weight += 2;
1408
  }
1409
  $weight = 0;
1410

    
1411
  if (count($element['#options']) > 0) {
1412
    foreach ($element['#options'] as $key => $choice) {
1413
      if (!isset($element[$key.'_preferred'])) {
1414
        $element[$key.'_preferred'] = array(
1415
        '#type' => 'radio',
1416
        '#name' => $element['#parents'][0].'_preferred',
1417
        '#return_value' => check_plain($key),
1418
        '#default_value' => $element['#default_value_2'],
1419
        '#attributes' => $element['#attributes'],
1420
        '#parents' => $element['#parents'],
1421
        '#spawned' => TRUE,
1422
        '#weight' => $weight + 1,
1423
        '#prefix' => '<td>',
1424
        '#suffix' => '</td></tr>',
1425
        //'#submit' => 'submit_checkboxes_preferred'
1426
        );
1427
      }
1428
      $weight += 2;
1429
    }
1430
  }
1431

    
1432
  $element['table_end'] = array(
1433
  //'#type'=>'value',
1434
  '#value' => '</table>', '#weight'=>$weight++);
1435
  return $element;
1436
}
1437

    
1438

    
1439
function theme_checkboxes_preferred($element){
1440
  return theme('form_element',
1441
  array(
1442
      '#title' => $element['#title'],
1443
      '#description' => $element['#description'],
1444
      '#id' => $element['#id'],
1445
      '#required' => $element['#required'],
1446
      '#error' => $element['#error'],
1447
  ),
1448
  $element['#children']);
1449
}
1450

    
1451
function checkboxes_preferred_after_build($form, &$form_values){
1452

    
1453
  $parent_id = $form['#parents'][0];
1454

    
1455
  if($_POST && count($_POST) > 0){
1456
    // first pass of form processing
1457
    $preferred_layer = $_POST[$parent_id.'_preferred'];
1458
    $form['#value']['PREFERRED'] = $preferred_layer;
1459
    $form_values[$parent_id] = $form['#value'];
1460
  } else {
1461
    // second pass of form processing
1462
    $preferred_layer = $form['#value']['PREFERRED'];
1463
  }
1464

    
1465
  // also set the chosen value (not sure if this is good drupal style ....)
1466
  foreach( $children = element_children($form) as $key ){
1467
    if($form[$key]['#type'] == 'radio'){
1468
      $form[$key]['#value'] = $preferred_layer;
1469
    }
1470
  }
1471
  // the default layer mus always be enabled
1472
  $form[$preferred_layer]['#value'] = $preferred_layer;
1473

    
1474

    
1475
  return $form;
1476
}
1477

    
(12-12/12)