Revision 7ca5ef1e
Added by Andreas Kohlbecker almost 8 years ago
modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
37 | 37 |
*/ |
38 | 38 |
define('CDM_HTTP_REQUEST_TIMEOUT', 90.0); |
39 | 39 |
|
40 |
define('SORT_ORDER_ID', 'sort_by_order_id'); |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* orderBy webservice query parameter value |
|
44 |
*/ |
|
45 |
define('CDM_ORDER_BY_ID_ASC', 'ORDER_BY_ID_ASC'); |
|
46 |
|
|
47 |
/** |
|
48 |
* orderBy webservice query parameter value |
|
49 |
*/ |
|
50 |
define('CDM_ORDER_BY_ID_DESC', 'ORDER_BY_ID_DESC'); |
|
51 |
/** |
|
52 |
* orderBy webservice query parameter value |
|
53 |
*/ |
|
54 |
define('CDM_ORDER_BY_TITLE_CACHE_ASC', 'ORDER_BY_TITLE_CACHE_ASC'); |
|
55 |
/** |
|
56 |
* orderBy webservice query parameter value |
|
57 |
*/ |
|
58 |
define('CDM_ORDER_BY_TITLE_CACHE_DESC', 'ORDER_BY_TITLE_CACHE_DESC'); |
|
59 |
/** |
|
60 |
* orderBy webservice query parameter value |
|
61 |
*/ |
|
62 |
define('CDM_NOMENCLATURAL_SORT_ORDER_ASC', 'NOMENCLATURAL_SORT_ORDER_ASC'); |
|
63 |
/** |
|
64 |
* orderBy webservice query parameter value |
|
65 |
*/ |
|
66 |
define('CDM_NOMENCLATURAL_SORT_DESC', 'NOMENCLATURAL_SORT_ORDER_DESC'); |
|
67 |
/** |
|
68 |
* orderBy webservice query parameter value |
|
69 |
*/ |
|
70 |
define('CDM_ORDER_BY_ORDER_INDEX_ASC', 'BY_ORDER_INDEX_ASC'); |
|
71 |
/** |
|
72 |
* orderBy webservice query parameter value |
|
73 |
*/ |
|
74 |
define('CDM_ORDER_BY_ORDER_INDEX_DESC', 'BY_ORDER_INDEX_DESC'); |
|
75 |
|
|
41 | 76 |
|
42 | 77 |
/** |
43 | 78 |
* Implements hook_menu(). |
... | ... | |
1350 | 1385 |
* @param array $terms |
1351 | 1386 |
* a list of CDM DefinedTermBase instances |
1352 | 1387 |
* |
1353 |
* @param $sort_by |
|
1354 |
* Optionally sort option SORT_ORDER_ID (default: sorts after the cdm order index ), |
|
1355 |
* to sort alphabetically: SORT_ASC, SORT_DESC |
|
1356 |
* |
|
1357 | 1388 |
* @param $term_label_callback |
1358 | 1389 |
* A callback function to override the term representations |
1359 | 1390 |
* |
1360 | 1391 |
* @return array |
1361 | 1392 |
* the terms in an array as options for a form element that allows multiple choices. |
1362 | 1393 |
*/ |
1363 |
function cdm_terms_as_options($terms, $sort_by = SORT_ORDER_ID, $term_label_callback = NULL){
|
|
1394 |
function cdm_terms_as_options($terms, $term_label_callback = NULL){ |
|
1364 | 1395 |
$options = array(); |
1365 |
if(isset($terms) && is_array($terms)){ |
|
1366 |
foreach ($terms as $term){ |
|
1396 |
if(isset($terms) && is_array($terms)) {
|
|
1397 |
foreach ($terms as $term) {
|
|
1367 | 1398 |
if ($term_label_callback && function_exists($term_label_callback)) { |
1368 | 1399 |
$options[$term->uuid] = call_user_func($term_label_callback, $term); |
1369 | 1400 |
} else { |
... | ... | |
1372 | 1403 |
} |
1373 | 1404 |
} |
1374 | 1405 |
} |
1375 |
switch($sort_by){ |
|
1376 |
case SORT_ORDER_ID: array_reverse($options); |
|
1377 |
break; |
|
1378 |
default: array_multisort($options, SORT_ASC); |
|
1379 |
} |
|
1380 | 1406 |
|
1381 | 1407 |
return $options; |
1382 | 1408 |
} |
1383 | 1409 |
|
1384 | 1410 |
/** |
1385 |
* @todo Please document this function. |
|
1386 |
* @see http://drupal.org/node/1354 |
|
1387 |
*/ |
|
1388 |
function cdm_Vocabulary_as_option($vocabularyUuid, $term_label_callback = NULL, $default_option = FALSE, $sort_by = SORT_ORDER_ID) { |
|
1411 |
* Creates and array of options for drupal select form elements. |
|
1412 |
* |
|
1413 |
* @param $vocabulary_uuid |
|
1414 |
* The UUID of the CDM Term Vocabulary |
|
1415 |
* @param $term_label_callback |
|
1416 |
* An optional call back function which can be used to modify the term label |
|
1417 |
* @param $default_option |
|
1418 |
* An additional element do be placed at the beginning og the list. This element will be the default option. |
|
1419 |
* In order to put an empty element the begining of the options pass an " " as argument. |
|
1420 |
* @param $order_by |
|
1421 |
* One of the order by constants defined in this file |
|
1422 |
*/ |
|
1423 |
function cdm_vocabulary_as_option($vocabulary_uuid, $term_label_callback = NULL, $default_option = FALSE, $order_by = CDM_ORDER_BY_ORDER_INDEX_ASC) { |
|
1389 | 1424 |
static $vocabularyOptions = array(); |
1390 | 1425 |
|
1391 |
if (!isset($vocabularyOptions[$vocabularyUuid])) { |
|
1392 |
$terms = cdm_ws_fetch_all('termVocabulary/' . $vocabularyUuid . '/terms'); |
|
1393 |
$vocabularyOptions[$vocabularyUuid] = cdm_terms_as_options($terms, $sort_by, $term_label_callback); |
|
1426 |
if (!isset($vocabularyOptions[$vocabulary_uuid])) { |
|
1427 |
$terms = cdm_ws_fetch_all('termVocabulary/' . $vocabulary_uuid . '/terms', |
|
1428 |
array( |
|
1429 |
'orderBy' => $order_by |
|
1430 |
) |
|
1431 |
); |
|
1432 |
$vocabularyOptions[$vocabulary_uuid] = cdm_terms_as_options($terms, $term_label_callback); |
|
1394 | 1433 |
} |
1395 | 1434 |
|
1396 |
$options = $vocabularyOptions[$vocabularyUuid];
|
|
1435 |
$options = $vocabularyOptions[$vocabulary_uuid];
|
|
1397 | 1436 |
if($default_option !== FALSE){ |
1398 | 1437 |
array_unshift ($options, ""); |
1399 | 1438 |
} |
... | ... | |
1439 | 1478 |
* - TextFormat |
1440 | 1479 |
* - DeterminationModifier |
1441 | 1480 |
* - DnaMarker |
1442 |
*/ |
|
1443 |
function cdm_terms_by_type_as_option($term_type, $sort_by = SORT_ORDER_ID, $term_label_callback = NULL){ |
|
1444 |
$terms = cdm_ws_fetch_all(CDM_WS_TERM, array('class' => $term_type)); |
|
1445 |
return cdm_terms_as_options($terms, $sort_by, $term_label_callback); |
|
1481 |
* |
|
1482 |
* @param $order_by |
|
1483 |
* Optionally sort option (default: CDM_ORDER_BY_TITLE_CACHE_ASC) |
|
1484 |
* possible values: |
|
1485 |
* - CDM_ORDER_BY_ID_ASC |
|
1486 |
* - CDM_ORDER_BY_ID_DESC |
|
1487 |
* - CDM_ORDER_BY_TITLE_CACHE_ASC |
|
1488 |
* - CDM_ORDER_BY_TITLE_CACHE_DESC |
|
1489 |
* - CDM_ORDER_BY_ORDER_INDEX_ASC (can only be used with OrderedTerms!!) |
|
1490 |
* - CDM_ORDER_BY_ORDER_INDEX_DESC (can only be used with OrderedTerms!!) |
|
1491 |
*/ |
|
1492 |
function cdm_terms_by_type_as_option($term_type, $order_by = CDM_ORDER_BY_TITLE_CACHE_ASC, $term_label_callback = NULL){ |
|
1493 |
$terms = cdm_ws_fetch_all( |
|
1494 |
CDM_WS_TERM, |
|
1495 |
array( |
|
1496 |
'class' => $term_type, |
|
1497 |
'orderBy' => $order_by |
|
1498 |
) |
|
1499 |
); |
|
1500 |
return cdm_terms_as_options($terms, $term_label_callback); |
|
1446 | 1501 |
} |
1447 | 1502 |
|
1448 | 1503 |
/** |
... | ... | |
1450 | 1505 |
* @see http://drupal.org/node/1354 |
1451 | 1506 |
*/ |
1452 | 1507 |
function cdm_rankVocabulary_as_option() { |
1453 |
$options = cdm_Vocabulary_as_option(UUID_RANK, NULL, "");
|
|
1508 |
$options = cdm_vocabulary_as_option(UUID_RANK, NULL, "");
|
|
1454 | 1509 |
return $options; |
1455 | 1510 |
} |
1456 | 1511 |
|
modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module | ||
---|---|---|
166 | 166 |
|
167 | 167 |
//GermanFederalStates |
168 | 168 |
if($state != null){ |
169 |
$nameRelationshipTypeOptions = cdm_Vocabulary_as_option($state);
|
|
169 |
$nameRelationshipTypeOptions = cdm_vocabulary_as_option($state);
|
|
170 | 170 |
asort($nameRelationshipTypeOptions); |
171 | 171 |
$form['regionFilter']['area'] = array( |
172 | 172 |
'#type' => 'checkboxes', |
modules/cdm_dataportal/settings.php | ||
---|---|---|
28 | 28 |
define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999); |
29 | 29 |
|
30 | 30 |
/* annotationTypeKeys */ |
31 |
$annotationTypeKeys = array_keys(cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE));
|
|
31 |
$annotationTypeKeys = array_keys(cdm_vocabulary_as_option(UUID_ANNOTATION_TYPE));
|
|
32 | 32 |
if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) { |
33 | 33 |
$annotationTypeKeys = array_flip($annotationTypeKeys); |
34 | 34 |
|
... | ... | |
1164 | 1164 |
), |
1165 | 1165 |
); |
1166 | 1166 |
|
1167 |
$marker_type_options = cdm_terms_as_options( cdm_ws_fetch_all('term', array('class' => 'MarkerType' )) );
|
|
1167 |
$marker_type_options = cdm_terms_by_type_as_option('MarkerType');
|
|
1168 | 1168 |
$form['distribution'][CDM_DISTRIBUTION_FILTER]['hiddenAreaMarkerType'] = array( |
1169 | 1169 |
'#type' => 'checkboxes', |
1170 | 1170 |
'#title' => 'Hide marked area filter', |
... | ... | |
1232 | 1232 |
and for the inverse.'), |
1233 | 1233 |
); |
1234 | 1234 |
|
1235 |
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
1235 |
$taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
1236 | 1236 |
$aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT)); |
1237 | 1237 |
|
1238 | 1238 |
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array( |
... | ... | |
1370 | 1370 |
'#description' => t('Check this if you do not want to show annotation footnotes'), |
1371 | 1371 |
); |
1372 | 1372 |
|
1373 |
$annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType', SORT_ASC);
|
|
1373 |
$annotationTypeOptions = cdm_terms_by_type_as_option('AnnotationType'); |
|
1374 | 1374 |
// Additional option for the NULL case. |
1375 | 1375 |
$annotationTypeOptions['NULL_VALUE'] = t('untyped'); |
1376 | 1376 |
$form['footnotes']['annotations_types_as_footnotes'] = array( |
... | ... | |
2175 | 2175 |
' for details on the <em>Marked area filter</em>.', |
2176 | 2176 |
); |
2177 | 2177 |
|
2178 |
$level_options = cdm_Vocabulary_as_option(UUID_NAMED_AREA_LEVEL, NULL, FALSE, SORT_ASC);
|
|
2178 |
$level_options = cdm_vocabulary_as_option(UUID_NAMED_AREA_LEVEL, NULL, FALSE, SORT_ASC);
|
|
2179 | 2179 |
$form['taxon_profile']['distribution_layout'][DISTRIBUTION_TREE_OMIT_LEVELS] = array( |
2180 | 2180 |
'#type' => 'checkboxes', |
2181 | 2181 |
'#title' => 'Omit area levels', |
... | ... | |
2265 | 2265 |
); |
2266 | 2266 |
|
2267 | 2267 |
/* === currently unused === |
2268 |
$nameRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
|
|
2268 |
$nameRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
|
|
2269 | 2269 |
$form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array( |
2270 | 2270 |
'#type' => 'checkboxes', |
2271 | 2271 |
'#title' => t('Display name relationships') . ':', |
... | ... | |
2291 | 2291 |
below selected taxon relationships of accepted taxa.'), |
2292 | 2292 |
); |
2293 | 2293 |
|
2294 |
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
2294 |
$taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
2295 | 2295 |
$form['taxon_synonymy']['taxon_relations'][CDM_TAXON_RELATIONSHIP_TYPES] = array( |
2296 | 2296 |
'#type' => 'checkboxes', |
2297 | 2297 |
'#title' => t('Taxon relationship types') . ':', |
... | ... | |
2309 | 2309 |
'#collapsed' => FALSE |
2310 | 2310 |
); |
2311 | 2311 |
|
2312 |
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
2312 |
$taxonRelationshipTypeOptions = cdm_vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
|
2313 | 2313 |
$form['taxon_synonymy']['name_relations'][CDM_NAME_RELATIONSHIP_TYPES] = array( |
2314 | 2314 |
'#type' => 'checkboxes', |
2315 | 2315 |
'#title' => t('Name relationship types') . ':', |
Also available in: Unified diff
#5482 fixing orderBy modes for CDM terms