Project

General

Profile

Revision 72d57201

ID72d57201d9c9b557895fd7ede7a277f84d1d9b76
Parent fb308159
Child b90ef618

Added by Katja Luther over 1 year ago

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

View differences:

modules/cdm_dataportal/cdm_dataportal.search.php
786 786
 */
787 787
function cdm_dataportal_blast_search_request($search_endpoint)
788 788
{
789

  
790 789
    $form_params = array();
791 790

  
792 791
    if (isset($_REQUEST['search']) && is_array($_REQUEST['search'])) {
793 792
        array_deep_copy($_REQUEST['search'], $form_params['data']);
794 793
    }
795

  
796

  
797
    //$query = trim($_REQUEST['query']);
798
    $form_params['data'] = formatParams($_REQUEST['search']);
799

  
800
    /*if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
801
        $form_params = array_merge($form_params, $_REQUEST['pager']);
802
    }*/
803

  
804
    $form_params['query']= trim($_REQUEST['query']);
805

  
806

  
794
    $form_params['data'] = formatWSParams($_REQUEST['search']);
795
    $form_params['query']= trim($_REQUEST['query']).$form_params['data'];
807 796
    // Store in session.
808 797
    $_SESSION['cdm']['search'] = $form_params;
809

  
810 798
    return $form_params;
811 799
}
812 800

  
813

  
814

  
815 801
/**
816 802
 * Provides the classification to which the last search has been limited to..
817 803
 *
......
933 919
    // parameters if necessary.
934 920
    $request_params = cdm_dataportal_blast_search_request($_REQUEST['ws']);
935 921
   // $url = drupal_http_build_query($_REQUEST['ws'], $request_params);
936

  
922
    $request_params['timeout'] = 200;
937 923
    $taxon_pager = drupal_http_request($_REQUEST['ws'].'?sequence='.$request_params['query'], $request_params);
938 924

  
939 925
    return $taxon_pager;
modules/cdm_dataportal/includes/common.inc
600 600
    return $paramString;
601 601
}
602 602

  
603
function formatWSParams($params) {
604
    if (is_array($params)){
605
        $keys =array_keys($params);
606
        $paramString = '';
607
        foreach ($keys as $k ){
608
            if ($k != 'pageNumber' && $k != 'pageSize'){
609
                $paramString .= '&'.$k.'='.urlencode($params[$k]);
610
            }
611
        }
612
    }
613
    return $paramString;
614
}
615

  
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']);
......
1255 1325
        $rows[] =  array(
1256 1326
            'data' => array(
1257 1327
                array(
1328
                    'data' => $expand_icon . $collapse_icon,
1329
                    'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
1330
                ),
1331
                array(
1258 1332
                    'data' => $row_data['def'],
1259 1333
                ),
1260 1334
                array(
......
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

  
modules/cdm_dataportal/includes/pages.inc
159 159
        );
160 160
    }
161 161
    else if(variable_get('cdm_dataportal_specimen_derivate_tree')){
162

  
163
        $expand_icon = font_awesome_icon_markup(
164
            'fa-plus-square-o',
165
            array(
166
                'alt' => 'Show details',
167
                'class' => array('expand_icon')
168
            )
169
        );
170
        $collapse_icon = font_awesome_icon_markup(
171
            'fa-minus-square-o',
172
            array(
173
                'alt' => 'Show details',
174
                'class' => array('collapse_icon')
175
            )
176
        );
177
        $tableId = "specimen_tree_table";
162 178
        $specimen_table = array(
163 179
            '#theme' => 'table',
164 180
            '#weight' => 2,
165 181
            // prefix attributes and rows with '#' to let it pass toF the theme function,
166 182
            // otherwise it is handled as child render array
167
            '#attributes' => array('class' => 'specimens'),
183
            '#attributes' => array('class' => 'specimens',
184
                                    'id' => $tableId),
168 185
            '#rows' => array(),
169 186
        );
170 187
        $specimen_array = compose_specimen_array($specimensOrObservations);
171

  
188
        $rowcount = 0;
172 189
        foreach($specimen_array as $value){
173 190
            $renderArray = array(
174 191
                '#theme' => 'item_list',
175
                '#items' => array($value),
192
                '#items' => $value['children'],
176 193
                '#type' => 'ul');
177 194
            $output = drupal_render($renderArray);
178
//            $specimen_table['#rows'][] = array(
179
//                // An array of table rows. collabsible row
180
//                'data' => "",
181
//                'class' => array('expand_column')
182
//            );
195

  
183 196
            $specimen_table['#rows'][] = array(
184
                // An array of table rows. Every row is an array of cells, or an associative array
185
                'data' => array($output),
186
                'class' =>  array(
187
                    'descriptionElement',
188
                    'descriptionElement_IndividualsAssociation'
189
                ),
190
            );
197
                'data' =>array(
198
                    array(
199
                        'data' => $expand_icon . $collapse_icon,
200
                        'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
201
                    ),
202
                    $value['data']),
191 203

  
204
                'id' => 'label' . $rowcount, // summary row id
205
                'class' => array('summary_row'),
206
            );
207
            $specimen_table['#rows'][] = array(
208
                'data' =>  array(
209
                        array(
210
                            'data' => "", //empty first column
211
                            'class' => array('expand_column')
212
                        ),
213
                        array(
214
                        'data' => $output
215

  
216
                        )
217
                    ),
218
                    'class' =>  array('detail_row')
219
//                'class' =>  array(
220
//                    'descriptionElement',
221
//                    'descriptionElement_IndividualsAssociation'
222
 //               ),
223
            );
224
            $rowcount++;
192 225

  
193 226
        }
227
        drupal_add_js_rowToggle("#".$tableId);
194 228

  
195 229
        $render_array['specimen_list'] = $specimen_table;
196 230

  
modules/cdm_dataportal/theme/cdm_dataportal.page.theme
99 99
        $out .= "Specimen ";
100 100
    }
101 101

  
102
  if($collection){
103
    $out .= $collection." ";
104
  }
105
  $out .= $specimenID;
102
    if($collection){
103
        $out .= $collection." ";
104
    }
105
    $out .= $specimenID;
106 106

  
107
  RenderHints::popFromRenderStack();
107
    RenderHints::popFromRenderStack();
108

  
109
    return '<span class="' . $specimen->class . '">' . $out . '</span>';
110
}
111

  
112
/**
113
 * Returns HTML for the default title of a specimen page.
114
 *  * The returned title is a the identifier of the specimen.
115
 *
116
 * @param array $variables
117
 *   An associative array containing:
118
 *   - specimen: The specimen being formatted for the title.
119
 *
120
 * @return string
121
 *  Markup for the title of a specimen page
122
 *
123
 * @ingroup themeable
124
 */
125
function theme_cdm_specimen_dto_page_title($variables)
126
{
127

  
128
    $specimen = $variables['specimen'];
129
    RenderHints::pushToRenderStack('specimen_page_title');
130
    $referenceUri = '';
131
    $out = '';
132

  
133
    $collection = null;
134
    if (!($specimen->class == 'FieldUnit')) {
135
        if ($specimen->collection) {
136
            if ($specimen->collection->code) {
137
                $collection = $specimen->collection->code;
138
            } elseif ($specimen->collection->name) {
139
                $collection = $specimen->collection->name;
140
            }
141
        }
142
        if ($specimen->accessionNumber) {
143
            $specimenID = $specimen->accessionNumber;
144
        } elseif ($specimen->barcode) {
145
            $specimenID = $specimen->barcode;
146
        } elseif ($specimen->catalogNumber) {
147
            $specimenID = $specimen->catalogNumber;
148
        } elseif ($specimen->titleCache) {
149
            $specimenID = $specimen->titleCache;
150
        }
151
        if (!isset($specimenID) and !isset($collection)) {
152
            $specimenID = $specimen->uuid;
153
        }
154
    }else{
155
        if ($specimen->titleCache) {
156
            $specimenID = $specimen->titleCache;
157
        }
158
        if (!isset($specimenID) and !isset($collection)) {
159
            $specimenID = $specimen->uuid;
160
        }
161
    }
162

  
163
    if ($specimen ->class == 'FieldUnit'){
164
        $out .= "FieldUnit ";
165
    }else{
166
        $out .= "Specimen ";
167
    }
168

  
169
    if($collection){
170
        $out .= $collection." ";
171
    }
172
    $out .= $specimenID;
173

  
174
    RenderHints::popFromRenderStack();
108 175

  
109
  return '<span class="' . $specimen->class . '">' . $out . '</span>';
176
    return '<span class="' . $specimen->class . '">' . $out . '</span>';
110 177
}
111 178

  
112 179
/**

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)