Project

General

Profile

Revision 6eaec849

ID6eaec8496bd0ce44b1ac261c6d0db7c3734f951d
Parent 9a7fc46c
Child 55a557d8

Added by Katja Luther over 1 year ago

implement blast search table for the result

View differences:

modules/cdm_dataportal/cdm_api/cdm_node.php
35 35
  // See cdm_add_node_content.
36 36
  switch ($node->type) {
37 37
    case 'cdm_' . NODETYPE_TAXON:
38
    case 'cdm_' . NODETYPE_SPECIMEN:
38 39
    case 'cdm_' . NODETYPE_NAME:
39 40
    case 'cdm_' . NODETYPE_REFERENCE:
40 41
    case 'cdm_' . NODETYPE_MEDIA:
modules/cdm_dataportal/cdm_api/webservice_uris.php
57 57
define('CDM_WS_PORTAL_TAXON_FINDBY_DESCRIPTIONELEMENT_FULLTEXT', 'portal/taxon/findByDescriptionElementFullText');
58 58

  
59 59

  
60

  
60 61
define('CDM_WS_TAXONNODE', 'taxonNode/$0');
61 62

  
62 63
/**
......
127 128

  
128 129
define('CDM_WS_OCCURRENCE', 'occurrence');
129 130
define('CDM_WS_PORTAL_OCCURRENCE', 'portal/occurrence');
131
define('CDM_WS_OCCURRENCE_ACCESSION_NUMBER', 'occurrence/byGeneticAccessionNumber');
130 132
/**
131 133
 * url query parameters:
132 134
 *
modules/cdm_dataportal/cdm_dataportal.module
431 431
  );
432 432

  
433 433
  $items['cdm_dataportal/occurrence'] = array(
434
      'page callback' => 'cdm_dataportal_specimen_page_view',
435
      'access arguments' => array('access cdm content'),
436
      'type' => MENU_CALLBACK,
437
      // Expected callback arguments: uuid.
438
  );
434
        'page callback' => 'cdm_dataportal_specimen_page_view',
435
        'access arguments' => array('access cdm content'),
436
        'type' => MENU_CALLBACK,
437
        // Expected callback arguments: uuid.
438
    );
439 439

  
440
    $items['cdm_dataportal/specimen/accession_number'] = array(
441
        'page callback' => 'cdm_dataportal_specimen_by_accession_number_page_view',
442
        'access arguments' => array('access cdm content'),
443
        'type' => MENU_CALLBACK,
444
        // Expected callback arguments: accession number.
445
    );
440 446
  $items['cdm_dataportal/named_area'] = array(
441 447
    'page callback' => 'cdm_dataportal_named_area_page_view',
442 448
    'access arguments' => array('access cdm content'),
......
499 505
    'access arguments' => array('access cdm content'),
500 506
    'type' => MENU_DEFAULT_LOCAL_TASK,
501 507
  );
502

  
508
if (variable_get(CDM_BLAST)) {
503 509
    $items['cdm_dataportal/search/blast'] = array(
504 510
        'title' => 'Blast', // will be passed through t()
505 511
        'page callback' => 'cdm_dataportal_view_search_blast',
506 512
        'access arguments' => array('access cdm content'),
507 513
        'type' => MENU_DEFAULT_LOCAL_TASK,
508 514
    );
509

  
515
}
510 516
  $items['cdm_dataportal/search/taxon_by_description'] = array(
511 517
    'title' => 'By content category', // will be passed through t()
512 518
    'page callback' => 'cdm_dataportal_view_search_taxon_by_description',
......
815 821

  
816 822
      if (variable_get('cdm_dataportal_show_advanced_search', 1)) {
817 823
        $block['content'] .= '<div>' . l(t('Advanced Search'), 'cdm_dataportal/search') . '</div>';
818
       // $block['content'] .= '<div>' . l(t('Blast Search'), 'cdm_dataportal/search/blast') . '</div>';
824
      }
825
      if (variable_get(CDM_BLAST)){
826
          $block['content'] .= '<div>' . l(t('Blast Search'), 'cdm_dataportal/search/blast') . '</div>';
819 827
      }
820 828
      return $block;
821 829
    case '4':
......
1588 1596

  
1589 1597
  return $taxonpage;
1590 1598
}
1599
function cdm_dataportal_specimen_by_accession_number_page_view($accession_number)
1600
{
1601
    if (isset($accession_number)) {
1602
        $specimen_or_observation = cdm_ws_get(CDM_WS_OCCURRENCE_ACCESSION_NUMBER, null, 'accessionNumber=' . $accession_number);
1603

  
1604
        if (isset($specimen_or_observation) && $specimen_or_observation){
1605
            cdm_dataportal_specimen_page_view($specimen_or_observation->uuid, $specimen_or_observation);
1606
        }
1591 1607

  
1608
    }
1609
}
1592 1610
/**
1593 1611
 * Creates a specimen page view.
1594 1612
 * @param string $uuid the UUID of the specimen
......
2085 2103
    }
2086 2104
}
2087 2105

  
2106
function path_to_specimen_by_accession_number($accession_number) {
2107

  
2108
    if (!$accession_number) {
2109
        return FALSE;
2110
    }
2111
    else {
2112
        return 'cdm_dataportal/specimen/accession_number/' . $accession_number;
2113
    }
2114
}
2115

  
2088 2116
function path_to_named_area($uuid) {
2089 2117

  
2090 2118
  if (!$uuid) {
modules/cdm_dataportal/cdm_dataportal.search.php
165 165
 * @return array
166 166
 *   the form array
167 167
 */
168
function cdm_dataportal_search_taxon_form($form, &$form_state, $advanced_form = FALSE, $classification_select = TRUE) {
168
function cdm_dataportal_search_taxon_form($form, &$form_state, $advanced_form = FALSE, $classification_select = TRUE)
169
{
169 170

  
170
  $query_field_default_value = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
171
    if ($form_state['build_info']['form_id'] == 'cdm_dataportal_search_blast_form') {
172
        $form = cdm_dataportal_search_blast_form($form, $form_state);
173
    } else {
171 174

  
172
  if ($advanced_form || variable_get(SIMPLE_SEARCH_USE_LUCENE_BACKEND, FALSE)) {
173
    $search_service_endpoint = CDM_WS_PORTAL_TAXON_SEARCH;
174
  }
175
  else {
176
    $search_service_endpoint = CDM_WS_PORTAL_TAXON_FIND;
177
  }
178 175

  
179
  $form = cdm_dataportal_search_form_prepare(
180
    'cdm_dataportal/search/results/taxon',
181
    $search_service_endpoint,
182
    $query_field_default_value,
183
    t('Enter the name or part of a name you wish to search for.
184
      The asterisk  character * can be used as wildcard, but must not be used as first character.')
185
  );
176
        $query_field_default_value = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
186 177

  
178
        if ($advanced_form || variable_get(SIMPLE_SEARCH_USE_LUCENE_BACKEND, FALSE)) {
179
            $search_service_endpoint = CDM_WS_PORTAL_TAXON_SEARCH;
180
        } else {
181
            $search_service_endpoint = CDM_WS_PORTAL_TAXON_FIND;
182
        }
183

  
184
        $form = cdm_dataportal_search_form_prepare(
185
            'cdm_dataportal/search/results/taxon',
186
            $search_service_endpoint,
187
            $query_field_default_value,
188
            t('Enter the name or part of a name you wish to search for.
189
          The asterisk  character * can be used as wildcard, but must not be used as first character.')
190
        );
191
    }
187 192
  if (!$advanced_form) {
188 193
    $form['query']['#size'] = 20;
189 194
  }
......
386 391
}
387 392

  
388 393
/**
394
 * Creates a search form for searching on taxa.
395
 *
396
 * If advanced $advanced_form id TRUE the form will offer additional choices
397
 *
398
 * @param array $form
399
 *   A drupal form array
400
 * @param array $form_state
401
 *   The drupal form state passed as reference
402
 * @param bool $advanced_form
403
 *   default is FALSE
404
 * @param bool $classification_select
405
 *   set TRUE to offer a classification selector in the form - default is FALSE
406
 *   if only available in the advanced mode
407
 *
408
 * @return array
409
 *   the form array
410
 */
411
function cdm_dataportal_search_blast_form($form, &$form_state) {
412

  
413
    $query_field_default_value = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
414

  
415
    $search_service_endpoint = CDM_WS_PORTAL_BLAST;
416

  
417

  
418
    $form = cdm_dataportal_search_blast_form_prepare(
419
        'cdm_dataportal/search/results/specimen',
420
        $search_service_endpoint,
421
        $query_field_default_value,
422
        t('Enter the sequence or part of a sequence you wish to search for.')
423
    );
424

  
425

  
426

  
427
    $form['search']['pageSize'] = array(
428
        '#weight' => -1,
429
        '#type' => 'hidden',
430
        '#value' => variable_get('cdm_dataportal_search_items_on_page', 25),
431
    );
432

  
433
    $form['search']['pageNumber'] = array(
434
        '#weight' => -1,
435
        '#type' => 'hidden',
436
        '#value' => 0,
437
    );
438

  
439

  
440

  
441

  
442

  
443
    return $form;
444
}
445

  
446
/**
447
 * Prepares a form array for a general purpose search form.
448
 *
449
 * The form is used for general purpose search functionality in the
450
 * dataportal. The form returned is populated with all necessary fields
451
 * for internal processing and has the textfield element $form['query']
452
 * which holds the query term.
453
 *
454
 * @param string $action_path
455
 *   The Drupal path to be put into the action url to which the form will
456
 *   be submitted.
457
 * @param string $search_webservice
458
 *   The cdm-remote webservice to be used, valid values are defined by
459
 *   the constants: FIXME.
460
 * @param string $query_field_default_value
461
 *   A default text for the query field
462
 * @param string $query_field_description
463
 *   The description text for the query field
464
 * @param string $process
465
 *   The value for #process, if NULL (default), 'cdm_dataportal_search_process'
466
 *   is used.
467
 *
468
 * @return array
469
 *   The prepared form array.
470
 */
471
function cdm_dataportal_search_blast_form_prepare($action_path, $search_webservice, $query_field_default_value, $query_field_description, $process = NULL) {
472

  
473
    if ($process == NULL) {
474
        $process = 'cdm_dataportal_search_process';
475
    }
476

  
477
    $form['#method'] = 'get';
478
    //
479
    //  $form['#process'] = array(
480
    //  $process => array(),
481
    //  );
482
    //
483
    $form['#action'] = url($action_path, array(
484
        'absolute' => TRUE,
485
    ));
486

  
487
    $form['ws'] = array(
488
        '#type' => 'hidden',
489
        '#value' => $search_webservice,
490
        '#name' => 'ws',
491
    );
492

  
493
    $form['query'] = array(
494
        '#weight' => 0,
495
        '#type' => 'textarea',
496
        '#size' => 68,
497
        // This causes the description to display also when hovering over
498
        // the textfield.
499
        // This is wanted behaviour for the simple seach but could
500
        // be disabled for the advances search.
501
        '#attributes' => array(
502
            'title' => $query_field_description,
503
        ),
504
        '#description' => $query_field_description,
505
       // '#value' => $query_field_default_value,
506
        // '#description' => $query_field_description,
507
    );
508

  
509

  
510
    $form['search'] = array(
511
        '#weight' => 3,
512
        '#tree' => TRUE,
513
        // '#type' => $advanced_form ? 'fieldset': 'hidden',
514
        '#title' => t('Options'),
515
    );
516

  
517
    // Clean URL get forms breaks if we don't give it a 'q'.
518
    if (!(bool) variable_get('clean_url', '0')) {
519
        $form['search']['q'] = array(
520
            '#type' => 'hidden',
521
            '#value' => $action_path,
522
            '#name' => 'q',
523
        );
524
    }
525

  
526
    $form['search']['word_size'] = array(
527
        '#weight' => 1,
528
        '#type' => 'textfield',
529
        '#title' => t('Word size'),
530
        '#default_value' => 7,
531
        '#description' => t('Length of initial exact match'),
532
    );
533

  
534
    $form['search']['reward'] = array(
535
        '#weight' => 2,
536
        '#type' => 'textfield',
537
        '#title' => t('Reward'),
538
        '#default_value' => 1,
539
        '#description' => t('Reward for Matching'),
540
    );
541

  
542
    $form['search']['penalty'] = array(
543
        '#weight' => 3,
544
        '#type' => 'textfield',
545
        '#title' => t('Penalty'),
546
        '#default_value' => -2,
547
        '#description' => t('Penalty for mismatching'),
548
    );
549

  
550
    $form['search']['gap_open'] = array(
551
        '#weight' => 4,
552
        '#type' => 'textfield',
553
        '#title' => t('Gap open'),
554
        '#default_value' => 5,
555
        '#description' => t('Cost to open a gap'),
556
    );
557

  
558
    $form['search']['gap_extend'] = array(
559
        '#weight' => 5,
560
        '#type' => 'textfield',
561
        '#title' => t('Gap extend'),
562
        '#default_value' => -2,
563
        '#description' => t('Cost for extend a gap'),
564
    );
565

  
566
    $form['submit'] = array(
567
        '#weight' => 5,
568
        '#type' => 'submit',
569
        '#name' => '',
570
        '#value' => t('Search'),
571
    );
572

  
573
    return $form;
574
}
575
/**
389 576
 * Wrapper function for cdm_dataportal_search_taxon_form().
390 577
 *
391 578
 * This function makes ot possible possible to just pass the
......
582 769
}
583 770

  
584 771
/**
772
 * Processes the query parameters of the blast search form.
773
 *
774
 * Reads the query parameters from $_REQUEST and modifies and adds additional
775
 * query parameters if necessary.
776
 *
777
 *  - Filters $_REQUEST by a list of valid request parameters
778
 *
779
 *
780
 * @param $search_endpoint string
781
 *    The web service endpoint which will be used for executing the search.
782
 *
783
 * @return array
784
 *   the processed request parameters submitted by the search form and
785
 *   also stores them in $_SESSION['cdm']['search']
786
 */
787
function cdm_dataportal_blast_search_request($search_endpoint)
788
{
789

  
790
    $form_params = array();
791

  
792
    if (isset($_REQUEST['search']) && is_array($_REQUEST['search'])) {
793
        array_deep_copy($_REQUEST['search'], $form_params['data']);
794
    }
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

  
807
    // Store in session.
808
    $_SESSION['cdm']['search'] = $form_params;
809

  
810
    return $form_params;
811
}
812

  
813

  
814

  
815
/**
585 816
 * Provides the classification to which the last search has been limited to..
586 817
 *
587 818
 * This function should only be used after the cdm_dataportal_search_taxon_execute()
......
669 900
  return $taxon_pager;
670 901
}
671 902

  
903
/**
904
 * Sends a search request to the cdm server.
905
 *
906
 * The parameters to build the query are taken obtained by calling
907
 * cdm_dataportal_search_request() which reads the query parameters
908
 * from $_REQUEST and add additional query parameters if nessecary.
909
 *
910
 * @see cdm_dataportal_search_request()
911
 */
912
function cdm_dataportal_search_blast_execute() {
913

  
914
    // Store as last search in session.
915
    $_SESSION['cdm']['last_blast_search'] = $_SERVER['REQUEST_URI'];
916

  
917
    // Validate the search webservice parameter:
918
    if (!isset($_REQUEST['ws'])) {
919
        drupal_set_message(
920
            t("Invalid search, webservice parameter 'ws' is missing"), 'warning'
921
        );
922
        return NULL;
923
    }
924
//    if (!cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
925
//        // Endpoint is unknown.
926
//        drupal_set_message(
927
//            t("Invalid search webservice parameter 'ws' given"), 'warning'
928
//        );
929
//        return NULL;
930
//    }
931

  
932
    // Read the query parameters from $_REQUEST and add additional query
933
    // parameters if necessary.
934
    $request_params = cdm_dataportal_blast_search_request($_REQUEST['ws']);
935
   // $url = drupal_http_build_query($_REQUEST['ws'], $request_params);
936

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

  
939
    return $taxon_pager;
940
}
941

  
942

  
672 943

  
673 944
/**
674 945
 * Sends a request for a registrations filter search to the cdm server.
modules/cdm_dataportal/includes/common.inc
587 587
  return $extensions_render_array;
588 588
}
589 589

  
590
function formatParams($params) {
591
    if (is_array($params)){
592
        $keys =array_keys($params);
593
        $paramString = '';
594
        foreach ($keys as $k ){
595
            if ($k != 'pageNumber' && $k != 'pageSize'){
596
                $paramString .= ' -'.$k.'='.urlencode($params[$k]);
597
            }
598
        }
599
    }
600
    return $paramString;
601
}
590 602

  
modules/cdm_dataportal/includes/media.inc
353 353
      $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
354 354
      if (isset($complete_media->representations[0]->parts[0])) {
355 355

  
356
        //
357
        // Find preferred representation.
358
        //
359

  
360
        $thumbnail_representations = cdm_preferred_media_representations($complete_media, array(
361
            'image/jpg',
362
            'image/jpeg',
363
            'image/png',
364
            'image/gif',
356
          //
357
          // Find preferred representation.
358
          //
359

  
360
          $thumbnail_representations = cdm_preferred_media_representations($complete_media, array(
361
              'image/jpg',
362
              'image/jpeg',
363
              'image/png',
364
              'image/gif',
365 365
          ),
366
          $maxExtend,
367
          $maxExtend
368
        );
369
        // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
370
        // which only contains the thumbnail representation even if the height and width filters are not set.
371
        // --> #6970
372
        // to get hold of the full resolution images we send a separate request :
373
       // $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
374
        $full_size_representations = cdm_preferred_media_representations($complete_media, array(
375
            'image/jpg',
376
            'image/jpeg',
377
            'image/png',
378
            'image/gif',
379
          )
380
        );
381
        if (count($thumbnail_representations) == 0) {
382
          // Fallback to using the first one in the list.
383
          $thumbnail_representations = $media->representations;
384
          $full_size_representations = $media->representations;
385
        }
386
        $thumbnail_representation = array_shift($thumbnail_representations);
387
        $full_size_representation = array_shift($full_size_representations);
388

  
389
        // $preferred_media_representation->parts[0]->uri =
390
        // "http://127.0.0.1/images/palmae/palm_tc_14415_1.jpg";
391
        $contentTypeDirectory = media_content_type_dir($thumbnail_representation, 'application');
392

  
393
        $mediaPartHtml = call_user_func_array(
394
          'cdm_media_gallerie_' . $contentTypeDirectory,
395
          array( $thumbnail_representation->parts[0], $maxExtend, TRUE)
396
        );
397
        // --- Compose Media Link.
398
        $mediaLinkUri = FALSE;
399
        if ($alternativeMediaUri) {
400
          if (isset($alternativeMediaUri[$mediaIndex])) {
401
            $mediaLinkUri = $alternativeMediaUri[$mediaIndex];
366
              $maxExtend,
367
              $maxExtend
368
          );
369
          // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
370
          // which only contains the thumbnail representation even if the height and width filters are not set.
371
          // --> #6970
372
          // to get hold of the full resolution images we send a separate request :
373
          // $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
374
          $full_size_representations = cdm_preferred_media_representations($complete_media, array(
375
                  'image/jpg',
376
                  'image/jpeg',
377
                  'image/png',
378
                  'image/gif',
379
              )
380
          );
381
          if (count($thumbnail_representations) == 0) {
382
              // Fallback to using the first one in the list.
383
              $thumbnail_representations = $media->representations;
384
              $full_size_representations = $media->representations;
402 385
          }
403
          if (is_string($alternativeMediaUri)) {
404
            $mediaLinkUri = $alternativeMediaUri;
386
          $thumbnail_representation = array_shift($thumbnail_representations);
387
          $full_size_representation = array_shift($full_size_representations);
388

  
389
          // $preferred_media_representation->parts[0]->uri =
390
          // "http://127.0.0.1/images/palmae/palm_tc_14415_1.jpg";
391
          $contentTypeDirectory = media_content_type_dir($thumbnail_representation, 'application');
392

  
393
          $mediaPartHtml = call_user_func_array(
394
              'cdm_media_gallerie_' . $contentTypeDirectory,
395
              array($thumbnail_representation->parts[0], $maxExtend, TRUE)
396
          );
397
          // --- Compose Media Link.
398
          $mediaLinkUri = FALSE;
399
          if ($alternativeMediaUri) {
400
              if (isset($alternativeMediaUri[$mediaIndex])) {
401
                  $mediaLinkUri = $alternativeMediaUri[$mediaIndex];
402
              }
403
              if (is_string($alternativeMediaUri)) {
404
                  $mediaLinkUri = $alternativeMediaUri;
405
              }
406
          } else {
407
              $mediaLinkUri = $full_size_representation->parts[0]->uri;
405 408
          }
406
        }
407
        else {
408
          $mediaLinkUri = $full_size_representation->parts[0]->uri;
409
        }
410
        $mediaIndex++;
411

  
412
        // media captions will be loaded via AHAH
413
        _add_js_ahah();
414
        $content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid);
415
        $cdm_proxy_url_caption = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements));
416
        $ahah_media_caption =  '<div class="ahah-content" data-cdm-ahah-url="' . $cdm_proxy_url_caption . '">'
417
          . '<span class="loading" style="display: none;">' . loading_image_html() . '</span></div>';
418

  
419
        // preparing the part link (= click on image itself) which can be handled in two ways
420
        //
421
        //  1. open image in lightbox, the captions in the lightbox will be loaded via AHAH
422
        //  2. open the media in a new window with target 'specimen'
423
        if ($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image') {
424
          $mediaPartLinkAttributes['class'] = array('lightbox');
425
        } else {
426
          $mediaPartLinkAttributes['target'] = "specimen";
427
          $openMediaLinkAttributes['target'] = "specimen";
428
        }
429
        $mediaPartLinkAttributes['alt'] = htmlentities($ahah_media_caption);
430

  
431
        // --- preparing the media caption
432

  
433
        /* old comment: "no caption elements to show up here except the $caption_link_uri, if at all"
434
         *
435
         * a.kohlbecker 2013-03-14 :
436
         *   It is unclear why no caption elements should be shown, Was it a technical reason?
437
         *   see commit r16723 740177eb-a1d8-4ec3-a630-accd905eb3da
438
         *   If not problems arise with this remove it after some weeks
439
         */
440
        $captionPartHtml = $ahah_media_caption;
441

  
442
        if ($caption_link_uri) {
443
          if ($contentTypeDirectory == 'image') {
444
            // it is an image, so open it in the media page
445
            $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, path_to_media($media->uuid), array(
446
                'attributes' => array(), 'html' => TRUE,
447
              )) . '</div>';
409
          $mediaIndex++;
410

  
411
          // media captions will be loaded via AHAH
412
          _add_js_ahah();
413
          $content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid);
414
          //if $captionElements == null, set $captionPartHtml = '' otherwise the loading image is shown but nothing is loaded.
415
          if ($captionElements) {
416

  
417
              $cdm_proxy_url_caption = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements));
418
              $ahah_media_caption = '<div class="ahah-content" data-cdm-ahah-url="' . $cdm_proxy_url_caption . '">'
419
                  . '<span class="loading" style="display: none;">' . loading_image_html() . '</span></div>';
420

  
421
            // preparing the part link (= click on image itself) which can be handled in two ways
422
            //
423
            //  1. open image in lightbox, the captions in the lightbox will be loaded via AHAH
424
            //  2. open the media in a new window with target 'specimen'
425
            if ($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image') {
426
              $mediaPartLinkAttributes['class'] = array('lightbox');
427
            } else {
428
              $mediaPartLinkAttributes['target'] = "specimen";
429
              $openMediaLinkAttributes['target'] = "specimen";
430
            }
431
            $mediaPartLinkAttributes['alt'] = htmlentities($ahah_media_caption);
432

  
433
            // --- preparing the media caption
434

  
435
            /* old comment: "no caption elements to show up here except the $caption_link_uri, if at all"
436
             *
437
             * a.kohlbecker 2013-03-14 :
438
             *   It is unclear why no caption elements should be shown, Was it a technical reason?
439
             *   see commit r16723 740177eb-a1d8-4ec3-a630-accd905eb3da
440
             *   If not problems arise with this remove it after some weeks
441
             */
442
            $captionPartHtml = $ahah_media_caption;
443
          }else{
444
              $captionPartHtml = '';
448 445
          }
449
          else {
450
            // otherwise open it directly and let the the browser handle the media type
451
            $openMediaLinkAttributes['absolute'] = TRUE;
452
            $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, $mediaLinkUri, array(
453
                'attributes' => $openMediaLinkAttributes, 'html' => TRUE,
454
              )) . '</div>';
446
          if ($caption_link_uri) {
447
              if ($contentTypeDirectory == 'image') {
448
                // it is an image, so open it in the media page
449

  
450
                $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, path_to_media($media->uuid), array(
451
                    'attributes' => array(), 'html' => TRUE,
452
                        )) . '</div>';
453

  
454

  
455
              }
456
              else {
457
                // otherwise open it directly and let the the browser handle the media type
458
                $openMediaLinkAttributes['absolute'] = TRUE;
459
                $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, $mediaLinkUri, array(
460
                    'attributes' => $openMediaLinkAttributes, 'html' => TRUE,
461
                  )) . '</div>';
462
              }
455 463
          }
456
        }
457 464

  
458
        $captionParts[] = $captionPartHtml;
465
          $captionParts[] = $captionPartHtml;
459 466

  
460
        // --- Surround imagePart with link, this .
461
        if ($doLink) {
462
          $mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, array(
463
            'attributes' => $mediaPartLinkAttributes, 'html' => TRUE,
464
          ));
465
        }
467
            // --- Surround imagePart with link, this .
468
          if ($doLink) {
469
            $mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, array(
470
                'attributes' => $mediaPartLinkAttributes, 'html' => TRUE,
471
            ));
472
          }
466 473
      }
467 474
      else {
468 475
        $mediaPartHtml = '';
modules/cdm_dataportal/includes/occurrences.inc
41 41
    ));
42 42
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
43 43
    $captionElements = array(
44
        'title',
44 45
        '#uri' => t('open media'),
45 46
    );
46 47
    if (isset($specimen->fieldObjectMediaDTO) ) {
......
260 261
            }
261 262
        }
262 263

  
264

  
265

  
263 266
        $gallery_html = compose_cdm_media_gallerie(array(
264 267
            'mediaList' => $images,
265 268
            'galleryName' => $galleryName,
......
268 271
            'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
269 272
            'captionElements' => $captionElements,
270 273
            'mediaLinkType' => 'LIGHTBOX',
271
            'alternativeMediaUri' => $alternativeMediaUris,
274
          // 'alternativeMediaUri' => $alternativeMediaUris,
275
            'alternativeMediaUri' => NULL,
272 276
            'galleryLinkUri' => NULL,
273 277
        ));
274 278
    }
......
462 466
                            $taxon_name = '';
463 467
                            $name_link = '';
464 468
                            if ($determinationEvent->taxonName) {
465
                                $taxon_name = $determinationEvent->taxonName;
466
                            } else if ($determinationEvent->taxon) {
467
                                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
468
                                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
469
                                $taxon_name = cdm_ws_get(CDM_WS_NAME, $determinationEvent->taxonName->uuid);
470
                                $taxon_name->taggedName = cdm_ws_get(CDM_WS_NAME, array($determinationEvent->taxonName->uuid, "taggedName"));
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);
469 475
                            }
470 476
                            if ($taxon_name) {
471 477
                                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
......
1033 1039
            }
1034 1040
        }
1035 1041

  
1036
        $title = $type_label . ': ' . $specimen_or_observation->titleCache;
1042
        if (isset($typeDesignation)){
1043
            $title = $type_label . ' for: ' . $typeDesignation->typifiedNames;
1044
        }else{
1045
            $title = $type_label;
1046
        }
1047

  
1037 1048
        $items['data'] = $title;
1038 1049

  
1039 1050
        $groups = array();
......
1074 1085

  
1075 1086
                    case 'listOfMedia':
1076 1087
                        $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
1088

  
1077 1089
                        $captionElements = array(
1090
                            'title',
1078 1091
                            '#uri' => t('open media'),
1079 1092
                        );
1080 1093
                        $gallery_html = compose_cdm_media_gallerie(array(
......
1087 1100
                            'mediaLinkType' => 'LIGHTBOX',
1088 1101
                            'alternativeMediaUri' => NULL,
1089 1102
                            'galleryLinkUri' => NULL,
1103
                            'showCaption' => true
1090 1104
                        ));
1091 1105

  
1092 1106
                         //@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
......
1232 1246
    return $output;
1233 1247
}
1234 1248

  
1249
function compose_table_of_blast_result(array $data){
1250

  
1251
    foreach ($data as $row_data){
1252
        $pathToSpecimen = path_to_specimen_by_accession_number($row_data['id']);
1253
        $specimenPageLink = l($row_data['id'], $pathToSpecimen, array('attributes' => array('target' => '_blank')));
1254

  
1255
        $rows[] =  array(
1256
            'data' => array(
1257
                array(
1258
                    'data' => $row_data['def'],
1259
                ),
1260
                array(
1261
                    'data' => $specimenPageLink,
1262
                ),
1263
                array(
1264
                    'data' => $row_data['hsp_align_length'],
1265
                ),
1266
              //  array(
1267
              //     'data' => $row_data['midline'],
1268
              //  ),
1269
                array(
1270
                    'data' => $row_data['hsp_evalue'],
1271
                )
1272
            )
1273
        );
1274
    }
1275
    $tableId = "blast_result_table";
1276
    $blast_result_table = array(
1277
        "#theme" => "table",
1278
        "#weight" => 2,
1279
        "#header" => array(
1280
                        "Name", "id", "Align Length", "e Value"),
1281
        "#rows" => $rows,
1282
        "#attributes" => array(
1283
            "id" => $tableId,
1284
            "border" => 2
1285
        )
1286
    );
1287

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

  
1290
    $render_array['content'] = $blast_result_table;
1291
    $out = drupal_render($render_array);
1292
   //$blast_result_page-> content = drupal_render($render_array);
1293
   return $out;
1294
}
1295

  
1296

  
1297

  
modules/cdm_dataportal/includes/pages.inc
82 82
    $type_specimens = array();
83 83
    $other_occurrences = array();
84 84
    foreach ($specimensOrObservations as $occurrence) {
85
        $typeDesignationsPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $occurrence->uuid);
85
       $typeDesignationsPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $occurrence->uuid);
86 86
        if (isset($typeDesignationsPager->count) && $typeDesignationsPager->count > 0) {
87 87
            $type_specimens[] = $occurrence;
88
        } else {
89
            $other_occurrences[] = $occurrence;
88
       } else {
89
           $other_occurrences[] = $occurrence;
90 90
        }
91 91
    }
92 92
    $specimensOrObservations = array_merge($type_specimens, $other_occurrences);
......
384 384
            'class' => array('summary_row_cell')
385 385
          ),
386 386
          array(
387
            'data' => $derivateHierarchy->collection,
387
            'data' => $derivateHierarchy->collectingString,
388 388
            'class' => array('summary_row_cell')
389 389
          ),
390 390
          @array(
modules/cdm_dataportal/node_types.php
9 9
define('NODETYPE_REFERENCE', 'reference');
10 10
define('NODETYPE_NAME', 'name');
11 11
define('NODETYPE_NAMED_AREA', 'named_area');
12

  
12
define('NODETYPE_SPECIMEN', 'specimen');
13 13
/**
14 14
 * Implements hook_cdm_nodetypes().
15 15
 */
......
22 22
      'cdm_' . NODETYPE_MEDIA => NODETYPE_MEDIA,
23 23
      'cdm_' . NODETYPE_NAME => NODETYPE_NAME,
24 24
      'cdm_' . NODETYPE_NAMED_AREA => NODETYPE_NAMED_AREA,
25
      'cdm_' . NODETYPE_SPECIMEN => NODETYPE_SPECIMEN,
25 26
    );
26 27
  }
27 28
  return $nodetypes;
modules/cdm_dataportal/settings.php
35 35
  define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
36 36
  define('CDM_DATAPORTAL_SPECIMEN_DERIVATE_TREE', 0);
37 37

  
38
  define('CDM_WS_PORTAL_BLAST', 'http://127.0.0.1:9001/api/sequence');
39
  define('CDM_BLAST', 0);
38 40
  define('CDM_REGISTRATION_PRESISTENT_IDENTIFIER_AS_LINK', 'cdm_registration_presistent_identifier_as_link');
39 41

  
40 42
  /* annotationTypeKeys */
......
2771 2773
    '#description' => t('Area uuids, comma separated, no whitespace. EXPERIMENTAL!!!!'),
2772 2774
  );
2773 2775

  
2776
    $form['blast_search_settings'] = array(
2777
        '#type' => 'fieldset',
2778
        '#title' => t('Blast Search'),
2779
        '#collapsible' => TRUE,
2780
        '#collapsed' => TRUE,
2781
        '#description' => t('<p>To perform blast searchs
2782
         the block <em>CDM Taxon Search</em> should be enabled and visible for users
2783
         where they can write the text to be searched. You can find Drupal block configuration
2784
         site at <a href="./?q=admin/build/block">Administer&#45&#62Site building&#45&#62Blocks</a></p>
2785
         <p>To perform a blast search a blast database for the cdm instance is needed.</p> '),
2786
    );
2787

  
2788
    $form['blast_search_settings'][CDM_BLAST] = array(
2789
        '#type' => 'checkbox',
2790
        '#title' => t('Activate Blast search') . ':',
2791
        '#default_value' => variable_get(CDM_BLAST, 0), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2792

  
2793
        '#description' => t('Activate the blast search for this portal, this works only with an existing blast database!'),
2794
    );
2795
    $form['blast_search_settings'][CDM_WS_PORTAL_BLAST] = array(
2796
        '#type' => 'textfield',
2797
        '#title' => t('Webservice URL for blast search') . ':',
2798
        '#default_value' => variable_get(CDM_WS_PORTAL_BLAST, 'http://127.0.0.1:9001/api/sequence'), // '05b0dd06-30f8-477d-bf4c-30d9def56320' =>  Caucasia (Ab + Ar + Gg + Rf(CS)) (Cc)
2799

  
2800
        '#description' => t('Enter the webservice URL for blast search'),
2801
    );
2802

  
2774 2803
  // --- SEARCH TAXA GALLERY ---- //
2775 2804
  $items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
2776 2805
  $collapsed = FALSE;
modules/cdm_dataportal/theme/cdm_dataportal.page.theme
334 334

  
335 335

  
336 336
/**
337
 * Returns HTML for the given result page including a pager.
338
 *
339
 * @param array $variables
340
 *   An associative array containing:
341
 *   - pager: TODO
342
 *   - path: The target path for the pager links, this will usually point to
343
 *     'cdm_dataportal/search/results/taxon'
344
 *
345
 * @return string
346
 *  Markup for the result page
347
 *
348
 * @throws Exception
349
 *
350
 * @ingroup themeable
351
 */
352
function theme_cdm_search_specimen_results($variables)
353
{
354
    $pager = $variables['pager'];
355
    $path = $variables['path'];
356

  
357

  
358

  
359
    // Add thumbnails checkbox and refine search link.
360
    $out = '<div class="page_options">';
361
    //if (isset($_REQUEST['ws'])) {
362
     //   if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
363
     //       $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
364
     //   }
365
    //}
366
    if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
367
        $out .= '<form name="pageoptions"><div id="showThumbnails"><input class="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Display image thumbnails') . '</div></form>';
368
    }
369
    $out .= '</div>';
370

  
371

  
372

  
373

  
374

  
375

  
376
    // List results.
377
    if (isset($pager->data) ) {
378
        $data = json_decode($pager->data, true);
379
        $out .= '<div id="search_results">';
380
        $list_of_result = compose_table_of_blast_result($data);
381
        $out .= $list_of_result;
382
        $out .= '</div>';
383
       // $out .= theme('cdm_pager', array(
384
       //     'pager' => $pager,
385
       //     'path' => $path,
386
       //     'parameters' => $_REQUEST,
387
        //));
388
    } else {
389
        $out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
390
    }
391
    return $out;
392
}
393

  
394

  
395
/**
337 396
 * TODO Implementation of Hook taxon_image_gallery()
338 397
 *
339 398
 * @param object $taxon
modules/cdm_dataportal/theme/theme_registry.inc
127 127
        'pager' => NULL,
128 128
        'path' => NULL
129 129
    )),
130
    'cdm_search_specimen_results' => array('variables' => array(
131
        'pager' => NULL,
132
        'path' => NULL
133
    )),
130 134
    'cdm_taxon_list_thumbnails' => array('variables' => array('taxon' => NULL)),
131 135

  
132 136
    // Themes in includes/pre-drupal8.inc

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)