Revision efa372e9
Added by Andreas Kohlbecker over 7 years ago
modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
1419 | 1419 |
* The UUID of the CDM Term Vocabulary |
1420 | 1420 |
* @param $term_label_callback |
1421 | 1421 |
* An optional call back function which can be used to modify the term label |
1422 |
* @param $default_option |
|
1422 |
* @param bool $default_option
|
|
1423 | 1423 |
* An additional element do be placed at the beginning og the list. This element will be the default option. |
1424 | 1424 |
* In order to put an empty element the begining of the options pass an " " as argument. |
1425 |
* @param $order_by |
|
1425 |
* @param array $include_filter |
|
1426 |
* An associative array consisting of a field name an regular expression. All term matching |
|
1427 |
* these filter are included. The value of the field is converted to a String by var_export() |
|
1428 |
* so a boolean 'true' can be matched by '/true/' |
|
1429 |
* @param string $order_by |
|
1426 | 1430 |
* One of the order by constants defined in this file |
1431 |
* @return mixed |
|
1427 | 1432 |
*/ |
1428 |
function cdm_vocabulary_as_option($vocabulary_uuid, $term_label_callback = NULL, $default_option = FALSE, $order_by = CDM_ORDER_BY_ORDER_INDEX_ASC) { |
|
1433 |
function cdm_vocabulary_as_option($vocabulary_uuid, $term_label_callback = NULL, $default_option = FALSE, |
|
1434 |
array $include_filter = null, $order_by = CDM_ORDER_BY_ORDER_INDEX_ASC) { |
|
1435 |
|
|
1429 | 1436 |
static $vocabularyOptions = array(); |
1430 | 1437 |
|
1431 | 1438 |
if (!isset($vocabularyOptions[$vocabulary_uuid])) { |
... | ... | |
1434 | 1441 |
'orderBy' => $order_by |
1435 | 1442 |
) |
1436 | 1443 |
); |
1444 |
|
|
1445 |
// apply the include filter |
|
1446 |
if($include_filter != null){ |
|
1447 |
$included_terms = array(); |
|
1448 |
|
|
1449 |
foreach ($terms as $term){ |
|
1450 |
$include = true; |
|
1451 |
foreach ($include_filter as $field=>$regex){ |
|
1452 |
$include = preg_match($regex, var_export($term->$field, true)) === 1; |
|
1453 |
if(!$include){ |
|
1454 |
break; |
|
1455 |
} |
|
1456 |
} |
|
1457 |
if($include){ |
|
1458 |
$included_terms[] = $term; |
|
1459 |
} |
|
1460 |
} |
|
1461 |
|
|
1462 |
$terms = $included_terms; |
|
1463 |
} |
|
1464 |
|
|
1465 |
// make options list |
|
1437 | 1466 |
$vocabularyOptions[$vocabulary_uuid] = cdm_terms_as_options($terms, $term_label_callback); |
1438 | 1467 |
} |
1439 | 1468 |
|
modules/cdm_dataportal/cdm_api/uuids.php | ||
---|---|---|
23 | 23 |
define('UUID_NAMED_AREA_LEVEL', '49034253-27c8-4219-97e8-f8d987d3d122'); |
24 | 24 |
define('UUID_FEATURE', 'b187d555-f06f-4d65-9e53-da7c93f8eaa8'); |
25 | 25 |
define('UUID_TDWG_AREA', '1fb40504-d1d7-44b0-9731-374fbe6cac77'); |
26 |
define('UUID_PRESENCE_TERM', 'adbbbe15-c4d3-47b7-80a8-c7d104e53a05'); |
|
27 |
define('UUID_ABSENCE_TERM', '5cd438c8-a8a1-4958-842e-169e83e2ceee'); |
|
26 |
define('UUID_PRESENCE_ABSENCE_TERM', 'adbbbe15-c4d3-47b7-80a8-c7d104e53a05'); |
|
28 | 27 |
define('UUID_SEX', '9718b7dd-8bc0-4cad-be57-3c54d4d432fe'); |
29 | 28 |
define('UUID_DERIVATION_EVENT_TYPE', '398b50bb-348e-4fe0-a7f5-a75afd846d1f'); |
30 | 29 |
define('UUID_PRESERVATION_METHOD', 'a7dc20c9-e6b3-459e-8f05-8d6d8fceb465'); |
modules/cdm_dataportal/cdm_dataportal.search.php | ||
---|---|---|
503 | 503 |
* the processed request parameters submitted by the search form and |
504 | 504 |
* also stores them in $_SESSION['cdm']['search'] |
505 | 505 |
*/ |
506 |
function cdm_dataportal_search_form_request()
|
|
506 |
function cdm_dataportal_search_request() |
|
507 | 507 |
{ |
508 | 508 |
|
509 | 509 |
$form_params = array(); |
... | ... | |
535 | 535 |
foreach ($_REQUEST['search']['areas']['area'] as $areas) { |
536 | 536 |
$area_uuids = array_merge($area_uuids, $areas); |
537 | 537 |
} |
538 |
// The area filter is limited to areas with non absent distribution status |
|
539 |
$presence_terms_options = cdm_vocabulary_as_option(UUID_PRESENCE_ABSENCE_TERM, null, FALSE, array('absenceTerm' => '/false/')); |
|
540 |
$presence_term_uuids = array_keys($presence_terms_options); |
|
541 |
$form_params['status'] = $presence_term_uuids; |
|
538 | 542 |
} |
539 | 543 |
if(count($area_uuids) > 0){ |
540 | 544 |
$form_params['area'] = implode(',', $area_uuids); |
... | ... | |
546 | 550 |
if (!isset($form_params['tree']) && !variable_get(SIMPLE_SEARCH_IGNORE_CLASSIFICATION, 0)) { |
547 | 551 |
$form_params['tree'] = get_current_classification_uuid(); |
548 | 552 |
} |
549 |
// If the 'NONE' classification has been chosen (adanced search) |
|
553 |
// If the 'NONE' classification has been chosen (advanced search)
|
|
550 | 554 |
// delete the tree information to avoid unknown uuid exceptions in the |
551 | 555 |
// cdm service. |
552 | 556 |
if (isset($form_params['tree']) |
... | ... | |
569 | 573 |
* Provides the classification to which the last search has been limited to.. |
570 | 574 |
* |
571 | 575 |
* This function should only be used after the cdm_dataportal_search_execute() |
572 |
* handler has been run, otherwise it will return the infomation from the last |
|
576 |
* handler has been run, otherwise it will return the information from the last
|
|
573 | 577 |
* search executed. The information is retrieved from |
574 | 578 |
* the $_SESSION variable: $_SESSION['cdm']['search']['tree'] |
575 | 579 |
* |
... | ... | |
607 | 611 |
* Sends a search request at the cdm web server. |
608 | 612 |
* |
609 | 613 |
* The parameters to build the query are taken obtained by calling |
610 |
* cdm_dataportal_search_form_request() which reads the query parameters
|
|
614 |
* cdm_dataportal_search_request() which reads the query parameters |
|
611 | 615 |
* from $_REQUEST and add additional query parameters if nessecary. |
612 | 616 |
* |
613 |
* @see cdm_dataportal_search_form_request()
|
|
617 |
* @see cdm_dataportal_search_request() |
|
614 | 618 |
*/ |
615 | 619 |
function cdm_dataportal_search_execute() { |
616 | 620 |
|
... | ... | |
634 | 638 |
|
635 | 639 |
// Read the query parameters from $_REQUEST and add additional query |
636 | 640 |
// parameters if necessary. |
637 |
$request_params = cdm_dataportal_search_form_request();
|
|
641 |
$request_params = cdm_dataportal_search_request(); |
|
638 | 642 |
|
639 | 643 |
$taxon_pager = cdm_ws_get($_REQUEST['ws'], NULL, queryString($request_params)); |
640 | 644 |
|
Also available in: Unified diff
fix #4497 simple exclusion of all areas with absent status from taxon search