Project

General

Profile

« Previous | Next » 

Revision 72d57201

Added by Katja Luther almost 5 years ago

ref #8182: specimen tree is collapsable, blast result table with clickable details

View differences:

modules/cdm_dataportal/includes/occurrences.inc
469 469
                                $taxon_name = cdm_ws_get(CDM_WS_NAME, $determinationEvent->taxonName->uuid);
470 470
                                $taxon_name->taggedName = cdm_ws_get(CDM_WS_NAME, array($determinationEvent->taxonName->uuid, "taggedName"));
471 471
                                $name_link = path_to_name($determinationEvent->taxonName->uuid);
472
                            }else if ($determinationEvent->taxon) {
473
                                 $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
474
                                 $name_link = path_to_taxon($determinationEvent->taxon->uuid);
472
                            } else if ($determinationEvent->taxon) {
473
                                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
474
                                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
475 475
                            }
476 476
                            if ($taxon_name) {
477 477
                                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
......
501 501
                        foreach ($value as $description) {
502 502
                            $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
503 503

  
504
                        if($description->imageGallery == TRUE) {
505
                            continue;
506
                        }
504
                            if ($description->imageGallery == TRUE) {
505
                                continue;
506
                            }
507 507
                            $elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
508 508
                            $description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
509 509
                            $dd_elements[] = $description_render_elements;
......
512 512
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
513 513
                        break;
514 514
                    case '_derivedUnitMedia':
515
                        if ($isSpecimen_page){
515
                        if ($isSpecimen_page) {
516 516
                            $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
517 517
                            $captionElements = array(
518 518
                                '#uri' => t('open media'),
......
528 528
                                'alternativeMediaUri' => NULL,
529 529
                                'galleryLinkUri' => NULL,
530 530
                            ));
531
                            @_description_list_group_add($groups, "Detail Images:" , markup_to_render_array($gallery_html),'',20);
531
                            @_description_list_group_add($groups, "Detail Images:", markup_to_render_array($gallery_html), '', 20);
532 532
                        }
533 533

  
534
                       // $dd_elements[] = markup_to_render_array($gallery_html);
534
                        // $dd_elements[] = markup_to_render_array($gallery_html);
535 535

  
536 536
                        break;
537 537
                    case 'sources':
......
546 546
                            NULL,
547 547
                            ''
548 548
                        );
549
                        if(!empty($annotations_and_sources['source_references'])){
550
                            @_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources['source_references']),'',12 );
549
                        if (!empty($annotations_and_sources['source_references'])) {
550
                            @_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources['source_references']), '', 12);
551 551
                        }
552 552
                        break;
553 553

  
......
559 559
                            foreach ($derivedFrom->originals as $original) {
560 560
                                $pathToSpecimen = path_to_specimen($original->uuid);
561 561
                                $description = "";
562
                                if (isset( $derivedFrom->description) && $derivedFrom->description != ''){
562
                                if (isset($derivedFrom->description) && $derivedFrom->description != '') {
563 563
                                    $description = $derivedFrom->description . ": ";
564 564
                                }
565 565

  
566 566
                                $originals[] = markup_to_render_array(l($description . $original->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank'))));
567
                                if ($original->class == 'FieldUnit'){
567
                                if ($original->class == 'FieldUnit') {
568 568
                                    $label = t('Field data');
569
                                }else{
569
                                } else {
570 570
                                    $label = t('Derived from');
571 571
                                }
572 572
                                @_description_list_group_add($groups, $label . ':',
......
588 588
                                    }
589 589

  
590 590
                                    $derived_units[] = markup_to_render_array(l($description . $derived_unit->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank'))));
591
                                 }
592
                            } @_description_list_group_add($groups, t('Derivates') . ':',
591
                                }
592
                            }
593
                            @_description_list_group_add($groups, t('Derivates') . ':',
593 594
                                $derived_units,
594
                                    '', 100);
595
                                '', 100);
595 596

  
596 597
                        }
597 598
                        break;
......
616 617
                    case 'storedUnder':
617 618
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
618 619
                        break;
620
                    case 'dnaQuality':
621
                        $sub_dl_groups = array();
622

  
623
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('purificationMethod'), $value->purificationMethod, NULL, 1);
624
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('ratioOfAbsorbance260_230'), $value->ratioOfAbsorbance260_230, NULL, 2);
625
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('ratioOfAbsorbance260_280'), $value->ratioOfAbsorbance260_280, NULL, 3);
626
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('concentration'), $value->concentration, NULL, 4);
627
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('concentrationUnit'), $value->concentrationUnit, NULL, 4);
628
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('qualityTerm'), $value->qualityTerm, NULL, 4);
629
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('qualityCheckDate'), $value->qualityCheckDate, NULL, 4);
630

  
631
                        if (is_array($sub_dl_groups) && sizeof($sub_dl_groups)>0) {
632
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
633
                                array(
634
                                    array('#markup' => $value->titleCache),
635
                                    array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
636
                                )
637
                            );
638
                        }
639
                        break;
640

  
641
                    case 'preservation':
642
                        $sub_dl_groups = array();
619 643

  
644
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('medium'), $value->medium, NULL, 1);
645
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('temperature'), $value->temperature, NULL, 2);
646
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('definedMaterialOrMethod'), $value->definedMaterialOrMethod, NULL, 3);
647

  
648
                        if (is_array($sub_dl_groups) && sizeof($sub_dl_groups)>0) {
649
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
650
                                array(
651
                                    array('#markup' => $value->titleCache),
652
                                    array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
653
                                )
654
                            );
655
                        }
656
                        break;
620 657

  
621 658
                    /* ---- Specimen --- */
622 659
                    case 'sequences':
......
1064 1101
                    case 'kindOfUnit':
1065 1102
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1);
1066 1103
                        break;
1067

  
1104
                    case 'accessionNumber':
1105
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 0);
1106
                        break;
1068 1107

  
1069 1108
                    case 'preferredStableUri':
1070 1109

  
......
1092 1131
                        );
1093 1132
                        $gallery_html = compose_cdm_media_gallerie(array(
1094 1133
                            'mediaList' => $value,
1095
                            'galleryName' => $specimen_or_observation->label,
1134
                            'galleryName' => $specimen_or_observation->uuid,
1096 1135
                            'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
1097 1136
                            'cols' => $gallery_settings['cdm_dataportal_media_cols'],
1098 1137
                            'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
......
1209 1248
                    case 'derivationEvents':
1210 1249
                        //@_description_list_group_add($groups, t('Association type'), $value->description);
1211 1250
                        break;
1251
                    case 'determinedNames':
1252
                        $dd_elements = array();
1253
                        foreach ($value as $name) {
1254
                            $taxon_name = cdm_ws_get(CDM_WS_NAME, $name->key);
1255
                            $taxon_name->taggedName = cdm_ws_get(CDM_WS_NAME, array($name->key, "taggedName"));
1256
                            $name_link = path_to_name($name->key);
1257

  
1258
                            //$taxon_html = render_taxon_or_name($taxon_name, $name_link);
1259
                            $taxon_html = l($taxon_name->titleCache, $name_link, array('attributes' => array('target' => '_blank')));
1260
                            $dd_elements[] = $taxon_html;
1261
                        }
1262
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label("Identification(s)"), $dd_elements,'', 100);
1263
                        break;
1212 1264

  
1213 1265

  
1214 1266
                    default:
......
1240 1292
            $output .= $gallery_html;
1241 1293
        }
1242 1294
        $pathToSpecimen = path_to_specimen($specimen_or_observation->uuid);
1243
        $output .=  l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
1295
        $output .=  l("Detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
1244 1296
    } // END of $specimenOrObservation exists
1245 1297

  
1246 1298
    return $output;
1247 1299
}
1248 1300

  
1249 1301
function compose_table_of_blast_result(array $data){
1302
   // get icon images
1303
  $expand_icon = font_awesome_icon_markup(
1304
      'fa-plus-square-o',
1305
      array(
1306
          'alt' => 'Show details',
1307
          'class' => array('expand_icon')
1308
      )
1309
  );
1310
  $collapse_icon = font_awesome_icon_markup(
1311
      'fa-minus-square-o',
1312
      array(
1313
          'alt' => 'Show details',
1314
          'class' => array('collapse_icon')
1315
      )
1316
  );
1317
  //$detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>';
1318
    $rowcount = 0;
1319
    $rows = array();
1250 1320

  
1251 1321
    foreach ($data as $row_data){
1252 1322
        $pathToSpecimen = path_to_specimen_by_accession_number($row_data['id']);
......
1254 1324

  
1255 1325
        $rows[] =  array(
1256 1326
            'data' => array(
1327
                array(
1328
                    'data' => $expand_icon . $collapse_icon,
1329
                    'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
1330
                ),
1257 1331
                array(
1258 1332
                    'data' => $row_data['def'],
1259 1333
                ),
......
1263 1337
                array(
1264 1338
                    'data' => $row_data['hsp_align_length'],
1265 1339
                ),
1266
              //  array(
1267
              //     'data' => $row_data['midline'],
1268
              //  ),
1269 1340
                array(
1270
                    'data' => $row_data['hsp_evalue'],
1341
                   'data' => $row_data['hsp_identity'],
1342
                ),
1343
                array(
1344
                    'data' => $row_data['hsp_identity']/$row_data['hsp_align_length']*100,
1271 1345
                )
1272
            )
1346
            ),
1347
            'id' => 'blast_summary' . $rowcount, // summary row id
1348
            'class' => array('summary_row'),
1349
        );
1350
        $detail_html = "";
1351

  
1352
        $detail_html .= create_label("Details") . $row_data["hsp_align_length"] . "<br>";
1353

  
1354

  
1355
        $detail_html .= "<br>";
1356
        $detail_html .= $row_data["hsp_midline"];
1357

  
1358
        //$detail_html .= "<br>";
1359

  
1360
        $rows[] = array(
1361
            'data' => array(
1362
                array(
1363
                    'data' => "", //empty first column
1364
                    'class' => array('expand_column')
1365
                ),
1366
                array(
1367
                    'data' => $detail_html,
1368
                    'colspan' => 5,
1369
                ),
1370
            ),
1371
            'id' => 'blast_detail' . $rowcount,//details row ID
1372
            'class' => array('detail_row'),
1273 1373
        );
1374
        $rowcount++;
1274 1375
    }
1376

  
1275 1377
    $tableId = "blast_result_table";
1276 1378
    $blast_result_table = array(
1277 1379
        "#theme" => "table",
1278 1380
        "#weight" => 2,
1279 1381
        "#header" => array(
1280
                        "Name", "id", "Align Length", "e Value"),
1382
            array(
1383
                'data' => "",
1384
                'class' => array('expand_column')
1385
            ),
1386
                        "Name", "Accession Number", "Align Length", "Identity", "% Identity"),
1281 1387
        "#rows" => $rows,
1282 1388
        "#attributes" => array(
1283 1389
            "id" => $tableId,
......
1287 1393

  
1288 1394
    drupal_add_js_rowToggle("#".$tableId);
1289 1395

  
1290
    $render_array['content'] = $blast_result_table;
1396
    $render_array[$tableId] = $blast_result_table;
1291 1397
    $out = drupal_render($render_array);
1292 1398
   //$blast_result_page-> content = drupal_render($render_array);
1293 1399
   return $out;
1294 1400
}
1295 1401

  
1296

  
1297

  

Also available in: Unified diff