Revision 30845bda
Added by Andreas Kohlbecker over 7 years ago
modules/cdm_dataportal/cdm_api/webservice_uris.php | ||
---|---|---|
106 | 106 |
|
107 | 107 |
define('CDM_WS_TERM_COMPARE', 'term/$0/compareTo/$1'); |
108 | 108 |
define('CDM_WS_TERM', 'term'); |
109 |
define('CDM_WS_PORTAL_TERM', 'portal/term/$0'); |
|
109 | 110 |
|
110 | 111 |
/** |
111 | 112 |
* Returns FeatureTrees that are stored in this community store. |
modules/cdm_dataportal/cdm_dataportal.module | ||
---|---|---|
414 | 414 |
// Expected callback arguments: uuid. |
415 | 415 |
); |
416 | 416 |
|
417 |
// Optional callback arguments: page. |
|
418 |
//FIXME point to view/page method in this module |
|
419 |
$items['cdm_dataportal/specimen'] = array( |
|
420 |
'page callback' => 'cdm_dataportal_specimen_page_view', |
|
421 |
'access arguments' => array('access cdm content'), |
|
422 |
'type' => MENU_CALLBACK, |
|
423 |
// Expected callback arguments: uuid. |
|
424 |
); |
|
417 |
$items['cdm_dataportal/specimen'] = array( |
|
418 |
'page callback' => 'cdm_dataportal_specimen_page_view', |
|
419 |
'access arguments' => array('access cdm content'), |
|
420 |
'type' => MENU_CALLBACK, |
|
421 |
// Expected callback arguments: uuid. |
|
422 |
); |
|
423 |
|
|
424 |
$items['cdm_dataportal/named_area'] = array( |
|
425 |
'page callback' => 'cdm_dataportal_named_area_page_view', |
|
426 |
'access arguments' => array('access cdm content'), |
|
427 |
'type' => MENU_CALLBACK, |
|
428 |
// Expected callback arguments: uuid. |
|
429 |
); |
|
425 | 430 |
|
426 | 431 |
$items['cdm_dataportal/name'] = array( |
427 | 432 |
'page callback' => 'cdm_dataportal_name_page_view', |
... | ... | |
1616 | 1621 |
} |
1617 | 1622 |
|
1618 | 1623 |
/** |
1624 |
* |
|
1625 |
* Creates a named area view. |
|
1626 |
* @param string $uuid the UUID of the specimen |
|
1627 |
* * @return object |
|
1628 |
* An object with two fields: |
|
1629 |
* - title: the page title |
|
1630 |
* - content: the page content |
|
1631 |
*/ |
|
1632 |
|
|
1633 |
function cdm_dataportal_named_area_view($uuid) { |
|
1634 |
$named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, $uuid); |
|
1635 |
if (empty($named_area) || $named_area->class !== 'NamedArea') { |
|
1636 |
drupal_set_title(t('Named area does not exist'), PASS_THROUGH); |
|
1637 |
return FALSE; |
|
1638 |
} |
|
1639 |
$named_area_page = new stdClass(); |
|
1640 |
|
|
1641 |
$named_area_page->title = $named_area->representation_L10n; |
|
1642 |
|
|
1643 |
// Render the specimen page. |
|
1644 |
$render_array = compose_cdm_named_area_page($uuid); |
|
1645 |
$named_area_page->content = drupal_render($render_array); |
|
1646 |
|
|
1647 |
return $named_area_page; |
|
1648 |
} |
|
1649 |
|
|
1650 |
function cdm_dataportal_named_area_page_view($uuid) { |
|
1651 |
|
|
1652 |
cdm_check_valid_portal_page(); |
|
1653 |
|
|
1654 |
$named_area_page = cdm_dataportal_named_area_view($uuid); |
|
1655 |
if (!empty($named_area_page)) { |
|
1656 |
return cdm_node_show(NODETYPE_NAME, $uuid, $named_area_page->title, $named_area_page->content); |
|
1657 |
} |
|
1658 |
else { |
|
1659 |
return ''; |
|
1660 |
} |
|
1661 |
|
|
1662 |
|
|
1663 |
} |
|
1664 |
|
|
1665 |
/** |
|
1619 | 1666 |
* Returns a name page as a Drupal node ready to be renderized by Drupal. |
1620 | 1667 |
* |
1621 | 1668 |
* The node page shows the taxon name title and the list of taxon related |
... | ... | |
1905 | 1952 |
} |
1906 | 1953 |
} |
1907 | 1954 |
|
1955 |
function path_to_named_area($uuid) { |
|
1956 |
|
|
1957 |
if (!$uuid) { |
|
1958 |
return FALSE; |
|
1959 |
} |
|
1960 |
else { |
|
1961 |
return 'cdm_dataportal/named_area/' . $uuid; |
|
1962 |
} |
|
1963 |
} |
|
1964 |
|
|
1908 | 1965 |
/** |
1909 | 1966 |
* Creates a URL to show a synonmy in the according taxon page. |
1910 | 1967 |
* |
modules/cdm_dataportal/includes/occurrences.inc | ||
---|---|---|
18 | 18 |
|
19 | 19 |
|
20 | 20 |
/** |
21 |
* @param $preservedSpecimenDTO |
|
22 |
* @param $detail_html |
|
23 |
* @return string |
|
24 |
*/ |
|
25 |
function compose_cdm_specimen_page($specimenUuid) |
|
26 |
{ |
|
27 |
drupal_set_title("Specimen Details"); |
|
28 |
$preservedSpecimenDTO = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($specimenUuid, 'specimenDerivates')); |
|
29 |
|
|
30 |
$render_array = array(); |
|
31 |
RenderHints::pushToRenderStack('specimen_page'); |
|
32 |
|
|
33 |
$detail_html = compose_cdm_specimen_page_html($preservedSpecimenDTO, true); |
|
34 |
$render_array['specimen_html'] = array( |
|
35 |
'#markup' => $detail_html |
|
36 |
); |
|
37 |
|
|
38 |
RenderHints::popFromRenderStack(); |
|
39 |
return $render_array; |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* @param $preservedSpecimenDTO |
|
21 |
* Provides the HTML markup for a specimen page |
|
22 |
* |
|
23 |
* @param $specimen |
|
24 |
* |
|
44 | 25 |
* @return string |
26 |
* The markup for a specimen page |
|
45 | 27 |
*/ |
46 |
function compose_cdm_specimen_page_html($preservedSpecimenDTO, $isSpecimenPage = false)
|
|
28 |
function render_cdm_specimen_page($specimen, $is_specimen_page = false)
|
|
47 | 29 |
{ |
48 | 30 |
$detail_html = ""; |
49 | 31 |
//link to specimen page |
50 |
$pathToSpecimen = path_to_specimen($preservedSpecimenDTO->uuid);
|
|
51 |
if (!$isSpecimenPage) {
|
|
52 |
$specimenPageLink = l($preservedSpecimenDTO->accessionNumber, $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
|
32 |
$pathToSpecimen = path_to_specimen($specimen->uuid);
|
|
33 |
if (!$is_specimen_page) {
|
|
34 |
$specimenPageLink = l($specimen->accessionNumber, $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
|
53 | 35 |
$detail_html .= "<strong>$specimenPageLink</strong><br>"; |
54 | 36 |
} |
55 | 37 |
|
56 |
if($isSpecimenPage) {
|
|
57 |
if($preservedSpecimenDTO->citation){
|
|
58 |
$detail_html .= "<br>".create_label("Citation") . $preservedSpecimenDTO->citation . "<br>";
|
|
38 |
if($is_specimen_page) {
|
|
39 |
if($specimen->citation){
|
|
40 |
$detail_html .= "<br>".create_label("Citation") . $specimen->citation . "<br>";
|
|
59 | 41 |
} |
60 | 42 |
} |
61 |
if($preservedSpecimenDTO->preferredStableUri){
|
|
62 |
$detail_html .= "<br>".create_label("Preferred stable URI") . cdm_external_uri($preservedSpecimenDTO->preferredStableUri) . "<br>";
|
|
43 |
if($specimen->preferredStableUri){
|
|
44 |
$detail_html .= "<br>".create_label("Preferred stable URI") . cdm_external_uri($specimen->preferredStableUri) . "<br>";
|
|
63 | 45 |
} |
64 |
if($isSpecimenPage){
|
|
46 |
if($is_specimen_page){
|
|
65 | 47 |
// associated taxa |
66 |
if($preservedSpecimenDTO->associatedTaxa){
|
|
48 |
if($specimen->associatedTaxa){
|
|
67 | 49 |
$detail_html .= "<br>"; |
68 | 50 |
$detail_html .= create_label("Associated with"); |
69 |
if(sizeof($preservedSpecimenDTO->associatedTaxa)>1){
|
|
51 |
if(sizeof($specimen->associatedTaxa)>1){
|
|
70 | 52 |
$detail_html .= "<br>"; |
71 | 53 |
} |
72 |
foreach($preservedSpecimenDTO->associatedTaxa as $associatedTaxon){
|
|
54 |
foreach($specimen->associatedTaxa as $associatedTaxon){
|
|
73 | 55 |
$detail_html .= l($associatedTaxon->second, path_to_taxon($associatedTaxon->first, "specimens"));//$associatedTaxon->second."<br>"; |
74 | 56 |
} |
75 | 57 |
} |
76 | 58 |
} |
77 | 59 |
// - type information |
78 | 60 |
$types = ""; |
79 |
if (isset($preservedSpecimenDTO->types)) {
|
|
61 |
if (isset($specimen->types)) {
|
|
80 | 62 |
//typed taxa |
81 |
if(sizeof($preservedSpecimenDTO->types)>1){
|
|
63 |
if(sizeof($specimen->types)>1){
|
|
82 | 64 |
$detail_html .= "<br>"; |
83 | 65 |
} |
84 |
foreach ($preservedSpecimenDTO->types as $typeStatus => $typedTaxa) {
|
|
85 |
if($isSpecimenPage){
|
|
86 |
if($preservedSpecimenDTO->types){
|
|
66 |
foreach ($specimen->types as $typeStatus => $typedTaxa) {
|
|
67 |
if($is_specimen_page){
|
|
68 |
if($specimen->types){
|
|
87 | 69 |
$detail_html .= "<i>".$typeStatus."</i>: "; |
88 | 70 |
foreach($typedTaxa as $typedTaxon){ |
89 | 71 |
$detail_html .= $typedTaxon." "; |
... | ... | |
96 | 78 |
} |
97 | 79 |
} |
98 | 80 |
} |
99 |
$derivateDataDTO = $preservedSpecimenDTO->derivateDataDTO;
|
|
81 |
$derivateDataDTO = $specimen->derivateDataDTO;
|
|
100 | 82 |
// - specimen scans |
101 | 83 |
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true); |
102 | 84 |
// - molecular data |
... | ... | |
138 | 120 |
$detailImages = create_html_links($derivateDataDTO->detailImages, true); |
139 | 121 |
|
140 | 122 |
if ($types) { |
141 |
$detail_html .= $isSpecimenPage?"<br>":"";
|
|
123 |
$detail_html .= $is_specimen_page?"<br>":"";
|
|
142 | 124 |
$detail_html .= create_label("Type(s)") . $types . "<br>"; |
143 | 125 |
} |
144 |
if ($specimenScans and !$isSpecimenPage) {
|
|
126 |
if ($specimenScans and !$is_specimen_page) {
|
|
145 | 127 |
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>"; |
146 | 128 |
} |
147 | 129 |
//specimen scan image gallery |
148 |
if($isSpecimenPage and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
|
130 |
if($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
|
149 | 131 |
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids); |
150 | 132 |
} |
151 | 133 |
|
152 | 134 |
if ($molecularData) { |
153 |
$detail_html .= $isSpecimenPage?"<br>":"";
|
|
135 |
$detail_html .= $is_specimen_page?"<br>":"";
|
|
154 | 136 |
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>"; |
155 | 137 |
} |
156 | 138 |
|
157 |
if ($detailImages and !$isSpecimenPage) {
|
|
139 |
if ($detailImages and !$is_specimen_page) {
|
|
158 | 140 |
$detail_html .= create_label("Detail Images") . $detailImages . "<br>"; |
159 | 141 |
} |
160 | 142 |
|
161 | 143 |
//detail image gallery |
162 |
if($isSpecimenPage and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)){
|
|
144 |
if($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)){
|
|
163 | 145 |
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids); |
164 | 146 |
} |
165 | 147 |
|
166 | 148 |
//character data |
167 |
if ($preservedSpecimenDTO->characterData) {
|
|
168 |
$detail_html .= $isSpecimenPage?"<br>":"";
|
|
149 |
if ($specimen->characterData) {
|
|
150 |
$detail_html .= $is_specimen_page?"<br>":"";
|
|
169 | 151 |
$detail_html .= create_label("Character Data"); |
170 |
if($isSpecimenPage) {
|
|
152 |
if($is_specimen_page) {
|
|
171 | 153 |
$detail_html .= "<br>"; |
172 |
foreach ($preservedSpecimenDTO->characterData as $characterStatePair) {
|
|
154 |
foreach ($specimen->characterData as $characterStatePair) {
|
|
173 | 155 |
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second; |
174 | 156 |
$detail_html .= "<br>"; |
175 | 157 |
} |
... | ... | |
504 | 486 |
if (isset($value->collectingAreas)) { |
505 | 487 |
$area_representations = array(); |
506 | 488 |
foreach ($value->collectingAreas as $area) { |
507 |
$area_representations[] = $area->representation_L10n;
|
|
489 |
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
|
508 | 490 |
} |
509 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'), implode(', ', $area_representations)); |
|
491 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'), |
|
492 |
array( |
|
493 |
array('#markup' => implode(', ', $area_representations)) |
|
494 |
) |
|
495 |
); |
|
510 | 496 |
} |
511 | 497 |
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) { |
512 | 498 |
$sub_dl_groups = array(); |
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
197 | 197 |
if($derivateHierarchy->preservedSpecimenDTOs){ |
198 | 198 |
foreach($derivateHierarchy->preservedSpecimenDTOs as $preservedSpecimenDTO) { |
199 | 199 |
$detail_html .= "<br>"; |
200 |
$detail_html .= compose_cdm_specimen_page_html($preservedSpecimenDTO);
|
|
200 |
$detail_html .= render_cdm_specimen_page($preservedSpecimenDTO);
|
|
201 | 201 |
} |
202 | 202 |
} |
203 | 203 |
$detail_html .= "<br>"; |
... | ... | |
1049 | 1049 |
|
1050 | 1050 |
} |
1051 | 1051 |
|
1052 |
$render_array['#items'] = $items; |
|
1052 | 1053 |
|
1054 |
return $render_array; |
|
1055 |
} |
|
1053 | 1056 |
|
1054 |
$render_array['#items'] = $items; |
|
1057 |
/** |
|
1058 |
* @param $specimen_uuid |
|
1059 |
* @return array |
|
1060 |
* The drupal render array for the page |
|
1061 |
* |
|
1062 |
* @ingroup compose |
|
1063 |
*/ |
|
1064 |
function compose_cdm_specimen_page($specimen_uuid) |
|
1065 |
{ |
|
1066 |
drupal_set_title("Specimen Details"); |
|
1067 |
$specimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($specimen_uuid, 'specimenDerivates')); |
|
1068 |
|
|
1069 |
$render_array = array(); |
|
1070 |
RenderHints::pushToRenderStack('specimen_page'); |
|
1055 | 1071 |
|
1072 |
$detail_html = render_cdm_specimen_page($specimen, true); |
|
1073 |
$render_array['specimen_html'] = array( |
|
1074 |
'#markup' => $detail_html |
|
1075 |
); |
|
1076 |
|
|
1077 |
RenderHints::popFromRenderStack(); |
|
1056 | 1078 |
return $render_array; |
1079 |
} |
|
1057 | 1080 |
|
1081 |
/** |
|
1082 |
* @param $named_area_uuid |
|
1083 |
* @return array |
|
1084 |
* The drupal render array for the page |
|
1085 |
* |
|
1086 |
* @ingroup compose |
|
1087 |
*/ |
|
1088 |
function compose_cdm_named_area_page($named_area_uuid) |
|
1089 |
{ |
|
1090 |
|
|
1091 |
$named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, array($named_area_uuid)); |
|
1092 |
|
|
1093 |
$render_array = array(); |
|
1094 |
RenderHints::pushToRenderStack('named_area_page'); |
|
1095 |
|
|
1096 |
$groups = array(); |
|
1097 |
@_description_list_group_add($groups, t('Name') . ':', $named_area->representation_L10n); |
|
1098 |
@_description_list_group_add($groups, t('IdInVocabulary') . ':', $named_area->idInVocabulary); |
|
1099 |
if(isset($named_area->level)) { |
|
1100 |
@_description_list_group_add($groups, t('Level') . ':', $named_area->level->representation_L10n); |
|
1101 |
} |
|
1102 |
|
|
1103 |
$name_area_details_elements = array( |
|
1104 |
// '#title' => $title, |
|
1105 |
'#theme' => 'description_list', |
|
1106 |
'#groups' => $groups, |
|
1107 |
'#attributes' => array('class' => html_class_attribute_ref($named_area)), |
|
1108 |
); |
|
1109 |
|
|
1110 |
$render_array[] = $name_area_details_elements; |
|
1111 |
|
|
1112 |
RenderHints::popFromRenderStack(); |
|
1113 |
return $render_array; |
|
1058 | 1114 |
} |
modules/cdm_dataportal/node_types.php | ||
---|---|---|
8 | 8 |
define('NODETYPE_MEDIA', 'media'); |
9 | 9 |
define('NODETYPE_REFERENCE', 'reference'); |
10 | 10 |
define('NODETYPE_NAME', 'name'); |
11 |
define('NODETYPE_NAMED_AREA', 'named_area'); |
|
11 | 12 |
|
12 | 13 |
/** |
13 | 14 |
* Implements hook_cdm_nodetypes(). |
... | ... | |
20 | 21 |
'cdm_' . NODETYPE_TAXON => NODETYPE_TAXON, |
21 | 22 |
'cdm_' . NODETYPE_MEDIA => NODETYPE_MEDIA, |
22 | 23 |
'cdm_' . NODETYPE_NAME => NODETYPE_NAME, |
24 |
'cdm_' . NODETYPE_NAMED_AREA => NODETYPE_NAMED_AREA, |
|
23 | 25 |
); |
24 | 26 |
} |
25 | 27 |
return $nodetypes; |
Also available in: Unified diff
ref #2985 implementing named area page to make area details like level accessible