Project

General

Profile

Download (40.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
// $Id$
3

    
4
/*
5
 * @file
6
 * cdm_dataportal
7
 *
8
 * Copyright (C) 2007 EDIT
9
 * European Distributed Institute of Taxonomy
10
 * http://www.e-taxonomy.eu
11
 *
12
 */
13

    
14
require_once('cdm_dataportal.theme.php');
15

    
16
define(CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE, 25);
17

    
18
/* ====================== hook implementations ====================== */
19

    
20
/**
21
 * Implementation of hook_help()
22
 *
23
 * Display help and module information
24
 * @param section which section of the site we're displaying help
25
 * @return help text for section
26
 */
27
function cdm_dataportal_help($section='') {
28

    
29
  $out = '';
30
  switch ($section) {
31
    case "admin/modules#description":
32
      $out = t("The dataportal publishes CDM data hosted in a CommunityStore on the web.");
33
      break;
34
  }
35
  return $out;
36
}
37

    
38

    
39
/**
40
 * Implementation of hook_perm()
41
 *
42
 * Valid permissions for this module
43
 * @return array An array of valid permissions for the portfolio module
44
 */
45
function cdm_dataportal_perm() {
46
  return array(
47
    	'administer cdm_dataportal',
48
        'cdm_dataportal view notes',
49
  //TODO which else permission are required? -> check the WP6 requirements document
50
  );
51
}
52

    
53

    
54
/**
55
 * Implementation of hook_menu()
56
 */
57
function cdm_dataportal_menu($may_cache) {
58
  $items = array();
59
  
60
  if ($may_cache) {
61

    
62
    $items[] = array(
63
      'path' => 'admin/settings/cdm_dataportal',
64
      'title' => t('CDM Dataportal'),
65
      'description' => t('Setting for the CDM Dataportal'),
66
      'access' => user_access('administer cdm_dataportal'),
67
      'callback' => 'drupal_get_form',
68
      'callback arguments' => 'cdm_dataportal_settings',
69
    );
70
    
71
    /*$items[] = array(
72
      'path' => 'admin/settings/cdm_dataportal/ws',
73
      'title' => t('Web Service'),
74
      'description' => t('Setting for the CDM Dataportal'),
75
      'access' => user_access('administer cdm_dataportal'),
76
      'callback' => 'drupal_get_form',
77
      'callback arguments' => 'cdm_dataportal_settings',
78
      'weight' => 1,
79
      'type' => MENU_DEFAULT_LOCAL_TASK,
80
    );*/
81
    
82
    $items[] = array(
83
	    'path' => 'cdm_dataportal/names',
84
	    'callback' => 'cdm_dataportal_view_names',
85
	    'access' => true,
86
	    'type' => MENU_CALLBACK,
87
    );
88
    // optional callback arguments: page
89
   
90
    $items[] = array(
91
      'path' => 'cdm_dataportal/taxon',
92
      'callback' => 'cdm_dataportal_view_taxon',
93
      'access' => true,
94
      'type' => MENU_CALLBACK,
95
    // expected callback arguments: name_uuid
96
    );
97
    
98
    $items[] = array(
99
      'path' => 'cdm_dataportal/reference',
100
      'callback' => 'cdm_dataportal_view_reference',
101
      'access' => true,
102
      'type' => MENU_CALLBACK,
103
    // expected callback arguments: name_uuid
104
    );
105
    
106
    $items[] = array(
107
      'path' => 'cdm_dataportal/reference/list',
108
      'callback' => 'cdm_dataportal_view_reference_list',
109
      'access' => true,
110
      'type' => MENU_CALLBACK,
111
    // expected callback arguments: name_uuid
112
    );
113
    
114
    $items[] = array(
115
      'path' => 'cdm_dataportal/media',
116
      'callback' => 'cdm_dataportal_view_media',
117
      'access' => true,
118
      'type' => MENU_CALLBACK,
119
    // expected callback arguments: media_uuid, mediarepresentation_uuid, part_uuid or part#
120
    );
121
    
122
    $items[] = array(
123
      'path' => 'cdm_dataportal/search',
124
      'callback' => 'cdm_dataportal_view_search_advanced',
125
      'access' => true,
126
      'type' => MENU_CALLBACK,
127
    );
128
    
129
    $items[] = array(
130
      'path' => 'cdm_dataportal/search/taxon',
131
      'callback' => 'cdm_dataportal_view_search_taxon',
132
      'access' => true,
133
      'type' => MENU_CALLBACK,
134
    );
135
    
136
    $items[] = array(
137
      'path' => 'cdm/xml2json',
138
      'callback' => 'cdm_view_xml2json',
139
      'access' => true,
140
      'type' => MENU_CALLBACK,
141
    );
142
    
143
    
144
  } else {
145
    // may not cache
146
        // --- local tasks for Taxon
147
    if(variable_get('cdm_dataportal_taxonpage_tabs', 1)) {
148
      
149
       $items[] = array(
150
      'path' => 'cdm_dataportal/taxon/'.arg(2),
151
      'title' => theme('cdm_taxonpage_tab', 'General'),
152
      'callback' => 'cdm_dataportal_view_taxon',
153
      'access' => true,
154
      'type' => MENU_CALLBACK,
155
      'weight' => 1,
156
      'callback arguments' => array(arg(2), "description")
157
      // expected callback arguments: name_uuid
158
      );
159
      
160
      $items[] = array(
161
      'path' => 'cdm_dataportal/taxon/'.arg(2).'/description',
162
      'title' => theme('cdm_taxonpage_tab', 'General'),
163
      'callback' => 'cdm_dataportal_view_taxon',
164
      'access' => true,
165
      'type' => MENU_DEFAULT_LOCAL_TASK,
166
      'weight' => 2,
167
      'callback arguments' => array(arg(2), "description")
168
      // expected callback arguments: name_uuid
169
      );
170
      
171
      $items[] = array(
172
      'path' => 'cdm_dataportal/taxon/'.arg(2).'/synonymy',
173
      'title' => theme('cdm_taxonpage_tab', 'Synonymy'),
174
      'callback' => 'cdm_dataportal_view_taxon',
175
      'access' => true,
176
      'type' => MENU_LOCAL_TASK,
177
      'weight' => 3,
178
      'callback arguments' => array(arg(2), "synonymy")
179
      // expected callback arguments: name_uuid
180
      );
181
      
182
      $items[] = array(
183
      'path' => 'cdm_dataportal/taxon/'.arg(2).'/images',
184
      'title' => theme('cdm_taxonpage_tab', 'Images'),
185
      'callback' => 'cdm_dataportal_view_taxon',
186
      'access' => true,
187
      'type' => MENU_LOCAL_TASK,
188
      'weight' => 4,
189
      'callback arguments' => array(arg(2), "images")
190
      // expected callback arguments: name_uuid
191
      );
192
    } 
193
  }
194
  
195
  drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal.css');
196
  //drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_print.css', 'print');
197
  drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_screen.css', 'screen');
198
  
199
  return $items;
200
  
201
}
202

    
203
/**
204
 * Implementation of hook_block()
205
 *
206
 * Provides the following blocks:
207
 *  0: list of links useful during development
208
 *
209
 * @param String $op
210
 * @param int $delta
211
 */
212
function cdm_dataportal_block($op='list', $delta=0) {
213
  // listing of blocks, such as on the admin/block page
214
  if ($op == "list") {
215
    $block[0]["info"] = t("CDM DataPortal DevLinks");
216
    $block[1]["info"] = t("CDM DataPortal Credits");
217
    $block[2]["info"] = t("CDM Search Taxa");
218
    $block[3]["info"] = t("CDM Filters");
219
    return $block;
220
  }
221
  else if ($op == 'view') {
222
    switch($delta){
223
      case 1:
224
        $block['subject'] = t('Credits');
225
        $block['content'] = theme('cdm_credits');
226
        return $block;
227
      case 2:
228
        $block['subject'] = t('Search Taxa');
229
        $block['content'] = drupal_get_form('cdm_dataportal_search_taxon_form');
230
        $block['content'] .= '<div>'.l('Advanced Search', '/cdm_dataportal/search').'</div>';
231
        return $block;
232
    }
233
  }
234
}
235

    
236

    
237
/**
238
 * Implementation of hook_validate()
239
 *
240
 * @param $element
241
 */
242
function cdm_dataportal_settings_validate($form_id, $form_values){
243
  
244
  if (!str_endsWith($form_values['cdm_webservice_url'], '/')) {
245
    form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
246
  }
247

    
248
  $cdm_webservice_url_changed = variable_get('cdm_webservice_url', '') != $form_values['cdm_webservice_url'];
249
  
250
  $cdm_secUuid_default_changed = variable_get('cdm_secUuid_default', '') != $form_values['cdm_secUuid_default'];
251
  
252
  if ($cdm_webservice_url_changed || $cdm_secUuid_default_changed) {
253
    
254
    _cdm_dataportal_set_currentSecUuid($form_values['cdm_secUuid_default']);
255
    // reset all cdm related data stored in the session
256
    // cdm_dataportal_session_clear($form_values['cdm_webservice_url']); // cdm_webservice_url is not further stored here
257
    // clear the cdm webservice cache
258
    cache_clear_all(NULL, 'cache_cdm_ws');
259
    // better clear secref_cache since i can not be sure if the cache has not be used during this response
260
    cdm_api_secref_cache_clear();
261
  }
262
  if($form_values['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)){
263
    cache_clear_all(NULL, 'cache_cdm_ws');
264
    // better clear secref_cache since i can not be sure if the cache has not be used during this response
265
    cdm_api_secref_cache_clear();
266
  }
267
  
268
}
269

    
270
/*
271
function cdm_dataportal_session_clear($cdm_ws_uri_update = false){
272
  $_SESSION['cdm'] = null;
273
  if(is_string($cdm_ws_uri_update)){
274
    $_SESSION['cdm'] = array('ws_uri'=>$cdm_ws_uri_update);
275
  }
276
}
277

    
278
function cdm_dataportal_session_validate(){
279

    
280
  if(!isset($_SESSION['cdm']['ws_uri'])){
281
    $_SESSION['cdm'] = array('ws_uri'=>variable_get('cdm_webservice_url', false));
282
  } else if($_SESSION['cdm']['ws_uri'] != variable_get('cdm_webservice_url', false)){
283
    cdm_dataportal_session_clear(variable_get('cdm_webservice_url', false));
284
  }
285
}
286
*/
287

    
288
function cdm_dataportal_search_taxon_form($advancedForm = false){
289
  
290
  $preset_query = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
291
  $preset_doTaxa = (isset($_SESSION['cdm']['search']['doTaxa']) ? 1 : 0);
292
  $preset_doSynonyms = (isset($_SESSION['cdm']['search']['doSynonyms']) ? 1 : 0);
293
  $preset_doTaxaByCommonNames = (isset($_SESSION['cdm']['search']['doTaxaByCommonNames']) ? 1 : 0);
294
  $tdwg_level_select =  (isset($_SESSION['cdm']['search']['tdwg_level_select']) ? $_SESSION['cdm']['search']['tdwg_level_select'] : 2);
295
  $selected_areas =  (isset($_SESSION['cdm']['search']['area']) ? $_SESSION['cdm']['search']['area'] : false);
296
  
297
  $url = 'cdm_dataportal/search/taxon';
298
  $form['#method'] = 'get';
299
  $form['#process'] = array('cdm_dataportal_search_process' => array());
300
  $form['#action'] = url($url, NULL, NULL, true);
301
  
302
  $form['query'] = array(
303
    '#delta' => 0,
304
    '#type' => 'textfield',
305
    '#size' => 20,
306
    '#attributes' => array('title' => t('Enter the name or part of a name you wish to search for. The asterisk  character * can always be used as wildcard')),
307
    '#value' => $preset_query,
308
  );
309
  
310
  $form['search'] = array(
311
      '#delta' => 1,
312
      '#tree' => true,
313
      //'#type' => $advancedForm ? 'fieldset': 'hidden',
314
      '#title' => t('Options')
315
    );
316
    
317
   $form['search']['tree'] = array(
318
    '#delta' => -1,
319
    '#type' => 'hidden',
320
    '#value' => variable_get('cdm_taxonomictree_uuid', false)
321
  );
322
  
323
  
324
  // clean URL get forms breaks if we don't give it a 'q'.
325
  if (!(bool)variable_get('clean_url', '0')) {
326
    $form['search']['q'] = array(
327
      '#delta' => -1,
328
      '#type' => 'hidden',
329
      '#value' => $url,
330
      '#name' => 'q',
331
    );
332
  }
333
  
334
  $form['search']['pageSize'] = array(
335
      '#delta' => -1,
336
      '#type' => 'hidden',
337
      '#value' => variable_get('cdm_dataportal_search_items_on_page', 25)
338
    );
339

    
340
  if($advancedForm){
341
    // general search parameters
342
    $form['search']['doTaxa'] = array(
343
      '#delta' => 2,
344
      '#type' => 'checkbox',
345
      '#title' => t('Search for accepted taxa'),
346
      '#value' => $preset_doTaxa
347
    );
348
    $form['search']['doSynonyms'] = array(
349
      '#delta' => 3,
350
      '#type' => 'checkbox',
351
      '#title' => t('Search for synonyms'),
352
      '#value' => $preset_doSynonyms
353
    );
354
    $form['search']['doTaxaByCommonNames'] = array(
355
      '#delta' => 4,
356
      '#type' => 'checkbox',
357
      '#title' => t('Search for common names'),
358
      '#value' => $preset_doTaxaByCommonNames
359
    );
360
     
361
    // Geographic Range
362
    $form['search']['geographic_range'] = array(
363
      '#type' => 'fieldset',
364
      '#delta' => 5,
365
      '#tree' => true,
366
      '#title' => t('Geographic range'),
367
    );
368
    
369
    $form['search']['geographic_range']['tdwg_level_select'] = array(
370
    '#type' => 'radios',
371
    '#title' => t('Select a TDWG distribution level and code:'),
372
    '#default_value' => $tdwg_level_select,
373
    '#options' => array(
374
      t('TDWG level-1, i.e. a continent'),
375
      t('TDWG level-2'),
376
      t('TDWG level-3, i.e. a country'),
377
      t('TDWG level-4')
378
      )     
379
    );
380
    $tdwg[1] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '1');
381
    $tdwg[2] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '2');
382
    $tdwg[3] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '3');
383
    $tdwg[4] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '4');
384
    
385
    $tdwg_js = '';
386
    foreach($tdwg as $key=>$tdwg_level){
387
      $tdwgOptions = array();
388
      $tdwgOptionsSelected = array();
389
      foreach($tdwg_level as $area){
390
        $representation = $area->representations[0];
391
        $tdwgOptions[$representation->abbreviatedLabel] = $area->representation_L10n;
392
        if(is_array($selected_areas) && in_array($representation->abbreviatedLabel, $selected_areas)){
393
          $tdwgOptionsSelected[] = $representation->abbreviatedLabel; //$area->uuid;
394
        }
395
      }
396
      asort($tdwgOptions);
397
      $form['search']['geographic_range']['tdwg_level_'.$key] = array(
398
        '#type' => 'select',
399
        '#title'         => t('TDWG level').' '.$key,
400
        '#default_value' => $tdwgOptionsSelected,
401
        '#multiple' => TRUE, 
402
        '#options' => $tdwgOptions
403
      );   
404
      $tdwg_js .= "$('#edit-search-geographic-range-tdwg-level-$key').parent()".($tdwg_level_select + 1 == $key ?  '.show()' : '.hide()'). ";\n";  
405
    }
406

    
407
    drupal_add_js(
408
    "$(document).ready(function(){
409
    
410
      $(\"input[@name='search[geographic_range][tdwg_level_select]']\").change( 
411
        function(event){
412
          var selectId = $(\"input[@name='search[geographic_range][tdwg_level_select]']:checked\").val();
413
          var i;
414
          for(i = 0; i < 4; i++){
415
            if(selectId == i){
416
              $('#edit-search-geographic-range-tdwg-level-' + (i + 1) ).parent().fadeIn('slow');
417
              $('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
418
            } else {
419
              $('#edit-search-geographic-range-tdwg-level-' + (i + 1)).parent().fadeOut('slow');
420
              $('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
421
            }
422
          }
423
        }
424
      );
425
      
426
     $tdwg_js
427
    });",
428
    'inline');
429
      
430
  } else {
431
    $form['search']['doTaxa'] = array(
432
      '#delta' => -2,
433
      '#type' => 'hidden',
434
      '#value' => 1
435
     );
436
      $form['search']['doSynonyms'] = array(
437
      '#delta' => -3,
438
      '#type' => 'hidden',
439
      '#value' => 1
440
     );
441
     $form['search']['doTaxaByCommonNames'] = array(
442
      '#delta' => -4,
443
      '#type' => 'hidden',
444
      '#value' => 1
445
     );
446
  }
447
  
448
   $form['submit'] = array(
449
  '#delta' => 9,
450
  '#type' => 'submit',
451
  '#name' => '',
452
  '#value' => t('Search')
453
  );
454
  
455
  return $form;
456
}
457

    
458
function cdm_dataportal_search_taxon_form_advanced(){
459
  return cdm_dataportal_search_taxon_form(true);
460
}
461

    
462
/**
463
 * Implementation #process method call, see form_builder()
464
 * <p>
465
 * Removes Drupal internal form elements from query
466
 * @param $form
467
 * @return unknown_type
468
 */
469
function cdm_dataportal_search_process($form) {
470
  unset($form['form_id']);
471
  unset($form['form_token']);
472
  return $form;
473
}
474

    
475
/**
476
 * Filters $_REQUEST by a list of valid request  parameters and also sets defaults if required.
477
 * returns the processed request parameters submitted by the search form.
478
 */
479
function cdm_dataportal_search_form_request(){
480

    
481
    
482
  $form_params = array();
483
  array_deep_copy($_REQUEST['search'], $form_params);
484
  $form_params['query'] =  trim($_REQUEST['query']);
485

    
486
  // split of  geographic range
487
  if(isset($_REQUEST['search']['geographic_range'])){
488
    $geographicRange = $_REQUEST['search']['geographic_range'];
489
    // remove 
490
    unset($form_params['geographic_range']);
491
  }
492
  
493
  // add geographic range
494
  if($geographicRange){
495
    $form_params['tdwg_level_select'] = $geographicRange['tdwg_level_select'];
496
    for($i = 1; $i < 5; $i++){
497
      if(isset($geographicRange['tdwg_level_'.$i])){
498
        $form_params['area'] = $geographicRange['tdwg_level_'.$i];
499
      }
500
    }
501
  }
502
  
503
  // store in session
504
  $_SESSION['cdm']['search'] = $form_params;
505
  
506
  return $form_params;
507
}
508
  
509

    
510
/* UNREACHABLE since action of form directly links to view
511
function cdm_dataportal_search_taxon_form_submit($form_id, $form_values) {
512
  
513
  $_SESSION['cdm']['search'] = $form_values;
514
  //return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['vernacular']?'1':'0').'/'.$form_values['language'];
515
  return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['onlyAccepted']?'1':'0');
516
  //$paramstr = compose_url_prameterstr($form_values);
517
  //return url('/cdm_dataportal/search/taxon/', $paramstr);
518
}
519
*/
520
/* ====================== menu callback functions ====================== */
521

    
522
/**
523
 * Generate main administration form.
524
 *
525
 * @return
526
 *   An array containing form items to place on the module settings page.
527
 */
528
function cdm_dataportal_settings(){
529

    
530
  $form = cdm_api_settings_form();
531

    
532
  //TODO: settings are still incomplete, compare with trunk/dataportal/inc/config_default.php.inc
533
  $form['cdm_dataportal'] = array(
534
      '#type' => 'fieldset',
535
      '#title' => t('CDM DataPortal'),
536
      '#collapsible' => FALSE,
537
      '#collapsed' => TRUE,
538
  );
539
  
540
//  $form['cdm_dataportal']['secuuid_widget'] = array(
541
//    '#type' => 'select_secuuid', // => will be themed by theme_select_secuuid(...)
542
//    '#title' => t('Default Concept References'),
543
//    '#description'   => t('The default \'sensu\' reference to start the CDM DataPortal with. Per user choices are possible and may override this value.'),
544
//    '#varname' => 'cdm_secUuid_default',
545
//    '#multiple' => false
546
//  );
547
  
548
  $taxonTrees = cdm_ws_get(CDM_WS_TAXONOMY);
549
  foreach($taxonTrees as $tree){
550
    $taxonomicTreeOptions[$tree->uuid] = $tree->titleCache;  
551
  }
552
  $form['cdm_dataportal']['cdm_taxonomictree_uuid'] = array(
553
    '#type' => 'select',
554
    '#title'         => t('Available taxonomic views'),
555
    '#default_value' => variable_get('cdm_taxonomictree_uuid', false),
556
    '#options' => $taxonomicTreeOptions,
557
    '#description'   => t('Select a taxonomic view for this webservice.')
558
  );
559
  
560
    
561
  //------------------ FEATURE TREE --------------------//
562
  
563
  $form['cdm_dataportal']['feature_tree'] = array(
564
    '#type' => 'fieldset',
565
    '#title' => t('Feature Tree'),
566
    '#collapsible' => TRUE,
567
    '#collapsed' => TRUE,
568
  );
569
  
570
    $form['cdm_dataportal']['feature_tree']['cdm_dataportal_featuretree_uuid'] = array(
571
    '#type' => 'select',
572
    '#title'         => t('Available FeatureTrees'),
573
    '#default_value' => variable_get('cdm_dataportal_featuretree_uuid', false),
574
	  '#options' => _get_feature_trees(),
575
    '#description'   => t('Select a FeatureTree for this webservice.'
576
          //.' If there is no applicable FeatureTree you can create a new one using the <a href="">FeatureTreeManager</a>'
577
          )
578
  );
579
  
580
  //------------------ LAYOUT --------------------//
581
  
582
  $form['cdm_dataportal']['layout'] = array(
583
    '#type' => 'fieldset',
584
    '#title' => t('Layout'),
585
    '#collapsible' => TRUE,
586
    '#collapsed' => TRUE,
587
  );
588
  
589
  $form['cdm_dataportal']['layout']['cdm_taxonname_type'] = array(
590
    '#type' => 'select',
591
    '#title'         => t('Taxon name type'),
592
    '#default_value' => variable_get('cdm_taxonname_type', 'BotanicalName'),
593
    '#options' => array( 'BotanicalName'=>t('BotanicalName'), 'ZoologicalName'=>t('ZoologicalName')),
594
    '#description'   => t('')
595
  );
596
  
597
  $form['cdm_dataportal']['layout']['cdm_dataportal_nomref_in_title'] = array(
598
    '#type' => 'checkbox',
599
    '#title' => t('Hide full nomenclatural reference in title'),
600
    '#default_value' => variable_get('cdm_dataportal_nomref_in_title', 1),
601
    '#description' => t('Uncheck this, if you want the title of a taxon page consisting of name and author plus publication year only.
602
    					If not checked, the first homotypic taxon is a repetition of the accepted taxon with
603
    					the full nomenclatural reference.')
604
  );
605
  
606
  $form['cdm_dataportal']['layout']['cdm_dataportal_display_name_relations'] = array(
607
    '#type' => 'checkbox',
608
    '#title' => t('Show name relations of accepted taxa on taxon page'),
609
    '#default_value' => variable_get('cdm_dataportal_display_name_relations', 1),
610
    '#description' => t('')
611
  );
612
  
613
  $form['cdm_dataportal']['layout']['cdm_dataportal_name_relations_skiptype_basionym'] = array(
614
    '#type' => 'checkbox',
615
    '#title' => t('Exclude the basionym relationship type from the taxon page'),
616
    '#default_value' => variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1),
617
    '#description' => t('')
618
  );
619
  
620
  $form['cdm_dataportal']['layout']['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('Split the taxon page into individual tabs for description, images, synonymy')
625
  );
626
  
627
  $form['cdm_dataportal']['layout']['cdm_dataportal_search_items_on_page'] = array(
628
    '#type' => 'textfield',
629
    '#title' => t('Search Page Size'),
630
    '#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
631
    '#description' => t('Number of Names to display per page in search results.')
632
  );
633
  
634
  $form['cdm_dataportal']['layout']['cdm_dataportal_descriptions_separated'] = array(
635
    '#type' => 'checkbox',
636
    '#title' => t('Separate Desriptions'),
637
    '#default_value' => variable_get('cdm_dataportal_descriptions_separated', 0),
638
    '#description' => t('By default corresponding elements of different descriptions are joined together'
639
                        .' into a common section per feature (i.e. type of description).'
640
                        .' Check this box to allow displaying all descriptions separately.')
641
  );
642
  
643
  $options = cdm_rankVocabulary_as_option();
644
  array_unshift($options, '-- DISABLED --');
645
  $form['cdm_dataportal']['layout']['image_hide_rank'] =  array(
646
    '#type'          => 'select',
647
    '#title'         => t('Hide Images for Taxa above'),
648
    '#default_value' => variable_get('image_hide_rank', '0'),
649
    '#options'       => $options,
650
    '#description'   => t(''),
651
  );
652
  
653
  // --- find taxa ---- //
654
   $form['cdm_dataportal']['layout']['findtaxa'] = array(
655
    '#type' => 'fieldset',
656
    '#title' => t('Search Taxa'),
657
    '#collapsible' => TRUE,
658
    '#collapsed' => TRUE,
659
  );
660
  
661
  //variable_get('', 1);
662
  $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_taxon_thumbnails'] = array(
663
    '#type' => 'checkbox',
664
    '#title' => t('Show media thumbnails for accepted taxa'),
665
    '#default_value' => variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1),
666
    '#description' => t('')
667
  );
668
  
669
  $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_synonym_thumbnails'] = array(
670
    '#type' => 'checkbox',
671
    '#title' => t('Show media thumbnails for syonyms'),
672
    '#default_value' => variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0),
673
    '#description' => t('')
674
  );
675
  
676
  //   $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
677
  $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_thumbnail_captions'] = array(
678
    '#type' => 'checkbox',
679
    '#title' => t('Show captions under thumbnails'),
680
    '#default_value' => variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 1),
681
    '#description' => t('')
682
  );
683
  
684
   $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_maxextend'] = array(
685
    '#type' => 'textfield',
686
    '#title' => t('Maximum extend of Images'),
687
    '#default_value' => variable_get('cdm_dataportal_findtaxa_media_maxextend', 120),
688
    '#description' => t('')
689
  );
690
  
691
  $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_cols'] = array(
692
    '#type' => 'textfield',
693
    '#title' => t('Number of columns'),
694
    '#default_value' => variable_get('cdm_dataportal_findtaxa_media_cols', 3),
695
    '#description' => t('')
696
  );
697
  
698
  $form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_maxRows'] = array(
699
    '#type' => 'textfield',
700
    '#title' => t('Maximum number of rows'),
701
    '#default_value' => variable_get('cdm_dataportal_findtaxa_media_maxRows', 1),
702
    '#description' => t('')
703
  );
704
  
705
  
706
 
707
  //---------------- GEOSERVICE ----------------//
708
  
709
  $form['cdm_dataportal']['geoservice'] = array(
710
    '#type' => 'fieldset',
711
    '#title' => t('Geoservice'),
712
    '#collapsible' => TRUE,
713
    '#collapsed' => TRUE,
714
  );
715
  
716
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_map_openlayers'] = array(
717
    '#type' => 'checkbox',
718
    '#title' => t('OpenLayers Viewer'),
719
    '#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
720
    '#description' => t('Display the maps in an interactive viewer which allows zooming and panning.')
721
  );
722
  
723
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_access_point'] = array(
724
    '#type' => 'textfield',
725
    '#title' => t('Geoservice Access Point'),
726
    '#default_value' => variable_get('cdm_dataportal_geoservice_access_point', ''),
727
    '#description' => t('Base URL of the geoservice to be used by this portal')
728
  );
729
  
730
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_display_width'] = array(
731
    '#type' => 'textfield',
732
    '#title' => t('Geoservice Display Width'),
733
    '#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
734
    '#description' => t('Width of the image generated by geoservice')
735
  );
736
  
737
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_bounding_box'] = array(
738
    '#type' => 'textfield',
739
    '#title' => t('Fixed Geoservice Bounding Box'),
740
    '#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
741
    '#description' => t('Define urrounding 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.')
742
  );
743
  
744
   //cdm_dataportal_geoservice_labels_on
745
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_labels_on'] = array(
746
    '#type' => 'checkbox',
747
    '#title' => t('Display Country Labels'),
748
    '#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
749
    '#description' => t('Check this if you like country names to be displayed in the maps. ')
750
  );
751
  
752
   //cdm_dataportal_geoservice_legend_on
753
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_legend_on'] = array(
754
    '#type' => 'checkbox',
755
    '#title' => t('Display a map legend'),
756
    '#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
757
    '#description' => t('Check this if you like a legend to be displayed with the maps. ')
758
  );
759
  
760
  return system_settings_form($form);
761
}
762

    
763
/**
764
 * Implementation of hook_elements().
765
 */
766
function cdm_dataportal_elements() {
767
  $type['select_secuuid'] = array(
768
    '#input' => TRUE,
769
    '#process' => array('cdm_dataportal_select_secuuid_expand' => array()),
770
    //'#validate' => array('cdm_dataportal_select_secuuid_validate' => array()),
771
    //'#default_value' => array(),
772
  );
773
  return $type;
774
}
775

    
776
/*
777
 *
778
 */
779
function cdm_dataportal_select_secuuid_expand($element){
780
  
781
  $element['#tree'] = FALSE;
782
  
783
  // any value submitted?
784
  if(isset($element['#post'][$element['#varname']])){
785
    $selected_values = $element['#post'][$element['#varname']];
786
  } else {
787
    // use those store in drupal
788
    $selected_values = variable_get( $element['#varname'], array());
789
  }
790
  if(!is_array($selected_values)){
791
    $selected_values = array($selected_values);
792
  }
793
  $options = array();
794
  foreach($selected_values as $secUuid){
795
    $options[$secUuid] = cdm_taxontree_secRefTitle_for($secUuid);
796
  }
797

    
798
  $element[$element['#varname']] =  array(
799
    '#type' => 'select',
800
    '#options' => $options,
801
    '#default_value' => array_values($options),
802
    '#size' => $element['#multiple'] ? 12 : 2,
803
    '#multiple' => $element['#multiple'],
804
  );
805
  return $element;
806
}
807

    
808

    
809

    
810
/**
811
 * Displays a list of the known taxonomic names. Long lists are split up into multiple pages
812
 *
813
 * TODO: parameters are still preliminar
814
 * @param String $page page number to diplay defaults to page 1
815
 * @param boolean $hide_unaccepted whether to hide nams which are not accepted by the current view
816
 */
817
function cdm_dataportal_view_names($beginsWith = 'A', $page = 1, $onlyAccepted = false ){
818

    
819
  $request_params  = array(
820
    'q' => $beginsWith,
821
         //'sec' = '',
822
         //'higherTaxa' => getFiters(),
823
          // 'matchAnywhere' => false, // default is false
824
    'page' => $page,
825
    'onlyAccepted' => $onlyAccepted,
826
    'pagesize' => 20  /*$_SESSION['cdm']['namelist_pagesize'] */);
827
  
828
  $taxonPager = cdm_ws_find(CDM_WS_FIND_TAXA, $request_params);
829
  /*
830
   * FIXME the filter for accepted names will be a form element, thus this widget
831
   * should be generated via form api preferably as block
832
   */
833
  //$out  = theme('cdm_dataportal_widget_filter_accepted', $onlyAccepted);
834
  //$out .= theme('cdm_dataportal_widget_names_list', $names, $page);
835
  $out .= theme('cdm_listof_taxa', $taxonPager);
836
  return $out;
837
}
838

    
839
function cdm_dataportal_view_reference($uuid, $arg2 = null){
840
    $reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
841
    return theme('cdm_reference_page', $reference);
842
}
843

    
844
function cdm_dataportal_view_reference_list($pageNumber){
845
    $referencePager = cdm_ws_page(CDM_WS_REFERENCE, variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE), $pageNumber);
846
    return theme('cdm_reference_pager', $referencePager, 'cdm_dataportal/reference/list/');
847
}
848

    
849
function cdm_dataportal_view_media($mediaUuid, $mediarepresentation_uuid = false, $part = 0){
850
   $media = cdm_ws_get(CDM_WS_MEDIA, $mediaUuid);
851
   return theme('cdm_media_page', $media, $mediarepresentation_uuid, $part);
852
}
853

    
854
/**
855
 * The taxon page gives detailed information on a taxon, it shows:
856
 *  - Taxon name
857
 *  - Full list of synonyms homotypic synonyms on top, followed by the
858
 *    heterotypic and finally followed by misapplied names.
859
 *    The list is ordered historically.
860
 *  - All facts associated with the very taxon concept and taxon name.
861
 *
862
 * @param String $uuid the UUID of the taxon
863
 */
864
function cdm_dataportal_view_taxon($uuid, $chapter = null){
865
  
866
    // display the page for the taxon defined by $uuid
867
    $taxon = cdm_ws_get(CDM_WS_TAXON, $uuid);
868
    if(!$taxon){
869
      drupal_set_title(t('Taxon does not exist'));
870
      return false;
871
    }
872
    _cdm_dataportal_set_currentSecUuid($taxon->sec->uuid);
873
    
874
    drupal_set_title(theme('cdm_taxon_page_title', $taxon));
875
    $out = theme('cdm_taxon_page_general', $taxon, $chapter);
876
    
877
    return $out;
878
  /*}*/
879
}
880

    
881
function cdm_dataportal_view_search_advanced(){
882
  
883
  drupal_set_title(t('Advanced Search'));
884
  
885
  $searchForm = cdm_dataportal_search_taxon_form(true);
886
    
887
  return drupal_get_form('cdm_dataportal_search_taxon_form_advanced');
888
  
889
}
890

    
891
/**
892
 *
893
 * future extensions to meet palmweb mockup requirements:
894
 *  - habitat
895
 *  - uses
896
 *  - conservation status
897
 *  - locality / tdwg region
898
 */
899
function cdm_dataportal_view_search_taxon(){
900
  
901
  $_SESSION['cdm']['last_search'] = $_SERVER['REQUEST_URI'];
902

    
903
  $request_params = cdm_dataportal_search_form_request();
904
  $taxonPager = cdm_ws_get(CDM_WS_FIND_TAXA, null, queryString($request_params));
905
  
906
  $search_params = $_REQUEST;
907
  unset($search_params['q']);
908
  return theme('cdm_search_results', $taxonPager, 'cdm_dataportal/search/taxon', $search_params);
909
}
910

    
911
function cdm_view_xml2json(){
912
  $file = arg(2);
913
  $datastr = get_content(variable_get('cdm_webservice_url', '').$file);
914
  return  xml2json::transformXmlStringToJson($datastr);
915
}
916

    
917
/* ====================== other functions ====================== */
918

    
919
/**
920
 * Enter description here...
921
 *
922
 * @param String $uuid the UUID of the taxon
923
 * @return the URL
924
 */
925
function path_to_taxon($uuid){
926
  if(!$uuid) return false;
927
  return 'cdm_dataportal/taxon/'.$uuid;
928
}
929

    
930
function path_to_reference($uuid){
931
  if(!$uuid) return false;
932
  return 'cdm_dataportal/reference/'.$uuid;
933
}
934

    
935
function path_to_media($uuid, $representaion_uuid = false, $partId = false){
936
  if(!$uuid) return false;
937
  $out = 'cdm_dataportal/media/'.$uuid;
938
  if($representaion_uuid){
939
    $out .= '/'.$representaion_uuid;
940
    if($partId !== false){
941
      $out .= '/'.$partId;
942
    }
943
  }
944
  return $out;
945
}
946

    
947
/**
948
 * Compares thisRank with thatRank.
949
 * Returns a negative integer, zero, or a positive integer 
950
 * as the of thisRank is higher than, equal to, or lower than thatRank.
951
 * e.g: 
952
 * <ul>
953
 * <li>rank_compare({species_uuid}, {genus_uuid}) = -1</li>
954
 * <li>rank_compare({genus_uuid}, {genus_uuid}) = 0</li>
955
 * <li>rank_compare({genus_uuid}, {tribus_uuid}) = 1</li>
956
 * </ul>
957
 * <p>
958
 * This compare logic of the underlying webservice is the
959
 * <b>inverse logic</b> of the the one implemented in 
960
 * java.lang.Comparable#compareTo(java.lang.Object)
961
 * @param $thisRankUuid
962
 * @param $thatRankUuid
963
 * @return  a negative integer, zero, or a positive integer 
964
 * as the thisRank is lower than, equal to, or higher than thatRank 
965
 */
966
function rank_compare($thisRankUuid, $thatRankUuid){
967
    $result = cdm_ws_get(CDM_WS_TERM_COMPARE, array($thisRankUuid, $thatRankUuid));
968
    return $result->Integer;
969
}
970

    
971
function uri_to_synonym($synonymUuid, $acceptedUuid, $pagePart = null){
972
   $acceptedPath = path_to_taxon($acceptedUuid);
973
   return url($acceptedPath.($pagePart ? '/'.$pagePart : ''), 'highlite='.$synonymUuid.'&acceptedFor='.$synonymUuid);
974
}
975

    
976
/**
977
 * Creates a short taxonname by using the taggename field of NameSTO or NameTO instances.
978
 * If the taggename if empty the fullname will be returned.
979
 *
980
 * @param unknown_type $Name or TreeNode
981
 * @return string
982
 */
983
function cdm_dataportal_shortname_of($name){
984

    
985
  $nameStr = '';
986
  // get all tagged text tokens of the scientific name
987
  foreach($name->taggedTitle as $tagtxt){
988
      if($tagtxt->type == 'name' || $tagtxt->type == 'rank'){
989
        $nameStr .= ($nameStr ? ' ' : '').$tagtxt->text;
990
      }
991
  }
992
  $nameStr = trim($nameStr);
993
  if($nameStr){
994
    // do not return short names for these
995
    if($nameStr == 'Incertae sedis' || $nameStr ==  'Nomina excludenda'){
996
      return $nameStr;
997
    }
998
    if($pos = stripos($nameStr, ' ')){
999
      return substr($nameStr, 0, 1).'. '.substr($nameStr, $pos);
1000
    } else {
1001
      return $nameStr;
1002
    }
1003
  } else {
1004
    return $name->titleCache;
1005
  }
1006
}
1007

    
1008
/**
1009
 * TODO Add Comments. I don't get what
1010
 *
1011
 * @param UUID $secUuid
1012
 */
1013
function _cdm_dataportal_set_currentSecUuid($secUuid){
1014
 
1015
  // do not save in session but in database
1016
  
1017
  if(is_array($secUuid)){
1018
    $secUuid = $secUuid[0];
1019
  }
1020
  if(!$secUuid){
1021
    variable_set('cdm_currentSecRef', null);
1022
  } else {
1023
    $secRef = cdm_ws_get(CDM_WS_REFERENCE, $secUuid);
1024
    if(isset($secRef)){
1025
      variable_set('cdm_currentSecRef', (array)($secRef));
1026
    }
1027
  }
1028
  
1029
}
1030

    
1031
/**
1032
 * TODO
1033
 * This will not work with multiple instances of the dataportal running
1034
 * under the same host as there is only one session for all instances.
1035
 * In case you switch instances with the same client, you will definitely
1036
 * run into trouble.
1037
 * Also this is not handling multiple secs.
1038
 *
1039
 *
1040
 * returns the current secRef array.
1041
 * If the according session variable is not jet set the default
1042
 * as configured in the setting is used otherwise null.
1043
 *
1044
 * currentSecRef['uuid']
1045
 * currentSecRef[....
1046
 *
1047
 * @return array
1048
 */
1049
function _cdm_dataportal_currentSecRef_array(){
1050

    
1051
  // do not look in session but in database
1052
  if( variable_get('cdm_currentSecRef', null) == null){
1053
     $secUuid = variable_get('cdm_secUuid_default', null);
1054
     _cdm_dataportal_set_currentSecUuid($secUuid);
1055
  }
1056
  return variable_get('cdm_currentSecRef', null);
1057
  
1058
}
1059

    
1060
/**
1061
 * Check if a taxon is accepted by the current taxonomic tree
1062
 *
1063
 * @param Taxon $taxon
1064
 * @return true if $taxon is accepted, false otherwise
1065
 */
1066

    
1067
function _cdm_dataportal_acceptedByCurrentView($taxon){
1068
  
1069
  //$current_secref = _cdm_dataportal_currentSecRef_array();
1070
  $defaultTreeUuid = variable_get('cdm_taxonomictree_uuid', false);
1071
  if($taxon->class == "Taxon" && isset($taxon->taxonNodes)){
1072
    foreach($taxon->taxonNodes as $node){
1073
      if($node->taxonomicTree == $defaultTreeUuid) {
1074
        return true;
1075
      }
1076
    }
1077
  }
1078
  return false;
1079
}
1080

    
1081
/**@Deprecated
1082
 * 
1083
 */
1084
function compose_url_prameterstr($parameters = array(), $parentPropertyName = false){
1085
  $pstr = '';
1086
  foreach($parameters as $key=>$value){
1087
    if(is_array($value)){
1088
      
1089
    } else {
1090
       $pstr .= ($pstr ? '&' :'').$key.'='.urlencode($value);    
1091
    }
1092
  }
1093
  return $pstr;
1094
}
1095

    
1096
function _get_feature_trees(){
1097
   $feature_trees = array();
1098
   
1099
   // set tree that contains all features
1100
   $feature_trees['0'] = 'No FeatureTree';
1101
   
1102
   // get features from database
1103
   $persisted_trees = cdm_ws_get(CDM_WS_FEATURETREES);
1104
   if(is_array($persisted_trees)){
1105
     foreach($persisted_trees as $featureTree){
1106
       
1107
       $featureLabels = array();
1108
       foreach ($featureTree->root->children as $featureNode){
1109
         $featureLabels[] = $featureNode->feature->representation_L10n;
1110
       }
1111
       
1112
       $feature_trees[$featureTree->uuid] = implode(", ", $featureLabels);
1113
       
1114
     }
1115
   }
1116
   return $feature_trees;
1117
}
1118

    
1119

    
1120
function get_nameRenderTemplate($renderPath, $nameLink = NULL, $refenceLink = NULL){
1121
  //TODO implement admin user interface to replace swicth statement 
1122
  //     preliminar solution: using themes 
1123
  
1124
  $template = theme('get_nameRenderTemplate', $renderPath);
1125
  
1126
  if(!is_array($template)){
1127
    switch($renderPath){
1128
      case 'list_of_taxa':
1129
      case  'acceptedFor':
1130
      case 'taxon_page_synonymy':
1131
      case 'typedesignations':
1132
      case 'taxon_page_title':
1133
      case 'na': $template = array(
1134
          'namePart' => array('#uri'=>true),
1135
          //'authorshipPart' => true,
1136
        );
1137
        break;
1138
      case 'nar': $template = array(
1139
          'namePart' => array('#uri'=>true),
1140
          //'authorshipPart' => true,
1141
          'referencePart' => array('#uri'=>true),
1142
          'microreferencePart' => true,
1143
        );
1144
        break;
1145
      default: $template = array(
1146
          'namePart' => array('#uri'=>true),
1147
          'authorshipPart' => true,
1148
          'referencePart' => array('#uri'=>true),
1149
          'microreferencePart' => true,
1150
          'statusPart' => true,
1151
          'descriptionPart' => true
1152
        );
1153
    }
1154
  }
1155
  
1156
  if($nameLink && isset($template['nameAuthorPart']['#uri'])){
1157
    $template['nameAuthorPart']['#uri'] = $nameLink;
1158
  } else{
1159
    unset($template['nameAuthorPart']['#uri']);
1160
  }
1161
  
1162
  if($nameLink && isset($template['namePart']['#uri'])){
1163
    $template['namePart']['#uri'] = $nameLink;
1164
  } else{
1165
    unset($template['namePart']['#uri']);
1166
  }
1167
  
1168
  if($refenceLink && isset($template['referencePart']['#uri'])){
1169
    $template['referencePart']['#uri'] = $refenceLink;
1170
  }else{
1171
    unset($template['referencePart']['#uri']);
1172
  }
1173
  
1174
  return $template;
1175
}
1176

    
1177
function get_partDefinition($taxonNameType){
1178
  //TODO implement admin user interface to allow specify the partdefinitions for any type
1179
  //     preliminar solution: using themes 
1180
  
1181
  $partdef = theme('get_partDefinition', $taxonNameType);
1182
  
1183
  if(!is_array($partdef)){  
1184
    switch($taxonNameType){
1185
      case 'ZoologicalName': $partdef = array(
1186
        'namePart' => array(
1187
          'name' => true,
1188
        ),
1189
        'referencePart' => array(
1190
          'authorTeam' => true
1191
        ),
1192
        'microreferencePart' => array(
1193
          'microreference' => true,
1194
        ),
1195
        'statusPart' => array(
1196
          'status' => true,
1197
        ),
1198
        'descriptionPart' => array(
1199
          'description' => true,
1200
        ),
1201
      );
1202
      break;
1203
      case 'BotanicalName': $partdef = array(
1204
        'namePart' => array(
1205
          'name' => true
1206
        ),
1207
        'authorTeamPart' => array(
1208
          'authorTeam' => true,   
1209
        ),
1210
        'referencePart' => array(
1211
          'reference' => true      
1212
        ),
1213
        'microreferencePart' => array(
1214
          'microreference' => true,
1215
        ),
1216
        'statusPart' => array(
1217
          'status' => true,
1218
        ),
1219
        'descriptionPart' => array(
1220
          'description' => true,
1221
        ),
1222
      );
1223
      break;
1224
      default: $partdef = array(
1225
        'namePart' => array(
1226
          'name' => true,
1227
        ),
1228
        'authorTeamPart' => array(
1229
          'authorTeam' => true,   
1230
        ),
1231
        'referencePart' => array(
1232
          'reference' => true      
1233
        ),
1234
        'microreferencePart' => array(
1235
          'microreference' => true,
1236
        ),
1237
        'statusPart' => array(
1238
          'status' => true,
1239
        ),
1240
        'descriptionPart' => array(
1241
          'description' => true,
1242
        ),
1243
      );
1244
    }
1245
  }
1246
  return $partdef;
1247
}
(5-5/9)