Project

General

Profile

Download (2.41 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Extensions to the cdm dataportal module specific for the Palmweb project
5
 *
6
 * @copyright
7
 *   (C) 2016 EDIT
8
 *   European Distributed Institute of Taxonomy
9
 *   http://www.e-taxonomy.eu
10
 *
11
 *   The contents of this module are subject to the Mozilla
12
 *   Public License Version 1.1.
13
 * @see http://www.mozilla.org/MPL/MPL-1.1.html
14
 *
15
 * @author
16
 *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
17
 */
18

    
19

    
20
/**
21
 * Implements hook_block_info().
22
 */
23
function phycobank_block_info() {
24

    
25
  // $block[0]["info"] = t("CDM DataPortal DevLinks");
26
  // $block[1]["info"] = t("CDM DataPortal Credits");
27
  $block['registration_data'] = array(
28
    'info' => t('Phycobank - Registration data'),
29
    'cache' => DRUPAL_NO_CACHE,
30
    'visibility' => BLOCK_VISIBILITY_LISTED,
31
    'pages' => "cdm_dataportal/taxon/*"
32
  );
33

    
34
  return $block;
35
}
36

    
37
/**
38
 * Implements hook_block_view().
39
 */
40
function phycobank_block_view($delta)
41
{
42
  switch ($delta) {
43
    // case 'delta-1':
44
    // $block['subject'] = t('Credits');
45
    // $block['content'] = theme('cdm_credits');
46
    // return $block;
47
    case 'registration_data':
48
      $block['subject'] = t('Registration data');
49
      $block['content'] = phycobank_registration_data();
50
      return $block;
51
      break;
52
  }
53
}
54

    
55
function phycobank_registration_data(){
56

    
57
  if(! (arg(0) == 'cdm_dataportal' && arg(1) == 'taxon' &&  is_uuid(arg(2))) ) {
58
    return markup_to_render_array("<span class='error'>This block can only be used on cdm_dataportal/taxon/* pages. Please check the block settings.</span>");
59
  }
60
  $taxon_uuid = arg(2);
61
  $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxon_uuid);
62
  $extensions = cdm_ws_get(CDM_WS_NAME . '/' . $taxon->name->uuid . '/extensions');
63

    
64
  if(isset($extensions->records[0])){
65
    $data = json_decode($extensions->records[0]->value);
66
    $rows = array();
67
    $rows[] = array(
68
      'data' => array('ID:', $data->regId),
69
      'no_striping' => true
70
    );
71
    $rows[] = array(
72
      'data' => array('Date:', preg_replace('/^(.*?\.)(97|98|99)$/', '${1}19$2', $data->date)),
73
        'no_striping' => true
74
      );
75
    $rows[] = array(
76
      'data' => array('Office:', $data->office),
77
      'no_striping' => true
78
    );
79
    if(isset($data->formNumber)) {
80
      $rows[] = array(
81
        'data' => array('Form number', $data->formNumber),
82
        'no_striping' => true
83
      );
84
    }
85

    
86
    $data_elements = array(
87
      '#theme' => 'table',
88
      '#rows' => $rows,
89
    );
90
    return $data_elements;
91
  }
92
}
(2-2/2)