Project

General

Profile

« Previous | Next » 

Revision 7535252d

Added by Andreas Kohlbecker over 6 years ago

fix #6959 displaying Registration entities in phycobank block

View differences:

modules/phycobank/phycobank.module
57 57
  if(! (arg(0) == 'cdm_dataportal' && arg(1) == 'taxon' &&  is_uuid(arg(2))) ) {
58 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 59
  }
60
  $rows = array();
60 61
  $taxon_uuid = arg(2);
61 62
  $taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxon_uuid);
62
  $extensions = cdm_ws_get(CDM_WS_NAME . '/' . $taxon->name->uuid . '/extensions');
63 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)),
64
  // read registrations
65
  $registrations = cdm_ws_get(CDM_WS_NAME . '/' . $taxon->name->uuid . '/registrations');
66
  if($registrations && count($registrations) > 0){
67
    foreach($registrations as $reg){
68
      if($reg->status == "PUBLISHED" && strpos($reg->identifier, "http://phycobank.org") == 0) {
69
        $rows[] = array(
70
          'data' => array('ID:', $reg->identifier),
71
          'no_striping' => true
72
        );
73
        $rows[] = array(
74
          'data' => array('Date:', preg_replace('/^([^T]*)(.*)$/', '${1}', $reg->registrationDate)),
75
          'no_striping' => true
76
        );
77
        if(isset($reg->institution->titleCache)){
78
          $rows[] = array(
79
            'data' => array('Office:', $reg->institution->titleCache),
80

  
81
            'no_striping' => true
82
          );
83
        }
84
        break;
85
      }
86
    }
87

  
88
  } else {
89
    // read extensions
90
    $extensions = cdm_ws_get(CDM_WS_NAME . '/' . $taxon->name->uuid . '/extensions');
91

  
92
    if(isset($extensions->records[0])){
93
      $data = json_decode($extensions->records[0]->value);
94

  
95
      $rows[] = array(
96
        'data' => array('ID:', $data->regId),
73 97
        'no_striping' => true
74 98
      );
75
    $rows[] = array(
76
      'data' => array('Office:', $data->office),
77
      'no_striping' => true
78
    );
79
    if(isset($data->formNumber)) {
80 99
      $rows[] = array(
81
        'data' => array('Form number', $data->formNumber),
100
        'data' => array('Date:', preg_replace('/^(.*?\.)(97|98|99)$/', '${1}19$2', $data->date)),
101
          'no_striping' => true
102
        );
103
      $rows[] = array(
104
        'data' => array('Office:', $data->office),
82 105
        'no_striping' => true
83 106
      );
107
      if(isset($data->formNumber)) {
108
        $rows[] = array(
109
          'data' => array('Form number', $data->formNumber),
110
          'no_striping' => true
111
        );
112
      }
84 113
    }
85 114

  
115
  }
116
  if(count($rows) > 0){
86 117
    $data_elements = array(
87 118
      '#theme' => 'table',
88 119
      '#rows' => $rows,

Also available in: Unified diff