Revision 22f5e82d
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
284 | 284 |
// --- PAGE PART: DESCRIPTION --- // |
285 | 285 |
if ($page_part == 'description' || $page_part == 'all') { |
286 | 286 |
|
287 |
// 1. fetch descriptions_by_featuretree but exclude the distribution feature |
|
288 |
$merged_tree = cdm_ws_descriptions_by_featuretree(get_profile_featureTree(), $taxon->uuid, array(UUID_DISTRIBUTION)); |
|
289 |
|
|
287 |
$merged_tree = merged_taxon_feature_tree($taxon); |
|
290 | 288 |
|
291 |
// 2. find the distribution feature node |
|
292 |
$distribution_node =& cdm_feature_tree_find_node($merged_tree->root->childNodes, UUID_DISTRIBUTION); |
|
293 |
|
|
294 |
if ( $distribution_node) { |
|
295 |
// 3. get the distributionInfoDTO |
|
296 |
$query_parameters = cdm_distribution_filter_query(); |
|
297 |
$query_parameters['part'] = array('mapUriParams'); |
|
298 |
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){ |
|
299 |
$query_parameters['part'][] = 'tree'; |
|
300 |
} else { |
|
301 |
$query_parameters['part'][] = 'elements'; |
|
302 |
} |
|
303 |
$query_parameters['omitLevels'] = array(UUID_NAMEDAREALEVEL_TDWGLEVEL_2); |
|
304 |
$customStatusColorsJson = variable_get(DISTRIBUTION_STATUS_COLORS, null); |
|
305 |
if($customStatusColorsJson){ |
|
306 |
$query_parameters['statusColors'] = $customStatusColorsJson; |
|
307 |
} |
|
308 |
|
|
309 |
$distribution_info_dto = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_INFO_FOR, $taxon->uuid, queryString($query_parameters)); |
|
310 |
// 4. get distribution TextData is there are any |
|
311 |
$distribution_text_data = cdm_ws_fetch_all(CDM_WS_DESCRIPTIONELEMENT_BY_TAXON, |
|
312 |
array( |
|
313 |
'taxon' => $taxon->uuid, |
|
314 |
'type'=>'TextData', |
|
315 |
'features' => UUID_DISTRIBUTION |
|
316 |
) |
|
317 |
); |
|
318 |
|
|
319 |
// 5. put all distribution data into the distribution feature node |
|
320 |
if($distribution_text_data //if text data exists |
|
321 |
|| ($distribution_info_dto && isset($distribution_info_dto->tree) && $distribution_info_dto->tree->rootElement->numberOfChildren>0) // OR if tree element has distribution elements |
|
322 |
|| ($distribution_info_dto && !empty($distribution_info_dto->elements))) { // OR if DTO has distribution elements |
|
323 |
$distribution_node->descriptionElements = array('#type' => 'DTO'); |
|
324 |
if($distribution_text_data){ |
|
325 |
$distribution_node->descriptionElements['TextData'] = $distribution_text_data; |
|
326 |
} |
|
327 |
if($distribution_info_dto){ |
|
328 |
$distribution_node->descriptionElements['DistributionInfoDTO'] = $distribution_info_dto; |
|
329 |
} |
|
330 |
} |
|
331 |
} |
|
332 | 289 |
|
333 | 290 |
$render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media); |
334 | 291 |
$render_array['general']['#weight'] = $weight++; |
... | ... | |
450 | 407 |
return $render_array; |
451 | 408 |
} |
452 | 409 |
|
410 |
/** |
|
411 |
* TODO move into description.inc or in cdm_api.module? |
|
412 |
* |
|
413 |
* @param $taxon |
|
414 |
* @param $distribution_node |
|
415 |
* @return array |
|
416 |
*/ |
|
417 |
function merged_taxon_feature_tree($taxon) { |
|
453 | 418 |
|
454 |
/** |
|
455 |
* TODO should this function really be a compose funtion? |
|
456 |
* For a compose function must there alway be a theme function with the same name? (ak 8.8.2013) |
|
419 |
// 1. fetch descriptions_by_featuretree but exclude the distribution feature |
|
420 |
$merged_tree = cdm_ws_descriptions_by_featuretree(get_profile_featureTree(), $taxon->uuid, array(UUID_DISTRIBUTION)); |
|
421 |
|
|
422 |
|
|
423 |
// 2. find the distribution feature node |
|
424 |
$distribution_node =& cdm_feature_tree_find_node($merged_tree->root->childNodes, UUID_DISTRIBUTION); |
|
425 |
|
|
426 |
if ($distribution_node) { |
|
427 |
// 3. get the distributionInfoDTO |
|
428 |
$query_parameters = cdm_distribution_filter_query(); |
|
429 |
$query_parameters['part'] = array('mapUriParams'); |
|
430 |
if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') { |
|
431 |
$query_parameters['part'][] = 'tree'; |
|
432 |
} |
|
433 |
else { |
|
434 |
$query_parameters['part'][] = 'elements'; |
|
435 |
} |
|
436 |
$query_parameters['omitLevels'] = array(UUID_NAMEDAREALEVEL_TDWGLEVEL_2); |
|
437 |
$customStatusColorsJson = variable_get(DISTRIBUTION_STATUS_COLORS, NULL); |
|
438 |
if ($customStatusColorsJson) { |
|
439 |
$query_parameters['statusColors'] = $customStatusColorsJson; |
|
440 |
} |
|
441 |
|
|
442 |
$distribution_info_dto = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_INFO_FOR, $taxon->uuid, queryString($query_parameters)); |
|
443 |
// 4. get distribution TextData is there are any |
|
444 |
$distribution_text_data = cdm_ws_fetch_all(CDM_WS_DESCRIPTIONELEMENT_BY_TAXON, |
|
445 |
array( |
|
446 |
'taxon' => $taxon->uuid, |
|
447 |
'type' => 'TextData', |
|
448 |
'features' => UUID_DISTRIBUTION |
|
449 |
) |
|
450 |
); |
|
451 |
|
|
452 |
// 5. put all distribution data into the distribution feature node |
|
453 |
if ($distribution_text_data //if text data exists |
|
454 |
|| ($distribution_info_dto && isset($distribution_info_dto->tree) && $distribution_info_dto->tree->rootElement->numberOfChildren > 0) // OR if tree element has distribution elements |
|
455 |
|| ($distribution_info_dto && !empty($distribution_info_dto->elements)) |
|
456 |
) { // OR if DTO has distribution elements |
|
457 |
$distribution_node->descriptionElements = array('#type' => 'DTO'); |
|
458 |
if ($distribution_text_data) { |
|
459 |
$distribution_node->descriptionElements['TextData'] = $distribution_text_data; |
|
460 |
} |
|
461 |
if ($distribution_info_dto) { |
|
462 |
$distribution_node->descriptionElements['DistributionInfoDTO'] = $distribution_info_dto; |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
return $merged_tree; |
|
467 |
} |
|
468 |
|
|
469 |
|
|
470 |
/** |
|
471 |
* TODO should this function really be a compose function? |
|
472 |
* For a compose function must there always be a theme function with the same name? (ak 8.8.2013) |
|
457 | 473 |
* |
458 | 474 |
* composes and returns an render array containing the components of the taxon profile tab: |
459 | 475 |
* - 'taxon_profile_image' |
Also available in: Unified diff
refactoring theme_cdm_descriptionElementTextData() #3484 , mock implementation of feature block settings #3257, solves most issues of #3915 (handling of annotations and sources inconsistent in theme_cdm_descriptionElementTextData)