90 |
90 |
|
91 |
91 |
|
92 |
92 |
/**
|
93 |
|
* Provides the HTML markup for a specimen page
|
|
93 |
* Renders a DerivedUnit either in a compact form or with full details.
|
94 |
94 |
*
|
95 |
|
* @param $specimen
|
|
95 |
* @param $derived_unit_dto
|
|
96 |
* The DerivedUnitDTO
|
|
97 |
* @param $with_full_details
|
|
98 |
* Wether to render the dertived unit data with full details, like for example for the specimen page
|
96 |
99 |
*
|
97 |
100 |
* @return string
|
98 |
101 |
* The markup for a specimen page
|
99 |
102 |
*/
|
100 |
|
function render_cdm_specimenDTO_page($specimen, $is_specimen_page = false)
|
|
103 |
function render_cdm_specimenDTO_page($derived_unit_dto, $with_full_details = false)
|
101 |
104 |
{
|
102 |
105 |
$detail_html = "";
|
103 |
106 |
//link to specimen page
|
104 |
|
$path_to_specimen = path_to_specimen($specimen->uuid);
|
105 |
|
if (!$is_specimen_page) {
|
106 |
|
$specimenPageLink = l($specimen->specimenIdentifier, $path_to_specimen);
|
|
107 |
$path_to_specimen = path_to_specimen($derived_unit_dto->uuid);
|
|
108 |
if (!$with_full_details) {
|
|
109 |
$specimenPageLink = l($derived_unit_dto->specimenIdentifier, $path_to_specimen);
|
107 |
110 |
$detail_html .= "<strong>Specimen summary: $specimenPageLink</strong><br>";
|
108 |
111 |
}
|
109 |
112 |
|
110 |
|
if($is_specimen_page) {
|
111 |
|
if($specimen->citation){
|
112 |
|
$detail_html .= "<br>".$specimen->citation."<br>";
|
|
113 |
if($with_full_details) {
|
|
114 |
if($derived_unit_dto->citation){
|
|
115 |
$detail_html .= "<br>".$derived_unit_dto->citation."<br>";
|
113 |
116 |
|
114 |
117 |
}
|
115 |
118 |
}
|
116 |
|
if ($specimen->preferredStableUri) {
|
117 |
|
$stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri);
|
|
119 |
if ($derived_unit_dto->preferredStableUri) {
|
|
120 |
$stableIdentifierLink = l($derived_unit_dto->preferredStableUri, $derived_unit_dto->preferredStableUri);
|
118 |
121 |
$detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>";
|
119 |
122 |
}
|
120 |
|
if ($is_specimen_page) {
|
|
123 |
if ($with_full_details) {
|
121 |
124 |
// associated taxa
|
122 |
|
if ($specimen->associatedTaxa) {
|
|
125 |
if ($derived_unit_dto->associatedTaxa) {
|
123 |
126 |
$detail_html .= "<br>";
|
124 |
127 |
$detail_html .= create_label("Associated with");
|
125 |
|
if (sizeof($specimen->associatedTaxa) > 1) {
|
|
128 |
if (sizeof($derived_unit_dto->associatedTaxa) > 1) {
|
126 |
129 |
$detail_html .= "<br>";
|
127 |
130 |
}
|
128 |
|
foreach ($specimen->associatedTaxa as $associatedTaxon) {
|
|
131 |
foreach ($derived_unit_dto->associatedTaxa as $associatedTaxon) {
|
129 |
132 |
$detail_html .= l($associatedTaxon->label, path_to_taxon($associatedTaxon->uuid, "specimens"));//$associatedTaxon->second."<br>";
|
130 |
133 |
}
|
131 |
134 |
$detail_html .= "<br>";
|
... | ... | |
133 |
136 |
}
|
134 |
137 |
// - type information
|
135 |
138 |
$types = "";
|
136 |
|
if (isset($specimen->types)) {
|
|
139 |
if (isset($derived_unit_dto->types)) {
|
137 |
140 |
//typed taxa
|
138 |
|
foreach ($specimen->types as $typeStatus => $typedTaxa) {
|
139 |
|
if($specimen->types){
|
|
141 |
foreach ($derived_unit_dto->types as $typeStatus => $typedTaxa) {
|
|
142 |
if($derived_unit_dto->types){
|
140 |
143 |
if(empty($typeStatus) || $typeStatus == "_empty_"|| $typeStatus == ""){
|
141 |
144 |
$detail_html .= "<i>Type for:</i> ";
|
142 |
145 |
} else {
|
... | ... | |
152 |
155 |
$detail_html .= '<br>';
|
153 |
156 |
}
|
154 |
157 |
}
|
155 |
|
$derivateDataDTO = $specimen->derivateDataDTO;
|
|
158 |
$derivateDataDTO = $derived_unit_dto->derivateDataDTO;
|
156 |
159 |
// - specimen scans
|
157 |
160 |
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
|
158 |
161 |
// - molecular data
|
... | ... | |
193 |
196 |
$detailImages = create_html_links($derivateDataDTO->detailImages, true);
|
194 |
197 |
|
195 |
198 |
if ($types) {
|
196 |
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
|
199 |
$detail_html .= $with_full_details ? "<br>" : "";
|
197 |
200 |
$detail_html .= create_label("Type(s)") . $types . "<br>";
|
198 |
201 |
}
|
199 |
|
if ($specimenScans and !$is_specimen_page) {
|
|
202 |
if ($specimenScans and !$with_full_details) {
|
200 |
203 |
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>";
|
201 |
204 |
}
|
202 |
205 |
//specimen scan image gallery
|
203 |
|
if ($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
|
206 |
if ($with_full_details and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
204 |
207 |
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids);
|
205 |
208 |
}
|
206 |
209 |
|
207 |
210 |
if ($molecularData) {
|
208 |
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
|
211 |
$detail_html .= $with_full_details ? "<br>" : "";
|
209 |
212 |
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
|
210 |
213 |
}
|
211 |
214 |
|
212 |
|
if ($detailImages and !$is_specimen_page) {
|
|
215 |
if ($detailImages and !$with_full_details) {
|
213 |
216 |
$detail_html .= create_label("Detail Images") . $detailImages . "<br>";
|
214 |
217 |
}
|
215 |
218 |
|
216 |
219 |
//detail image gallery
|
217 |
|
if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
|
|
220 |
if ($with_full_details and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
|
218 |
221 |
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
|
219 |
222 |
}
|
220 |
223 |
|
221 |
224 |
//character data
|
222 |
|
if ($specimen->characterData) {
|
223 |
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
|
225 |
if ($derived_unit_dto->characterData) {
|
|
226 |
$detail_html .= $with_full_details ? "<br>" : "";
|
224 |
227 |
$detail_html .= create_label("Character Data");
|
225 |
|
if ($is_specimen_page) {
|
|
228 |
if ($with_full_details) {
|
226 |
229 |
$detail_html .= "<br>";
|
227 |
|
foreach ($specimen->characterData as $characterStatePair) {
|
|
230 |
foreach ($derived_unit_dto->characterData as $characterStatePair) {
|
228 |
231 |
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second;
|
229 |
232 |
$detail_html .= "<br>";
|
230 |
233 |
}
|
... | ... | |
1000 |
1003 |
/**
|
1001 |
1004 |
* Creates render array items for FieldUnitDTO or DerivedUnitDTO.
|
1002 |
1005 |
*
|
1003 |
|
* @param array $fieldunit_dtos
|
1004 |
|
* list of FieldUnitDTOs
|
|
1006 |
* @param array $root_unit_dtos
|
|
1007 |
* list of SpecimenOrObservationDTOs
|
1005 |
1008 |
* @return array
|
1006 |
1009 |
* An array which can be used in render arrays to be passed to the
|
1007 |
1010 |
* theme_table() and theme_list().
|
1008 |
1011 |
*/
|
1009 |
|
function specimen_render_array_items(array $fieldunit_dtos){
|
|
1012 |
function specimen_render_array_items(array $root_unit_dtos){
|
1010 |
1013 |
|
1011 |
1014 |
$render_array_items = array();
|
1012 |
1015 |
$items = array();
|
1013 |
1016 |
|
1014 |
1017 |
//we need one more item to contain the items of one level (fieldunit, derivate data etc.)
|
1015 |
|
foreach ($fieldunit_dtos as &$fieldunit_dto) {
|
1016 |
|
$items['data'] = $fieldunit_dto->label;
|
1017 |
|
$specimen = compose_cdm_specimen_or_observation_tree_entry($fieldunit_dto);
|
|
1018 |
foreach ($root_unit_dtos as &$sob_dto) {
|
|
1019 |
$items['data'] = $sob_dto->label;
|
|
1020 |
$specimen = compose_cdm_specimen_or_observation_tree_entry($sob_dto);
|
1018 |
1021 |
$children = array();
|
1019 |
1022 |
$child = array();
|
1020 |
1023 |
$child['data'] =$specimen;
|
1021 |
1024 |
// $children[] = create_specimen_array($specimenOrObservation->derivatives);
|
1022 |
|
if (isset($fieldunit_dto->derivatives) && sizeof($fieldunit_dto->derivatives) > 0){
|
1023 |
|
usort($fieldunit_dto->derivatives, 'compare_specimen_or_observation_dtos');
|
1024 |
|
$child['children']= specimen_render_array_items($fieldunit_dto->derivatives);
|
|
1025 |
if (isset($sob_dto->derivatives) && sizeof($sob_dto->derivatives) > 0){
|
|
1026 |
usort($sob_dto->derivatives, 'compare_specimen_or_observation_dtos');
|
|
1027 |
$child['children']= specimen_render_array_items($sob_dto->derivatives);
|
1025 |
1028 |
}
|
1026 |
1029 |
$children[]=$child;
|
1027 |
1030 |
$items['children'] = $children;
|
... | ... | |
1034 |
1037 |
* Composes a compressed derivate table showing all derivatives which
|
1035 |
1038 |
* stem from a common gathering event.
|
1036 |
1039 |
*
|
1037 |
|
* @param $field_unit_uuids array
|
1038 |
|
* An array of uuids for cdm FieldUnit entities.
|
|
1040 |
* @param $root_unit_uuids array
|
|
1041 |
* An array of uuids for cdm root units of the derivation graphs.
|
1039 |
1042 |
*
|
1040 |
1043 |
* @return array
|
1041 |
1044 |
* A drupal render array for a table
|
... | ... | |
1045 |
1048 |
* @ingroup compose
|
1046 |
1049 |
*/
|
1047 |
1050 |
|
1048 |
|
function compose_compressed_specimen_derivate_table($field_unit_uuids) {
|
|
1051 |
function compose_compressed_specimen_derivate_table($root_unit_uuids) {
|
1049 |
1052 |
|
1050 |
1053 |
// prepare font icons
|
1051 |
1054 |
$expand_icon = font_awesome_icon_markup(
|
... | ... | |
1070 |
1073 |
$rowcount = 0;
|
1071 |
1074 |
$rows = array();
|
1072 |
1075 |
|
1073 |
|
foreach ($field_unit_uuids as $field_unit_uuid) {
|
|
1076 |
foreach ($root_unit_uuids as $root_unit_uuid) {
|
1074 |
1077 |
|
1075 |
1078 |
//get derivate hierarchy for the FieldUnit
|
1076 |
|
$derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy'));
|
1077 |
|
if ($derivateHierarchy) {
|
|
1079 |
$sob_dto = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE_AS_DTO, array($root_unit_uuid));
|
|
1080 |
if ($sob_dto) {
|
1078 |
1081 |
//summary row
|
1079 |
|
$rows[] = array(
|
1080 |
|
'data' => array(
|
1081 |
|
array(
|
1082 |
|
'data' => $expand_icon . $collapse_icon,
|
1083 |
|
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
|
1084 |
|
),
|
1085 |
|
array(
|
1086 |
|
'data' => $derivateHierarchy->country,
|
1087 |
|
'class' => array('summary_row_cell')
|
1088 |
|
),
|
1089 |
|
array(
|
1090 |
|
'data' => $derivateHierarchy->date,
|
1091 |
|
'class' => array('summary_row_cell')
|
1092 |
|
),
|
1093 |
|
array(
|
1094 |
|
'data' => $derivateHierarchy->collectingString,
|
1095 |
|
'class' => array('summary_row_cell')
|
1096 |
|
),
|
1097 |
|
@array(
|
1098 |
|
'data' => $derivateHierarchy->collectionStatistics,
|
1099 |
|
'class' => array('summary_row_cell')
|
1100 |
|
),
|
1101 |
|
array(
|
1102 |
|
'data' => $derivateHierarchy->hasType ? $checked_box_icon : "",
|
1103 |
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
1104 |
|
),
|
1105 |
|
array(
|
1106 |
|
'data' => $derivateHierarchy->hasSpecimenScan ? $checked_box_icon : "",
|
1107 |
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
|
1082 |
if($sob_dto->class == "FieldUnitDTO"){
|
|
1083 |
$rows[] = array(
|
|
1084 |
'data' => array(
|
|
1085 |
array(
|
|
1086 |
'data' => $expand_icon . $collapse_icon,
|
|
1087 |
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
|
|
1088 |
),
|
|
1089 |
array(
|
|
1090 |
'data' => $sob_dto->country,
|
|
1091 |
'class' => array('summary_row_cell')
|
|
1092 |
),
|
|
1093 |
array(
|
|
1094 |
'data' => $sob_dto->date,
|
|
1095 |
'class' => array('summary_row_cell')
|
|
1096 |
),
|
|
1097 |
array(
|
|
1098 |
'data' => $sob_dto->collectingString,
|
|
1099 |
'class' => array('summary_row_cell')
|
|
1100 |
),
|
|
1101 |
@array(
|
|
1102 |
'data' => $sob_dto->collectionStatistics,
|
|
1103 |
'class' => array('summary_row_cell')
|
|
1104 |
),
|
|
1105 |
array(
|
|
1106 |
'data' => $sob_dto->hasType ? $checked_box_icon : "",
|
|
1107 |
'class' => array('summary_row_cell', 'summary_row_icon')
|
|
1108 |
),
|
|
1109 |
array(
|
|
1110 |
'data' => $sob_dto->hasSpecimenScan ? $checked_box_icon : "",
|
|
1111 |
'class' => array('summary_row_cell', 'summary_row_icon')
|
|
1112 |
),
|
|
1113 |
array(
|
|
1114 |
'data' => ($sob_dto->hasDna ? $sequence_icon : "") . " "
|
|
1115 |
. ($sob_dto->hasDetailImage ? $detail_image_icon : "") . " "
|
|
1116 |
. ($sob_dto->hasCharacterData ? $character_data_icon : ""),
|
|
1117 |
'class' => array('summary_row_cell', 'summary_row_icon')
|
|
1118 |
)
|
1108 |
1119 |
),
|
1109 |
|
array(
|
1110 |
|
'data' => ($derivateHierarchy->hasDna ? $sequence_icon : "") . " "
|
1111 |
|
. ($derivateHierarchy->hasDetailImage ? $detail_image_icon : "") . " "
|
1112 |
|
. ($derivateHierarchy->hasCharacterData ? $character_data_icon : ""),
|
1113 |
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
|
1120 |
'id' => 'derivate_summary' . $rowcount, // summary row id
|
|
1121 |
'class' => array('summary_row'),
|
|
1122 |
);
|
|
1123 |
} else {
|
|
1124 |
$rows[] = array(
|
|
1125 |
'data' => array(
|
|
1126 |
array(
|
|
1127 |
'data' => $expand_icon . $collapse_icon,
|
|
1128 |
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
|
|
1129 |
),
|
|
1130 |
array(
|
|
1131 |
'data' => $sob_dto->label,
|
|
1132 |
'class' => array('summary_row_cell'),
|
|
1133 |
'colspan' => 7
|
|
1134 |
)
|
1114 |
1135 |
)
|
1115 |
|
),
|
1116 |
|
'id' => 'derivate_summary' . $rowcount, // summary row id
|
1117 |
|
'class' => array('summary_row'),
|
1118 |
|
);
|
|
1136 |
);
|
|
1137 |
}
|
1119 |
1138 |
|
1120 |
1139 |
//assemble field unit details
|
1121 |
1140 |
$detail_html = "";
|
1122 |
1141 |
// - citation
|
1123 |
|
if ($derivateHierarchy->citation) {
|
1124 |
|
$detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>";
|
|
1142 |
if ($sob_dto->citation) {
|
|
1143 |
$detail_html .= create_label("Citation") . $sob_dto->citation . "<br>";
|
1125 |
1144 |
}
|
1126 |
1145 |
//assemble specimen details
|
1127 |
|
if ($derivateHierarchy->derivatives) {
|
|
1146 |
if ($sob_dto->derivatives) {
|
1128 |
1147 |
$derivatives_orderd = [];
|
1129 |
|
foreach ($derivateHierarchy->derivatives as $derivedUnitDTO) {
|
1130 |
|
$derivatives_orderd[$derivedUnitDTO->specimenIdentifier] = $derivedUnitDTO;
|
|
1148 |
foreach ($sob_dto->derivatives as $derivative_dto) {
|
|
1149 |
$derivatives_orderd[$derivative_dto->specimenIdentifier] = $derivative_dto;
|
1131 |
1150 |
}
|
1132 |
1151 |
ksort($derivatives_orderd);
|
1133 |
|
foreach ($derivatives_orderd as $derivedUnitDTO) {
|
|
1152 |
foreach ($derivatives_orderd as $derivative_dto) {
|
1134 |
1153 |
$detail_html .= "<br>";
|
1135 |
|
$detail_html .= render_cdm_specimenDTO_page($derivedUnitDTO);
|
|
1154 |
$detail_html .= render_cdm_specimenDTO_page($derivative_dto);
|
1136 |
1155 |
}
|
1137 |
1156 |
}
|
1138 |
1157 |
$detail_html .= "<br>";
|
... | ... | |
1182 |
1201 |
* Composes the view on specimens and occurrences as derivate tree
|
1183 |
1202 |
* starting from the field unit including all derivatives.
|
1184 |
1203 |
*
|
1185 |
|
* @see DM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
|
|
1204 |
* @see CDM_SPECIMEN_LIST_VIEW_MODE_OPTION_DERIVATE_TREE
|
1186 |
1205 |
*
|
1187 |
|
* @param object $fieldunit_dtos
|
1188 |
|
* list of FieldUnitDTOs
|
|
1206 |
* @param array $root_unit_dtos
|
|
1207 |
* list of SpecimenOrObservationDTOs
|
1189 |
1208 |
* @return array
|
1190 |
1209 |
* The Drupal render array
|
1191 |
1210 |
*
|
1192 |
1211 |
* @ingroup compose
|
1193 |
1212 |
*/
|
1194 |
|
function compose_specimen_table_top_down(array $fieldunit_dtos){
|
|
1213 |
function compose_specimen_table_top_down(array $root_unit_dtos){
|
1195 |
1214 |
|
1196 |
|
$specimen_render_array_items = specimen_render_array_items($fieldunit_dtos);
|
|
1215 |
$specimen_render_array_items = specimen_render_array_items($root_unit_dtos);
|
1197 |
1216 |
|
1198 |
1217 |
// add icons
|
1199 |
1218 |
$expand_icon = font_awesome_icon_markup(
|
... | ... | |
1765 |
1784 |
*/
|
1766 |
1785 |
function order_specimens_or_observations_by_date_and_type($specimens_or_observations)
|
1767 |
1786 |
{
|
1768 |
|
// order occurrences by date but types should be on top of the list
|
1769 |
1787 |
$type_specimens = array();
|
1770 |
1788 |
$other_occurrences = array();
|
1771 |
1789 |
if(is_array($specimens_or_observations)){
|
... | ... | |
1793 |
1811 |
*/
|
1794 |
1812 |
function order_fieldUnitDtos_by_date_and_type($fieldUnitDTOs)
|
1795 |
1813 |
{
|
1796 |
|
return order_specimens_or_observations_by_date_and_type($fieldUnitDTOs);
|
|
1814 |
$units_with_types = [];
|
|
1815 |
$units_no_types = [];
|
|
1816 |
|
|
1817 |
foreach($fieldUnitDTOs as $dto){
|
|
1818 |
if(isset($dto->specimenTypeDesignations[0])){
|
|
1819 |
$units_with_types[] = $dto;
|
|
1820 |
} else {
|
|
1821 |
$units_no_types[] = $dto;
|
|
1822 |
}
|
|
1823 |
}
|
|
1824 |
usort($units_with_types, 'compare_specimen_or_observation_dtos_by_date');
|
|
1825 |
usort($units_no_types, 'compare_specimen_or_observation_dtos_by_date');
|
|
1826 |
|
|
1827 |
return array_merge($units_with_types, $units_no_types);
|
1797 |
1828 |
}
|
1798 |
1829 |
|
1799 |
1830 |
/**
|
... | ... | |
1901 |
1932 |
}
|
1902 |
1933 |
|
1903 |
1934 |
/**
|
1904 |
|
* Compares two SpecimenTypeDesignations
|
|
1935 |
* Compares two SpecimenTypeDesignations by identifier and label
|
1905 |
1936 |
*
|
1906 |
1937 |
* @param object $a
|
1907 |
1938 |
* A SpecimenOrObservationDTO.
|
... | ... | |
1914 |
1945 |
$b_text = isset($b->specimenIdentifier) ? $b->specimenIdentifier : $b->label;
|
1915 |
1946 |
return strcasecmp($a_text, $b_text);
|
1916 |
1947 |
}
|
|
1948 |
|
|
1949 |
/**
|
|
1950 |
* Compares two SpecimenTypeDesignations by date or label
|
|
1951 |
*
|
|
1952 |
* @param object $a
|
|
1953 |
* A SpecimenOrObservationDTO.
|
|
1954 |
* @param object $b
|
|
1955 |
* The SpecimenOrObservationDTO.
|
|
1956 |
*/
|
|
1957 |
function compare_specimen_or_observation_dtos_by_date($a, $b) {
|
|
1958 |
// Sort alphabetically.
|
|
1959 |
$a_text = isset($a->date) ? $a->date : $a->label;
|
|
1960 |
$b_text = isset($b->date) ? $b->date : $b->label;
|
|
1961 |
return strcasecmp($a_text, $b_text);
|
|
1962 |
}
|
ref #7704, ref #9395 using web-services now returning all root units