1 |
c70b93c3
|
Andreas Kohlbecker
|
<?php
|
2 |
f19f47fa
|
Andreas Kohlbecker
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Page functions.
|
5 |
|
|
*
|
6 |
|
|
* @copyright
|
7 |
|
|
* (C) 2007-2012 EDIT
|
8 |
|
|
* European Distributed Institute of Taxonomy
|
9 |
|
|
* http://www.e-taxonomy.eu
|
10 |
|
|
*
|
11 |
|
|
* The contents of this module are subject to the Mozilla
|
12 |
|
|
* Public License Version 1.1.
|
13 |
c70b93c3
|
Andreas Kohlbecker
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*
|
15 |
|
|
* @author
|
16 |
f19f47fa
|
Andreas Kohlbecker
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* Creates a render array representing the ocurrences associetad with the $taxon.
|
22 |
|
|
*
|
23 |
|
|
* The resulting render array contains two elements:
|
24 |
|
|
* - 'map': A map showing all point locations of the occurences is availabale
|
25 |
|
|
* - 'specimen_list': the list of occurences prepated as table for theme_table()
|
26 |
|
|
*
|
27 |
|
|
* @param object $taxon
|
28 |
|
|
* A cdm Taxon object
|
29 |
|
|
* @return
|
30 |
|
|
* A render array suitable for drupal_render()
|
31 |
|
|
*
|
32 |
c70b93c3
|
Andreas Kohlbecker
|
*/
|
33 |
f19f47fa
|
Andreas Kohlbecker
|
function cdm_dataportal_taxon_page_specimens($taxon) {
|
34 |
|
|
|
35 |
1ce9afb7
|
Patric Plitzner
|
$render_array = array();
|
36 |
|
|
RenderHints::pushToRenderStack('taxon_page_specimens');
|
37 |
30f78c59
|
Andreas Kohlbecker
|
|
38 |
b8afc4bb
|
Patric Plitzner
|
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
|
39 |
|
|
$relationship_choice['direct'] = get_selection($relationship_choice['direct']);
|
40 |
|
|
$relationship_choice['invers'] = get_selection($relationship_choice['invers']);
|
41 |
|
|
|
42 |
|
|
$by_associatedtaxon_query_parameters = array(
|
43 |
|
|
'relationshipsInvers' => implode(',', $relationship_choice['invers']),
|
44 |
|
|
'relationships' => implode(',', $relationship_choice['direct']),
|
45 |
|
|
);
|
46 |
|
|
|
47 |
|
|
if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
|
48 |
|
|
$by_associatedtaxon_query_parameters = array_merge($by_associatedtaxon_query_parameters, $_REQUEST['pager']);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
$by_associatedtaxon_query = http_build_query($by_associatedtaxon_query_parameters);
|
52 |
276f39f6
|
Katja Luther
|
|
53 |
d3f77ada
|
Katja Luther
|
$ws_string = 'specimensOrObservation';
|
54 |
276f39f6
|
Katja Luther
|
if (variable_get('cdm_dataportal_specimen_derivate_tree')){
|
55 |
d3f77ada
|
Katja Luther
|
$ws_string .= "DTOs";
|
56 |
|
|
}else{
|
57 |
|
|
$ws_string .= "s";
|
58 |
|
|
}
|
59 |
b8afc4bb
|
Patric Plitzner
|
|
60 |
9a124e57
|
Katja Luther
|
$specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, $ws_string));
|
61 |
|
|
if(!variable_get('cdm_dataportal_specimen_derivate_tree')) {
|
62 |
|
|
$pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
|
63 |
|
|
null,
|
64 |
|
|
$by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
|
65 |
|
|
);
|
66 |
|
|
$specimensOrObservations = array();
|
67 |
|
|
if (isset($pager->records[0])) {
|
68 |
|
|
$specimensOrObservations = $pager->records;
|
69 |
|
|
}
|
70 |
59781fc6
|
Katja Luther
|
}
|
71 |
c10f70e4
|
Katja Luther
|
// cdm_ws_get(CDM_WS_OCCURRENCE_FIELDUNIT_DTO_BY_ASSOCIATEDTAXON,
|
72 |
|
|
// null,
|
73 |
|
|
// $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
|
74 |
|
|
// );
|
75 |
|
|
|
76 |
|
|
// $specimensOrObservations = array();
|
77 |
|
|
// if(isset($pager->records[0])){
|
78 |
|
|
// $specimensOrObservations = $pager->records;
|
79 |
|
|
// }
|
80 |
b8afc4bb
|
Patric Plitzner
|
|
81 |
|
|
// order occurrences by date but types should be on top of the list
|
82 |
|
|
$type_specimens = array();
|
83 |
|
|
$other_occurrences = array();
|
84 |
98262d29
|
Katja Luther
|
foreach ($specimensOrObservations as $occurrence) {
|
85 |
6eaec849
|
Katja Luther
|
$typeDesignationsPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $occurrence->uuid);
|
86 |
b8afc4bb
|
Patric Plitzner
|
if (isset($typeDesignationsPager->count) && $typeDesignationsPager->count > 0) {
|
87 |
|
|
$type_specimens[] = $occurrence;
|
88 |
6eaec849
|
Katja Luther
|
} else {
|
89 |
|
|
$other_occurrences[] = $occurrence;
|
90 |
b8afc4bb
|
Patric Plitzner
|
}
|
91 |
|
|
}
|
92 |
|
|
$specimensOrObservations = array_merge($type_specimens, $other_occurrences);
|
93 |
|
|
|
94 |
|
|
// Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field
|
95 |
a2acff0a
|
Katja Luther
|
if (!variable_get('cdm_dataportal_specimen_derivate_tree')) {
|
96 |
|
|
foreach ($specimensOrObservations as &$occurrence) {
|
97 |
|
|
$occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
98 |
|
|
$occurrence->uuid,
|
99 |
|
|
'fieldObjectMediaDTO',
|
100 |
|
|
));
|
101 |
|
|
$occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
102 |
|
|
$occurrence->uuid,
|
103 |
|
|
'derivedUnitMedia',
|
104 |
|
|
));
|
105 |
|
|
}
|
106 |
7965ef92
|
Katja Luther
|
}
|
107 |
b8afc4bb
|
Patric Plitzner
|
|
108 |
b5c89485
|
Patric Plitzner
|
// --- get map service HTTP query parameters
|
109 |
c10f70e4
|
Katja Luther
|
|
110 |
b8afc4bb
|
Patric Plitzner
|
if (count($specimensOrObservations) > 0) {
|
111 |
106e1cf9
|
Katja Luther
|
|
112 |
|
|
$occurrence_queryDto = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid, $by_associatedtaxon_query);
|
113 |
|
|
|
114 |
|
|
$map_visibility = variable_get(SPECIMEN_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY_DEFAULT);
|
115 |
|
|
if ($map_visibility == 'always' ||
|
116 |
|
|
variable_get(SPECIMEN_MAP_VISIBILITY, SPECIMEN_MAP_VISIBILITY_DEFAULT) == 'automatic' &&
|
117 |
|
|
(isset($occurrence_queryDto->fieldUnitPoints[0]) || isset($occurrence_queryDto->derivedUnitPoints[0]))) {
|
118 |
|
|
$occurrence_query = $occurrence_queryDto->occurrenceQuery;
|
119 |
|
|
$legend_format_query = null;
|
120 |
|
|
$distribution_query = NULL;
|
121 |
|
|
$render_array['map'] = compose_map('specimens', $occurrence_query, $distribution_query, $legend_format_query, array());
|
122 |
c10f70e4
|
Katja Luther
|
}
|
123 |
b8afc4bb
|
Patric Plitzner
|
}
|
124 |
db725031
|
Andreas Kohlbecker
|
|
125 |
|
|
// -------------------------------------------------------
|
126 |
106e1cf9
|
Katja Luther
|
|
127 |
|
|
|
128 |
d3f77ada
|
Katja Luther
|
|
129 |
1ce9afb7
|
Patric Plitzner
|
if(variable_get('cdm_dataportal_compressed_specimen_derivate_table')){
|
130 |
|
|
|
131 |
|
|
//COMPRESSED SPECIMEN DERIVATE TABLE
|
132 |
4cb163f8
|
Patric Plitzner
|
$associatedFieldUnitsQuery_parameters = array();
|
133 |
|
|
if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
|
134 |
|
|
$associatedFieldUnitsQuery_parameters = array_merge($associatedFieldUnitsQuery_parameters, $_REQUEST['pager']);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
$by_associatedtaxon_query = http_build_query($associatedFieldUnitsQuery_parameters);
|
138 |
09f028e2
|
Andreas Kohlbecker
|
$pager_field_units = cdm_ws_get(CDM_WS_PORTAL_TAXON,
|
139 |
2e82a602
|
Patrick Plitzner
|
array($taxon->uuid, 'associatedFieldUnits'),
|
140 |
|
|
$by_associatedtaxon_query . '&pageSize=' . variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size')
|
141 |
|
|
);
|
142 |
1e87f89f
|
Andreas Kohlbecker
|
|
143 |
09f028e2
|
Andreas Kohlbecker
|
if (isset($pager_field_units->records[0])) {
|
144 |
|
|
$field_unit_uuids = array();
|
145 |
|
|
foreach ($pager_field_units->records as $field_unit) {
|
146 |
|
|
$field_unit_uuids[] = $field_unit->uuid;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
02f3768c
|
Andreas Kohlbecker
|
$render_array['derivate_hierarchy_table'] = compose_specimen_table($field_unit_uuids);
|
150 |
|
|
}
|
151 |
f19f47fa
|
Andreas Kohlbecker
|
|
152 |
1e87f89f
|
Andreas Kohlbecker
|
$render_array['pager'] = markup_to_render_array(
|
153 |
|
|
theme('cdm_pager', array(
|
154 |
|
|
'pager' => $pager_field_units,
|
155 |
|
|
'path' => $_REQUEST['q'],
|
156 |
|
|
'parameters' => $_REQUEST
|
157 |
|
|
)),
|
158 |
|
|
10 // weight
|
159 |
|
|
);
|
160 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
161 |
276f39f6
|
Katja Luther
|
else if(variable_get('cdm_dataportal_specimen_derivate_tree')){
|
162 |
7965ef92
|
Katja Luther
|
$specimen_table = array(
|
163 |
|
|
'#theme' => 'table',
|
164 |
|
|
'#weight' => 2,
|
165 |
|
|
// prefix attributes and rows with '#' to let it pass toF the theme function,
|
166 |
|
|
// otherwise it is handled as child render array
|
167 |
|
|
'#attributes' => array('class' => 'specimens'),
|
168 |
|
|
'#rows' => array(),
|
169 |
|
|
);
|
170 |
106e1cf9
|
Katja Luther
|
$specimen_array = compose_specimen_array($specimensOrObservations);
|
171 |
7965ef92
|
Katja Luther
|
|
172 |
|
|
foreach($specimen_array as $value){
|
173 |
|
|
$renderArray = array(
|
174 |
|
|
'#theme' => 'item_list',
|
175 |
|
|
'#items' => array($value),
|
176 |
|
|
'#type' => 'ul');
|
177 |
|
|
$output = drupal_render($renderArray);
|
178 |
52f57468
|
Katja Luther
|
// $specimen_table['#rows'][] = array(
|
179 |
|
|
// // An array of table rows. collabsible row
|
180 |
|
|
// 'data' => "",
|
181 |
|
|
// 'class' => array('expand_column')
|
182 |
|
|
// );
|
183 |
7965ef92
|
Katja Luther
|
$specimen_table['#rows'][] = array(
|
184 |
|
|
// An array of table rows. Every row is an array of cells, or an associative array
|
185 |
|
|
'data' => array($output),
|
186 |
|
|
'class' => array(
|
187 |
|
|
'descriptionElement',
|
188 |
|
|
'descriptionElement_IndividualsAssociation'
|
189 |
|
|
),
|
190 |
|
|
);
|
191 |
52f57468
|
Katja Luther
|
|
192 |
|
|
|
193 |
7965ef92
|
Katja Luther
|
}
|
194 |
|
|
|
195 |
|
|
$render_array['specimen_list'] = $specimen_table;
|
196 |
52f57468
|
Katja Luther
|
|
197 |
267da0d1
|
Katja Luther
|
|
198 |
|
|
}
|
199 |
1ce9afb7
|
Patric Plitzner
|
else{
|
200 |
|
|
//BOTTOM-UP-SPECIMEN-TABLE
|
201 |
|
|
// --- generate the specimen list as table
|
202 |
|
|
$specimen_table = array(
|
203 |
|
|
'#theme' => 'table',
|
204 |
|
|
'#weight' => 2,
|
205 |
1e87f89f
|
Andreas Kohlbecker
|
// prefix attributes and rows with '#' to let it pass toF the theme function,
|
206 |
1ce9afb7
|
Patric Plitzner
|
// otherwise it is handled as child render array
|
207 |
|
|
'#attributes' => array('class' => 'specimens'),
|
208 |
|
|
'#rows' => array(),
|
209 |
|
|
);
|
210 |
f19f47fa
|
Andreas Kohlbecker
|
|
211 |
1ce9afb7
|
Patric Plitzner
|
if ($specimensOrObservations) {
|
212 |
|
|
|
213 |
|
|
foreach ($specimensOrObservations as $specimenOrObservation) {
|
214 |
|
|
|
215 |
|
|
$mediaList = array();
|
216 |
59781fc6
|
Katja Luther
|
if (is_array($specimenOrObservation->_fieldObjectMedia)) {
|
217 |
|
|
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia);
|
218 |
1ce9afb7
|
Patric Plitzner
|
}
|
219 |
59781fc6
|
Katja Luther
|
if (is_array($specimenOrObservation->_derivedUnitMedia)) {
|
220 |
1ce9afb7
|
Patric Plitzner
|
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia);
|
221 |
|
|
}
|
222 |
|
|
|
223 |
59781fc6
|
Katja Luther
|
|
224 |
1ce9afb7
|
Patric Plitzner
|
// typelabel will contain the typeStatus
|
225 |
|
|
$type_label = '';
|
226 |
|
|
$typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid);
|
227 |
0e533708
|
Patric Plitzner
|
if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) {
|
228 |
1ce9afb7
|
Patric Plitzner
|
$type_status = array();
|
229 |
|
|
foreach ($typeDesignationPager->records as $typeDesignation) {
|
230 |
|
|
if (isset($typeDesignation->typeStatus->representation_L10n)){
|
231 |
|
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
232 |
|
|
}
|
233 |
|
|
}
|
234 |
|
|
$type_label = implode(', ', $type_status);
|
235 |
|
|
if($type_label){
|
236 |
|
|
$type_label .= ': ' ;
|
237 |
|
|
}
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
// --- Specimen entry as dynamic label:
|
241 |
|
|
// -> Dynabox for the specimenOrObservation
|
242 |
|
|
$gallery_name = $specimenOrObservation->uuid;
|
243 |
|
|
|
244 |
c02da888
|
Katja Luther
|
$derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array( $specimenOrObservation->uuid));
|
245 |
267da0d1
|
Katja Luther
|
// --- Render associated media.
|
246 |
|
|
$gallery_html = '';
|
247 |
|
|
if (count($mediaList) > 0) {
|
248 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
249 |
|
|
$captionElements = array(
|
250 |
|
|
'#uri' => t('open media'),
|
251 |
|
|
);
|
252 |
|
|
|
253 |
|
|
$gallery_html = compose_cdm_media_gallerie(array(
|
254 |
|
|
'mediaList' => $mediaList,
|
255 |
|
|
'galleryName' => $gallery_name,
|
256 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
257 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
258 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
259 |
|
|
'captionElements' => $captionElements,
|
260 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
261 |
|
|
'alternativeMediaUri' => NULL,
|
262 |
|
|
'galleryLinkUri' => NULL,
|
263 |
|
|
));
|
264 |
|
|
}
|
265 |
c10f70e4
|
Katja Luther
|
//here we should use the data we already have
|
266 |
1ce9afb7
|
Patric Plitzner
|
$label_html = cdm_dynabox(
|
267 |
cea412e7
|
Andreas Kohlbecker
|
$specimenOrObservation->uuid,
|
268 |
|
|
$type_label . $specimenOrObservation->titleCache,
|
269 |
|
|
$derived_unit_ws_request,
|
270 |
bd814ea2
|
Andreas Kohlbecker
|
'cdm_specimen_or_observation',
|
271 |
cea412e7
|
Andreas Kohlbecker
|
'Click for details',
|
272 |
|
|
array('div', 'div'),
|
273 |
|
|
array(),
|
274 |
|
|
null, // $content_element_selector
|
275 |
|
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
|
276 |
|
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
|
277 |
1ce9afb7
|
Patric Plitzner
|
);
|
278 |
|
|
|
279 |
|
|
// --- Render associated media.
|
280 |
|
|
$gallery_html = '';
|
281 |
|
|
if (count($mediaList) > 0) {
|
282 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
283 |
|
|
$captionElements = array(
|
284 |
|
|
'#uri' => t('open media'),
|
285 |
|
|
);
|
286 |
|
|
|
287 |
a9815578
|
Andreas Kohlbecker
|
$gallery_html = compose_cdm_media_gallerie(array(
|
288 |
1ce9afb7
|
Patric Plitzner
|
'mediaList' => $mediaList,
|
289 |
|
|
'galleryName' => $gallery_name,
|
290 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
291 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
292 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
293 |
|
|
'captionElements' => $captionElements,
|
294 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
295 |
|
|
'alternativeMediaUri' => NULL,
|
296 |
|
|
'galleryLinkUri' => NULL,
|
297 |
|
|
));
|
298 |
|
|
}
|
299 |
|
|
|
300 |
|
|
$specimen_table['#rows'][] = array(
|
301 |
|
|
// An array of table rows. Every row is an array of cells, or an associative array
|
302 |
|
|
'data' => array(
|
303 |
|
|
// Each cell can be either a string or an associative array
|
304 |
|
|
$label_html . $gallery_html
|
305 |
|
|
),
|
306 |
|
|
'class' => array(
|
307 |
|
|
'descriptionElement',
|
308 |
|
|
'descriptionElement_IndividualsAssociation'
|
309 |
|
|
),
|
310 |
|
|
);
|
311 |
|
|
}
|
312 |
|
|
}
|
313 |
f19f47fa
|
Andreas Kohlbecker
|
|
314 |
1ce9afb7
|
Patric Plitzner
|
$render_array['specimen_list'] = $specimen_table;
|
315 |
|
|
$render_array['pager'] = markup_to_render_array(
|
316 |
|
|
theme('cdm_pager', array(
|
317 |
|
|
'pager' => $pager,
|
318 |
|
|
'path' => $_REQUEST['q'],
|
319 |
|
|
'parameters' => $_REQUEST,
|
320 |
|
|
)),
|
321 |
|
|
10 // weight
|
322 |
|
|
);
|
323 |
|
|
}
|
324 |
106e1cf9
|
Katja Luther
|
|
325 |
1ce9afb7
|
Patric Plitzner
|
RenderHints::popFromRenderStack();
|
326 |
|
|
return $render_array;
|
327 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
328 |
1e87f89f
|
Andreas Kohlbecker
|
|
329 |
|
|
/**
|
330 |
67f32f09
|
Andreas Kohlbecker
|
* Creates the drupal render array for the table showing all derivated which are
|
331 |
|
|
* derive from a common gathering event.
|
332 |
1e87f89f
|
Andreas Kohlbecker
|
*
|
333 |
|
|
* @param $field_unit_uuids array
|
334 |
|
|
* An array of uuids for cdm FieldUnit entities.
|
335 |
|
|
*
|
336 |
|
|
* @return array
|
337 |
|
|
* A drupal render array for a table
|
338 |
|
|
*
|
339 |
|
|
* @ingroup compose
|
340 |
|
|
*/
|
341 |
67f32f09
|
Andreas Kohlbecker
|
function compose_specimen_table($field_unit_uuids)
|
342 |
1e87f89f
|
Andreas Kohlbecker
|
{
|
343 |
|
|
// get icon images
|
344 |
|
|
$expand_icon = font_awesome_icon_markup(
|
345 |
|
|
'fa-plus-square-o',
|
346 |
|
|
array(
|
347 |
|
|
'alt' => 'Show details',
|
348 |
|
|
'class' => array('expand_icon')
|
349 |
|
|
)
|
350 |
|
|
);
|
351 |
|
|
$collapse_icon = font_awesome_icon_markup(
|
352 |
|
|
'fa-minus-square-o',
|
353 |
|
|
array(
|
354 |
|
|
'alt' => 'Show details',
|
355 |
|
|
'class' => array('collapse_icon')
|
356 |
|
|
)
|
357 |
|
|
);
|
358 |
|
|
$detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>';
|
359 |
|
|
$checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>';
|
360 |
|
|
$sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>';
|
361 |
|
|
$character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>';
|
362 |
|
|
|
363 |
|
|
$rowcount = 0;
|
364 |
|
|
$rows = array();
|
365 |
|
|
|
366 |
|
|
foreach ($field_unit_uuids as $field_unit_uuid) {
|
367 |
|
|
|
368 |
|
|
//get derivate hierarchy for the FieldUnit
|
369 |
|
|
$derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy'));
|
370 |
|
|
if ($derivateHierarchy) {
|
371 |
|
|
//summary row
|
372 |
|
|
$rows[] = array(
|
373 |
|
|
'data' => array(
|
374 |
|
|
array(
|
375 |
|
|
'data' => $expand_icon . $collapse_icon,
|
376 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
|
377 |
|
|
),
|
378 |
|
|
array(
|
379 |
|
|
'data' => $derivateHierarchy->country,
|
380 |
|
|
'class' => array('summary_row_cell')
|
381 |
|
|
),
|
382 |
|
|
array(
|
383 |
|
|
'data' => $derivateHierarchy->date,
|
384 |
|
|
'class' => array('summary_row_cell')
|
385 |
|
|
),
|
386 |
|
|
array(
|
387 |
6eaec849
|
Katja Luther
|
'data' => $derivateHierarchy->collectingString,
|
388 |
1e87f89f
|
Andreas Kohlbecker
|
'class' => array('summary_row_cell')
|
389 |
|
|
),
|
390 |
5446f047
|
Andreas Kohlbecker
|
@array(
|
391 |
1e87f89f
|
Andreas Kohlbecker
|
'data' => $derivateHierarchy->herbarium,
|
392 |
|
|
'class' => array('summary_row_cell')
|
393 |
|
|
),
|
394 |
|
|
array(
|
395 |
|
|
'data' => $derivateHierarchy->hasType ? $checked_box_icon : "",
|
396 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
397 |
|
|
),
|
398 |
|
|
array(
|
399 |
|
|
'data' => $derivateHierarchy->hasSpecimenScan ? $checked_box_icon : "",
|
400 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
401 |
|
|
),
|
402 |
|
|
array(
|
403 |
|
|
'data' => ($derivateHierarchy->hasDna ? $sequence_icon : "") . " "
|
404 |
|
|
. ($derivateHierarchy->hasDetailImage ? $detail_image_icon : "") . " "
|
405 |
|
|
. ($derivateHierarchy->hasCharacterData ? $character_data_icon : ""),
|
406 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
407 |
|
|
)
|
408 |
|
|
),
|
409 |
8cba0a5f
|
Andreas Kohlbecker
|
'id' => 'derivate_summary' . $rowcount, // summary row id
|
410 |
1e87f89f
|
Andreas Kohlbecker
|
'class' => array('summary_row'),
|
411 |
|
|
);
|
412 |
|
|
|
413 |
|
|
//assemble field unit details
|
414 |
|
|
$detail_html = "";
|
415 |
|
|
// - citation
|
416 |
|
|
if ($derivateHierarchy->citation) {
|
417 |
|
|
$detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>";
|
418 |
|
|
}
|
419 |
|
|
//assemble specimen details
|
420 |
d68a30b0
|
Andreas Kohlbecker
|
if ($derivateHierarchy->derivates) {
|
421 |
|
|
foreach ($derivateHierarchy->derivates as $preservedSpecimenDTO) {
|
422 |
1e87f89f
|
Andreas Kohlbecker
|
$detail_html .= "<br>";
|
423 |
8cba0a5f
|
Andreas Kohlbecker
|
$detail_html .= render_cdm_specimenDTO_page($preservedSpecimenDTO);
|
424 |
a2acff0a
|
Katja Luther
|
}
|
425 |
1e87f89f
|
Andreas Kohlbecker
|
}
|
426 |
|
|
$detail_html .= "<br>";
|
427 |
|
|
//detail row resp. one BIG detail cell
|
428 |
|
|
$rows[] = array(
|
429 |
|
|
'data' => array(
|
430 |
|
|
array(
|
431 |
|
|
'data' => "", //empty first column
|
432 |
|
|
'class' => array('expand_column')
|
433 |
|
|
),
|
434 |
|
|
array(
|
435 |
|
|
'data' => $detail_html,
|
436 |
|
|
'colspan' => 7,
|
437 |
|
|
),
|
438 |
|
|
),
|
439 |
8cba0a5f
|
Andreas Kohlbecker
|
'id' => 'derivate_details' . $rowcount,//details row ID
|
440 |
1e87f89f
|
Andreas Kohlbecker
|
'class' => array('detail_row'),
|
441 |
|
|
);
|
442 |
|
|
$rowcount++;
|
443 |
|
|
}
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
$tableId = "derivate_hierarchy_table";
|
447 |
|
|
$derivateHierarchyTable = array(
|
448 |
|
|
"#theme" => "table",
|
449 |
|
|
"#weight" => 2,
|
450 |
|
|
"#header" => array(
|
451 |
|
|
array(
|
452 |
|
|
'data' => "",
|
453 |
|
|
'class' => array('expand_column')
|
454 |
|
|
),
|
455 |
|
|
"Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"),
|
456 |
|
|
"#rows" => $rows,
|
457 |
|
|
"#attributes" => array(
|
458 |
|
|
"id" => $tableId,
|
459 |
|
|
"border" => 2
|
460 |
|
|
)
|
461 |
|
|
);
|
462 |
|
|
|
463 |
|
|
//add toggle functionality to derivate hierarchy table
|
464 |
|
|
drupal_add_js_rowToggle("#" . $tableId);
|
465 |
|
|
|
466 |
|
|
return $derivateHierarchyTable;
|
467 |
|
|
}
|
468 |
|
|
|
469 |
65a4de51
|
Patrick Plitzner
|
function create_html_link($link, $openInExternalWindow=false){
|
470 |
7d8ef9fa
|
Patric Plitzner
|
$html = "";
|
471 |
65a4de51
|
Patrick Plitzner
|
if($link->uri && $link->uri!=""){
|
472 |
|
|
$html .= '<a href="' . $link->uri . '"';
|
473 |
|
|
if($openInExternalWindow){
|
474 |
|
|
$html .= ' target="_blank"';
|
475 |
|
|
}
|
476 |
|
|
$html .= '>' . $link->linkText . '</a>';
|
477 |
7d8ef9fa
|
Patric Plitzner
|
}
|
478 |
|
|
else{
|
479 |
|
|
$html .= $link->linkText;
|
480 |
|
|
}
|
481 |
|
|
return $html;
|
482 |
|
|
}
|
483 |
|
|
|
484 |
|
|
/**
|
485 |
65a4de51
|
Patrick Plitzner
|
* Creates HTML links from the given link list concatenated by default by a comma.
|
486 |
7d8ef9fa
|
Patric Plitzner
|
* @param $linkList the list with Link objects having "uri" and "linkText" as members
|
487 |
|
|
* @return string the assembled HTML string containing the links
|
488 |
|
|
*/
|
489 |
65a4de51
|
Patrick Plitzner
|
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
|
490 |
7d8ef9fa
|
Patric Plitzner
|
{
|
491 |
|
|
$html = "";
|
492 |
|
|
if ($linkList) {
|
493 |
|
|
foreach ($linkList as $link) {
|
494 |
65a4de51
|
Patrick Plitzner
|
$html .= create_html_link($link, $openInExternalWindow).$separator;
|
495 |
7d8ef9fa
|
Patric Plitzner
|
}
|
496 |
65a4de51
|
Patrick Plitzner
|
$html = rtrim($html, $separator);
|
497 |
7d8ef9fa
|
Patric Plitzner
|
}
|
498 |
|
|
return $html;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
00a8e4b6
|
Andreas Kohlbecker
|
/**
|
502 |
|
|
* Composes a taxon page which can consist of multiple parts like
|
503 |
|
|
* 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed
|
504 |
|
|
* as tabs or as sections of a single page.
|
505 |
|
|
*
|
506 |
|
|
* It is headed by the name of the accepted taxon without author and reference.
|
507 |
|
|
*
|
508 |
|
|
* @param $taxon
|
509 |
|
|
* The CDM Taxon Instance to compose the page for.
|
510 |
|
|
* @param $page_part
|
511 |
|
|
* Name of the part to display, valid values are:
|
512 |
|
|
* - 'description' - for the general part
|
513 |
|
|
* - 'images'
|
514 |
|
|
* - 'synonymy'
|
515 |
|
|
* - 'keys'
|
516 |
|
|
* - 'all'
|
517 |
|
|
*
|
518 |
|
|
* @return array
|
519 |
|
|
* A drupal render array
|
520 |
|
|
*
|
521 |
|
|
* @ingroup compose
|
522 |
|
|
*/
|
523 |
|
|
function compose_cdm_taxon_page($taxon, $page_part = 'description') {
|
524 |
|
|
|
525 |
0ae57522
|
Patric Plitzner
|
// we better cache here since drupal_get_query_parameters has no internal static cache variable
|
526 |
|
|
$http_request_params = drupal_get_query_parameters();
|
527 |
00a8e4b6
|
Andreas Kohlbecker
|
|
528 |
0ae57522
|
Patric Plitzner
|
// add all mandatory js sources
|
529 |
|
|
_add_js_footnotes();
|
530 |
00a8e4b6
|
Andreas Kohlbecker
|
|
531 |
|
|
|
532 |
0ae57522
|
Patric Plitzner
|
$render_array = array();
|
533 |
|
|
$weight = 0; // the weight for the render array elements
|
534 |
00a8e4b6
|
Andreas Kohlbecker
|
|
535 |
0ae57522
|
Patric Plitzner
|
$tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
|
536 |
00a8e4b6
|
Andreas Kohlbecker
|
|
537 |
0ae57522
|
Patric Plitzner
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
538 |
00a8e4b6
|
Andreas Kohlbecker
|
|
539 |
22383f95
|
Andreas Kohlbecker
|
$synonymy_as_tab = variable_get(CDM_SYNONYMY_AS_TAB, CDM_SYNONYMY_AS_TAB_DEFAULT) === 1;
|
540 |
|
|
if(!$synonymy_as_tab){
|
541 |
|
|
unset($tabsToDisplay["Synonymy"]);
|
542 |
3e6dfbb3
|
Andreas Kohlbecker
|
// the synonymy is located in the general part in this case
|
543 |
|
|
if($page_part == 'synonymy'){
|
544 |
|
|
$page_part = 'description';
|
545 |
|
|
}
|
546 |
22383f95
|
Andreas Kohlbecker
|
}
|
547 |
|
|
|
548 |
0ae57522
|
Patric Plitzner
|
$media = _load_media_for_taxon($taxon);
|
549 |
00a8e4b6
|
Andreas Kohlbecker
|
|
550 |
|
|
|
551 |
0ae57522
|
Patric Plitzner
|
if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
|
552 |
48a6d7e8
|
Andreas Kohlbecker
|
taxon_page_tabs_hidden_add('images');
|
553 |
0ae57522
|
Patric Plitzner
|
}
|
554 |
00a8e4b6
|
Andreas Kohlbecker
|
|
555 |
0ae57522
|
Patric Plitzner
|
// --- GET specimensOrObservations --- //
|
556 |
c10f70e4
|
Katja Luther
|
$specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservationsCount'));
|
557 |
00a8e4b6
|
Andreas Kohlbecker
|
|
558 |
c10f70e4
|
Katja Luther
|
$specimensOrObservationsCount = $specimensOrObservations != null ? $specimensOrObservations->result : 0;
|
559 |
0ae57522
|
Patric Plitzner
|
if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
|
560 |
48a6d7e8
|
Andreas Kohlbecker
|
taxon_page_tabs_hidden_add('specimens');
|
561 |
0ae57522
|
Patric Plitzner
|
}
|
562 |
00a8e4b6
|
Andreas Kohlbecker
|
|
563 |
0ae57522
|
Patric Plitzner
|
// --- GET polytomousKeys --- //
|
564 |
|
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
|
565 |
|
|
$identificationKeyCount = 0;
|
566 |
|
|
if ($polytomousKeysPager) {
|
567 |
|
|
$identificationKeyCount += $polytomousKeysPager->count;
|
568 |
|
|
}
|
569 |
|
|
if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
|
570 |
48a6d7e8
|
Andreas Kohlbecker
|
taxon_page_tabs_hidden_add('keys');
|
571 |
0ae57522
|
Patric Plitzner
|
}
|
572 |
092744e1
|
Andreas Kohlbecker
|
|
573 |
22383f95
|
Andreas Kohlbecker
|
// --- GET TaxonNodeAgentRelations --- //
|
574 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
575 |
|
|
$taxon_node_agent_relations_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
|
576 |
|
|
array(
|
577 |
|
|
$taxon->uuid,
|
578 |
|
|
$current_classification_uuid,
|
579 |
|
|
),
|
580 |
|
|
"pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible!
|
581 |
|
|
);
|
582 |
|
|
if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){
|
583 |
48a6d7e8
|
Andreas Kohlbecker
|
taxon_page_tabs_hidden_add('experts');
|
584 |
22383f95
|
Andreas Kohlbecker
|
}
|
585 |
7663cd0b
|
Andreas Kohlbecker
|
|
586 |
22383f95
|
Andreas Kohlbecker
|
if (!isset($tabsToDisplay["Synonymy"]) || $tabsToDisplay["Synonymy"] == '0') {
|
587 |
48a6d7e8
|
Andreas Kohlbecker
|
taxon_page_tabs_hidden_add('synonymy');
|
588 |
0ae57522
|
Patric Plitzner
|
}
|
589 |
00a8e4b6
|
Andreas Kohlbecker
|
|
590 |
0ae57522
|
Patric Plitzner
|
// -------------------------------------------- //
|
591 |
00a8e4b6
|
Andreas Kohlbecker
|
|
592 |
0ae57522
|
Patric Plitzner
|
if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
|
593 |
7272d19c
|
Andreas Kohlbecker
|
$render_array['accepted_for'] = markup_to_render_array(cdm_accepted_for($_REQUEST['acceptedFor']), $weight++);
|
594 |
0ae57522
|
Patric Plitzner
|
}
|
595 |
00a8e4b6
|
Andreas Kohlbecker
|
|
596 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: DESCRIPTION --- //
|
597 |
48a6d7e8
|
Andreas Kohlbecker
|
if (!taxon_page_tabs_hidden_check('description') && ($page_part == 'description' || $page_part == 'all')) {
|
598 |
00a8e4b6
|
Andreas Kohlbecker
|
|
599 |
0ae57522
|
Patric Plitzner
|
$merged_tree = merged_taxon_feature_tree($taxon);
|
600 |
00a8e4b6
|
Andreas Kohlbecker
|
|
601 |
7d8ef9fa
|
Patric Plitzner
|
|
602 |
22383f95
|
Andreas Kohlbecker
|
$render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, !$synonymy_as_tab);
|
603 |
0ae57522
|
Patric Plitzner
|
$render_array['general']['#weight'] = $weight++;
|
604 |
|
|
$render_array['general']['#prefix'] = '<div id="general" class="page-part">';
|
605 |
|
|
$render_array['general']['#suffix'] = '</div>';
|
606 |
|
|
}
|
607 |
7d8ef9fa
|
Patric Plitzner
|
|
608 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: IMAGES --- //
|
609 |
48a6d7e8
|
Andreas Kohlbecker
|
if (!taxon_page_tabs_hidden_check('images') && ($page_part == 'images' || $page_part == 'all')) {
|
610 |
0ae57522
|
Patric Plitzner
|
$images_html = '<div id="images" class="page-part">';
|
611 |
|
|
if ($page_part == 'all') {
|
612 |
4feeabc7
|
Andreas Kohlbecker
|
$images_html .= '<h2>' . t(cdm_taxonpage_tab_label('Images')) . '</h2>';
|
613 |
7d8ef9fa
|
Patric Plitzner
|
}
|
614 |
0ae57522
|
Patric Plitzner
|
// Get the image gallery as configured by the admin.
|
615 |
8f4eb9ce
|
Andreas Kohlbecker
|
$default_image_gallery = 'default';
|
616 |
|
|
$configured_image_gallery_viewer = variable_get('image_gallery_viewer', 'default');
|
617 |
4feeabc7
|
Andreas Kohlbecker
|
$taxon_image_gallery = '<div class="error">No image gallery viewer configured</div>';
|
618 |
8f4eb9ce
|
Andreas Kohlbecker
|
if($configured_image_gallery_viewer == $default_image_gallery || $configured_image_gallery_viewer == 'fsi'){
|
619 |
|
|
// the fsi_gallery requires a flash plugin, in case the client browser is not supporting
|
620 |
|
|
// flash we also need to provide an the default gallery as alternative
|
621 |
|
|
$taxon_image_gallery = '<div id="default-gallery-viewer">' .
|
622 |
|
|
call_user_func_array('taxon_image_gallery_' . $default_image_gallery, array(
|
623 |
|
|
$taxon,
|
624 |
|
|
$media,
|
625 |
|
|
))
|
626 |
|
|
. '</div>';
|
627 |
|
|
}
|
628 |
|
|
if($configured_image_gallery_viewer == 'fsi'){
|
629 |
|
|
$taxon_image_gallery .= '<div id="'. $configured_image_gallery_viewer .'-gallery-viewer">' .
|
630 |
|
|
call_user_func_array('taxon_image_gallery_' . $configured_image_gallery_viewer, array(
|
631 |
|
|
$taxon,
|
632 |
|
|
$media,
|
633 |
|
|
))
|
634 |
|
|
. '</div>';
|
635 |
|
|
}
|
636 |
0ae57522
|
Patric Plitzner
|
$images_html .= $taxon_image_gallery;
|
637 |
|
|
$images_html .= '</div>';
|
638 |
|
|
$render_array['images'] = markup_to_render_array($images_html, $weight++);
|
639 |
|
|
}
|
640 |
7d8ef9fa
|
Patric Plitzner
|
|
641 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: SYNONYMY --- //
|
642 |
48a6d7e8
|
Andreas Kohlbecker
|
if (!taxon_page_tabs_hidden_check('synonymy') && (($page_part == 'synonymy' || $page_part == 'all') && $synonymy_as_tab)) {
|
643 |
0ae57522
|
Patric Plitzner
|
$synonymy_html = '<div id="synonymy" class="page-part">';
|
644 |
|
|
if ($page_part == 'all') {
|
645 |
4feeabc7
|
Andreas Kohlbecker
|
$synonymy_html .= '<h2>' . t(cdm_taxonpage_tab_label('Synonymy')) . '</h2>';
|
646 |
00a8e4b6
|
Andreas Kohlbecker
|
}
|
647 |
0ae57522
|
Patric Plitzner
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
648 |
41b4bfc9
|
Andreas Kohlbecker
|
|
649 |
1cda248c
|
Andreas Kohlbecker
|
$synonym_a = compose_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon);
|
650 |
|
|
$synonymy_html .= drupal_render($synonym_a);
|
651 |
00a8e4b6
|
Andreas Kohlbecker
|
|
652 |
0ae57522
|
Patric Plitzner
|
$synonymy_html .= '</div>';
|
653 |
|
|
$render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
|
654 |
00a8e4b6
|
Andreas Kohlbecker
|
|
655 |
0ae57522
|
Patric Plitzner
|
}
|
656 |
00a8e4b6
|
Andreas Kohlbecker
|
|
657 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: SPECIMENS --- //
|
658 |
48a6d7e8
|
Andreas Kohlbecker
|
if (!taxon_page_tabs_hidden_check('specimens') && ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all'))) {
|
659 |
0ae57522
|
Patric Plitzner
|
$render_array['specimens'] = array(
|
660 |
4feeabc7
|
Andreas Kohlbecker
|
'#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Specimens')) . '</h2>' : ''),
|
661 |
0ae57522
|
Patric Plitzner
|
'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
|
662 |
|
|
'#suffix' => '</div>',
|
663 |
|
|
);
|
664 |
|
|
}
|
665 |
|
|
|
666 |
|
|
// --- PAGE PART: KEYS --- //
|
667 |
48a6d7e8
|
Andreas Kohlbecker
|
if(!taxon_page_tabs_hidden_check('keys')){
|
668 |
|
|
if ($identificationKeyCount == 1 && $page_part == 'keys'){
|
669 |
|
|
drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
|
670 |
|
|
}
|
671 |
|
|
else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
|
672 |
|
|
$keys_html = '<div id="keys" class="page-part">';
|
673 |
|
|
if ($page_part == 'all') {
|
674 |
|
|
$keys_html .= '<h2>' . t(cdm_taxonpage_tab_label('Keys')) . '</h2>';
|
675 |
|
|
}
|
676 |
|
|
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
|
677 |
|
|
$keys_html .= '</div>';
|
678 |
|
|
$render_array['keys'] = markup_to_render_array($keys_html, $weight++);
|
679 |
0ae57522
|
Patric Plitzner
|
}
|
680 |
|
|
}
|
681 |
|
|
|
682 |
7663cd0b
|
Andreas Kohlbecker
|
// --- PAGE PART: EXPERTS --- //
|
683 |
|
|
|
684 |
48a6d7e8
|
Andreas Kohlbecker
|
if (!taxon_page_tabs_hidden_check('experts') && ($page_part == 'experts' || $page_part == 'all')) {
|
685 |
7663cd0b
|
Andreas Kohlbecker
|
$render_array['experts'] = array(
|
686 |
4feeabc7
|
Andreas Kohlbecker
|
'#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t(cdm_taxonpage_tab_label('Experts')) . '</h2>' : ''),
|
687 |
7663cd0b
|
Andreas Kohlbecker
|
'content' => compose_cdm_taxon_page_experts($taxon), // returns render array
|
688 |
|
|
'#suffix' => '</div>',
|
689 |
|
|
);
|
690 |
|
|
}
|
691 |
|
|
|
692 |
|
|
// ------------------ END OF PARTS -------------- //
|
693 |
0ae57522
|
Patric Plitzner
|
|
694 |
|
|
// adjust weights of page and toc elements according to the settings
|
695 |
4feeabc7
|
Andreas Kohlbecker
|
$taxontabs_weights = get_array_variable_merged(CDM_TAXONPAGE_TAB_WEIGHT, CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
|
696 |
0ae57522
|
Patric Plitzner
|
foreach($taxontabs_weights as $tab_key => $weight){
|
697 |
|
|
if(isset($render_array[$tab_key])){
|
698 |
|
|
$render_array[$tab_key]['#weight'] = $weight;
|
699 |
|
|
}
|
700 |
|
|
}
|
701 |
|
|
|
702 |
|
|
|
703 |
|
|
// set up the TOC for the pages which contain all pageparts
|
704 |
|
|
if($page_part == 'all') {
|
705 |
|
|
|
706 |
|
|
asort($taxontabs_weights);
|
707 |
|
|
foreach(array_keys($taxontabs_weights) as $tab_key){
|
708 |
|
|
if(isset($render_array[$tab_key])){
|
709 |
|
|
if($tab_key != 'general'){
|
710 |
|
|
// add entry for page part
|
711 |
|
|
$toc_elements[] = array(
|
712 |
4feeabc7
|
Andreas Kohlbecker
|
'data' => l(t(cdm_taxonpage_tab_label(ucfirst($tab_key))), $_GET['q'], array('fragment' => $tab_key, 'query' => $http_request_params)),
|
713 |
0ae57522
|
Patric Plitzner
|
'class' => array('page-part-toc-item-' . $tab_key)
|
714 |
|
|
);
|
715 |
|
|
} else {
|
716 |
|
|
// add content of profile part instead
|
717 |
|
|
if(isset($render_array['general'])) {
|
718 |
|
|
// in case all tabs are shown at once the feature tocs
|
719 |
|
|
// should be integrated into the tabs toc as sub list
|
720 |
|
|
// and the profile image should be on top of the page
|
721 |
|
|
if(isset($render_array['general']['taxon_description_feature_toc'])){;
|
722 |
|
|
foreach ($render_array['general']['taxon_description_feature_toc']['#items'] as $profile_toc_item){
|
723 |
|
|
$toc_elements[] = $profile_toc_item;
|
724 |
7d8ef9fa
|
Patric Plitzner
|
}
|
725 |
0ae57522
|
Patric Plitzner
|
unset($render_array['general']['taxon_description_feature_toc']);
|
726 |
|
|
}
|
727 |
|
|
}
|
728 |
7d8ef9fa
|
Patric Plitzner
|
}
|
729 |
0ae57522
|
Patric Plitzner
|
}
|
730 |
|
|
}
|
731 |
7d8ef9fa
|
Patric Plitzner
|
|
732 |
0ae57522
|
Patric Plitzner
|
// move profile image in page structure
|
733 |
|
|
if(isset($render_array['general']['taxon_profile_image'])){
|
734 |
|
|
$render_array['profile_image'] = $render_array['general']['taxon_profile_image'];
|
735 |
|
|
$render_array['profile_image']['#weight'] = -100;
|
736 |
|
|
unset($render_array['general']['taxon_profile_image']);
|
737 |
7d8ef9fa
|
Patric Plitzner
|
}
|
738 |
|
|
|
739 |
0ae57522
|
Patric Plitzner
|
// finally add the table of contents to the render array
|
740 |
|
|
$render_array['toc'] = array(
|
741 |
|
|
'#theme' => 'item_list',
|
742 |
|
|
'#items' => $toc_elements,
|
743 |
|
|
'#title' => t('Content'),
|
744 |
|
|
'#weight' => -101,
|
745 |
|
|
'#suffix' => '</div>',
|
746 |
|
|
'#prefix'=> '<div id="page-toc">'
|
747 |
|
|
);
|
748 |
|
|
}
|
749 |
|
|
|
750 |
7d8ef9fa
|
Patric Plitzner
|
|
751 |
0ae57522
|
Patric Plitzner
|
return $render_array;
|
752 |
00a8e4b6
|
Andreas Kohlbecker
|
}
|
753 |
|
|
|
754 |
1ce9afb7
|
Patric Plitzner
|
/**
|
755 |
22f5e82d
|
Andreas Kohlbecker
|
* TODO should this function really be a compose function?
|
756 |
|
|
* For a compose function must there always be a theme function with the same name? (ak 8.8.2013)
|
757 |
bf97c2e8
|
Andreas Kohlbecker
|
*
|
758 |
|
|
* composes and returns an render array containing the components of the taxon profile tab:
|
759 |
|
|
* - 'taxon_profile_image'
|
760 |
|
|
* - 'taxon_description_feature_toc'
|
761 |
|
|
* - 'taxon_description_features'
|
762 |
|
|
*
|
763 |
|
|
*
|
764 |
8a1b451e
|
Andreas Kohlbecker
|
* @param object taxon
|
765 |
|
|
* @param object $merged_tree
|
766 |
|
|
* @param object media
|
767 |
|
|
* @param bool $add_synonymy
|
768 |
bf97c2e8
|
Andreas Kohlbecker
|
*
|
769 |
|
|
* @return array
|
770 |
f78fda81
|
Andreas Kohlbecker
|
* A Drupal render array with the following elements:
|
771 |
bf97c2e8
|
Andreas Kohlbecker
|
* - 'taxon_profile_image'
|
772 |
|
|
* - 'taxon_description_feature_toc'
|
773 |
|
|
* - 'taxon_description_features'
|
774 |
|
|
*
|
775 |
8a1b451e
|
Andreas Kohlbecker
|
* @throws Exception
|
776 |
|
|
*
|
777 |
bf97c2e8
|
Andreas Kohlbecker
|
* @ingroup compose
|
778 |
|
|
*/
|
779 |
22383f95
|
Andreas Kohlbecker
|
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, $add_synonymy) {
|
780 |
bf97c2e8
|
Andreas Kohlbecker
|
|
781 |
0ae57522
|
Patric Plitzner
|
$render_array = array();
|
782 |
|
|
|
783 |
|
|
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
|
784 |
|
|
|
785 |
|
|
$hide_taxon_profile_image = FALSE;
|
786 |
|
|
if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
|
787 |
|
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
788 |
|
|
$hide_taxon_profile_image = ($rankCompare > -1);
|
789 |
|
|
}
|
790 |
|
|
|
791 |
|
|
if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
|
792 |
|
|
|
793 |
|
|
$representationPart = new stdClass();
|
794 |
|
|
$attributes = array();
|
795 |
02faa087
|
Andreas Kohlbecker
|
if (isset($media[0])) {
|
796 |
|
|
// due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
|
797 |
|
|
// which only contains the thumbnail representation even if the height and width filters are not set.
|
798 |
673929dd
|
Andreas Kohlbecker
|
// -->
|
799 |
02faa087
|
Andreas Kohlbecker
|
$preferred_media = cdm_ws_get(CDM_WS_MEDIA, $media[0]->uuid);
|
800 |
|
|
$preferred_representations = cdm_preferred_media_representations($preferred_media, array(
|
801 |
|
|
'image/jpg',
|
802 |
|
|
'image/jpeg',
|
803 |
|
|
'image/png',
|
804 |
|
|
'image/gif',
|
805 |
|
|
),
|
806 |
|
|
$taxon_profile_image_settings['maxextend'],
|
807 |
|
|
$taxon_profile_image_settings['maxextend']
|
808 |
|
|
);
|
809 |
|
|
if(count($preferred_representations) > 0){
|
810 |
|
|
|
811 |
|
|
$representation = array_shift($preferred_representations);
|
812 |
|
|
$representationPart = $representation->parts[0];
|
813 |
|
|
$attributes['alt'] = $representationPart->uri;
|
814 |
|
|
|
815 |
|
|
if (!empty($taxon_profile_image_settings['media_uri_query'])) {
|
816 |
|
|
$representationPart->uri = $representationPart->uri
|
817 |
|
|
. (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
|
818 |
|
|
. $taxon_profile_image_settings['media_uri_query'];
|
819 |
|
|
}
|
820 |
0ae57522
|
Patric Plitzner
|
}
|
821 |
|
|
}
|
822 |
|
|
else {
|
823 |
9506fd1f
|
Andreas Kohlbecker
|
if ($taxon_profile_image_settings['custom_placeholder_enabled']) {
|
824 |
ca47ea76
|
Andreas Kohlbecker
|
// show placeholder image instead
|
825 |
|
|
if (!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])) {
|
826 |
|
|
// use the user provided image
|
827 |
|
|
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
|
828 |
|
|
$url = file_create_url($profile_image_file->uri);
|
829 |
|
|
$image_info = image_get_info($profile_image_file->uri);
|
830 |
|
|
$representationPart->width = $image_info['width'];
|
831 |
|
|
$representationPart->height = $image_info['height'];
|
832 |
|
|
$representationPart->uri = $url;
|
833 |
|
|
}
|
834 |
|
|
else {
|
835 |
|
|
// use the hard coded default
|
836 |
|
|
$representationPart->width = 184;
|
837 |
|
|
$representationPart->height = 144;
|
838 |
|
|
$representationPart->uri = base_path() . drupal_get_path('module',
|
839 |
|
|
'cdm_dataportal') . '/images/no_picture.png';
|
840 |
|
|
}
|
841 |
|
|
$attributes['alt'] = "no image available";
|
842 |
0ae57522
|
Patric Plitzner
|
}
|
843 |
|
|
}
|
844 |
|
|
|
845 |
ca47ea76
|
Andreas Kohlbecker
|
if (isset($representationPart->uri)) {
|
846 |
a9815578
|
Andreas Kohlbecker
|
$profile_image = cdm_media_gallerie_image($representationPart, $taxon_profile_image_settings['maxextend'], FALSE, $attributes);
|
847 |
ca47ea76
|
Andreas Kohlbecker
|
// NOTE: style="width:${maxextend}px' is needed for IE8 !!!
|
848 |
|
|
$render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image . '</div>',
|
849 |
|
|
-101);
|
850 |
|
|
}
|
851 |
0ae57522
|
Patric Plitzner
|
}
|
852 |
|
|
|
853 |
22383f95
|
Andreas Kohlbecker
|
if($add_synonymy){
|
854 |
1cda248c
|
Andreas Kohlbecker
|
$synonymy_a = compose_cdm_taxon_page_synonymy($taxon, true);
|
855 |
|
|
$synonymy_a['#weight'] = -102;
|
856 |
|
|
$render_array['synonymy'] = $synonymy_a;
|
857 |
22383f95
|
Andreas Kohlbecker
|
}
|
858 |
|
|
|
859 |
1b756c5f
|
Andreas Kohlbecker
|
$pseudo_feature_blocks = array();
|
860 |
|
|
$pseudo_feature_block_toc_items = array();
|
861 |
0ae57522
|
Patric Plitzner
|
|
862 |
|
|
|
863 |
1b756c5f
|
Andreas Kohlbecker
|
// Render the sections for each real feature
|
864 |
|
|
$feature_block_list = make_feature_block_list($merged_tree->root->childNodes, $taxon);
|
865 |
|
|
|
866 |
|
|
// Bibliography
|
867 |
0ae57522
|
Patric Plitzner
|
$bibliography_settings = get_bibliography_settings();
|
868 |
|
|
if($bibliography_settings['enabled'] == 1){
|
869 |
850092a7
|
Andreas Kohlbecker
|
$bibliography_markup = FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', '');
|
870 |
|
|
if($bibliography_markup) {
|
871 |
|
|
$feature_bibliography = make_pseudo_feature('Bibliography', 'BIBLIOGRAPHY');
|
872 |
|
|
$bibliography_block = feature_block(t('Bibliography'), $feature_bibliography);
|
873 |
|
|
$bibliography_item = markup_to_render_array($bibliography_markup);
|
874 |
|
|
$bibliography_block->content[] = compose_feature_block_wrap_elements(array($bibliography_item), $feature_bibliography);
|
875 |
0ae57522
|
Patric Plitzner
|
|
876 |
1b756c5f
|
Andreas Kohlbecker
|
$pseudo_feature_block_toc_items['Bibliography']= 'bibliography';
|
877 |
|
|
$pseudo_feature_blocks[] = $bibliography_block;
|
878 |
0ae57522
|
Patric Plitzner
|
}
|
879 |
1b756c5f
|
Andreas Kohlbecker
|
}
|
880 |
|
|
|
881 |
|
|
$render_array['taxon_description_features'] = _block_get_renderable_array(
|
882 |
|
|
array_merge($feature_block_list, $pseudo_feature_blocks)
|
883 |
|
|
);
|
884 |
0ae57522
|
Patric Plitzner
|
|
885 |
1b756c5f
|
Andreas Kohlbecker
|
if($pseudo_feature_block_toc_items){
|
886 |
|
|
foreach ($pseudo_feature_block_toc_items as $label=>$fragment){
|
887 |
|
|
cdm_toc_list_add_item($label, $fragment);
|
888 |
|
|
}
|
889 |
0ae57522
|
Patric Plitzner
|
}
|
890 |
|
|
|
891 |
|
|
// create the table of content
|
892 |
|
|
$toc = array(
|
893 |
|
|
'#theme' => 'item_list',
|
894 |
|
|
'#items' => cdm_toc_list(),
|
895 |
|
|
'#title' => t('Content'),
|
896 |
|
|
'#weight' => -100, // move to the top
|
897 |
|
|
'#suffix' => '</div>',
|
898 |
|
|
'#prefix'=> '<div id="page-toc">'
|
899 |
|
|
);
|
900 |
|
|
$render_array['taxon_description_feature_toc'] = $toc;
|
901 |
|
|
|
902 |
|
|
return $render_array;
|
903 |
bf97c2e8
|
Andreas Kohlbecker
|
}
|
904 |
|
|
|
905 |
f9a3d0f6
|
Andreas Kohlbecker
|
/**
|
906 |
|
|
* composes and returns an render array for the experts associated with the given taxon
|
907 |
|
|
*
|
908 |
8a1b451e
|
Andreas Kohlbecker
|
* @param object taxon
|
909 |
f9a3d0f6
|
Andreas Kohlbecker
|
*
|
910 |
|
|
* @return array
|
911 |
|
|
* A Drupal render array for a table with the experts
|
912 |
|
|
*
|
913 |
|
|
* @ingroup compose
|
914 |
|
|
*/
|
915 |
7663cd0b
|
Andreas Kohlbecker
|
function compose_cdm_taxon_page_experts($taxon){
|
916 |
|
|
|
917 |
|
|
$render_array = array();
|
918 |
|
|
if(!isset($taxon->uuid)){
|
919 |
|
|
return $render_array;
|
920 |
|
|
}
|
921 |
|
|
|
922 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
923 |
|
|
// TODO use cdm_ws_fetchall below but this failes! needs fix!
|
924 |
|
|
$taxon_node_agent_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
|
925 |
|
|
array(
|
926 |
|
|
$taxon->uuid,
|
927 |
|
|
$current_classification_uuid
|
928 |
|
|
)
|
929 |
|
|
);
|
930 |
|
|
|
931 |
|
|
$header = array(
|
932 |
|
|
array('data' => t('Expert')),
|
933 |
|
|
array('data' => t('Role'))
|
934 |
|
|
);
|
935 |
|
|
$rows = array();
|
936 |
|
|
|
937 |
|
|
|
938 |
|
|
foreach($taxon_node_agent_relations->records as $taxon_node_agent_relation){
|
939 |
|
|
|
940 |
d9763fd3
|
Andreas Kohlbecker
|
|
941 |
|
|
$expert_role_id = $taxon_node_agent_relation->agent->uuid . '-' . $taxon_node_agent_relation->type->uuid;
|
942 |
|
|
$expert_details_container_id = 'expert_details_' . $expert_role_id;
|
943 |
|
|
|
944 |
|
|
$agent_label_markup = cdm_dynabox(
|
945 |
|
|
'expert_' . $expert_role_id,
|
946 |
|
|
$taxon_node_agent_relation->agent->titleCache,
|
947 |
|
|
// specifying both ends of the relationship will return only one record in the pager
|
948 |
|
|
cdm_compose_url(CDM_WS_PORTAL_AGENT,
|
949 |
|
|
array($taxon_node_agent_relation->agent->uuid, 'taxonNodeAgentRelations'),
|
950 |
|
|
'taxon_uuid=' . $taxon->uuid . '&relType_uuid=' . $taxon_node_agent_relation->type->uuid),
|
951 |
|
|
'cdm_taxon_expert',
|
952 |
|
|
'Click for details',
|
953 |
|
|
array('div', 'div'),
|
954 |
|
|
array(), // attributes
|
955 |
cea412e7
|
Andreas Kohlbecker
|
'#' . $expert_details_container_id // $content_element_selector
|
956 |
d9763fd3
|
Andreas Kohlbecker
|
);
|
957 |
|
|
|
958 |
|
|
// Expert and Role
|
959 |
|
|
$rows[] = array(
|
960 |
|
|
'data' => array(
|
961 |
|
|
array(
|
962 |
|
|
'data' => $agent_label_markup,
|
963 |
|
|
'class' => array(html_class_attribute_ref($taxon_node_agent_relation->agent))
|
964 |
7663cd0b
|
Andreas Kohlbecker
|
),
|
965 |
d9763fd3
|
Andreas Kohlbecker
|
array(
|
966 |
|
|
'data' => $taxon_node_agent_relation->type->representation_L10n,
|
967 |
|
|
'class' => array(html_class_attribute_ref($taxon_node_agent_relation->type))
|
968 |
|
|
)
|
969 |
|
|
)
|
970 |
|
|
);
|
971 |
|
|
// Agent details
|
972 |
|
|
$rows[] = array(
|
973 |
|
|
'data' => array(
|
974 |
|
|
array(
|
975 |
|
|
'data' => '<!-- expert_details_container -->',
|
976 |
|
|
'id' => $expert_details_container_id,
|
977 |
|
|
'colspan' => 2
|
978 |
|
|
)
|
979 |
|
|
)
|
980 |
7663cd0b
|
Andreas Kohlbecker
|
);
|
981 |
d9763fd3
|
Andreas Kohlbecker
|
|
982 |
7663cd0b
|
Andreas Kohlbecker
|
}
|
983 |
|
|
|
984 |
|
|
|
985 |
|
|
$render_array['experts_table'] = array(
|
986 |
|
|
'#theme' => 'table',
|
987 |
|
|
'#header' => $header,
|
988 |
|
|
'#rows' => $rows,
|
989 |
|
|
);
|
990 |
|
|
|
991 |
|
|
|
992 |
|
|
return $render_array;
|
993 |
|
|
}
|
994 |
|
|
|
995 |
bf97c2e8
|
Andreas Kohlbecker
|
|
996 |
3f259ca3
|
Andreas Kohlbecker
|
/**
|
997 |
7663cd0b
|
Andreas Kohlbecker
|
* Manages the tabs to be hidden in the taxon page.
|
998 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
999 |
|
|
* The tabs are identified by their last menu link path element:
|
1000 |
|
|
* - description
|
1001 |
|
|
* - synonymy
|
1002 |
|
|
* - images
|
1003 |
|
|
* - specimens
|
1004 |
|
|
* - key
|
1005 |
|
|
*
|
1006 |
|
|
* Internally the tabs are stored in a static variable which is
|
1007 |
|
|
* managed by drupal_static().
|
1008 |
|
|
*
|
1009 |
|
|
* @param string $add_tab
|
1010 |
7663cd0b
|
Andreas Kohlbecker
|
* Optional parameter. The given string will be added to the array of tabs
|
1011 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
1012 |
|
|
* @return
|
1013 |
|
|
* The array of tabs
|
1014 |
|
|
*/
|
1015 |
48a6d7e8
|
Andreas Kohlbecker
|
function taxon_page_tabs_hidden_add($add_tab = NULL) {
|
1016 |
|
|
$tabs = &drupal_static('taxon_page_tabs_hidden');
|
1017 |
3f259ca3
|
Andreas Kohlbecker
|
|
1018 |
0ae57522
|
Patric Plitzner
|
if(!isset($tabs)){
|
1019 |
|
|
$tabs = array();
|
1020 |
|
|
}
|
1021 |
3f259ca3
|
Andreas Kohlbecker
|
|
1022 |
0ae57522
|
Patric Plitzner
|
if (isset($add_tab) && !array_key_exists($add_tab, $tabs)) {
|
1023 |
|
|
$tabs[] = $add_tab;
|
1024 |
|
|
}
|
1025 |
3f259ca3
|
Andreas Kohlbecker
|
|
1026 |
0ae57522
|
Patric Plitzner
|
return $tabs;
|
1027 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
1028 |
|
|
|
1029 |
48a6d7e8
|
Andreas Kohlbecker
|
/**
|
1030 |
|
|
* Manages the tabs to be hidden in the taxon page.
|
1031 |
|
|
*
|
1032 |
|
|
* The tabs names are identified by their last menu link path element:
|
1033 |
|
|
* - description
|
1034 |
|
|
* - synonymy
|
1035 |
|
|
* - images
|
1036 |
|
|
* - specimens
|
1037 |
|
|
* - key
|
1038 |
|
|
*
|
1039 |
|
|
* Internally the tabs are stored in a static variable which is
|
1040 |
|
|
* managed by drupal_static().
|
1041 |
|
|
*
|
1042 |
|
|
* @param string $tabname
|
1043 |
|
|
* The name of the tab to check
|
1044 |
|
|
*
|
1045 |
|
|
* @return boolean
|
1046 |
|
|
* True if the tab or section is to be hidden
|
1047 |
|
|
*/
|
1048 |
|
|
function taxon_page_tabs_hidden_check($tabname) {
|
1049 |
|
|
|
1050 |
|
|
$tabs = &drupal_static('taxon_page_tabs_hidden');
|
1051 |
|
|
|
1052 |
|
|
if(!isset($tabs)){
|
1053 |
|
|
$tabs = array();
|
1054 |
|
|
}
|
1055 |
|
|
|
1056 |
|
|
return array_search($tabname, $tabs) !== FALSE;
|
1057 |
|
|
}
|
1058 |
|
|
|
1059 |
3f259ca3
|
Andreas Kohlbecker
|
/**
|
1060 |
|
|
* Implements the hook_preprocess_HOOK() for theme_menu_local_tasks()
|
1061 |
|
|
*
|
1062 |
48a6d7e8
|
Andreas Kohlbecker
|
* - Removes the tabs to be hidden, @see taxon_page_tabs_hidden_add()
|
1063 |
9438ad3a
|
Andreas Kohlbecker
|
* - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!)
|
1064 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
1065 |
|
|
* @param array $variables
|
1066 |
|
|
* The variables array
|
1067 |
|
|
*/
|
1068 |
|
|
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) {
|
1069 |
|
|
|
1070 |
48a6d7e8
|
Andreas Kohlbecker
|
$hidden_tabs = taxon_page_tabs_hidden_add();
|
1071 |
3f259ca3
|
Andreas Kohlbecker
|
|
1072 |
0ae57522
|
Patric Plitzner
|
if (is_array($variables['primary'])) {
|
1073 |
|
|
foreach ($variables['primary'] as $key => &$element) {
|
1074 |
6f1a217c
|
Andreas Kohlbecker
|
|
1075 |
0ae57522
|
Patric Plitzner
|
// 1. Remove the tabs to be hidden
|
1076 |
|
|
foreach ($hidden_tabs as $tab) {
|
1077 |
|
|
if ($element['#link']['path'] == 'cdm_dataportal/taxon/%/' . $tab) {
|
1078 |
|
|
// remove the tab
|
1079 |
|
|
unset($variables['primary'][$key]);
|
1080 |
9438ad3a
|
Andreas Kohlbecker
|
}
|
1081 |
0ae57522
|
Patric Plitzner
|
}
|
1082 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
1083 |
0ae57522
|
Patric Plitzner
|
}
|
1084 |
6f1a217c
|
Andreas Kohlbecker
|
}
|
1085 |
|
|
|
1086 |
|
|
|
1087 |
|
|
|
1088 |
|
|
/**
|
1089 |
|
|
* Implements the hook_preprocess_HOOK() for theme_menu_local_task()
|
1090 |
|
|
*
|
1091 |
|
|
*
|
1092 |
|
|
* @param array $variables
|
1093 |
|
|
* An associative array containing:
|
1094 |
|
|
* - element: A render element containing:
|
1095 |
|
|
* #link: A menu link array with 'title', 'href', and 'localized_options' keys.
|
1096 |
|
|
* #active: A boolean indicating whether the local task is active.
|
1097 |
|
|
*
|
1098 |
|
|
*/
|
1099 |
|
|
function cdm_dataportal_preprocess_menu_local_task(&$variables) {
|
1100 |
|
|
|
1101 |
0ae57522
|
Patric Plitzner
|
$link = $variables['element']['#link'];
|
1102 |
|
|
if (preg_match('/cdm_dataportal\/.*\/refresh$/', $link['href'])) {
|
1103 |
|
|
$link['title'] = '<img class="refresh" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/view-refresh.png' . '" alt="' . check_plain($link['title']) . '" title="' . check_plain($link['title']) . '"/>';
|
1104 |
|
|
$link['localized_options']['html'] = TRUE;
|
1105 |
6f1a217c
|
Andreas Kohlbecker
|
|
1106 |
0ae57522
|
Patric Plitzner
|
$variables['element']['#link'] = $link;
|
1107 |
|
|
}
|
1108 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
1109 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
1110 |
|
|
/* =================== block composition ===================== */
|
1111 |
|
|
|
1112 |
|
|
/**
|
1113 |
23ad16a1
|
Andreas Kohlbecker
|
* Composes and returns an render array for the classification breadcrumbs of the given taxon.
|
1114 |
f9a3d0f6
|
Andreas Kohlbecker
|
*
|
1115 |
|
|
* @param taxon
|
1116 |
|
|
*
|
1117 |
|
|
* @return array
|
1118 |
|
|
* A Drupal render array for a table with the experts
|
1119 |
|
|
*
|
1120 |
|
|
* @ingroup compose
|
1121 |
|
|
*/
|
1122 |
|
|
function compose_classification_breadcrumbs($taxon_uuid) {
|
1123 |
|
|
|
1124 |
b0adfd32
|
Andreas Kohlbecker
|
_add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
|
1125 |
d0d23caa
|
Andreas Kohlbecker
|
|
1126 |
f9a3d0f6
|
Andreas Kohlbecker
|
$render_array = array();
|
1127 |
|
|
|
1128 |
|
|
$render_array['#theme'] = 'item_list';
|
1129 |
|
|
$render_array['#type'] = 'ul';
|
1130 |
|
|
$render_array['#attributes'] = array(
|
1131 |
|
|
'id' => 'classification-breadcrumbs',
|
1132 |
|
|
'class' => 'breadcrumbs inline',
|
1133 |
|
|
);
|
1134 |
|
|
|
1135 |
|
|
$items = array();
|
1136 |
|
|
|
1137 |
38da4e54
|
Andreas Kohlbecker
|
$parent_taxon_nodes = null;
|
1138 |
|
|
if($taxon_uuid){
|
1139 |
|
|
$parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
|
1140 |
|
|
}
|
1141 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
1142 |
38da4e54
|
Andreas Kohlbecker
|
$classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
|
1143 |
|
|
// find current classification in list
|
1144 |
|
|
$classification = null;
|
1145 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
1146 |
|
|
foreach ($classifications as $classification){
|
1147 |
|
|
if($classification->uuid == $current_classification_uuid){
|
1148 |
|
|
break;
|
1149 |
b0adfd32
|
Andreas Kohlbecker
|
}
|
1150 |
38da4e54
|
Andreas Kohlbecker
|
}
|
1151 |
b0adfd32
|
Andreas Kohlbecker
|
|
1152 |
38da4e54
|
Andreas Kohlbecker
|
$node_name = '';
|
1153 |
|
|
if(count($classifications) > 1 ){
|
1154 |
|
|
// need to add the current classification as first label
|
1155 |
0af3ce28
|
Andreas Kohlbecker
|
|
1156 |
|
|
$label = $classification->titleCache;
|
1157 |
|
|
if(strlen($label) > 20){
|
1158 |
|
|
$label = substr($label, 0, strpos($label, ' ', 15)) . '...';
|
1159 |
|
|
}
|
1160 |
|
|
$node_name = font_awesome_icon_markup('fa-th-list') . ' ' . l($label, '#', array(
|
1161 |
|
|
'attributes' => array(
|
1162 |
|
|
'class' => 'taxonomic-children-button classification-chooser',
|
1163 |
|
|
'data-destination-uri' => drupal_get_destination(),
|
1164 |
|
|
'data-cdm-align-with' => array('prev')
|
1165 |
|
|
),
|
1166 |
|
|
'html' => true
|
1167 |
|
|
));
|
1168 |
f9a3d0f6
|
Andreas Kohlbecker
|
}
|
1169 |
b0adfd32
|
Andreas Kohlbecker
|
|
1170 |
38da4e54
|
Andreas Kohlbecker
|
$rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
|
1171 |
0af3ce28
|
Andreas Kohlbecker
|
|
1172 |
|
|
$rank_separator = '<span> '
|
1173 |
38da4e54
|
Andreas Kohlbecker
|
. font_awesome_icon_markup('fa-chevron-right')
|
1174 |
|
|
. ' </span>';
|
1175 |
0af3ce28
|
Andreas Kohlbecker
|
$more_children_icon = font_awesome_icon_markup('fa-sitemap fa-rotate-270');
|
1176 |
69fb3dbb
|
Andreas Kohlbecker
|
$more_children_label = '...';
|
1177 |
38da4e54
|
Andreas Kohlbecker
|
|
1178 |
0af3ce28
|
Andreas Kohlbecker
|
$items[] = $node_name;
|
1179 |
38da4e54
|
Andreas Kohlbecker
|
|
1180 |
0af3ce28
|
Andreas Kohlbecker
|
$more_children_for = null;
|
1181 |
e3235962
|
Andreas Kohlbecker
|
if($parent_taxon_nodes){
|
1182 |
0af3ce28
|
Andreas Kohlbecker
|
foreach ($parent_taxon_nodes as $node) {
|
1183 |
38da4e54
|
Andreas Kohlbecker
|
|
1184 |
|
|
$is_first_item = count($items) == 0;
|
1185 |
0af3ce28
|
Andreas Kohlbecker
|
$is_last_item = count($items) == count($parent_taxon_nodes);
|
1186 |
38da4e54
|
Andreas Kohlbecker
|
$node_name = cdm_dataportal_shortname_of($node);
|
1187 |
|
|
$path = path_to_taxon($node->taxonUuid);
|
1188 |
|
|
|
1189 |
0af3ce28
|
Andreas Kohlbecker
|
if($node->taxonomicChildrenCount > 0) {
|
1190 |
|
|
$more_children_for = $node->taxonUuid;
|
1191 |
|
|
} else {
|
1192 |
|
|
$more_children_for = null;
|
1193 |
38da4e54
|
Andreas Kohlbecker
|
}
|
1194 |
|
|
|
1195 |
0af3ce28
|
Andreas Kohlbecker
|
// 'fa-sitemap'
|
1196 |
|
|
|
1197 |
38da4e54
|
Andreas Kohlbecker
|
$items[] =
|
1198 |
0af3ce28
|
Andreas Kohlbecker
|
($is_first_item ? '' : ' ')
|
1199 |
|
|
. $rank_separator
|
1200 |
|
|
. l(
|
1201 |
4b3be949
|
Andreas Kohlbecker
|
'<span class="' . html_class_attribute_ref($node) . '">' . $node_name . '</span>',
|
1202 |
0af3ce28
|
Andreas Kohlbecker
|
$path,
|
1203 |
|
|
array(
|
1204 |
|
|
'attributes' => array(
|
1205 |
|
|
'class' => array('taxonomic-children-button'),
|
1206 |
|
|
'data-cdm-taxon-uuid' => array($node->taxonUuid),
|
1207 |
|
|
'data-cdm-classification-mode' => array('siblings'),
|
1208 |
|
|
'data-cdm-align-with' => array('prev')
|
1209 |
4b3be949
|
Andreas Kohlbecker
|
),
|
1210 |
|
|
'html' => true
|
1211 |
0af3ce28
|
Andreas Kohlbecker
|
)
|
1212 |
|
|
);
|
1213 |
|
|
}
|
1214 |
38da4e54
|
Andreas Kohlbecker
|
}
|
1215 |
0af3ce28
|
Andreas Kohlbecker
|
|
1216 |
|
|
// add more button to the end
|
1217 |
|
|
if(!$parent_taxon_nodes) {
|
1218 |
|
|
// not taxon focused yet, adding button to make the root nodes available
|
1219 |
69fb3dbb
|
Andreas Kohlbecker
|
$items[] = '<span>'
|
1220 |
|
|
. $more_children_icon . ' ' .
|
1221 |
|
|
'<span class="taxonomic-children-button" data-classification-uuid="' . $current_classification_uuid
|
1222 |
53c705d4
|
Andreas Kohlbecker
|
. '" data-rank-limit-uuid="' . $rank_limit_uuid . '" data-cdm-align-with="prev"> ' . $more_children_label . '<span>'
|
1223 |
69fb3dbb
|
Andreas Kohlbecker
|
. '</span>';
|
1224 |
0af3ce28
|
Andreas Kohlbecker
|
} else if($more_children_for){
|
1225 |
|
|
// last parent item has child taxon nodes
|
1226 |
69fb3dbb
|
Andreas Kohlbecker
|
$items[] = ' <span>'
|
1227 |
|
|
. $more_children_icon . ' ' .
|
1228 |
|
|
'<span class="taxonomic-children-button" data-cdm-taxon-uuid="' .$more_children_for
|
1229 |
53c705d4
|
Andreas Kohlbecker
|
. '" data-cdm-classification-mode="children" data-cdm-align-with="prev"> ' . $more_children_label . '</span>'
|
1230 |
69fb3dbb
|
Andreas Kohlbecker
|
. '</span>';
|
1231 |
0af3ce28
|
Andreas Kohlbecker
|
|
1232 |
e3235962
|
Andreas Kohlbecker
|
}
|
1233 |
b0adfd32
|
Andreas Kohlbecker
|
|
1234 |
30845bda
|
Andreas Kohlbecker
|
$render_array['#items'] = $items;
|
1235 |
0af3ce28
|
Andreas Kohlbecker
|
|
1236 |
30845bda
|
Andreas Kohlbecker
|
return $render_array;
|
1237 |
|
|
}
|
1238 |
0af3ce28
|
Andreas Kohlbecker
|
|
1239 |
69fb3dbb
|
Andreas Kohlbecker
|
|
1240 |
30845bda
|
Andreas Kohlbecker
|
/**
|
1241 |
|
|
* @param $specimen_uuid
|
1242 |
|
|
* @return array
|
1243 |
|
|
* The drupal render array for the page
|
1244 |
|
|
*
|
1245 |
|
|
* @ingroup compose
|
1246 |
|
|
*/
|
1247 |
e89c1115
|
Katja Luther
|
function compose_cdm_specimen_page($specimen_uuid)
|
1248 |
30845bda
|
Andreas Kohlbecker
|
{
|
1249 |
|
|
drupal_set_title("Specimen Details");
|
1250 |
|
|
$render_array = array();
|
1251 |
|
|
RenderHints::pushToRenderStack('specimen_page');
|
1252 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
1253 |
78a42a9b
|
Katja Luther
|
$specimen_table = array(
|
1254 |
|
|
'#theme' => 'table',
|
1255 |
|
|
'#weight' => 2,
|
1256 |
|
|
// prefix attributes and rows with '#' to let it pass toF the theme function,
|
1257 |
|
|
// otherwise it is handled as child render array
|
1258 |
489f7610
|
Katja Luther
|
|
1259 |
|
|
'#attributes' => array('class' => 'specimens'),
|
1260 |
78a42a9b
|
Katja Luther
|
'#rows' => array(),
|
1261 |
93fb962c
|
Katja Luther
|
'#prefix' => '<div id="specimens">',
|
1262 |
|
|
'#suffix' => '</div>',
|
1263 |
|
|
|
1264 |
489f7610
|
Katja Luther
|
|
1265 |
78a42a9b
|
Katja Luther
|
);
|
1266 |
|
|
$specimen = compose_cdm_specimen_or_observation($specimen_uuid, true);
|
1267 |
|
|
$renderArray = array(
|
1268 |
|
|
'#theme' => 'item_list',
|
1269 |
|
|
'#items' => array($specimen),
|
1270 |
|
|
'#type' => 'ul');
|
1271 |
|
|
$output = drupal_render($renderArray);
|
1272 |
|
|
|
1273 |
|
|
$specimen_table['#rows'][] = array(
|
1274 |
|
|
// An array of table rows. Every row is an array of cells, or an associative array
|
1275 |
|
|
'data' => array($output),
|
1276 |
|
|
'class' => array(
|
1277 |
|
|
'descriptionElement',
|
1278 |
|
|
'descriptionElement_IndividualsAssociation'
|
1279 |
|
|
),
|
1280 |
489f7610
|
Katja Luther
|
|
1281 |
78a42a9b
|
Katja Luther
|
);
|
1282 |
e89c1115
|
Katja Luther
|
|
1283 |
|
|
|
1284 |
78a42a9b
|
Katja Luther
|
// $detail_html = compose_cdm_specimen_or_observation($specimen_uuid, true);
|
1285 |
93fb962c
|
Katja Luther
|
// $render_array['markup'] = array(
|
1286 |
|
|
// '#prefix' => '<div id="specimens" class="page">',
|
1287 |
|
|
// 'content' => $specimen_table,
|
1288 |
|
|
// '#suffix' => '</div>',
|
1289 |
|
|
// );
|
1290 |
|
|
$render_array['markup'] = $specimen_table;
|
1291 |
e89c1115
|
Katja Luther
|
|
1292 |
30845bda
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
1293 |
f9a3d0f6
|
Andreas Kohlbecker
|
return $render_array;
|
1294 |
30845bda
|
Andreas Kohlbecker
|
}
|
1295 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
1296 |
30845bda
|
Andreas Kohlbecker
|
/**
|
1297 |
|
|
* @param $named_area_uuid
|
1298 |
|
|
* @return array
|
1299 |
|
|
* The drupal render array for the page
|
1300 |
|
|
*
|
1301 |
|
|
* @ingroup compose
|
1302 |
|
|
*/
|
1303 |
|
|
function compose_cdm_named_area_page($named_area_uuid)
|
1304 |
|
|
{
|
1305 |
|
|
|
1306 |
|
|
$named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, array($named_area_uuid));
|
1307 |
|
|
|
1308 |
|
|
$render_array = array();
|
1309 |
|
|
RenderHints::pushToRenderStack('named_area_page');
|
1310 |
|
|
|
1311 |
|
|
$groups = array();
|
1312 |
|
|
@_description_list_group_add($groups, t('Name') . ':', $named_area->representation_L10n);
|
1313 |
|
|
@_description_list_group_add($groups, t('IdInVocabulary') . ':', $named_area->idInVocabulary);
|
1314 |
|
|
if(isset($named_area->level)) {
|
1315 |
|
|
@_description_list_group_add($groups, t('Level') . ':', $named_area->level->representation_L10n);
|
1316 |
|
|
}
|
1317 |
|
|
|
1318 |
|
|
$name_area_details_elements = array(
|
1319 |
|
|
// '#title' => $title,
|
1320 |
|
|
'#theme' => 'description_list',
|
1321 |
|
|
'#groups' => $groups,
|
1322 |
|
|
'#attributes' => array('class' => html_class_attribute_ref($named_area)),
|
1323 |
|
|
);
|
1324 |
|
|
|
1325 |
|
|
$render_array[] = $name_area_details_elements;
|
1326 |
|
|
|
1327 |
|
|
RenderHints::popFromRenderStack();
|
1328 |
|
|
return $render_array;
|
1329 |
f9a3d0f6
|
Andreas Kohlbecker
|
}
|
1330 |
4feeabc7
|
Andreas Kohlbecker
|
|
1331 |
|
|
/**
|
1332 |
|
|
* Provides the the label string for taxon page tabs.
|
1333 |
|
|
*
|
1334 |
|
|
* The $tabname as passed to the method will be returned if no override
|
1335 |
|
|
* label is configured in the settings.
|
1336 |
|
|
*/
|
1337 |
|
|
function cdm_taxonpage_tab_label($tabname) {
|
1338 |
|
|
static $taxon_tabs_labels = null;
|
1339 |
|
|
if($taxon_tabs_labels == null){
|
1340 |
|
|
$taxon_tabs_labels = get_array_variable_merged(CDM_TAXONPAGE_TAB_LABELS, CDM_TAXONPAGE_TAB_LABELS_DEFAULT);
|
1341 |
|
|
}
|
1342 |
|
|
$tabname_key = strtolower($tabname);
|
1343 |
|
|
if(isset($taxon_tabs_labels[$tabname_key]) && $taxon_tabs_labels[$tabname_key]){
|
1344 |
|
|
return $taxon_tabs_labels[$tabname_key];
|
1345 |
|
|
}
|
1346 |
|
|
return $tabname;
|
1347 |
|
|
}
|