Project

General

Profile

« Previous | Next » 

Revision 67ce7111

Added by Patrick Plitzner over 4 years ago

ref #8595 Show associated specimen on description detail page

  • drupal formatting code

View differences:

modules/cdm_dataportal/includes/pages.inc
628 628
  $pathToDescription = path_to_description($description->uuid);
629 629
  $attributes['class'][] = html_class_attribute_ref($description);
630 630
  $descriptionPageLink = l($description->titleCache, $pathToDescription, array('attributes' => $attributes));
631
  $detail_html = "$descriptionPageLink<br>";
631
  $detail_html = $descriptionPageLink."<br>";
632 632
  return $detail_html;
633 633
}
634 634

  
635
/**
636
 * Renders the link which will lead to the specimen detail page
637
 * @param $specimen the specimen which will be linked to
638
 *
639
 * @return string the HTML
640
 */
641
function render_cdm_specimen_link($specimen) {
642
  $path = path_to_specimen($specimen->uuid);
643
  $attributes['class'][] = html_class_attribute_ref($specimen);
644
  $link = l($specimen->titleCache, $path, array('attributes' => $attributes));
645
  return $link;
646
}
647

  
635 648
/**
636 649
 * Returns HTML containing the synonymy for the accepted taxon.
637 650
 *
......
1139 1152

  
1140 1153
/**
1141 1154
 * Compose a description as a table of Feature<->State
1155
 *
1142 1156
 * @param $description_uuid
1157
 *
1143 1158
 * @return array
1144 1159
 *    The drupal render array for the page
1145 1160
 *
1146 1161
 * @ingroup compose
1147 1162
 */
1148
function compose_cdm_description($description_uuid)
1149
{
1163
function compose_cdm_description($description_uuid) {
1150 1164
  RenderHints::pushToRenderStack('description_page');
1151 1165

  
1152
  $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, array($description_uuid));
1166
  $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, [$description_uuid]);
1153 1167

  
1154
  $render_array = array();
1155

  
1156
  if(isset($description->describedSpecimenOrObservation)){
1168
  $render_array = [];
1157 1169

  
1170
  if (isset($description->describedSpecimenOrObservation)) {
1171
    $render_array[] = markup_to_render_array("<b>Specimen</b><br>");
1172
    $render_array[] = markup_to_render_array(render_cdm_specimen_link($description->describedSpecimenOrObservation));
1158 1173
  }
1159 1174

  
1160
  $header = array('Feature/Character', 'State');
1161
  $rows = array();
1175
  $header = ['Feature/Character', 'State'];
1176
  $rows = [];
1162 1177
  foreach ($description->elements as $element) {
1163 1178

  
1164 1179
    switch ($element->class) {
1165 1180
      case 'CategoricalData':
1166
        $rows[] = array($element->feature->representation_L10n, compose_state_data_strings($element));
1181
        $rows[] = [
1182
          $element->feature->representation_L10n,
1183
          compose_state_data_strings($element),
1184
        ];
1167 1185
        break;
1168 1186
      case 'QuantitativeData':
1169
        $rows[] = array($element->feature->representation_L10n, compose_quant_stats($element));
1187
        $rows[] = [
1188
          $element->feature->representation_L10n,
1189
          compose_quant_stats($element),
1190
        ];
1170 1191
        break;
1171 1192
    }
1172 1193
  }
1173
  $render_array[] = markup_to_render_array(theme('table', array('header' => $header, 'rows' => $rows)));
1174

  
1175
  $items = array();
1176
  if(isset($description->sources)){
1177
    foreach($description->sources as $source) {
1194
  $render_array[] = markup_to_render_array(theme('table', [
1195
    'header' => $header,
1196
    'rows' => $rows,
1197
  ]));
1198

  
1199
  if (isset($description->sources) and !empty($description->sources)) {
1200
    $items = [];
1201
    foreach ($description->sources as $source) {
1178 1202
      if ($source->type == 'Aggregation' and $source->idNamespace == 'SpecimenDescription') {
1179 1203
        $specimendescription = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, [$source->idInSource]);
1180
        $items[] = array(
1204
        $items[] = [
1181 1205
          'data' => render_cdm_description_link($specimendescription),
1182
        );
1206
        ];
1183 1207
      }
1184 1208
    }
1209
    $render_array[] = [
1210
      '#title' => 'Sources',
1211
      '#theme' => 'item_list',
1212
      '#type' => 'ul',
1213
      '#items' => $items,
1214
    ];
1185 1215
  }
1186 1216

  
1187
  $render_array[] = array(
1188
    '#title' => 'Sources',
1189
    '#theme' => 'item_list',
1190
    '#type' => 'ul',
1191
    '#items' => $items
1192
  );
1193

  
1194 1217

  
1195 1218
  RenderHints::popFromRenderStack();
1196 1219
  return $render_array;

Also available in: Unified diff