Project

General

Profile

« Previous | Next » 

Revision 93ae67cc

Added by Patrick Plitzner almost 7 years ago

Implemented auto suggest for taxon search in data portal #5890

View differences:

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