Revision ea0ae3c7
Added by Patrick Plitzner over 4 years ago
modules/cdm_dataportal/cdm_dataportal.module | ||
---|---|---|
1791 | 1791 |
/** |
1792 | 1792 |
* |
1793 | 1793 |
* Creates a description view. |
1794 |
* |
|
1794 | 1795 |
* @param string $uuid the UUID of the description |
1795 |
* @return object |
|
1796 |
* Page object with the fields |
|
1797 |
* - title |
|
1798 |
* - content |
|
1796 |
* @param null $descriptive_dataset_uuid the uuid of the data set which defines |
|
1797 |
* the display of the description detail page |
|
1798 |
* |
|
1799 |
* @return object Page object with the fields |
|
1800 |
* Page object with the fields |
|
1801 |
* - title |
|
1802 |
* - content |
|
1799 | 1803 |
*/ |
1800 |
function cdm_dataportal_description_view($uuid) { |
|
1804 |
function cdm_dataportal_description_view($uuid, $descriptive_dataset_uuid = NULL) {
|
|
1801 | 1805 |
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $uuid); |
1802 | 1806 |
if (empty($description)) { |
1803 | 1807 |
drupal_set_title(t('Description does not exist'), PASS_THROUGH); |
... | ... | |
1809 | 1813 |
drupal_set_title($descriptionpage->title); // not necessary if correctly implemented as drupal node |
1810 | 1814 |
|
1811 | 1815 |
// Render the description page. |
1812 |
$render_array = compose_cdm_description($description->uuid); |
|
1816 |
$render_array = compose_cdm_description($description->uuid, $descriptive_dataset_uuid);
|
|
1813 | 1817 |
$descriptionpage->content = drupal_render($render_array); |
1814 | 1818 |
|
1815 | 1819 |
return $descriptionpage; |
1816 | 1820 |
} |
1817 | 1821 |
|
1818 |
function cdm_dataportal_description_page_view($uuid) { |
|
1822 |
function cdm_dataportal_description_page_view($uuid, $descriptive_dataset_uuid = NULL) {
|
|
1819 | 1823 |
|
1820 | 1824 |
cdm_check_valid_portal_page(); |
1821 |
$descriptionpage = cdm_dataportal_description_view($uuid); |
|
1825 |
$descriptionpage = cdm_dataportal_description_view($uuid, $descriptive_dataset_uuid);
|
|
1822 | 1826 |
if (!empty($descriptionpage)) { |
1823 | 1827 |
return cdm_node_show_simulate($descriptionpage->content); |
1824 | 1828 |
} |
... | ... | |
2318 | 2322 |
} |
2319 | 2323 |
} |
2320 | 2324 |
|
2321 |
function path_to_description($uuid) { |
|
2325 |
function path_to_description($uuid, $descriptive_dataset_uuid = NULL) {
|
|
2322 | 2326 |
|
2323 | 2327 |
if (!$uuid) { |
2324 | 2328 |
return FALSE; |
2325 | 2329 |
} |
2326 | 2330 |
else { |
2327 |
return 'cdm_dataportal/description/' . $uuid; |
|
2331 |
return 'cdm_dataportal/description/' . $uuid. |
|
2332 |
'/' . (is_uuid($descriptive_dataset_uuid) ? $descriptive_dataset_uuid : "null"); |
|
2328 | 2333 |
} |
2329 | 2334 |
} |
2330 | 2335 |
|
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
582 | 582 |
if (isset($aggregatedDescriptions) and !empty($aggregatedDescriptions)) { |
583 | 583 |
// descriptions pseudo feature |
584 | 584 |
$feature_description = make_pseudo_feature('Descriptions (aggregated)', 'AGGREGATION_DESCRIPTIONS'); |
585 |
$description_item = "";
|
|
585 |
$description_item = '';
|
|
586 | 586 |
foreach ($aggregatedDescriptions as $description) { |
587 |
$description_item .= render_cdm_description($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 = []; |
... | ... | |
626 | 626 |
* |
627 | 627 |
* @param bool $show_description_elements if True the description elements will be rendered |
628 | 628 |
* |
629 |
* @param string $link_text an optional link text; default is the description titleCache |
|
630 |
* |
|
631 | 629 |
* @return string the markup for the description |
632 | 630 |
*/ |
633 |
function render_cdm_description($description, $show_description_elements = FALSE, $link_text = '') { |
|
634 |
if (empty($link_text)) { |
|
635 |
$link_text = $description->titleCache; |
|
636 |
} |
|
637 |
$pathToDescription = path_to_description($description->uuid); |
|
631 |
function render_cdm_description($description, $show_description_elements = False, $descriptive_dataset_uuid = NULL) { |
|
632 |
$link_text = $description->titleCache; |
|
633 |
$pathToDescription = path_to_description($description->uuid, $descriptive_dataset_uuid); |
|
638 | 634 |
$attributes['class'][] = html_class_attribute_ref($description); |
639 | 635 |
$descriptionString = ''; |
640 | 636 |
if($show_description_elements){ |
... | ... | |
1205 | 1201 |
* |
1206 | 1202 |
* @ingroup compose |
1207 | 1203 |
*/ |
1208 |
function compose_cdm_description($description_uuid) { |
|
1204 |
function compose_cdm_description($description_uuid, $descriptive_dataset_uuid = NULL) {
|
|
1209 | 1205 |
RenderHints::pushToRenderStack('description_table'); |
1210 | 1206 |
|
1211 |
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, [$description_uuid]); |
|
1212 |
|
|
1213 | 1207 |
$render_array = []; |
1214 | 1208 |
|
1209 |
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, [$description_uuid]); |
|
1210 |
$dataSet = NULL; |
|
1211 |
// find dataset |
|
1212 |
if($descriptive_dataset_uuid != NULL){ |
|
1213 |
foreach ($description->descriptiveDataSets as $set) { |
|
1214 |
if($set->uuid == $descriptive_dataset_uuid){ |
|
1215 |
$dataSet = $set; |
|
1216 |
break; |
|
1217 |
} |
|
1218 |
} |
|
1219 |
} |
|
1220 |
if (!isset($dataSet) && !empty($description->descriptiveDataSets)) { |
|
1221 |
// FIXME handle multiple data sets #8741 |
|
1222 |
foreach ($description->descriptiveDataSets as $dataSet) { |
|
1223 |
break; |
|
1224 |
} |
|
1225 |
} |
|
1226 |
// generate page title |
|
1227 |
$associated_description_cdm_entity = isset($description->describedSpecimenOrObservation) |
|
1228 |
? $description->describedSpecimenOrObservation->titleCache |
|
1229 |
: (isset($description->taxon) ? $description->taxon->titleCache : NULL); |
|
1230 |
if (isset($dataSet)) { |
|
1231 |
$title = 'Descriptive Data ' . $dataSet->titleCache; |
|
1232 |
if (isset($associated_description_cdm_entity)) { |
|
1233 |
$title .= ' for ' . $associated_description_cdm_entity; |
|
1234 |
} |
|
1235 |
drupal_set_title($title); |
|
1236 |
} |
|
1237 |
|
|
1215 | 1238 |
if (isset($description->describedSpecimenOrObservation)) { |
1216 | 1239 |
$render_array[] = markup_to_render_array("<b>Specimen</b><br>"); |
1217 | 1240 |
$render_array[] = markup_to_render_array(render_cdm_specimen_link($description->describedSpecimenOrObservation)); |
Also available in: Unified diff
ref #8657 Add descriptive data set information to description detail page