Revision dbf4b8a8
Added by Andreas Kohlbecker about 11 years ago
7.x/modules/cdm_dataportal/cdm_dataportal.search.php | ||
---|---|---|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
/** |
117 |
* @todo document ths function. |
|
117 |
* Creates a search form for searching on taxa. |
|
118 |
* |
|
119 |
* If advanced $advancedForm id TRUE the form will offer additinal choices |
|
120 |
* |
|
121 |
* @param unknown_type $form |
|
122 |
* @param unknown_type $form_state |
|
123 |
* @param bool $advancedForm |
|
124 |
* default is FALSE |
|
125 |
* @param bool $classificationSelect |
|
126 |
* set TRUE to offer a classifiaction selector in the form - default is FALSE |
|
127 |
* if only available in the advanced mode |
|
128 |
* |
|
129 |
* @return |
|
130 |
* the form array |
|
131 |
* |
|
132 |
* |
|
118 | 133 |
*/ |
119 |
function cdm_dataportal_search_taxon_form($form, &$form_state, $advancedForm = FALSE) { |
|
134 |
function cdm_dataportal_search_taxon_form($form, &$form_state, $advancedForm = FALSE, $classificationSelect = TRUE) {
|
|
120 | 135 |
global $theme_key; |
121 | 136 |
|
122 | 137 |
$tdwg_level_select = (isset($_SESSION['cdm']['search']['tdwg_level_select']) ? $_SESSION['cdm']['search']['tdwg_level_select'] : 2); |
... | ... | |
130 | 145 |
$form['query']['#size'] = 20; |
131 | 146 |
} |
132 | 147 |
|
133 |
$form['search']['tree'] = array( |
|
134 |
'#weight' => -1, |
|
135 |
'#type' => 'hidden', |
|
136 |
'#value' => get_taxonomictree_uuid_selected(), |
|
137 |
); |
|
138 |
|
|
139 | 148 |
$form['search']['pageSize'] = array( |
140 | 149 |
'#weight' => -1, |
141 | 150 |
'#type' => 'hidden', |
... | ... | |
150 | 159 |
|
151 | 160 |
if ($advancedForm) { |
152 | 161 |
|
162 |
|
|
163 |
|
|
153 | 164 |
// Get presets from settings. |
154 | 165 |
$preset_doTaxa = variable_get('cdm_search_doTaxa', 1); |
155 | 166 |
$preset_doSynonyms = variable_get('cdm_search_doSynonyms', 1); |
... | ... | |
164 | 175 |
$preset_doMisappliedNames = (isset($_SESSION['cdm']['search']['doMisappliedNames']) ? 1 : 0); |
165 | 176 |
$preset_doTaxaByCommonNames = (isset($_SESSION['cdm']['search']['doTaxaByCommonNames']) ? 1 : 0); |
166 | 177 |
} |
178 |
|
|
179 |
|
|
180 |
if ($classificationSelect === TRUE) { |
|
181 |
$form['search']['tree'] = array( |
|
182 |
'#weight' => 1, |
|
183 |
'#type' => 'select', |
|
184 |
'#default_value' => get_taxonomictree_uuid_selected(), |
|
185 |
'#options' => cdm_get_taxontrees_as_options(), |
|
186 |
); |
|
187 |
} |
|
188 |
|
|
167 | 189 |
// General search parameters. |
168 | 190 |
$form['search']['doTaxa'] = array( |
169 | 191 |
'#weight' => 2, |
... | ... | |
244 | 266 |
var selectId = $(\"input[name='search[geographic_range][tdwg_level_select]']:checked\").val(); |
245 | 267 |
var i; |
246 | 268 |
for(i = 0; i < 4; i++){ |
247 |
|
|
269 |
|
|
248 | 270 |
if(selectId == i){ |
249 | 271 |
$('#edit-search-geographic-range-tdwg-level-' + (i + 1) ).parent().fadeIn('slow'); |
250 | 272 |
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected'); |
... | ... | |
386 | 408 |
} |
387 | 409 |
|
388 | 410 |
/** |
389 |
* Filters $_REQUEST by a list of valid request parameters and also sets |
|
390 |
* defaults if required. |
|
391 |
* returns the processed request parameters submitted by the search form and |
|
392 |
* also stores them |
|
393 |
* in $_SESSION['cdm']['search'] |
|
411 |
* Reads the query parameters from $_REQUEST and modifies and adds additional query parameters if nessecary. |
|
412 |
* |
|
413 |
* - Filters $_REQUEST by a list of valid request parameters |
|
414 |
* - modifies geographic_range parameters |
|
415 |
* - adds taxon tree uuid if it is missing and if it should not be |
|
416 |
* ignored (parameter value = 'IGNORE') |
|
417 |
* - and more |
|
418 |
* |
|
419 |
* |
|
420 |
* @return |
|
421 |
* the processed request parameters submitted by the search form and |
|
422 |
* also stores them in $_SESSION['cdm']['search'] |
|
394 | 423 |
*/ |
395 | 424 |
function cdm_dataportal_search_form_request() { |
396 | 425 |
$form_params = array(); |
... | ... | |
413 | 442 |
} |
414 | 443 |
} |
415 | 444 |
|
445 |
if (!isset($form_params['tree'])) { |
|
446 |
$form_params['tree'] = get_taxonomictree_uuid_selected(); |
|
447 |
} else if ($form_params['tree'] != 'IGNORE') { |
|
448 |
unset($form_params['tree']); |
|
449 |
} |
|
450 |
|
|
416 | 451 |
// Store in session. |
417 | 452 |
$_SESSION['cdm']['search'] = $form_params; |
418 | 453 |
|
... | ... | |
429 | 464 |
} |
430 | 465 |
|
431 | 466 |
/** |
432 |
* @todo Please document this function. |
|
433 |
* @see http://drupal.org/node/1354 |
|
467 |
* Sends a search request at the cdm web server. |
|
468 |
* |
|
469 |
* The parameters to build the query are taken obtained by calling |
|
470 |
* cdm_dataportal_search_form_request() which reads the query parameters |
|
471 |
* from $_REQUEST and add additional query parameters if nessecary. |
|
472 |
* |
|
473 |
* @see cdm_dataportal_search_form_request() |
|
474 |
* |
|
434 | 475 |
*/ |
435 | 476 |
function cdm_dataportal_search_execute() { |
436 | 477 |
|
... | ... | |
444 | 485 |
return NULL; |
445 | 486 |
} |
446 | 487 |
|
488 |
// read the query parameters from $_REQUEST and add additional query parameters if nessecary. |
|
447 | 489 |
$request_params = cdm_dataportal_search_form_request(); |
490 |
|
|
448 | 491 |
$taxonPager = cdm_ws_get($_REQUEST['ws'], NULL, queryString($request_params)); |
449 | 492 |
|
450 | 493 |
return $taxonPager; |
Also available in: Unified diff
fixing #2896 (Classification switch should affect search results)