584 |
584 |
$feature_description = make_pseudo_feature('Descriptions (aggregated)', 'AGGREGATION_DESCRIPTIONS');
|
585 |
585 |
$description_item = "";
|
586 |
586 |
foreach ($aggregatedDescriptions as $description) {
|
587 |
|
$description_item .= render_cdm_description_link($description, '', TRUE);
|
|
587 |
$description_item .= render_cdm_description($description, '', TRUE);
|
588 |
588 |
}
|
589 |
589 |
$description_block = feature_block(t('Descriptions (aggregated)'), $feature_description);
|
590 |
590 |
$description_block->content = [];
|
... | ... | |
619 |
619 |
}
|
620 |
620 |
|
621 |
621 |
/**
|
622 |
|
* Renders the link which will lead to the description detail page
|
|
622 |
* Renders the description and adds a link to the description detail page
|
|
623 |
*
|
623 |
624 |
* @param object $description
|
624 |
625 |
* the cdm description entity which will be linked to
|
625 |
626 |
*
|
626 |
|
* @return string
|
627 |
|
* the markup for the link
|
|
627 |
* @param string $linkText an optional link text; default is the description titleCache
|
|
628 |
* @param bool $renderDescriptionElements if True the description elements will be rendered
|
|
629 |
*
|
|
630 |
* @return string the markup for the description
|
628 |
631 |
*/
|
629 |
|
function render_cdm_description_link($description, $linkText = '', $renderDescriptionElements = False) {
|
|
632 |
function render_cdm_description($description, $linkText = '', $renderDescriptionElements = False) {
|
630 |
633 |
if (empty($linkText)) {
|
631 |
634 |
$linkText = $description->titleCache;
|
632 |
635 |
}
|
633 |
636 |
$pathToDescription = path_to_description($description->uuid);
|
634 |
637 |
$attributes['class'][] = html_class_attribute_ref($description);
|
635 |
638 |
$descriptionString = '';
|
636 |
|
if ($renderDescriptionElements) {
|
637 |
|
foreach ($description->elements as $element) {
|
638 |
|
switch ($element->class) {
|
639 |
|
case 'CategoricalData':
|
640 |
|
$state_data = compose_state_data($element);
|
641 |
|
$state_data = implode(', ', $state_data);
|
642 |
|
if (!empty($state_data)) {
|
643 |
|
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . $state_data . "; ";
|
644 |
|
}
|
645 |
|
break;
|
646 |
|
case 'QuantitativeData':
|
647 |
|
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . compose_quant_stats($element) . "; ";
|
648 |
|
break;
|
649 |
|
}
|
650 |
|
}
|
|
639 |
if($renderDescriptionElements){
|
|
640 |
$descriptionString = render_description_string($description, get_root_nodes_for_dataset($description));
|
651 |
641 |
}
|
652 |
642 |
$detail_html = $descriptionString.l($linkText, $pathToDescription, array('attributes' => $attributes))."<br><br>";
|
653 |
643 |
return $detail_html;
|
654 |
644 |
}
|
655 |
645 |
|
656 |
646 |
/**
|
|
647 |
* @param $description
|
|
648 |
* @param $root_nodes
|
|
649 |
*
|
|
650 |
* @return string
|
|
651 |
*/
|
|
652 |
function render_description_string($description, $root_nodes) {
|
|
653 |
$descriptionString = '';
|
|
654 |
if (!empty($root_nodes)) {
|
|
655 |
foreach ($root_nodes as $root_node) {
|
|
656 |
foreach ($root_node->descriptionElements as $element) {
|
|
657 |
switch ($element->class) {
|
|
658 |
case 'CategoricalData':
|
|
659 |
$state_data = compose_state_data($element);
|
|
660 |
$state_data = implode(', ', $state_data);
|
|
661 |
if (!empty($state_data)) {
|
|
662 |
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . $state_data . "; ";
|
|
663 |
}
|
|
664 |
break;
|
|
665 |
case 'QuantitativeData':
|
|
666 |
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . compose_quant_stats($element) . "; ";
|
|
667 |
break;
|
|
668 |
}
|
|
669 |
}
|
|
670 |
// recurse child nodes
|
|
671 |
$descriptionString .= render_description_string($description, $root_node->childNodes);
|
|
672 |
}
|
|
673 |
}
|
|
674 |
return $descriptionString;
|
|
675 |
}
|
|
676 |
|
|
677 |
/**
|
657 |
678 |
* Renders the link which will lead to the specimen detail page
|
658 |
679 |
* @param object $specimen
|
659 |
680 |
* the cdm specimen entity which will be linked to
|
... | ... | |
1195 |
1216 |
$render_array[] = markup_to_render_array(render_cdm_specimen_link($description->describedSpecimenOrObservation));
|
1196 |
1217 |
}
|
1197 |
1218 |
|
|
1219 |
$root_nodes = [];
|
|
1220 |
$root_nodes = get_root_nodes_for_dataset($description);
|
|
1221 |
|
1198 |
1222 |
$header = ['Feature/Character', 'State'];
|
|
1223 |
|
1199 |
1224 |
$rows = [];
|
1200 |
|
foreach ($description->elements as $element) {
|
|
1225 |
$rows = compose_description_element_rows($root_nodes, $rows);
|
1201 |
1226 |
|
1202 |
|
switch ($element->class) {
|
1203 |
|
case 'CategoricalData':
|
1204 |
|
$rows[] = [
|
1205 |
|
$element->feature->representation_L10n,
|
1206 |
|
compose_state_data_span($element),
|
1207 |
|
];
|
1208 |
|
break;
|
1209 |
|
case 'QuantitativeData':
|
1210 |
|
$rows[] = [
|
1211 |
|
$element->feature->representation_L10n,
|
1212 |
|
compose_quant_stats($element),
|
1213 |
|
];
|
1214 |
|
break;
|
1215 |
|
}
|
1216 |
|
}
|
1217 |
1227 |
$render_array[] = markup_to_render_array(theme('table', [
|
1218 |
1228 |
'header' => $header,
|
1219 |
1229 |
'rows' => $rows,
|
... | ... | |
1225 |
1235 |
if ($source->type == 'Aggregation' and isset($source->cdmSource) and $source->cdmSource->class=='SpecimenDescription') {
|
1226 |
1236 |
$specimendescription = $source->cdmSource;
|
1227 |
1237 |
$items[] = [
|
1228 |
|
'data' => render_cdm_description_link($specimendescription),
|
|
1238 |
'data' => render_cdm_description($specimendescription),
|
1229 |
1239 |
];
|
1230 |
1240 |
}
|
1231 |
1241 |
}
|
... | ... | |
1243 |
1253 |
}
|
1244 |
1254 |
|
1245 |
1255 |
/**
|
|
1256 |
* For a given description returns the root nodes according to the
|
|
1257 |
*corresponding term tree. The term tree is determined as follow:
|
|
1258 |
* 1. If description is part of a descriptive data set the term tree of that
|
|
1259 |
* data set is used (FIXME handle multiple term trees)
|
|
1260 |
* 2. Otherwise the portal taxon profile tree is used
|
|
1261 |
* @param $description
|
|
1262 |
*
|
|
1263 |
* @return array
|
|
1264 |
*/
|
|
1265 |
function get_root_nodes_for_dataset($description) {
|
|
1266 |
if (!empty($description->descriptiveDataSets)) {
|
|
1267 |
foreach ($description->descriptiveDataSets as $dataSet) {
|
|
1268 |
break;// FIXME handle multiple term trees
|
|
1269 |
}
|
|
1270 |
$tree = cdm_ws_get(CDM_WS_TERMTREE, $dataSet->descriptiveSystem->uuid);
|
|
1271 |
$root_nodes = _mergeFeatureTreeDescriptions($tree->root->childNodes, $description->elements);
|
|
1272 |
}
|
|
1273 |
else {
|
|
1274 |
$root_nodes = _mergeFeatureTreeDescriptions(get_profile_feature_tree()->root->childNodes, $description->elements);
|
|
1275 |
}
|
|
1276 |
return $root_nodes;
|
|
1277 |
}
|
|
1278 |
|
|
1279 |
/**
|
|
1280 |
* @param $root_nodes
|
|
1281 |
* @param $rows
|
|
1282 |
*
|
|
1283 |
* @return array
|
|
1284 |
*/
|
|
1285 |
function compose_description_element_rows($root_nodes, $rows) {
|
|
1286 |
foreach ($root_nodes as $root_node) {
|
|
1287 |
foreach ($root_node->descriptionElements as $element) {
|
|
1288 |
switch ($element->class) {
|
|
1289 |
case 'CategoricalData':
|
|
1290 |
if (!empty($element->stateData)) {
|
|
1291 |
$rows[] = [
|
|
1292 |
$element->feature->representation_L10n,
|
|
1293 |
compose_state_data_span($element),
|
|
1294 |
];
|
|
1295 |
}
|
|
1296 |
break;
|
|
1297 |
case 'QuantitativeData':
|
|
1298 |
$rows[] = [
|
|
1299 |
$element->feature->representation_L10n,
|
|
1300 |
compose_quant_stats($element),
|
|
1301 |
];
|
|
1302 |
break;
|
|
1303 |
}
|
|
1304 |
}
|
|
1305 |
// recurse child nodes
|
|
1306 |
$rows = compose_description_element_rows($root_node->childNodes, $rows);
|
|
1307 |
}
|
|
1308 |
return $rows;
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
/**
|
1246 |
1312 |
* @param $named_area_uuid
|
1247 |
1313 |
* @return array
|
1248 |
1314 |
* The drupal render array for the page
|
ref #8657 Retain hierarchy information of description elements