Revision 072122ee
Added by Andreas Kohlbecker almost 8 years ago
modules/cdm_dataportal/cdm_dataportal.search.php | ||
---|---|---|
278 | 278 |
} |
279 | 279 |
} |
280 | 280 |
|
281 |
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/search_area_filter.js');
|
|
281 |
$show_area_filter = ! variable_get(CDM_SEARCH_AREA_FILTER_PRESET, '');
|
|
282 | 282 |
|
283 |
drupal_add_js('jQuery(document).ready(function() { |
|
283 |
if($show_area_filter){ |
|
284 |
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/search_area_filter.js'); |
|
285 |
|
|
286 |
drupal_add_js('jQuery(document).ready(function() { |
|
284 | 287 |
jQuery(\'#edit-search-areas\').search_area_filter(\'#edit-search-areas-areas-filter\'); |
285 | 288 |
}); |
286 | 289 |
', array('type' => 'inline')); |
287 | 290 |
|
288 |
$form['search']['areas'] = array( |
|
289 |
'#type' => 'fieldset', |
|
290 |
'#title' => t('Filter by distribution areas'), |
|
291 |
'#description' => t('The search will return taxa having distribution |
|
291 |
$form['search']['areas'] = array(
|
|
292 |
'#type' => 'fieldset',
|
|
293 |
'#title' => t('Filter by distribution areas'),
|
|
294 |
'#description' => t('The search will return taxa having distribution
|
|
292 | 295 |
information for at least one of the selected areas.') . ' ' |
293 |
.(count($term_tree) > 1 ? t('The areas are grouped |
|
296 |
.(count($term_tree) > 1 ? t('The areas are grouped
|
|
294 | 297 |
by the vocabularies to which the highest level areas belong.') : ''), |
295 |
); |
|
296 |
$form['search']['areas']['areas_filter'] = array( |
|
297 |
'#type' => 'textfield', |
|
298 |
'#description' => t('Type to filter the areas listed below.'), |
|
299 |
); |
|
300 |
$vocab_cnt = 0; |
|
301 |
$areas_defaults = array(); |
|
302 |
if (isset($_SESSION['cdm']['search']['area'])) { |
|
303 |
$areas_defaults = explode(',', $_SESSION['cdm']['search']['area']); |
|
304 |
} |
|
305 |
foreach ($term_tree as $vocab_uuid => $term_dto_tree) { |
|
306 |
$vocabulary = cdm_ws_get(CDM_WS_TERMVOCABULARY, array($vocab_uuid)); |
|
307 |
$areas_options = term_tree_as_options($term_dto_tree); |
|
308 |
$form['search']['areas']['area'][$vocab_cnt++] = array( |
|
309 |
'#prefix' => '<strong>' . $vocabulary->representation_L10n |
|
310 |
. (isset($mixed_vocabularies[$vocab_uuid]) ? ' <span title="Contains terms of at least one other area vocabulary.">(' . t('mixed') . ')</span>': '') |
|
311 |
. '</strong>', |
|
312 |
'#type' => 'checkboxes', |
|
313 |
'#default_value' => $areas_defaults, |
|
314 |
'#options' => $areas_options, |
|
315 | 298 |
); |
299 |
$form['search']['areas']['areas_filter'] = array( |
|
300 |
'#type' => 'textfield', |
|
301 |
'#description' => t('Type to filter the areas listed below.'), |
|
302 |
); |
|
303 |
$vocab_cnt = 0; |
|
304 |
$areas_defaults = array(); |
|
305 |
if (isset($_SESSION['cdm']['search']['area'])) { |
|
306 |
$areas_defaults = explode(',', $_SESSION['cdm']['search']['area']); |
|
307 |
} |
|
308 |
foreach ($term_tree as $vocab_uuid => $term_dto_tree) { |
|
309 |
$vocabulary = cdm_ws_get(CDM_WS_TERMVOCABULARY, array($vocab_uuid)); |
|
310 |
$areas_options = term_tree_as_options($term_dto_tree); |
|
311 |
$form['search']['areas']['area'][$vocab_cnt++] = array( |
|
312 |
'#prefix' => '<strong>' . $vocabulary->representation_L10n |
|
313 |
. (isset($mixed_vocabularies[$vocab_uuid]) ? ' <span title="Contains terms of at least one other area vocabulary.">(' . t('mixed') . ')</span>': '') |
|
314 |
. '</strong>', |
|
315 |
'#type' => 'checkboxes', |
|
316 |
'#default_value' => $areas_defaults, |
|
317 |
'#options' => $areas_options, |
|
318 |
); |
|
319 |
} |
|
316 | 320 |
} |
317 | 321 |
|
318 | 322 |
} |
... | ... | |
478 | 482 |
// --- handle geographic range |
479 | 483 |
// Split of geographic range. |
480 | 484 |
unset($form_params['areas']); |
481 |
if (isset($_REQUEST['search']['areas']['area']) && is_array($_REQUEST['search']['areas']['area'])) { |
|
485 |
|
|
486 |
$area_filter_preset = explode(',', variable_get(CDM_SEARCH_AREA_FILTER_PRESET, '')); |
|
487 |
|
|
488 |
if($area_filter_preset){ |
|
489 |
$area_uuids = $area_filter_preset; |
|
490 |
} |
|
491 |
elseif (isset($_REQUEST['search']['areas']['area']) && is_array($_REQUEST['search']['areas']['area'])) { |
|
482 | 492 |
$area_uuids = array(); |
483 | 493 |
foreach ($_REQUEST['search']['areas']['area'] as $areas) { |
484 | 494 |
$area_uuids = array_merge($area_uuids, $areas); |
485 | 495 |
} |
496 |
} |
|
497 |
if(isset($area_uuids[0])){ |
|
486 | 498 |
$form_params['area'] = implode(',', $area_uuids); |
487 | 499 |
} |
488 | 500 |
|
Also available in: Unified diff
experimental feature for caucasus flora: area filter preset