Project

General

Profile

Download (53.4 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
/* gallery variables */
14
$gallery_settings = array(
15
    "cdm_dataportal_show_taxon_thumbnails" => 1,
16
    "cdm_dataportal_show_synonym_thumbnails" => 0,
17
    "cdm_dataportal_show_thumbnail_captions" => 1,
18
    "cdm_dataportal_media_maxextend" => 120,
19
    "cdm_dataportal_media_cols" => 3,
20
    "cdm_dataportal_media_maxRows" => 1);
21

    
22

    
23
$taxon_tab_options = array(
24
  0 => 'General',
25
  1 => 'Synonymy',
26
  2 => 'Images',
27
  3 => 'Specimens',
28
  CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX => 'Last visited tab',
29
);
30

    
31
define('EDIT_MAPSERVER_URI', 'http://edit.br.fgov.be/edit_wp5/v1/');
32

    
33
/**
34
 * default settings for all gallerys
35
 * @var unknown_type
36
 */
37
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
38
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
39
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
40
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
41
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
42
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
43
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
44
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
45
//define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
46
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
47
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
48
define('CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
49
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
50

    
51
function getGallerySettings($gallery_config_form_name){
52
	$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
53
	return variable_get($gallery_config_form_name, $default_values);
54
}
55

    
56
function get_default_taxon_tab($index = false) {
57

    
58
	global $user;
59
	$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
60
	$user_tab_active = 'cdm_dataportal_' .$user->uid . '_default_tab_active';
61
	$user_tab = 'cdm_dataportal_' .$user->uid . '_default_tab';
62
	//get the user value
63
	$user_tab_on = variable_get($user_tab_active, false);
64
	if($user_tab_on){
65
		$user_value = variable_get($user_tab, 0);
66
		$index_value = $user_value;
67
	//get the system value
68
	}else{
69
		$system_value = variable_get('cdm_dataportal_default_tab', 0);
70
		$index_value = $system_value;
71
	}
72
	if (!index){
73
	   return ($values[$index_value]);
74
	}else{
75
	   return $index_value;
76
	}
77
	
78

    
79
	switch ($value){
80
		case 0:
81
			$res = 'General';
82
			break;
83
		case 1:
84
			$res = 'Synonymy';
85
			break;
86
		case 2:
87
			$res = 'Images';
88
			break;
89
		case 3:
90
			$res = 'Specimens';
91
			break;
92
		case 4:
93
			$res = 'last_visited_tab';
94
			break;
95
		default:
96
			$res = 'General';
97
	}
98
	return $res;
99
}
100

    
101
function cdm_dataportal_menu_admin($may_cache, &$items){
102

    
103
	if (!$may_cache) {
104

    
105
		$items[] = array(
106
      'path' => 'admin/settings/cdm_dataportal',
107
      'title' => t('CDM Dataportal'),
108
      'description' => t('Setting for the CDM DataPortal'),
109
      'access' => user_access('administer cdm_dataportal'),
110
      'callback' => 'drupal_get_form',
111
      'callback arguments' => 'cdm_settings_general',
112
      'type' => MENU_NORMAL_ITEM,
113
		);
114

    
115
		$items[] = array(
116
      'path' => 'admin/settings/cdm_dataportal/general',
117
      'title' => t('General'),
118
      'description' => t('Setting for the CDM DataPortal'),
119
      'access' => user_access('administer cdm_dataportal'),
120
      'callback' => 'drupal_get_form',
121
      'callback arguments' => 'cdm_settings_general',
122
      'weight' => 0,
123
      'type' => MENU_LOCAL_TASK,
124
		);
125

    
126
		$items[] = array(
127
      'path' => 'admin/settings/cdm_dataportal/cachesite',
128
      'title' => t('Cache'),
129
      'description' => t('Cache'),
130
      'access' => user_access('administer cdm_dataportal'),
131
      'callback' => 'drupal_get_form',
132
      'callback arguments' => 'cdm_settings_cache',
133
      'weight' => 10,
134
      'type' => MENU_LOCAL_TASK,
135
		);
136

    
137
		$items[] = array(
138
      'path' => 'admin/settings/cdm_dataportal/geo',
139
      'title' => t('Geo & Map'),
140
      'description' => t('Geo & Map'),
141
      'access' => user_access('administer cdm_dataportal'),
142
      'callback' => 'drupal_get_form',
143
      'callback arguments' => 'cdm_settings_geo',
144
      'weight' => 1,
145
      'type' => MENU_LOCAL_TASK,
146
		);
147

    
148
		$items[] = array(
149
      'path' => 'admin/settings/cdm_dataportal/layout',
150
      'title' => t('Layout'),
151
      'description' => t('Configure and adjust the layout of your DataPortal '),
152
      'access' => user_access('administer cdm_dataportal'),
153
      'callback' => 'drupal_get_form',
154
      'callback arguments' => 'cdm_settings_layout',
155
      'weight' => 2,
156
      'type' => MENU_LOCAL_TASK,
157
		);
158

    
159
		$items[] = array(
160
      'path' => 'admin/settings/cdm_dataportal/layout/taxon',
161
      'title' => t('Taxon'),
162
      'description' => t('Configure and adjust the layout of your DataPortal '),
163
      'access' => user_access('administer cdm_dataportal'),
164
      'callback' => 'drupal_get_form',
165
      'callback arguments' => 'cdm_settings_layout_taxon',
166
      'weight' => 1,
167
      'type' => MENU_LOCAL_TASK,
168
		);
169
/*
170
		$items[] = array(
171
      'path' => 'admin/settings/cdm_dataportal/layout/synonymy',
172
      'title' => t('Synonymy'),
173
      'description' => t('Configure and adjust the layout of your DataPortal '),
174
      'access' => user_access('administer cdm_dataportal'),
175
      'callback' => 'drupal_get_form',
176
      'callback arguments' => 'cdm_settings_layout_synonymy',
177
      'weight' => 1,
178
      'type' => MENU_LOCAL_TASK,
179
		);
180

    
181
		$items[] = array(
182
      'path' => 'admin/settings/cdm_dataportal/layout/specimens',
183
      'title' => t('Specimens'),
184
      'description' => t('Configure and adjust the layout of your DataPortal '),
185
      'access' => user_access('administer cdm_dataportal'),
186
      'callback' => 'drupal_get_form',
187
      'callback arguments' => 'cdm_settings_layout_specimens',
188
      'weight' => 1,
189
      'type' => MENU_LOCAL_TASK,
190
		);
191
*/
192
		$items[] = array(
193
      'path' => 'admin/settings/cdm_dataportal/layout/search',
194
      'title' => t('Search'),
195
      'description' => t('Configure and adjust the layout of your DataPortal '),
196
      'access' => user_access('administer cdm_dataportal'),
197
      'callback' => 'drupal_get_form',
198
      'callback arguments' => 'cdm_settings_layout_search',
199
      'weight' => 2,
200
      'type' => MENU_LOCAL_TASK,
201
		);
202

    
203
		$items[] = array(
204
      'path' => 'admin/settings/cdm_dataportal/layout/media',
205
      'title' => t('Media'),
206
      'description' => t('Configure and adjust the layout of your DataPortal '),
207
      'access' => user_access('administer cdm_dataportal'),
208
      'callback' => 'drupal_get_form',
209
      'callback arguments' => 'cdm_settings_layout_media',
210
      'weight' => 3,
211
      'type' => MENU_LOCAL_TASK,
212
		);
213

    
214
	}
215

    
216

    
217
}
218

    
219
function cdm_help_general_cache(){
220
  $form = array();
221
  $form['cache_help'] = array(
222
  	'#type' => 'fieldset',
223
 	'#title' => t('Help'),
224
	'#collapsible' => TRUE,
225
	'#collapsed' => TRUE,
226
  );
227
  $form['cache_help']['test'] = array('#value' => t('probando'));
228
  return drupal_render($form);
229
  $res = array();
230
  $res['default'] = drupal_render($help);
231
  return $res;
232
}
233

    
234
/**
235
 * Configures the settings form for the CDM-API module.
236
 *
237
 * @return Array Drupal settings form
238
 */
239
function cdm_settings_general(){
240

    
241
	$form['cdm_webservice'] = array(
242
      '#type' => 'fieldset',
243
      '#title' => t('CDM Server'),
244
      '#collapsible' => FALSE,
245
      '#collapsed' => FALSE,
246
	  '#description' => t('<em>CDM Server</em> makes possible the dialogue with
247
	                       <em>CDM Data Portal</em> thanks to his web services.'),
248
	);
249

    
250
	$form['cdm_webservice']['cdm_webservice_url'] =  array(
251
    '#type' => 'textfield',
252
    '#title'         => t('CDM web service URL'),
253
    '#description'   => t('This is the ip address of the location of the CDM Web Server which contains
254
                           your collection database. The address must follow the format <em>"http://X:Y/Z"</em>
255
                           where "<em>X</em>" is the ip address of the machine where the server is running, "<em>Y</em>" is
256
                           the port number where the server is listening and "<em>Z</em>" the name of the database
257
                           where your collection is, e.g. <em>"http://160.45.63.201:8080/palmae"</em>'),
258
    '#default_value' => variable_get('cdm_webservice_url', NULL),
259
	);
260

    
261
	/** MOVED TO DATAPORTAL
262
	$form['cdm_webservice']['taxontree_ranklimit'] =  array(
263
    '#type'          => 'select',
264
    '#title'         => t('Rank of highest displayed taxon'),
265
    '#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT), //before DEFAULT_TAXONTREE_RANKLIMIT_UUID
266
    '#options'       => cdm_rankVocabulary_as_option(),
267
    '#description'   => t('The rank of the highest displayed taxon in the <em>taxontree</em>. When you explore
268
                           your collection, you can navigate it through a tree structure (<em>taxontree</em>). You can
269
                           select here which rank should be at the top level of the tree structure.'),
270
	);
271
	*/
272
/*
273
	$form['cdm_webservice']['cdm_webservice_cache'] =  array(
274
    '#type' => 'checkbox',
275
    '#title'         => t('<b>Enable caching</b>'),
276
	'#options'		 => cdm_help_general_cache(),
277
    '#default_value' => variable_get('cdm_webservice_cache', 1),
278
    '#description'   => t('When caching is enabled all single taxon sites are stored in an internal drupal cache doing
279
                           the portal response of taxa sites faster. This is possible because the sites are loaded from
280
                           the cache and are not created from scratch.
281
                           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>' .
282
	                       '<b>Note:</b> If taxa are modified by the editor or any other application the changes will be not
283
	                       visible till the cache is erased. Therefore developers should deactived this feature when they
284
	                       are working on the CDM Dataportal Module')
285
    );
286
*/
287
    $form['cdm_webservice']['cdm_webservice_debug'] =  array(
288
    '#type' => 'checkbox',
289
    '#title'         => t('<b>Debug CDM Web Service</b>'),
290
    '#default_value' => variable_get('cdm_webservice_debug', 1),
291
    '#description'   => t('When enabled is possible to see which web services from CDM Server have been called and its
292
                           results. A black box will appear at the top of the web site with the information.<br>' .
293
                          '<b>Note:</b> this is meanly a feature for developers.')
294
    );
295

    
296
    $form['cdm_webservice']['proxy'] = array(
297
      '#type' => 'fieldset',
298
      '#title' => t('Proxy'),
299
      '#collapsible' => TRUE,
300
      '#collapsed' => TRUE
301
    );
302

    
303
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] =  array(
304
    '#type' => 'textfield',
305
    '#title'         => t('Proxy URL'),
306
    '#description'   => t('If this proxy url is set the cdm api tries
307
    to connect the web service over the given proxy server.
308
    Otherwise proxy usage is deactivated.'),
309
    '#default_value' => variable_get('cdm_webservice_proxy_url', false),
310
    );
311

    
312
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] =  array(
313
    '#type' => 'textfield',
314
    '#title'         => t('Proxy port'),
315
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
316
    );
317

    
318
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] =  array(
319
    '#type' => 'textfield',
320
    '#title'         => t('Login'),
321
    '#default_value' => variable_get('cdm_webservice_proxy_usr', false),
322
    );
323

    
324
    $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] =  array(
325
    '#type' => 'textfield',
326
    '#title'         => t('Password'),
327
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', false),
328
    );
329

    
330
    //TODO: settings are still incomplete, compare with trunk/dataportal/inc/config_default.php.inc
331
    $form['cdm_dataportal'] = array(
332
      '#type' => 'fieldset',
333
      '#title' => t('Taxon Tree'),
334
      '#collapsible' => FALSE,
335
      '#collapsed' => TRUE,
336
      '#description' => t('<p>When you explore your collection, you can navigate it through a
337
                           tree structure also called <em>Taxon Tree</em>.</p><p>To be able to navigate through
338
                           your collection the
339
                           <a href="http://drupal.org/handbook/blocks">drupal block</a>
340
                           <em>CDM Taxon Tree</em> should be visible for users. Enable the block at
341
                           <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p>'),
342
    );
343

    
344
    $form['cdm_dataportal'][CDM_TAXONOMICTREE_UUID] = array(
345
      '#type' => 'select',
346
      '#title'         => t('Available classifications'),
347
      '#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, false),
348
      '#options' => cdm_get_taxontrees_as_options(),
349
      '#description'   => t('Select the default taxa classification for your <em>taxon tree</em>,
350
                             the other classifications will be also available but with a manual user change.')
351
    );
352

    
353
    $form['cdm_dataportal']['taxontree_ranklimit'] =  array(
354
    '#type'          => 'select',
355
    '#title'         => t('Rank of highest displayed taxon'),
356
    '#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT), //before DEFAULT_TAXONTREE_RANKLIMIT_UUID
357
    '#options'       => cdm_rankVocabulary_as_option(),
358
    '#description'   => t('This is the rank of the highest displayed taxon in the <em>taxon tree</em>. You can
359
                           select here which rank should be at the top level of the tree structure.'),
360
	);
361

    
362
    return system_settings_form($form);
363
}
364

    
365
function gen_layout_form_submit ($form, $form_values) {
366
	drupal_set_message('This is a test!');
367
}
368

    
369

    
370
/**
371
 * LAYOUT settings
372
 * @return unknown_type
373
 */
374
function cdm_settings_layout(){
375

    
376
	//drupal_goto('admin/settings/cdm_dataportal/layout/taxon');
377
	$form = array();
378
/*
379
	// -- tabbed pages -- //
380
	$form['cdm_dataportal_taxonpage_tabs'] = array(
381
    '#type' => 'checkbox',
382
    '#title' => t('Tabbed taxon page'),
383
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
384
    '#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.')
385
	);
386
*/
387
	$form['gen_layout'] = array(
388
		'#type' => 'fieldset',
389
	    '#title' => t('Portal Layout'),
390
        '#collapsible' => FALSE,
391
        '#collapsed' => FALSE,
392
	    '#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.'),
393
	);
394
	
395
	//---- footnotes ---//
396
	$form['gen_layout']['footnotes'] = array(
397
      '#type' => 'fieldset',
398
      '#title' => t('Footnotes'),
399
      '#collapsible' => FALSE,
400
      '#collapsed' => FALSE,
401
	  '#description' => t('Taxa data such authors, synonyms names, descriptions, media or distribution areas may have annotations or footnotes. When the footnotes are enabled
402
	                       they will be visible (if they exist).'),
403
	);
404

    
405
	$form['gen_layout']['footnotes']['cdm_dataportal_all_footnotes'] = array(
406
      '#type' => 'checkbox',
407
      '#title' => t('Do not show footnotes'),
408
      '#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
409
      '#description' => t('Check this if you do not want to show any footnotes')
410
	);
411

    
412
	$form['gen_layout']['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
413
      '#type' => 'checkbox',
414
      '#title' => t('Do not show annotations footnotes'),
415
      '#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
416
      '#description' => t('Check this if you do not want to show annotation footnotes')
417
	);
418
	
419
	//--- Advanced Search ---//
420
	$form['gen_layout']['asearch'] = array(
421
      '#type' => 'fieldset',
422
      '#title' => t('Advanced search'),
423
      '#collapsible' => FALSE,
424
      '#collapsed' => FALSE,
425
    );
426
    $form['gen_layout']['asearch']['cdm_dataportal_show_advanced_search'] = array(
427
      '#type' => 'checkbox',
428
      '#title' => t('Show advanced search link'),
429
      '#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
430
      '#description' => t('Check this box if the link to advanced search should be show below the search box.'),
431
    );
432
    
433
	return system_settings_form($form);
434
}
435

    
436
function cdm_settings_layout_synonymy(){
437
  /* ====== SYNONYMY ====== */
438
  $form['synonymy'] = array(
439
      '#type' => 'fieldset',
440
      '#title' => t('Synonymy'),
441
      '#collapsible' => TRUE,
442
      '#collapsed' => FALSE,
443
      '#description' => t('This section covers the settings related to the taxon <b>synonymy</b> tab.'),
444
  );
445

    
446
  $form['synonymy']['cdm_dataportal_nomref_in_title'] = array(
447
    '#type' => 'checkbox',
448
    '#title' => t('Show accepted taxon on top of the synonymy'),
449
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
450
    '#description' => t('If checked, the first homotypic taxon is a repetition of the accepted taxon most likely
451
                        with the full nomenclatural reference (depending on the currently chosen theme).')
452
  );
453

    
454
  $form['synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
455
    '#type' => 'checkbox',
456
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when coming from a synonym link.'),
457
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
458
    '#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.')
459
  );
460

    
461
  $name_relationships_terms = cdm_ws_get(CDM_WS_TERMVOCABULARY, UUID_NAME_RELATIONSHIP_TYPE);
462
  $name_rel_options = array();
463
  //$name_rel_options['default'] = 'Show all';
464
  foreach ($name_relationships_terms->terms as $element){
465
    $name_rel_options[$element->uuid] = t('Show "' . $element->representation_L10n_abbreviated . '" relationships');
466
  }
467

    
468
  $name_relationships_form['name_relationships_to_show']= array(
469
    '#type' => 'checkboxes',
470
    '#title' => t('Display name relationships'),
471
    '#default_value' => variable_get('name_relationships_to_show', 0),
472
    '#options' => $name_rel_options,
473
    '#description' => t('Select the name relationships you want to show for the accepted taxa.'),
474
  );
475

    
476
  $form['synonymy']['name_relationships'] = $name_relationships_form;
477
      /*
478
       $form['synonymy'][CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS] = array(
479
       '#type' => 'checkbox',
480
       '#title' => t('Show name relations of accepted taxa on taxon page'),
481
       '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT),
482
       //'#description' => t('Check this if you want the synonymy list to show all the name relationships where other names implies the accepted taxa.')
483
       '#description' => t('Check this if you want the synonymy list to show all the name relationships of accepted taxa.')
484
       );
485
     */
486
  $form['synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
487
    '#type' => 'checkbox',
488
    '#title' => t('Show taxon relations of accepted taxa on taxon page'),
489
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
490
    '#description' => t('Check this if you want the synonymy list to show the <em>"Misapplied Name for"</em> and <em>"Invalid Designation for"</em> relationships of accepted taxa.')
491
  );
492

    
493
  return system_settings_form($form);
494
      /*
495
       $form['synonymy']['cdm_dataportal_name_relations_skiptype_basionym'] = array(
496
       '#type' => 'checkbox',
497
       '#title' => t('Exclude the basionym relationship type from the taxon page'),
498
       '#default_value' => variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1),
499
       '#description' => t('')
500
       );
501
       */
502
}
503

    
504
function cdm_settings_layout_taxon(){
505
  $collapsed = false;
506
  $form = array();
507

    
508
	/* ======  TAXON_PROFILE ====== */
509

    
510
	$form['taxon_profile'] = array(
511
      '#type' => 'fieldset',
512
      '#title' => t('Taxon profile'),
513
      '#description' => t('<p>This section covers the setting related to the taxon profile tab, also known as the <strong>"General"</strong> tab.
514
                      It is possible to split the taxon profile in different tabs, visit the section Taxon tabs to discover and configure the tabs</p>'),
515
      '#collapsible' => FALSE,
516
      '#collapsed' => FALSE,
517
	);
518
	
519
	$form['taxon_profile']['cdm_dataportal_show_back_to_search_results'] = array(
520
	    '#type' => 'checkbox',
521
        '#title' => t('Show <em>Back to search results</em> link at the taxon site.'),
522
        '#default_value' => variable_get('cdm_dataportal_show_back_to_search_results', 1),
523
        '#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>')
524
	);
525

    
526
	//--------- TABBED TAXON -------//
527
	$form['taxon_profile']['taxon_tabs'] = array(
528
	  '#type' => 'fieldset',
529
      '#title' => t('Taxon tabs'),
530
      '#collapsible' => TRUE,
531
      '#collapsed' => FALSE,
532
	  '#description' => t('If tabbed taxon page is enabled the taxon profile will be splitted in four diferent tabs;
533
	           General, Synonymy, Images and Specimens. If the taxon has no information for any of the tabs/sections such tab will be not displayed.'),
534
	);
535

    
536
	$form['taxon_profile']['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
537
    '#type' => 'checkbox',
538
    '#title' => t('Tabbed taxon page'),
539
    '#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
540
    '#description' => t('<p>If selected split the taxon page into individual tabs for description, images, synonymy and specimens.
541
                            If not the taxon data is renderized as a long single page without tabs.</p>')
542
	);
543

    
544
	$form['taxon_profile']['taxon_tabs']['cdm_dataportal_detault_tab'] =  array(
545
      '#type'          => 'select',
546
      '#title'         => t('Default tab to display'),
547
      '#default_value' => variable_get('cdm_dataportal_detault_tab', 0),
548
      '#options'       => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
549
      '#description'   => t('<p>Select the default tab to display when visiting a taxon page. Only available if Tabbed Taxon Page is enable.</p>
550
              <strong>Note:</strong> After performing a search and clicking in any synonym, the taxon tab
551
              to be renderized will be the synonymy of the accepted taxon and not the above selected tab.'),
552
	);
553

    
554
/* THIS SECTION HAS BEEN MOVED TO LAYOUT
555
	//---- footnotes ---//
556
	$form['taxon_profile']['footnotes'] = array(
557
      '#type' => 'fieldset',
558
      '#title' => t('Footnotes'),
559
      '#collapsible' => TRUE,
560
      '#collapsed' => TRUE,
561
	  '#description' => t('Taxa data such authors, synonyms names or some taxa description text may have annotations or footnotes. When the footnotes are enabled
562
	                       they will be visible (if they exist). Taxon synonymy and taxon speciemens sections or tabs may contain also footnotes.'),
563
	);
564

    
565
	$form['taxon_profile']['footnotes']['cdm_dataportal_all_footnotes'] = array(
566
      '#type' => 'checkbox',
567
      '#title' => t('Do not show footnotes'),
568
      '#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
569
      '#description' => t('Check this if you do not want to show any footnotes')
570
	);
571

    
572
	$form['taxon_profile']['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
573
      '#type' => 'checkbox',
574
      '#title' => t('Do not show annotations footnotes'),
575
      '#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
576
      '#description' => t('Check this if you do not want to show annotation footnotes')
577
	);
578
*/
579
	// ---- PROFILE PICTURE ----//
580
	$form['taxon_profile']['picture'] = array(
581
      '#type' => 'fieldset',
582
      '#title' => t('Profile Picture'),
583
      '#collapsible' => TRUE,
584
      '#collapsed' => FALSE,
585
	  '#description' => t('Select a profile picture for taxa. Like a facebook of plants.'),
586
	);
587

    
588
	$form['taxon_profile']['picture']['cdm_dataportal_show_default_image'] = array(
589
      '#type' => 'checkbox',
590
      '#title' => t('Enable profil picture'),
591
      '#default_value' => variable_get('cdm_dataportal_show_default_image', false),
592
      '#description'   => t('Show the profil picture.')
593
	);
594

    
595
	$options = cdm_rankVocabulary_as_option();
596
	array_unshift($options, '-- DISABLED --');
597
	$form['taxon_profile']['picture']['image_hide_rank'] =  array(
598
      '#type'          => 'select',
599
      '#title'         => t('Hide picture for taxa above'),
600
      '#default_value' => variable_get('image_hide_rank', '0'),
601
      '#options'       => $options,
602
      '#description'   => t('Select which rank of pictures should not have a profil picture.'),
603
	);
604
	//show picture
605
	$selectShowMedia = array(0 => "Show only taxon pictures",
606
	1 => "Show taxon and child taxa pictures");
607

    
608
	$form['taxon_profile']['picture']['cdm_dataportal_show_media'] = array(
609
      '#type' => 'select',
610
      '#title' => t('Available picture files'),
611
      '#default_value' => variable_get('cdm_dataportal_show_media', false),
612
      '#options' => $selectShowMedia,
613
      '#description'   => t('Show the profil pictures current taxon\'s children.')
614
	);
615

    
616
	//-- FEATURE TREE --//
617
	$form['taxon_profile']['taxon_profile'] = array(
618
	 '#type' => 'fieldset',
619
     '#title' => t('Features'),
620
     '#collapsible' => TRUE,
621
     '#collapsed' => FALSE,
622
	 '#description' => t('This section covers settings related to the taxon\'s <em>Feature Tree</em>. The <em>feature tree</em> are the taxon\'s
623
	                      features such description, distribution, common names, etc. that drupal will render at his taxon profile page.'),
624
	);
625
	$form['taxon_profile']['taxon_profile'][CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID] = array(
626
      '#type' => 'radios',
627
      '#title'         => t('Taxon profile sections'),
628
      '#default_value' => variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE),
629
      '#options' => cdm_get_featureTrees_as_options(TRUE),
630
      '#description'   => t('Select the Feature Tree to be displayed at the taxon profile. Click "Show Details" to see the Feature Tree elemets.'
631
      )
632
      );
633

    
634
      $form['taxon_profile']['taxon_profile'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
635
      '#type' => 'radios',
636
      '#title'         => t('Natural language representation of structured descriptions'),
637
      '#default_value' => variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, null),
638
      '#options' => cdm_get_featureTrees_as_options(),
639
      '#description'   => t('Taxon descriptions can be stored in a highly structured form.'.
640
        ' The feature tree selected here will be used to generate textual representation in natural language.'
641
        //.' If there is no applicable FeatureTree you can create a new one using the <a href="">FeatureTreeManager</a>'
642
      )
643
      );
644

    
645

    
646
  /* ------ DISTRIBUTION LAYOUT ------ */
647

    
648
      $form['taxon_profile']['distribution_layout'] = array(
649
        '#title' => t('Distribution'),
650
        '#collapsible' => TRUE,
651
        '#collapsed' => FALSE,
652
        '#type' => 'fieldset',
653
      	'#description' => t('Select if you want to sort or not the distribution text located below the distribution map.'),
654
      );
655

    
656
      $form['taxon_profile']['distribution_layout']['distribution_sort'] =  array(
657
    '#type'          => 'radios',
658
    '#title'         => t('Sort'),
659
    '#default_value' => variable_get('distribution_sort', 'NO_SORT'),
660
    '#options' => array(
661
        'NO_SORT' => t('Standard (No sort)'),
662
        'HIDE_TDWG2' => t('Sorted without TDWG Level 2'),
663
      ));
664

    
665
 /* ====== SYNONYMY ====== */
666
  $form['taxon_profile']['synonymy'] = array(
667
      '#type' => 'fieldset',
668
      '#title' => t('Taxon Synonymy (Tab)'),
669
      '#collapsible' => TRUE,
670
      '#collapsed' => FALSE,
671
      '#description' => t('This section covers the settings related to the taxon <b>synonymy</b> tab.'),
672
  );
673

    
674
  $form['taxon_profile']['synonymy']['cdm_dataportal_nomref_in_title'] = array(
675
    '#type' => 'checkbox',
676
    '#title' => t('Show accepted taxon on top of the synonymy'),
677
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
678
    '#description' => t('If checked, the first homotypic taxon is a repetition of the accepted taxon most likely
679
                        with the full nomenclatural reference (depending on the currently chosen theme).')
680
  );
681

    
682
  $form['taxon_profile']['synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
683
    '#type' => 'checkbox',
684
    '#title' => t('Display <em>is accepted for ...</em> on taxon pages when coming from a synonym link.'),
685
    '#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
686
    '#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.')
687
  );
688

    
689
  $name_relationships_terms = cdm_ws_get(CDM_WS_TERMVOCABULARY, UUID_NAME_RELATIONSHIP_TYPE);
690
  $name_rel_options = array();
691
  //$name_rel_options['default'] = 'Show all';
692
  foreach ($name_relationships_terms->terms as $element){
693
    $name_rel_options[$element->uuid] = t('Show "' . $element->representation_L10n_abbreviated . '" relationships');
694
  }
695

    
696
  $name_relationships_form['name_relationships_to_show']= array(
697
    '#type' => 'checkboxes',
698
    '#title' => t('Display name relationships'),
699
    '#default_value' => variable_get('name_relationships_to_show', 0),
700
    '#options' => $name_rel_options,
701
    '#description' => t('Select the name relationships you want to show for the accepted taxa.'),
702
  );
703

    
704
  $form['taxon_profile']['synonymy']['name_relationships'] = $name_relationships_form;
705
      /*
706
       $form['synonymy'][CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS] = array(
707
       '#type' => 'checkbox',
708
       '#title' => t('Show name relations of accepted taxa on taxon page'),
709
       '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT),
710
       //'#description' => t('Check this if you want the synonymy list to show all the name relationships where other names implies the accepted taxa.')
711
       '#description' => t('Check this if you want the synonymy list to show all the name relationships of accepted taxa.')
712
       );
713
     */
714
  $form['taxon_profile']['synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
715
    '#type' => 'checkbox',
716
    '#title' => t('Show taxon relations of accepted taxa on taxon page'),
717
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
718
    '#description' => t('Check this if you want the synonymy list to show the <em>"Misapplied Name for"</em> and <em>"Invalid Designation for"</em> relationships of accepted taxa.')
719
  );
720

    
721
  // ====== SPECIMENS ====== //
722
  $form['taxon_profile']['specimens'] = array(
723
      '#type' => 'fieldset',
724
      '#title' => t('Taxon Specimens (Tab)'),
725
      '#collapsible' => TRUE,
726
      '#collapsed' => FALSE,
727
      '#description' => t('This section covers the settings related to the taxon <b>specimens</b> tab.'),
728
  );
729
  $form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
730
  $form_title = 'Specimen media';
731
  $form_description = 'TODO: write text.';
732
  $form['taxon_profile']['specimens'][] =
733
    cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
734

    
735
  //-- MEDIA THUMBNAILS --//
736
  $form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
737
  $form_tittle = 'Taxon Images (Tab)';
738
  $form_description = 'This section covers the settings related to the taxon images tab. Taxon images display all the media (in this case images) found for a given taxon as a thumbnails.';
739
  $form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_tittle, $collapsed, $form_description);
740

    
741
  return system_settings_form($form);
742
}
743

    
744
function cdm_settings_layout_search(){
745

    
746
	$form = array();
747

    
748
	$form['search_settings'] = array(
749
      '#type' => 'fieldset',
750
      '#title' => t('Taxa Search'),
751
      '#collapsible' => TRUE,
752
      '#collapsed' => FALSE,
753
	  '#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
754
	                       the block <em>CDM Taxon Search</em> should be enabled and visible for users
755
	                       where they can write the text to be searched. You can find Drupal block configuration
756
	                       site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p> '),
757
      );
758

    
759
	$form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
760
    '#type' => 'textfield',
761
    '#title' => t('Results per page'),
762
    '#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
763
    '#description' => t('Number of results to display per page.')
764
	);
765

    
766
	// --- SEARCH TAXA GALLERY ---- //
767
	$items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
768
	$collapsed = FALSE;
769
	$form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
770
	$form_title = 'Taxa Search thumbnails';
771
	$form_description = 'Search results may show thumbnails. ';
772
	$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
773

    
774
	return system_settings_form($form);
775
}
776

    
777
function cdm_settings_layout_media(){
778

    
779
	$form = array();
780

    
781
	$form['media_settings'] = array(
782
      '#type' => 'fieldset',
783
      '#title' => t('Images Settings'),
784
      '#collapsible' => TRUE,
785
      '#collapsed' => FALSE,
786
	    '#description' => t('This section covers the settings related to the taxon images tab.'),
787
      );
788

    
789
	$form['media_settings']['image_gallery_viewer'] =  array(
790
    '#type'          => 'select',
791
    '#title'         => t('Image gallery viewer'),
792
    '#default_value' => variable_get('image_gallery_viewer', 'default'),
793
    '#options' => array(
794
        'default' => t('Standart image gallery'),
795
        'fsi' => t('FSI viewer (requires FSI server!)'),
796
	'#description' => t('Select your '),
797
	));
798

    
799
	// --- MEDIA GALLERY ---- //
800
	$form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
801
	$form_title = 'Media gallery';
802
	$form_description = 'What it is supposed to do this form? TODO: write description text.';
803
	//$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
804
	$form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
805

    
806

    
807
	return system_settings_form($form);
808
}
809

    
810

    
811
/**
812
 * GEOSERVICE and Map settings
813
 * @return unknown_type
814
 */
815
function cdm_settings_geo(){
816

    
817
	$form = array();
818

    
819
	/*
820
	 * GEO SERVER
821
	 */
822

    
823
     $form['geoserver'] = array(
824
      '#type' => 'fieldset',
825
      '#title' => t('Geo Server Settings'),
826
      '#collapsible' => TRUE,
827
      '#collapsed' => TRUE,
828
      '#description' => t('Configuration and selection of your geo server. The Geo Server is the responsible for generating the maps.'),
829
	 );
830

    
831
	$form['geoserver']['edit_map_server'] = array(
832
    '#type' => 'select',
833
    '#title' => t('Geoservice access point URL'),
834
    '#default_value' => variable_get('edit_map_server', 'http://edit.br.fgov.be/edit_wp5/v1/'),
835

    
836
    '#options' => array(
837
	      EDIT_MAPSERVER_URI => 'EDIT Map Server',
838
	/*
839
	 'http://edit.br.fgov.be/edit_wp5/v1/' => 'EDIT Map Server - Mirror 1',
840
	 'http://edit.br.fgov.be/edit_wp5/v1/' => 'EDIT Map Server - Mirror 2',
841
	 */
842
	      'ALTERNATIVE' => '-- Alternative URL --'
843
	      ),
844
    '#description' => t('Select the Map Server you want the data portal to connect.
845
                         If you want to introduce a custom address just select the Alternative URL value and fill the field Geoservice
846
                         Access Point - Alternative URL with the custem ip address.')
847
	      );
848

    
849
	      $form['geoserver']['edit_map_server_alternative'] = array(
850
    '#type' => 'textfield',
851
    '#title' => t('Geoservice access point - alternative URL'),
852
    '#default_value' => variable_get('edit_map_server_alternative', ''),
853
    '#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.')
854
	      );
855

    
856

    
857
	/*
858
	 *  MAP SETTINGS
859
	 */
860

    
861
	      $form['map_settings'] = array(
862
      '#type' => 'fieldset',
863
      '#title' => t('Maps settings'),
864
      '#collapsible' => TRUE,
865
      '#collapsed' => TRUE,
866
	  '#description' => t('Configuration of the renderized maps.'),
867
	      );
868

    
869
	      $form['map_settings']['cdm_dataportal_geoservice_display_width'] = array(
870
    '#type' => 'textfield',
871
    '#title' => t('Maps size'),
872
    '#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
873
    '#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.')
874
	      );
875

    
876
	      $form['map_settings']['cdm_dataportal_geoservice_bounding_box'] = array(
877
    '#type' => 'textfield',
878
    '#title' => t('Fixed bounding box'),
879
    '#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
880
    '#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.')
881
	      );
882

    
883
	      $form['map_settings']['cdm_dataportal_geoservice_labels_on'] = array(
884
    '#type' => 'checkbox',
885
    '#title' => t('<b>Display area labels</b>'),
886
    '#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
887
    '#description' => t('Check this if you like area names to be displayed in the maps. DOES IT WORKS???? ')
888
	      );
889

    
890
	      $form['map_settings']['cdm_dataportal_geoservice_map_caption'] = array(
891
    '#type' => 'textfield',
892
    '#title' => t('Map caption'),
893
    '#default_value' => variable_get('cdm_dataportal_geoservice_map_caption', ''),
894
    '#description' => t('Define a caption for the map.')
895
	      );
896

    
897
	      $form['map_settings']['cdm_dataportal_geoservice_distributionOpacity'] = array(
898
    '#type' => 'textfield',
899
    '#title' => t('Distribution layer opacity'),
900
    '#default_value' => variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5'),
901
    '#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions (the countries or regions) will
902
                         fully visible, while a value near to 0.0 will be not much visible.')
903
	      );
904

    
905
/*
906
	      $form['map_settings']['cdm_dataportal_map_openlayers'] = array(
907
    '#type' => 'checkbox',
908
    '#title' => t('<b>Open Layers viewer</b>'),
909
    '#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
910
    '#description' => t('Display the maps in an interactive viewer which allows zooming and panning. If not enabled the maps will consist
911
                         on a static image. If enabled you can configure the default layer (background of your maps) below. Only one of
912
                         them will be renderized, the one selected as <em>Default</em>.')
913
	      );
914
*/
915

    
916
	      // --- OpenLayers Settings --- //
917

    
918
	      $form['openlayers'] = array(
919
      '#type' => 'fieldset',
920
      '#title' => t('Open Layers settings'),
921
      '#collapsible' => TRUE,
922
	  '#collapsed' => TRUE,
923
      //'#collapsed' => !variable_get('cdm_dataportal_map_openlayers', 1),
924
	  '#description' => t('If you activate the interactive maps (Open Layers Viewer checkbox). You need to configure which layer you prefer to use as map background.'),
925
	      );
926

    
927
	      $baselayer_options = array(
928
	      /*
929
	       * NOTICE: must correspond to the layers defined in js/openlayers_,ap.js#getLayersByName()
930
	       */
931
    'osgeo_vmap0' => "OpenLayers World", // EPSG:4326
932
    'metacarta_vmap0' => "Metacarta Vmap0" , // EPSG:4326, EPSG:900913
933
	      // all others EPSG:900913 ...
934
    'osmarender' => 'OpenStreetMap',
935
    //'oam' => 'OpenAerialMap', // currently unavailable
936
    'gmap' => 'Google Streets',
937
    'gsat' => 'Google Satellite',
938
    'ghyb' => 'Google Hybrid',
939
    'veroad' => 'Virtual Earth Roads',
940
    'veaer' => 'Virtual Earth Aerial',
941
    'vehyb' => 'Virtual Earth Hybrid'
942
	      //  ,
943
	      //    'yahoo' => 'Yahoo Street',
944
	      //    'yahoosat' => 'Yahoo Satellite',
945
	      //    'yahoohyb' => 'Yahoo Hybrid'
946

    
947
	      );
948

    
949
	      $form['openlayers']['cdm_dataportal_map_openlayers'] = array(
950
    '#type' => 'checkbox',
951
    '#title' => t('<b>Open Layers viewer</b>'),
952
    '#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
953
    '#description' => t('Display the maps in an interactive viewer which allows zooming and panning. If not enabled the maps will consist
954
                         on a static image. If enabled you can configure the default layer (background of your maps) below. Only one of
955
                         them will be renderized.')
956
	      );
957
	      $form['openlayers']['baselayers'] = array(
958
    '#type' => 'checkboxes_preferred',
959
    '#title' => t('Baser Layers'),
960
    '#options' => $baselayer_options,
961
    '#default_value' => variable_get('baselayers', array('metacarta_vmap0' => "metacarta_vmap0", 'PREFERRED' => 'metacarta_vmap0')),
962
    '#description' => t('')
963
	      );
964

    
965
	      // cdm_dataportal_geoservice_showLayerSwitcher
966
	      $form['openlayers']['cdm_dataportal_geoservice_showLayerSwitcher'] = array(
967
    '#type' => 'checkbox',
968
    '#title' => t('<b>Show Layer Switcher</b>'),
969
    '#default_value' => variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE),
970
    '#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.')
971
	      );
972

    
973
	      $localhostkey = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
974
	      $gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
975
	      $form['openlayers']['gmap_api_key'] = array(
976
    '#type' => 'textfield',
977
    '#title' => t('Gogle maps API key'),
978
    '#default_value' => variable_get('gmap_api_key', $gmap_api_key),
979
    '#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>
980
         <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.')
981
	      );
982

    
983
	      $form['cdm_dataportal_geoservice_map_legend'] = array(
984
      '#type' => 'fieldset',
985
      '#title' => t('Map legend'),
986
      '#collapsible' => TRUE,
987
      '#collapsed' => TRUE,
988
	  '#description' => t('Configure the maps legend.')
989
	      );
990

    
991
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_on'] = array(
992
    '#type' => 'checkbox',
993
    '#title' => t('<b>Display a map legend</b>'),
994
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
995
    '#description' => t('Check this if you like a legend to be displayed with the maps.')
996
	      );
997

    
998
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legendOpacity'] = array(
999
    '#type' => 'textfield',
1000
    '#title' => t('Legend opacity'),
1001
    '#default_value' => variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5'),
1002
    '#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
1003
                         to 0.0 will be not much visible.')
1004
	      );
1005

    
1006
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_size'] = array(
1007
    '#type' => 'textfield',
1008
    '#title' => t('Font size'),
1009
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_size', 10),
1010
    '#description' => t('Font size in pixels.')
1011
	      );
1012

    
1013
	      $fontStyles = array(0 => "plane", 1 => "italic");
1014
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_style'] = array(
1015
    '#type' => 'select',
1016
    '#title' => t('Available font styles'),
1017
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_style', false),
1018
    '#options' => $fontStyles,
1019
    '#description'   => t('Select a font style for the map legend.')
1020
	      );
1021

    
1022
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_width'] = array(
1023
    '#type' => 'textfield',
1024
    '#title' => t('Legend icon width'),
1025
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_width', 35),
1026
    '#description' => t('Legend icon width in pixels.')
1027
	      );
1028

    
1029
	      $form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_height'] = array(
1030
    '#type' => 'textfield',
1031
    '#title' => t('Legend icon height'),
1032
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_height', 15),
1033
    '#description' => t('Legend icon height in pixels.')
1034
	      );
1035

    
1036
	      return system_settings_form($form);
1037
}
1038

    
1039

    
1040
function cdm_settings_cache(){
1041

    
1042
  $form = array();
1043

    
1044
  $form['cache_settings'] = array(
1045
      '#type' => 'fieldset',
1046
      '#title' => t('Cache Settings'),
1047
      '#collapsible' => FALSE,
1048
      '#collapsed' => FALSE,
1049
	  '#description' => t('<p>TODO: cache process does not work, check java script.</p><p>When caching is enabled all single taxon sites are stored in an internal drupal cache doing
1050
                           the portal response of taxa pages faster. This is possible because the sites are loaded from
1051
                           the cache and are not created from scratch.</p>'),
1052
      );
1053

    
1054
  $form['cache_settings']['cdm_webservice_cache'] =  array(
1055
    '#type'          => 'checkbox',
1056
    '#title'         => t('<strong>Enable caching</strong>'),
1057
	'#options'		 => cdm_help_general_cache(),
1058
    '#default_value' => variable_get('cdm_webservice_cache', 1),
1059
    '#description'   => t('<p>Enable drupal to load taxa pages from the cache.</p>' .
1060
	                       '<p><strong>Note:</strong> If taxa are modified by the editor or any other application the changes will be not
1061
	                       visible till the cache is erased. Therefore developers should deactived this feature when they
1062
	                       are working on the CDM Dataportal Module.</p>')
1063
    );
1064

    
1065
  $form['cache_settings']['cdm_run_cache'] = array(
1066
    '#value' => cdm_view_cache_site()
1067
  );
1068

    
1069
  return system_settings_form($form);
1070
}
1071

    
1072
/**
1073
 * @return walk and cache all taxon pages
1074
 */
1075
function cdm_view_cache_site(){
1076

    
1077
	$out = '';
1078

    
1079
    _add_js_progressbar();
1080
	drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cache_all_taxa.js');
1081

    
1082
	$request_params = array();
1083
	$request_params['query'] = '%';
1084
	$request_params['tree'] = variable_get('cdm_taxonomictree_uuid', false); //cache only the dafault classification
1085
	$request_params['doTaxa'] = 1;
1086
	$request_params['doSynonyms'] = 0;
1087
	$request_params['doTaxaByCommonNames'] = 0;
1088
	$search_url = cdm_compose_url(CDM_WS_PORTAL_TAXON_FIND, null, queryString($request_params));
1089
	$search_url = uri_uriByProxy($search_url);
1090
	$taxon_page_url = url('cdm_dataportal/taxon/');
1091

    
1092

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

    
1099
	$out .= '<form id="cache_site">';
1100
	$out .= '<div>'.t('This caching process may take long time and could cause heavy load on your server').'</div>';
1101
	$out .= '<div id="progress"></div>';
1102
	$out .= '<input type="hidden" name="searchTaxaUrl" value="'.$search_url.'"/>';
1103
	$out .= '<input type="hidden" name="taxonPageUrl" value="'.$taxon_page_url.'"/>';
1104
	$out .= '<input type="button" name="start" value="'.t('Start').'"/>';
1105
	$out .= '<input type="button" name="stop" value="'.t('Stop').'"/>';
1106
	$out .= '</form>';
1107
	$out .= '</div>';
1108
	//  foreach($taxonPager->records as $taxon){
1109
	//    cdm_dataportal_taxon_view($uuid);
1110
	//  }
1111

    
1112
	return $out;
1113
}
1114

    
1115

    
1116
/**
1117
 * Implementation of hook_validate()
1118
 *
1119
 * @param $element
1120
 */
1121
function cdm_settings_validate($form_id, $form_values){
1122

    
1123
	if (!str_endsWith($form_values['cdm_webservice_url'], '/')) {
1124
		//form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
1125
		$form_values['cdm_webservice_url'] .= '/';
1126
	}
1127

    
1128
	if($form_values['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)){
1129
		cache_clear_all(NULL, 'cache_cdm_ws');
1130
		// better clear secref_cache since i can not be sure if the cache has not be used during this response
1131
		cdm_api_secref_cache_clear();
1132
	}
1133

    
1134
}
1135

    
1136
function getEDITMapServiceURI(){
1137

    
1138
	if(variable_get('edit_map_server', false) == 'ALTERNATIVE'){
1139
		return (variable_get('edit_map_server_alternative', false));
1140
	} else if(variable_get('edit_map_server', false)) {
1141
		return variable_get('edit_map_server', false);
1142
	} else {
1143
		return EDIT_MAPSERVER_URI;
1144
	}
1145

    
1146
}
1147

    
1148
/**
1149
 * Implementation of hook_elements()
1150
 *
1151
 * see http://drupal.org/node/37862 for an example
1152
 */
1153
function cdm_dataportal_elements() {
1154
	$type['checkboxes_preferred'] = array(
1155
    '#input' => TRUE,
1156
    '#process' => array('expand_checkboxes_preferred' => array()),
1157
    '#after_build' => array('checkboxes_preferred_after_build')
1158
	);
1159
	return $type;
1160
}
1161

    
1162
/**
1163
 * #process function for the custom form element type 'checkbox_preferred'
1164
 */
1165
function expand_checkboxes_preferred($element){
1166

    
1167
	// first of all create the checkboxes
1168
	$element = expand_checkboxes($element);
1169

    
1170
	$children = element_children($element);
1171
	$element['table_start'] = array(
1172
    '#value' => '<table class="checkboxes_preferred"><tr><th></th><th>'.t('Enabled').'</th><th>'.t('Default').'</th></tr>',
1173
    '#weight'=>-1
1174
	);
1175
	$weight = 0;
1176
	foreach ($children as $key) {
1177
		$odd_even = $weight % 4 == 0 ? 'odd' : 'even';
1178
		$element[$key]['#weight'] = $weight;
1179
		$element[$key]['#prefix'] = '<tr class="'.$odd_even.'"><td>'.t($element['#options'][$key]).'</td><td>';
1180
		$element[$key]['#suffix'] = '</td>';
1181
		unset($element[$key]['#title']);
1182
		$weight += 2;
1183
	}
1184
	$weight = 0;
1185

    
1186
	if (count($element['#options']) > 0) {
1187
		foreach ($element['#options'] as $key => $choice) {
1188
			if (!isset($element[$key.'_preferred'])) {
1189
				$element[$key.'_preferred'] = array(
1190
        '#type' => 'radio',
1191
        '#name' => $element['#parents'][0].'_preferred',
1192
        '#return_value' => check_plain($key),
1193
        '#default_value' => $element['#default_value_2'],
1194
        '#attributes' => $element['#attributes'],
1195
        '#parents' => $element['#parents'],
1196
        '#spawned' => TRUE,
1197
        '#weight' => $weight + 1,
1198
        '#prefix' => '<td>',
1199
        '#suffix' => '</td></tr>',
1200
				//'#submit' => 'submit_checkboxes_preferred'
1201
				);
1202
			}
1203
			$weight += 2;
1204
		}
1205
	}
1206

    
1207
	$element['table_end'] = array(
1208
	//'#type'=>'value',
1209
  '#value' => '</table>', '#weight'=>$weight++);
1210
	return $element;
1211
}
1212

    
1213

    
1214
function theme_checkboxes_preferred($element){
1215
	return theme('form_element',
1216
	array(
1217
      '#title' => $element['#title'],
1218
      '#description' => $element['#description'],
1219
      '#id' => $element['#id'],
1220
      '#required' => $element['#required'],
1221
      '#error' => $element['#error'],
1222
	),
1223
	$element['#children']);
1224
}
1225

    
1226
function checkboxes_preferred_after_build($form, &$form_values){
1227

    
1228
	$parent_id = $form['#parents'][0];
1229

    
1230
	if($_POST && count($_POST) > 0){
1231
		// first pass of form processing
1232
		$preferred_layer = $_POST[$parent_id.'_preferred'];
1233
		$form['#value']['PREFERRED'] = $preferred_layer;
1234
		$form_values[$parent_id] = $form['#value'];
1235
	} else {
1236
		// second pass of form processing
1237
		$preferred_layer = $form['#value']['PREFERRED'];
1238
	}
1239

    
1240
	// also set the chosen value (not sure if this is good drupal style ....)
1241
	foreach( $children = element_children($form) as $key ){
1242
		if($form[$key]['#type'] == 'radio'){
1243
			$form[$key]['#value'] = $preferred_layer;
1244
		}
1245
	}
1246
	// the default layer mus always be enabled
1247
	$form[$preferred_layer]['#value'] = $preferred_layer;
1248

    
1249

    
1250
	return $form;
1251
}
1252

    
(12-12/12)