Project

General

Profile

Revision 93ae67cc

ID93ae67ccec3c00088748de7dde2f6ff44cee74ec
Parent fab2c158
Child 6e842c77

Added by Patrick Plitzner over 5 years ago

Implemented auto suggest for taxon search in data portal #5890

View differences:

modules/cdm_dataportal/cdm_api/webservice_uris.php
49 49
define('CDM_WS_PORTAL_TAXON_TAXONNODES', 'portal/taxon/$0/taxonNodes');
50 50
define('CDM_WS_PORTAL_TAXON_FIND', 'portal/taxon/find');
51 51
define('CDM_WS_PORTAL_TAXON_SEARCH', 'portal/taxon/search');
52
define('CDM_WS_TAXON_SEARCH', 'taxon/search');
52 53
define('CDM_WS_PORTAL_TAXON_FINDBY_DESCRIPTIONELEMENT_FULLTEXT', 'portal/taxon/findByDescriptionElementFullText');
53 54

  
54 55
/**
modules/cdm_dataportal/cdm_dataportal.module
610 610
        'page arguments' => array(2, "experts")
611 611
    , // Expected callback arguments: taxon_uuid.
612 612
    );
613

  
614
    $items['cdm_dataportal/taxonSearch/autocomplete'] = array(
615
        'page callback' => 'cdm_dataportal_taxaon_search_autocomplete',
616
        'access arguments' => array('access taxon search autocomplete'),
617
        'type' => MENU_CALLBACK
618
    );
613 619
  }
614 620

  
615 621
  // --- refresh link for all cdmnode types
modules/cdm_dataportal/cdm_dataportal.search.php
90 90
    '#description' => $query_field_description,
91 91
    '#value' => $query_field_default_value,
92 92
    // '#description' => $query_field_description,
93
    '#autocomplete_path' => 'cdm_dataportal/taxonSearch/autocomplete'
93 94
  );
94 95

  
95
  $form['search'] = array(
96
    $form['search'] = array(
96 97
    '#weight' => 3,
97 98
    '#tree' => TRUE,
98 99
    // '#type' => $advanced_form ? 'fieldset': 'hidden',
......
118 119
  return $form;
119 120
}
120 121

  
121
/**
122
function cdm_dataportal_taxaon_search_autocomplete($string) {
123
  $matches = array();
124

  
125
  $queryParams = array();
126
  $queryParams['query'] = $string."*";
127
  $queryParams['pageNumber'] = '0';
128
  $queryParams['pageSize'] = '100';
129
  $queryParams['doTaxa'] = true;
130
  $queryParams['doSynonyms'] = true;
131
  $queryParams['doMisappliedNames'] = true;
132
  $queryParams['doTaxaByCommonNames'] = true;
133

  
134
  $search_results = cdm_ws_get(CDM_WS_TAXON_SEARCH, NULL, queryString($queryParams));
135
  foreach($search_results->records as $record){
136
      $titleCache = $record->entity->titleCache;
137
      preg_match('/(.*) sec.*/', $titleCache, $trimmedTitle);//remove sec reference
138
      $trimmedTitle = trim($trimmedTitle[1]);
139
      $matches[$trimmedTitle] = $trimmedTitle;
140
  }
141
  drupal_json_output($matches);
142
}
143

  
144

  
145
  /**
122 146
 * Creates a search form for searching on taxa.
123 147
 *
124 148
 * If advanced $advanced_form id TRUE the form will offer additional choices

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)