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 |
|
|
|
53 |
|
|
$pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
|
54 |
|
|
null,
|
55 |
|
|
$by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
|
56 |
|
|
);
|
57 |
|
|
|
58 |
|
|
$specimensOrObservations = array();
|
59 |
|
|
if(isset($pager->records[0])){
|
60 |
|
|
$specimensOrObservations = $pager->records;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
// order occurrences by date but types should be on top of the list
|
64 |
|
|
$type_specimens = array();
|
65 |
|
|
$other_occurrences = array();
|
66 |
|
|
foreach ($specimensOrObservations as &$occurrence) {
|
67 |
|
|
$typeDesignationsPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $occurrence->uuid);
|
68 |
|
|
if (isset($typeDesignationsPager->count) && $typeDesignationsPager->count > 0) {
|
69 |
|
|
$type_specimens[] = $occurrence;
|
70 |
|
|
} else {
|
71 |
|
|
$other_occurrences[] = $occurrence;
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
$specimensOrObservations = array_merge($type_specimens, $other_occurrences);
|
75 |
|
|
|
76 |
|
|
// Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field
|
77 |
|
|
// $occurrence->_fieldObjectMedia
|
78 |
|
|
foreach ($specimensOrObservations as &$occurrence) {
|
79 |
|
|
$occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
80 |
|
|
$occurrence->uuid,
|
81 |
|
|
'fieldObjectMedia',
|
82 |
|
|
));
|
83 |
|
|
$occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
84 |
|
|
$occurrence->uuid,
|
85 |
|
|
'derivedUnitMedia',
|
86 |
|
|
));
|
87 |
|
|
}
|
88 |
|
|
|
89 |
b5c89485
|
Patric Plitzner
|
// --- get map service HTTP query parameters
|
90 |
b8afc4bb
|
Patric Plitzner
|
if (count($specimensOrObservations) > 0) {
|
91 |
62cd8253
|
Patric Plitzner
|
$occurrence_queryDto = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid, $by_associatedtaxon_query);
|
92 |
b8afc4bb
|
Patric Plitzner
|
|
93 |
62cd8253
|
Patric Plitzner
|
if( isset($occurrence_queryDto->occurrenceQuery) ) {
|
94 |
|
|
$occurrence_query = $occurrence_queryDto->occurrenceQuery;
|
95 |
b8afc4bb
|
Patric Plitzner
|
$legend_format_query = null;
|
96 |
|
|
$distribution_query = NULL;
|
97 |
5823dc04
|
Patric Plitzner
|
$render_array['map'] = compose_map($occurrence_query, $distribution_query, $legend_format_query, array());
|
98 |
b8afc4bb
|
Patric Plitzner
|
}
|
99 |
|
|
}
|
100 |
1ce9afb7
|
Patric Plitzner
|
if(variable_get('cdm_dataportal_compressed_specimen_derivate_table')){
|
101 |
|
|
|
102 |
|
|
//COMPRESSED SPECIMEN DERIVATE TABLE
|
103 |
4cb163f8
|
Patric Plitzner
|
$associatedFieldUnitsQuery_parameters = array();
|
104 |
|
|
if (isset($_REQUEST['pager']) && is_array($_REQUEST['pager'])) {
|
105 |
|
|
$associatedFieldUnitsQuery_parameters = array_merge($associatedFieldUnitsQuery_parameters, $_REQUEST['pager']);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
$by_associatedtaxon_query = http_build_query($associatedFieldUnitsQuery_parameters);
|
109 |
|
|
$pagerFieldUnits = cdm_ws_get(CDM_WS_PORTAL_TAXON, array($taxon->uuid, 'associatedFieldUnits'), $by_associatedtaxon_query);
|
110 |
7d8ef9fa
|
Patric Plitzner
|
// get icon images
|
111 |
9cf53dd8
|
Patrick Plitzner
|
$expand_icon = font_awesome_icon_markup(
|
112 |
|
|
'fa-plus-square-o',
|
113 |
|
|
array(
|
114 |
|
|
'alt'=>'Show details',
|
115 |
|
|
'class' => array('expand_icon')
|
116 |
|
|
)
|
117 |
|
|
);
|
118 |
|
|
$collapse_icon = font_awesome_icon_markup(
|
119 |
|
|
'fa-minus-square-o',
|
120 |
|
|
array(
|
121 |
|
|
'alt'=>'Show details',
|
122 |
|
|
'class' => array('collapse_icon')
|
123 |
|
|
)
|
124 |
|
|
);
|
125 |
1ce9afb7
|
Patric Plitzner
|
$detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>';
|
126 |
|
|
$checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>';
|
127 |
|
|
$sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>';
|
128 |
d7e61010
|
Patric Plitzner
|
$character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>';
|
129 |
4cb163f8
|
Patric Plitzner
|
if (isset($pagerFieldUnits->records[0])) {
|
130 |
1ce9afb7
|
Patric Plitzner
|
$rowcount = 0;
|
131 |
4cb163f8
|
Patric Plitzner
|
foreach ($pagerFieldUnits->records as $fieldUnit) {
|
132 |
1ce9afb7
|
Patric Plitzner
|
//get derivate hierarchy for the FieldUnit
|
133 |
|
|
$derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($fieldUnit->uuid, 'derivateHierarchy'), 'taxonUuid=' . $taxon->uuid);
|
134 |
|
|
if($derivateHierarchy){
|
135 |
|
|
//summary row
|
136 |
|
|
$rows[] = array(
|
137 |
|
|
'data' => array(
|
138 |
b8783a48
|
Patric Plitzner
|
array(
|
139 |
44eebb6f
|
Patric Plitzner
|
'data' => $expand_icon . $collapse_icon,
|
140 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column')
|
141 |
b8783a48
|
Patric Plitzner
|
),
|
142 |
|
|
array(
|
143 |
|
|
'data' => $derivateHierarchy->country,
|
144 |
|
|
'class' => array('summary_row_cell')
|
145 |
|
|
),
|
146 |
|
|
array(
|
147 |
|
|
'data' => $derivateHierarchy->date,
|
148 |
|
|
'class' => array('summary_row_cell')
|
149 |
|
|
),
|
150 |
|
|
array(
|
151 |
|
|
'data' => $derivateHierarchy->collection,
|
152 |
|
|
'class' => array('summary_row_cell')
|
153 |
|
|
),
|
154 |
|
|
array(
|
155 |
|
|
'data' => $derivateHierarchy->herbarium,
|
156 |
|
|
'class' => array('summary_row_cell')
|
157 |
|
|
),
|
158 |
1ce9afb7
|
Patric Plitzner
|
array(
|
159 |
|
|
'data' => $derivateHierarchy->hasType? $checked_box_icon:"",
|
160 |
b8783a48
|
Patric Plitzner
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
161 |
1ce9afb7
|
Patric Plitzner
|
),
|
162 |
|
|
array(
|
163 |
|
|
'data' => $derivateHierarchy->hasSpecimenScan? $checked_box_icon:"",
|
164 |
b8783a48
|
Patric Plitzner
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
165 |
1ce9afb7
|
Patric Plitzner
|
),
|
166 |
b8783a48
|
Patric Plitzner
|
array(
|
167 |
|
|
'data' => ($derivateHierarchy->hasDna? $sequence_icon :"")." "
|
168 |
|
|
.($derivateHierarchy->hasDetailImage?$detail_image_icon:"")." "
|
169 |
|
|
.($derivateHierarchy->hasCharacterData?$character_data_icon:""),
|
170 |
|
|
'class' => array('summary_row_cell', 'summary_row_icon')
|
171 |
|
|
)
|
172 |
1ce9afb7
|
Patric Plitzner
|
),
|
173 |
|
|
'id' => ('derivate_summary' . $rowcount), // summary row id
|
174 |
|
|
'class' => array('summary_row'),
|
175 |
|
|
);
|
176 |
|
|
|
177 |
e3d43134
|
Patric Plitzner
|
//assemble field unit details
|
178 |
|
|
$detail_html = "";
|
179 |
7d8ef9fa
|
Patric Plitzner
|
// - taxon name
|
180 |
e3d43134
|
Patric Plitzner
|
if (variable_get('cdm_dataportal_compressed_specimen_derivate_table_show_determined_as') && $derivateHierarchy->taxonName) {
|
181 |
0ee2b205
|
Patrick Plitzner
|
$detail_html .= create_label("Associated with") . $derivateHierarchy->taxonName . "<br>";
|
182 |
db390e35
|
Patric Plitzner
|
}
|
183 |
7d8ef9fa
|
Patric Plitzner
|
// - prtologue
|
184 |
e3d43134
|
Patric Plitzner
|
if ($derivateHierarchy->protologue) {
|
185 |
|
|
//$detail_html .= "<strong>Protologue:</strong> " . $derivateHierarchy->protologue . "<br>"
|
186 |
|
|
}
|
187 |
7d8ef9fa
|
Patric Plitzner
|
// - citation
|
188 |
e3d43134
|
Patric Plitzner
|
if ($derivateHierarchy->citation) {
|
189 |
3dd58832
|
Patric Plitzner
|
$detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>";
|
190 |
1ce9afb7
|
Patric Plitzner
|
}
|
191 |
e3d43134
|
Patric Plitzner
|
//assemble specimen details
|
192 |
9af9c5b3
|
Patric Plitzner
|
if($derivateHierarchy->preservedSpecimenDTOs){
|
193 |
|
|
foreach($derivateHierarchy->preservedSpecimenDTOs as $preservedSpecimenDTO) {
|
194 |
3dd58832
|
Patric Plitzner
|
$detail_html .= "<br>";
|
195 |
9af9c5b3
|
Patric Plitzner
|
$detail_html .= compose_cdm_specimen_page_html($preservedSpecimenDTO);
|
196 |
|
|
}
|
197 |
e3d43134
|
Patric Plitzner
|
}
|
198 |
3dd58832
|
Patric Plitzner
|
$detail_html .= "<br>";
|
199 |
1ce9afb7
|
Patric Plitzner
|
//detail row resp. one BIG detail cell
|
200 |
|
|
$rows[] = array(
|
201 |
|
|
'data' => array(
|
202 |
b8783a48
|
Patric Plitzner
|
array(
|
203 |
|
|
'data' => "", //empty first column
|
204 |
44eebb6f
|
Patric Plitzner
|
'class' => array('expand_column')
|
205 |
b8783a48
|
Patric Plitzner
|
),
|
206 |
1ce9afb7
|
Patric Plitzner
|
array(
|
207 |
|
|
'data' => $detail_html,
|
208 |
b8783a48
|
Patric Plitzner
|
'colspan' => 7,
|
209 |
1ce9afb7
|
Patric Plitzner
|
),
|
210 |
|
|
),
|
211 |
|
|
'id' => ('derivate_details' . $rowcount),//details row ID
|
212 |
|
|
'class' => array('detail_row'),
|
213 |
|
|
);
|
214 |
|
|
$rowcount++;
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
f19f47fa
|
Andreas Kohlbecker
|
|
219 |
1ce9afb7
|
Patric Plitzner
|
$tableId = "derivate_hierarchy_table";
|
220 |
|
|
$derivateHierarchyTable = array(
|
221 |
|
|
"#theme" => "table",
|
222 |
|
|
"#weight" => 2,
|
223 |
44eebb6f
|
Patric Plitzner
|
"#header" => array(
|
224 |
|
|
array(
|
225 |
|
|
'data' => "",
|
226 |
|
|
'class' => array('expand_column')
|
227 |
|
|
),
|
228 |
f097a7d6
|
Patric Plitzner
|
"Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"),
|
229 |
1ce9afb7
|
Patric Plitzner
|
"#rows" => $rows,
|
230 |
|
|
"#attributes" => array(
|
231 |
|
|
"id" => $tableId,
|
232 |
|
|
"border" => 2
|
233 |
|
|
)
|
234 |
f19f47fa
|
Andreas Kohlbecker
|
);
|
235 |
|
|
|
236 |
1ce9afb7
|
Patric Plitzner
|
//add toggle functionality to derivate hierarchy table
|
237 |
|
|
drupal_add_js_rowToggle("#".$tableId);
|
238 |
f19f47fa
|
Andreas Kohlbecker
|
|
239 |
1ce9afb7
|
Patric Plitzner
|
$render_array['derivate_hierarchy_table'] = $derivateHierarchyTable;
|
240 |
4cb163f8
|
Patric Plitzner
|
$render_array['pager'] = markup_to_render_array(
|
241 |
|
|
theme('cdm_pager', array(
|
242 |
|
|
'pager' => $pagerFieldUnits,
|
243 |
|
|
'path' => $_REQUEST['q'],
|
244 |
|
|
'parameters' => $_REQUEST
|
245 |
|
|
)),
|
246 |
|
|
10 // weight
|
247 |
|
|
);
|
248 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
249 |
1ce9afb7
|
Patric Plitzner
|
else{
|
250 |
|
|
//BOTTOM-UP-SPECIMEN-TABLE
|
251 |
|
|
// --- generate the specimen list as table
|
252 |
|
|
$specimen_table = array(
|
253 |
|
|
'#theme' => 'table',
|
254 |
|
|
'#weight' => 2,
|
255 |
|
|
// prefix attributes and rows with '#' to let it pass to the theme function,
|
256 |
|
|
// otherwise it is handled as child render array
|
257 |
|
|
'#attributes' => array('class' => 'specimens'),
|
258 |
|
|
'#rows' => array(),
|
259 |
|
|
);
|
260 |
f19f47fa
|
Andreas Kohlbecker
|
|
261 |
1ce9afb7
|
Patric Plitzner
|
if ($specimensOrObservations) {
|
262 |
|
|
|
263 |
|
|
foreach ($specimensOrObservations as $specimenOrObservation) {
|
264 |
|
|
|
265 |
|
|
$mediaList = array();
|
266 |
|
|
if (is_array($specimenOrObservation->_fieldObjectMedia)) {
|
267 |
|
|
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia);
|
268 |
|
|
}
|
269 |
|
|
if (is_array($specimenOrObservation->_derivedUnitMedia)) {
|
270 |
|
|
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia);
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
// typelabel will contain the typeStatus
|
274 |
|
|
$type_label = '';
|
275 |
|
|
$typeDesignationPager = cdm_ws_get(CDM_WS_OCCURRENCE . '/$0/specimenTypeDesignations', $specimenOrObservation->uuid);
|
276 |
0e533708
|
Patric Plitzner
|
if (isset($typeDesignationPager) and isset($typeDesignationPager->records)) {
|
277 |
1ce9afb7
|
Patric Plitzner
|
$type_status = array();
|
278 |
|
|
foreach ($typeDesignationPager->records as $typeDesignation) {
|
279 |
|
|
if (isset($typeDesignation->typeStatus->representation_L10n)){
|
280 |
|
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
281 |
|
|
}
|
282 |
|
|
}
|
283 |
|
|
$type_label = implode(', ', $type_status);
|
284 |
|
|
if($type_label){
|
285 |
|
|
$type_label .= ': ' ;
|
286 |
|
|
}
|
287 |
|
|
}
|
288 |
|
|
|
289 |
|
|
// --- Specimen entry as dynamic label:
|
290 |
|
|
// -> Dynabox for the specimenOrObservation
|
291 |
|
|
$gallery_name = $specimenOrObservation->uuid;
|
292 |
|
|
|
293 |
|
|
$derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array( $specimenOrObservation->uuid));
|
294 |
|
|
$label_html = cdm_dynabox(
|
295 |
cea412e7
|
Andreas Kohlbecker
|
$specimenOrObservation->uuid,
|
296 |
|
|
$type_label . $specimenOrObservation->titleCache,
|
297 |
|
|
$derived_unit_ws_request,
|
298 |
|
|
'cdm_specimenOrObservation',
|
299 |
|
|
'Click for details',
|
300 |
|
|
array('div', 'div'),
|
301 |
|
|
array(),
|
302 |
|
|
null, // $content_element_selector
|
303 |
|
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
|
304 |
|
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
|
305 |
1ce9afb7
|
Patric Plitzner
|
);
|
306 |
|
|
|
307 |
|
|
// --- Render associated media.
|
308 |
|
|
$gallery_html = '';
|
309 |
|
|
if (count($mediaList) > 0) {
|
310 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
311 |
|
|
$captionElements = array(
|
312 |
|
|
'#uri' => t('open media'),
|
313 |
|
|
);
|
314 |
|
|
|
315 |
|
|
$gallery_html = theme('cdm_media_gallerie', array(
|
316 |
|
|
'mediaList' => $mediaList,
|
317 |
|
|
'galleryName' => $gallery_name,
|
318 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
319 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
320 |
|
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
321 |
|
|
'captionElements' => $captionElements,
|
322 |
|
|
'mediaLinkType' => 'LIGHTBOX',
|
323 |
|
|
'alternativeMediaUri' => NULL,
|
324 |
|
|
'galleryLinkUri' => NULL,
|
325 |
|
|
));
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
$specimen_table['#rows'][] = array(
|
329 |
|
|
// An array of table rows. Every row is an array of cells, or an associative array
|
330 |
|
|
'data' => array(
|
331 |
|
|
// Each cell can be either a string or an associative array
|
332 |
|
|
$label_html . $gallery_html
|
333 |
|
|
),
|
334 |
|
|
'class' => array(
|
335 |
|
|
'descriptionElement',
|
336 |
|
|
'descriptionElement_IndividualsAssociation'
|
337 |
|
|
),
|
338 |
|
|
);
|
339 |
|
|
}
|
340 |
|
|
}
|
341 |
f19f47fa
|
Andreas Kohlbecker
|
|
342 |
1ce9afb7
|
Patric Plitzner
|
$render_array['specimen_list'] = $specimen_table;
|
343 |
|
|
$render_array['pager'] = markup_to_render_array(
|
344 |
|
|
theme('cdm_pager', array(
|
345 |
|
|
'pager' => $pager,
|
346 |
|
|
'path' => $_REQUEST['q'],
|
347 |
|
|
'parameters' => $_REQUEST,
|
348 |
|
|
)),
|
349 |
|
|
10 // weight
|
350 |
|
|
);
|
351 |
|
|
}
|
352 |
|
|
RenderHints::popFromRenderStack();
|
353 |
|
|
return $render_array;
|
354 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
355 |
db390e35
|
Patric Plitzner
|
|
356 |
65a4de51
|
Patrick Plitzner
|
function create_html_link($link, $openInExternalWindow=false){
|
357 |
7d8ef9fa
|
Patric Plitzner
|
$html = "";
|
358 |
65a4de51
|
Patrick Plitzner
|
if($link->uri && $link->uri!=""){
|
359 |
|
|
$html .= '<a href="' . $link->uri . '"';
|
360 |
|
|
if($openInExternalWindow){
|
361 |
|
|
$html .= ' target="_blank"';
|
362 |
|
|
}
|
363 |
|
|
$html .= '>' . $link->linkText . '</a>';
|
364 |
7d8ef9fa
|
Patric Plitzner
|
}
|
365 |
|
|
else{
|
366 |
|
|
$html .= $link->linkText;
|
367 |
|
|
}
|
368 |
|
|
return $html;
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
/**
|
372 |
65a4de51
|
Patrick Plitzner
|
* Creates HTML links from the given link list concatenated by default by a comma.
|
373 |
7d8ef9fa
|
Patric Plitzner
|
* @param $linkList the list with Link objects having "uri" and "linkText" as members
|
374 |
|
|
* @return string the assembled HTML string containing the links
|
375 |
|
|
*/
|
376 |
65a4de51
|
Patrick Plitzner
|
function create_html_links($linkList, $openInExternalWindow=false, $separator=", ")
|
377 |
7d8ef9fa
|
Patric Plitzner
|
{
|
378 |
|
|
$html = "";
|
379 |
|
|
if ($linkList) {
|
380 |
|
|
foreach ($linkList as $link) {
|
381 |
65a4de51
|
Patrick Plitzner
|
$html .= create_html_link($link, $openInExternalWindow).$separator;
|
382 |
7d8ef9fa
|
Patric Plitzner
|
}
|
383 |
65a4de51
|
Patrick Plitzner
|
$html = rtrim($html, $separator);
|
384 |
7d8ef9fa
|
Patric Plitzner
|
}
|
385 |
|
|
return $html;
|
386 |
|
|
}
|
387 |
|
|
|
388 |
00a8e4b6
|
Andreas Kohlbecker
|
/**
|
389 |
|
|
* Composes a taxon page which can consist of multiple parts like
|
390 |
|
|
* 'General', 'Synonymy', 'Images', 'Keys'. These parts can be displayed
|
391 |
|
|
* as tabs or as sections of a single page.
|
392 |
|
|
*
|
393 |
|
|
* It is headed by the name of the accepted taxon without author and reference.
|
394 |
|
|
*
|
395 |
|
|
* @param $taxon
|
396 |
|
|
* The CDM Taxon Instance to compose the page for.
|
397 |
|
|
* @param $page_part
|
398 |
|
|
* Name of the part to display, valid values are:
|
399 |
|
|
* - 'description' - for the general part
|
400 |
|
|
* - 'images'
|
401 |
|
|
* - 'synonymy'
|
402 |
|
|
* - 'keys'
|
403 |
|
|
* - 'all'
|
404 |
|
|
*
|
405 |
|
|
* @return array
|
406 |
|
|
* A drupal render array
|
407 |
|
|
*
|
408 |
|
|
* @ingroup compose
|
409 |
|
|
*/
|
410 |
|
|
function compose_cdm_taxon_page($taxon, $page_part = 'description') {
|
411 |
|
|
|
412 |
0ae57522
|
Patric Plitzner
|
// we better cache here since drupal_get_query_parameters has no internal static cache variable
|
413 |
|
|
$http_request_params = drupal_get_query_parameters();
|
414 |
00a8e4b6
|
Andreas Kohlbecker
|
|
415 |
0ae57522
|
Patric Plitzner
|
// add all mandatory js sources
|
416 |
|
|
_add_js_footnotes();
|
417 |
00a8e4b6
|
Andreas Kohlbecker
|
|
418 |
|
|
|
419 |
0ae57522
|
Patric Plitzner
|
$render_array = array();
|
420 |
|
|
$weight = 0; // the weight for the render array elements
|
421 |
00a8e4b6
|
Andreas Kohlbecker
|
|
422 |
0ae57522
|
Patric Plitzner
|
$tabsToDisplay = variable_get('cdm_taxonpage_tabs_visibility', unserialize(TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT));
|
423 |
00a8e4b6
|
Andreas Kohlbecker
|
|
424 |
0ae57522
|
Patric Plitzner
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
425 |
00a8e4b6
|
Andreas Kohlbecker
|
|
426 |
0ae57522
|
Patric Plitzner
|
$media = _load_media_for_taxon($taxon);
|
427 |
00a8e4b6
|
Andreas Kohlbecker
|
|
428 |
|
|
|
429 |
0ae57522
|
Patric Plitzner
|
if (!isset($media[0]) || ($tabsToDisplay["Images"] == '0')) {
|
430 |
|
|
taxon_page_tabs_hidden('images');
|
431 |
|
|
}
|
432 |
00a8e4b6
|
Andreas Kohlbecker
|
|
433 |
0ae57522
|
Patric Plitzner
|
// --- GET specimensOrObservations --- //
|
434 |
|
|
$specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
|
435 |
00a8e4b6
|
Andreas Kohlbecker
|
|
436 |
0ae57522
|
Patric Plitzner
|
$specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
|
437 |
|
|
if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
|
438 |
|
|
taxon_page_tabs_hidden('specimens');
|
439 |
|
|
}
|
440 |
00a8e4b6
|
Andreas Kohlbecker
|
|
441 |
0ae57522
|
Patric Plitzner
|
// --- GET polytomousKeys --- //
|
442 |
|
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, NULL, "findByTaxonomicScope=$taxon->uuid");
|
443 |
|
|
$identificationKeyCount = 0;
|
444 |
|
|
if ($polytomousKeysPager) {
|
445 |
|
|
$identificationKeyCount += $polytomousKeysPager->count;
|
446 |
|
|
}
|
447 |
|
|
if ($identificationKeyCount == 0 || ($tabsToDisplay["Keys"] == '0')) {
|
448 |
|
|
taxon_page_tabs_hidden('keys');
|
449 |
|
|
}
|
450 |
092744e1
|
Andreas Kohlbecker
|
|
451 |
7663cd0b
|
Andreas Kohlbecker
|
// --- GET TaxonNodeAgentRelations --- //
|
452 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
453 |
|
|
$taxon_node_agent_relations_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
|
454 |
|
|
array(
|
455 |
|
|
$taxon->uuid,
|
456 |
|
|
$current_classification_uuid,
|
457 |
|
|
),
|
458 |
|
|
"pageSize=1&pageIndex=0"// we are only interested into the count so we are fetching only one item, o is not possible!
|
459 |
|
|
);
|
460 |
|
|
if (!$taxon_node_agent_relations_pager || $taxon_node_agent_relations_pager->count == 0){
|
461 |
|
|
taxon_page_tabs_hidden('experts');
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
if ($tabsToDisplay["Synonymy"] == '0') {
|
465 |
0ae57522
|
Patric Plitzner
|
taxon_page_tabs_hidden('synonymy');
|
466 |
|
|
}
|
467 |
00a8e4b6
|
Andreas Kohlbecker
|
|
468 |
0ae57522
|
Patric Plitzner
|
// -------------------------------------------- //
|
469 |
00a8e4b6
|
Andreas Kohlbecker
|
|
470 |
0ae57522
|
Patric Plitzner
|
if (variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR) && isset($_REQUEST['acceptedFor'])) {
|
471 |
7272d19c
|
Andreas Kohlbecker
|
$render_array['accepted_for'] = markup_to_render_array(cdm_accepted_for($_REQUEST['acceptedFor']), $weight++);
|
472 |
0ae57522
|
Patric Plitzner
|
}
|
473 |
00a8e4b6
|
Andreas Kohlbecker
|
|
474 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: DESCRIPTION --- //
|
475 |
|
|
if ($page_part == 'description' || $page_part == 'all') {
|
476 |
00a8e4b6
|
Andreas Kohlbecker
|
|
477 |
0ae57522
|
Patric Plitzner
|
$merged_tree = merged_taxon_feature_tree($taxon);
|
478 |
00a8e4b6
|
Andreas Kohlbecker
|
|
479 |
7d8ef9fa
|
Patric Plitzner
|
|
480 |
0ae57522
|
Patric Plitzner
|
$render_array['general'] = compose_cdm_taxon_page_profile($taxon, $merged_tree, $media);
|
481 |
|
|
$render_array['general']['#weight'] = $weight++;
|
482 |
|
|
$render_array['general']['#prefix'] = '<div id="general" class="page-part">';
|
483 |
|
|
$render_array['general']['#suffix'] = '</div>';
|
484 |
|
|
}
|
485 |
7d8ef9fa
|
Patric Plitzner
|
|
486 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: IMAGES --- //
|
487 |
|
|
if (array_search('images', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'images' || $page_part == 'all')) {
|
488 |
|
|
$images_html = '<div id="images" class="page-part">';
|
489 |
|
|
if ($page_part == 'all') {
|
490 |
|
|
$images_html .= '<h2>' . t('Images') . '</h2>';
|
491 |
7d8ef9fa
|
Patric Plitzner
|
}
|
492 |
0ae57522
|
Patric Plitzner
|
// Get the image gallery as configured by the admin.
|
493 |
8f4eb9ce
|
Andreas Kohlbecker
|
$default_image_gallery = 'default';
|
494 |
|
|
$configured_image_gallery_viewer = variable_get('image_gallery_viewer', 'default');
|
495 |
|
|
if($configured_image_gallery_viewer == $default_image_gallery || $configured_image_gallery_viewer == 'fsi'){
|
496 |
|
|
// the fsi_gallery requires a flash plugin, in case the client browser is not supporting
|
497 |
|
|
// flash we also need to provide an the default gallery as alternative
|
498 |
|
|
$taxon_image_gallery = '<div id="default-gallery-viewer">' .
|
499 |
|
|
call_user_func_array('taxon_image_gallery_' . $default_image_gallery, array(
|
500 |
|
|
$taxon,
|
501 |
|
|
$media,
|
502 |
|
|
))
|
503 |
|
|
. '</div>';
|
504 |
|
|
}
|
505 |
|
|
if($configured_image_gallery_viewer == 'fsi'){
|
506 |
|
|
$taxon_image_gallery .= '<div id="'. $configured_image_gallery_viewer .'-gallery-viewer">' .
|
507 |
|
|
call_user_func_array('taxon_image_gallery_' . $configured_image_gallery_viewer, array(
|
508 |
|
|
$taxon,
|
509 |
|
|
$media,
|
510 |
|
|
))
|
511 |
|
|
. '</div>';
|
512 |
|
|
}
|
513 |
0ae57522
|
Patric Plitzner
|
$images_html .= $taxon_image_gallery;
|
514 |
|
|
$images_html .= '</div>';
|
515 |
|
|
$render_array['images'] = markup_to_render_array($images_html, $weight++);
|
516 |
|
|
}
|
517 |
7d8ef9fa
|
Patric Plitzner
|
|
518 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: SYNONYMY --- //
|
519 |
|
|
if (($page_part == 'synonymy' || $page_part == 'all')) {
|
520 |
|
|
$synonymy_html = '<div id="synonymy" class="page-part">';
|
521 |
|
|
if ($page_part == 'all') {
|
522 |
|
|
$synonymy_html .= '<h2>' . t('Synonymy') . '</h2>';
|
523 |
00a8e4b6
|
Andreas Kohlbecker
|
}
|
524 |
0ae57522
|
Patric Plitzner
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
525 |
41b4bfc9
|
Andreas Kohlbecker
|
|
526 |
0ae57522
|
Patric Plitzner
|
$synonymy_html .= theme('cdm_taxon_page_synonymy', array('taxon' => $taxon, 'addAcceptedTaxon' => $addAcceptedTaxon));
|
527 |
00a8e4b6
|
Andreas Kohlbecker
|
|
528 |
0ae57522
|
Patric Plitzner
|
$synonymy_html .= '</div>';
|
529 |
|
|
$render_array['synonymy'] = markup_to_render_array($synonymy_html, $weight++);
|
530 |
00a8e4b6
|
Andreas Kohlbecker
|
|
531 |
0ae57522
|
Patric Plitzner
|
}
|
532 |
00a8e4b6
|
Andreas Kohlbecker
|
|
533 |
0ae57522
|
Patric Plitzner
|
// --- PAGE PART: SPECIMENS --- //
|
534 |
|
|
if ($specimensOrObservationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all')) {
|
535 |
|
|
$render_array['specimens'] = array(
|
536 |
|
|
'#prefix' => '<div id="specimens" class="page-part">' . ($page_part == 'all' ? '<h2>' . t('Specimens') . '</h2>' : ''),
|
537 |
|
|
'content' => cdm_dataportal_taxon_page_specimens($taxon), // returns render array
|
538 |
|
|
'#suffix' => '</div>',
|
539 |
|
|
);
|
540 |
|
|
}
|
541 |
|
|
|
542 |
|
|
// --- PAGE PART: KEYS --- //
|
543 |
|
|
if ($identificationKeyCount == 1 && $page_part == 'keys'){
|
544 |
|
|
drupal_goto(path_to_key($polytomousKeysPager->records[0]->class, $polytomousKeysPager->records[0]->uuid));
|
545 |
|
|
}
|
546 |
|
|
else if ($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all')) {
|
547 |
|
|
$keys_html = '<div id="keys" class="page-part">';
|
548 |
|
|
if ($page_part == 'all') {
|
549 |
|
|
$keys_html .= '<h2>' . t('Keys') . '</h2>';
|
550 |
|
|
}
|
551 |
|
|
$keys_html .= theme('cdm_block_IdentificationKeys', array('taxonUuid' => $taxon->uuid));
|
552 |
|
|
$keys_html .= '</div>';
|
553 |
|
|
$render_array['keys'] = markup_to_render_array($keys_html, $weight++);
|
554 |
|
|
}
|
555 |
|
|
|
556 |
7663cd0b
|
Andreas Kohlbecker
|
// --- PAGE PART: EXPERTS --- //
|
557 |
|
|
|
558 |
|
|
if (array_search('experts', taxon_page_tabs_hidden()) === FALSE && ($page_part == 'experts' || $page_part == 'all')) {
|
559 |
|
|
$render_array['experts'] = array(
|
560 |
|
|
'#prefix' => '<div id="experts" class="page-part">' . ($page_part == 'all' ? '<h2>' . t('Experts') . '</h2>' : ''),
|
561 |
|
|
'content' => compose_cdm_taxon_page_experts($taxon), // returns render array
|
562 |
|
|
'#suffix' => '</div>',
|
563 |
|
|
);
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
// ------------------ END OF PARTS -------------- //
|
567 |
0ae57522
|
Patric Plitzner
|
|
568 |
|
|
// adjust weights of page and toc elements according to the settings
|
569 |
|
|
$taxontabs_weights = get_array_variable_merged('cdm_taxonpage_tabs_weight', CDM_TAXONPAGE_TAB_WEIGHT_DEFAULT);
|
570 |
|
|
foreach($taxontabs_weights as $tab_key => $weight){
|
571 |
|
|
if(isset($render_array[$tab_key])){
|
572 |
|
|
$render_array[$tab_key]['#weight'] = $weight;
|
573 |
|
|
}
|
574 |
|
|
}
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
// set up the TOC for the pages which contain all pageparts
|
578 |
|
|
if($page_part == 'all') {
|
579 |
|
|
|
580 |
|
|
asort($taxontabs_weights);
|
581 |
|
|
foreach(array_keys($taxontabs_weights) as $tab_key){
|
582 |
|
|
if(isset($render_array[$tab_key])){
|
583 |
|
|
if($tab_key != 'general'){
|
584 |
|
|
// add entry for page part
|
585 |
|
|
$toc_elements[] = array(
|
586 |
7cc085da
|
Andreas Kohlbecker
|
'data' => l(t('@tab-name', array('@tab-name' => ucfirst($tab_key))), $_GET['q'], array('fragment' => $tab_key, 'query' => $http_request_params)),
|
587 |
0ae57522
|
Patric Plitzner
|
'class' => array('page-part-toc-item-' . $tab_key)
|
588 |
|
|
);
|
589 |
|
|
} else {
|
590 |
|
|
// add content of profile part instead
|
591 |
|
|
if(isset($render_array['general'])) {
|
592 |
|
|
// in case all tabs are shown at once the feature tocs
|
593 |
|
|
// should be integrated into the tabs toc as sub list
|
594 |
|
|
// and the profile image should be on top of the page
|
595 |
|
|
if(isset($render_array['general']['taxon_description_feature_toc'])){;
|
596 |
|
|
foreach ($render_array['general']['taxon_description_feature_toc']['#items'] as $profile_toc_item){
|
597 |
|
|
$toc_elements[] = $profile_toc_item;
|
598 |
7d8ef9fa
|
Patric Plitzner
|
}
|
599 |
0ae57522
|
Patric Plitzner
|
unset($render_array['general']['taxon_description_feature_toc']);
|
600 |
|
|
}
|
601 |
|
|
}
|
602 |
7d8ef9fa
|
Patric Plitzner
|
}
|
603 |
0ae57522
|
Patric Plitzner
|
}
|
604 |
|
|
}
|
605 |
7d8ef9fa
|
Patric Plitzner
|
|
606 |
0ae57522
|
Patric Plitzner
|
// move profile image in page structure
|
607 |
|
|
if(isset($render_array['general']['taxon_profile_image'])){
|
608 |
|
|
$render_array['profile_image'] = $render_array['general']['taxon_profile_image'];
|
609 |
|
|
$render_array['profile_image']['#weight'] = -100;
|
610 |
|
|
unset($render_array['general']['taxon_profile_image']);
|
611 |
7d8ef9fa
|
Patric Plitzner
|
}
|
612 |
|
|
|
613 |
0ae57522
|
Patric Plitzner
|
// finally add the table of contents to the render array
|
614 |
|
|
$render_array['toc'] = array(
|
615 |
|
|
'#theme' => 'item_list',
|
616 |
|
|
'#items' => $toc_elements,
|
617 |
|
|
'#title' => t('Content'),
|
618 |
|
|
'#weight' => -101,
|
619 |
|
|
'#suffix' => '</div>',
|
620 |
|
|
'#prefix'=> '<div id="page-toc">'
|
621 |
|
|
);
|
622 |
|
|
}
|
623 |
|
|
|
624 |
7d8ef9fa
|
Patric Plitzner
|
|
625 |
0ae57522
|
Patric Plitzner
|
return $render_array;
|
626 |
00a8e4b6
|
Andreas Kohlbecker
|
}
|
627 |
|
|
|
628 |
1ce9afb7
|
Patric Plitzner
|
/**
|
629 |
22f5e82d
|
Andreas Kohlbecker
|
* TODO should this function really be a compose function?
|
630 |
|
|
* For a compose function must there always be a theme function with the same name? (ak 8.8.2013)
|
631 |
bf97c2e8
|
Andreas Kohlbecker
|
*
|
632 |
|
|
* composes and returns an render array containing the components of the taxon profile tab:
|
633 |
|
|
* - 'taxon_profile_image'
|
634 |
|
|
* - 'taxon_description_feature_toc'
|
635 |
|
|
* - 'taxon_description_features'
|
636 |
|
|
*
|
637 |
|
|
*
|
638 |
f78fda81
|
Andreas Kohlbecker
|
* @param taxon
|
639 |
|
|
* @param mergedTrees
|
640 |
|
|
* @param media
|
641 |
bf97c2e8
|
Andreas Kohlbecker
|
*
|
642 |
|
|
* @return array
|
643 |
f78fda81
|
Andreas Kohlbecker
|
* A Drupal render array with the following elements:
|
644 |
bf97c2e8
|
Andreas Kohlbecker
|
* - 'taxon_profile_image'
|
645 |
|
|
* - 'taxon_description_feature_toc'
|
646 |
|
|
* - 'taxon_description_features'
|
647 |
|
|
*
|
648 |
|
|
* @ingroup compose
|
649 |
|
|
*/
|
650 |
|
|
function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media) {
|
651 |
|
|
|
652 |
0ae57522
|
Patric Plitzner
|
$render_array = array();
|
653 |
|
|
|
654 |
|
|
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
|
655 |
|
|
|
656 |
|
|
$hide_taxon_profile_image = FALSE;
|
657 |
|
|
if (variable_get('image_hide_rank', '0') != '0' && isset($taxon->name->rank->uuid)) {
|
658 |
|
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
659 |
|
|
$hide_taxon_profile_image = ($rankCompare > -1);
|
660 |
|
|
}
|
661 |
|
|
|
662 |
|
|
if ($taxon_profile_image_settings['show'] && !$hide_taxon_profile_image) {
|
663 |
|
|
|
664 |
|
|
$representationPart = new stdClass();
|
665 |
|
|
$attributes = array();
|
666 |
|
|
if (isset($media[0]->representations[0]->parts[0])) {
|
667 |
|
|
$representationPart = $media[0]->representations[0]->parts[0];
|
668 |
|
|
$attributes['alt'] = $representationPart->uri;
|
669 |
|
|
|
670 |
ca47ea76
|
Andreas Kohlbecker
|
if (!empty($taxon_profile_image_settings['media_uri_query'])) {
|
671 |
0ae57522
|
Patric Plitzner
|
$representationPart->uri = $representationPart->uri
|
672 |
ca47ea76
|
Andreas Kohlbecker
|
. (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?')
|
673 |
|
|
. $taxon_profile_image_settings['media_uri_query'];
|
674 |
0ae57522
|
Patric Plitzner
|
}
|
675 |
|
|
}
|
676 |
|
|
else {
|
677 |
9506fd1f
|
Andreas Kohlbecker
|
if ($taxon_profile_image_settings['custom_placeholder_enabled']) {
|
678 |
ca47ea76
|
Andreas Kohlbecker
|
// show placeholder image instead
|
679 |
|
|
if (!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])) {
|
680 |
|
|
// use the user provided image
|
681 |
|
|
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
|
682 |
|
|
$url = file_create_url($profile_image_file->uri);
|
683 |
|
|
$image_info = image_get_info($profile_image_file->uri);
|
684 |
|
|
$representationPart->width = $image_info['width'];
|
685 |
|
|
$representationPart->height = $image_info['height'];
|
686 |
|
|
$representationPart->uri = $url;
|
687 |
|
|
}
|
688 |
|
|
else {
|
689 |
|
|
// use the hard coded default
|
690 |
|
|
$representationPart->width = 184;
|
691 |
|
|
$representationPart->height = 144;
|
692 |
|
|
$representationPart->uri = base_path() . drupal_get_path('module',
|
693 |
|
|
'cdm_dataportal') . '/images/no_picture.png';
|
694 |
|
|
}
|
695 |
|
|
$attributes['alt'] = "no image available";
|
696 |
0ae57522
|
Patric Plitzner
|
}
|
697 |
|
|
}
|
698 |
|
|
|
699 |
ca47ea76
|
Andreas Kohlbecker
|
if (isset($representationPart->uri)) {
|
700 |
|
|
$profile_image = theme('cdm_media_gallerie_image', array(
|
701 |
0ae57522
|
Patric Plitzner
|
'mediaRepresentationPart' => $representationPart,
|
702 |
|
|
'maxExtend' => $taxon_profile_image_settings['maxextend'],
|
703 |
|
|
'addPassePartout' => FALSE,
|
704 |
|
|
'attributes' => $attributes,
|
705 |
ca47ea76
|
Andreas Kohlbecker
|
));
|
706 |
|
|
// NOTE: style="width:${maxextend}px' is needed for IE8 !!!
|
707 |
|
|
$render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image . '</div>',
|
708 |
|
|
-101);
|
709 |
|
|
}
|
710 |
0ae57522
|
Patric Plitzner
|
}
|
711 |
|
|
|
712 |
|
|
|
713 |
|
|
// Render the sections for each feature
|
714 |
aa26f9f0
|
Andreas Kohlbecker
|
$render_array['taxon_description_features'] = compose_feature_blocks($merged_tree->root->childNodes, $taxon);
|
715 |
0ae57522
|
Patric Plitzner
|
|
716 |
|
|
$bibliography_settings = get_bibliography_settings();
|
717 |
|
|
if($bibliography_settings['enabled'] == 1){
|
718 |
|
|
$bibliography_block = feature_block(t('Bibliography'));
|
719 |
|
|
$bibliography_block->content = FootnoteManager::renderFootnoteList('BIBLIOGRAPHY', '');
|
720 |
|
|
|
721 |
|
|
if(!empty($bibliography_block->content)){
|
722 |
|
|
$render_array['taxon_description_bibliography'] = markup_to_render_array(
|
723 |
|
|
theme('block',
|
724 |
|
|
array(
|
725 |
|
|
'elements' => array(
|
726 |
|
|
'#block' => $bibliography_block,
|
727 |
|
|
'#children' => $bibliography_block->content,
|
728 |
|
|
)
|
729 |
|
|
)
|
730 |
|
|
),
|
731 |
|
|
100 // weight
|
732 |
|
|
);
|
733 |
|
|
cdm_toc_list_add_item('Bibliography', 'bibliography');
|
734 |
|
|
}
|
735 |
|
|
|
736 |
|
|
}
|
737 |
|
|
|
738 |
|
|
// create the table of content
|
739 |
|
|
$toc = array(
|
740 |
|
|
'#theme' => 'item_list',
|
741 |
|
|
'#items' => cdm_toc_list(),
|
742 |
|
|
'#title' => t('Content'),
|
743 |
|
|
'#weight' => -100, // move to the top
|
744 |
|
|
'#suffix' => '</div>',
|
745 |
|
|
'#prefix'=> '<div id="page-toc">'
|
746 |
|
|
);
|
747 |
|
|
$render_array['taxon_description_feature_toc'] = $toc;
|
748 |
|
|
|
749 |
|
|
return $render_array;
|
750 |
bf97c2e8
|
Andreas Kohlbecker
|
}
|
751 |
|
|
|
752 |
f9a3d0f6
|
Andreas Kohlbecker
|
/**
|
753 |
|
|
* composes and returns an render array for the experts associated with the given taxon
|
754 |
|
|
*
|
755 |
|
|
* @param taxon
|
756 |
|
|
*
|
757 |
|
|
* @return array
|
758 |
|
|
* A Drupal render array for a table with the experts
|
759 |
|
|
*
|
760 |
|
|
* @ingroup compose
|
761 |
|
|
*/
|
762 |
7663cd0b
|
Andreas Kohlbecker
|
function compose_cdm_taxon_page_experts($taxon){
|
763 |
|
|
|
764 |
|
|
$render_array = array();
|
765 |
|
|
if(!isset($taxon->uuid)){
|
766 |
|
|
return $render_array;
|
767 |
|
|
}
|
768 |
|
|
|
769 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
770 |
|
|
// TODO use cdm_ws_fetchall below but this failes! needs fix!
|
771 |
|
|
$taxon_node_agent_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODEAGENTRELATIONS,
|
772 |
|
|
array(
|
773 |
|
|
$taxon->uuid,
|
774 |
|
|
$current_classification_uuid
|
775 |
|
|
)
|
776 |
|
|
);
|
777 |
|
|
|
778 |
|
|
$header = array(
|
779 |
|
|
array('data' => t('Expert')),
|
780 |
|
|
array('data' => t('Role'))
|
781 |
|
|
);
|
782 |
|
|
$rows = array();
|
783 |
|
|
|
784 |
|
|
|
785 |
|
|
foreach($taxon_node_agent_relations->records as $taxon_node_agent_relation){
|
786 |
|
|
|
787 |
d9763fd3
|
Andreas Kohlbecker
|
|
788 |
|
|
$expert_role_id = $taxon_node_agent_relation->agent->uuid . '-' . $taxon_node_agent_relation->type->uuid;
|
789 |
|
|
$expert_details_container_id = 'expert_details_' . $expert_role_id;
|
790 |
|
|
|
791 |
|
|
$agent_label_markup = cdm_dynabox(
|
792 |
|
|
'expert_' . $expert_role_id,
|
793 |
|
|
$taxon_node_agent_relation->agent->titleCache,
|
794 |
|
|
// specifying both ends of the relationship will return only one record in the pager
|
795 |
|
|
cdm_compose_url(CDM_WS_PORTAL_AGENT,
|
796 |
|
|
array($taxon_node_agent_relation->agent->uuid, 'taxonNodeAgentRelations'),
|
797 |
|
|
'taxon_uuid=' . $taxon->uuid . '&relType_uuid=' . $taxon_node_agent_relation->type->uuid),
|
798 |
|
|
'cdm_taxon_expert',
|
799 |
|
|
'Click for details',
|
800 |
|
|
array('div', 'div'),
|
801 |
|
|
array(), // attributes
|
802 |
cea412e7
|
Andreas Kohlbecker
|
'#' . $expert_details_container_id // $content_element_selector
|
803 |
d9763fd3
|
Andreas Kohlbecker
|
);
|
804 |
|
|
|
805 |
|
|
// Expert and Role
|
806 |
|
|
$rows[] = array(
|
807 |
|
|
'data' => array(
|
808 |
|
|
array(
|
809 |
|
|
'data' => $agent_label_markup,
|
810 |
|
|
'class' => array(html_class_attribute_ref($taxon_node_agent_relation->agent))
|
811 |
7663cd0b
|
Andreas Kohlbecker
|
),
|
812 |
d9763fd3
|
Andreas Kohlbecker
|
array(
|
813 |
|
|
'data' => $taxon_node_agent_relation->type->representation_L10n,
|
814 |
|
|
'class' => array(html_class_attribute_ref($taxon_node_agent_relation->type))
|
815 |
|
|
)
|
816 |
|
|
)
|
817 |
|
|
);
|
818 |
|
|
// Agent details
|
819 |
|
|
$rows[] = array(
|
820 |
|
|
'data' => array(
|
821 |
|
|
array(
|
822 |
|
|
'data' => '<!-- expert_details_container -->',
|
823 |
|
|
'id' => $expert_details_container_id,
|
824 |
|
|
'colspan' => 2
|
825 |
|
|
)
|
826 |
|
|
)
|
827 |
7663cd0b
|
Andreas Kohlbecker
|
);
|
828 |
d9763fd3
|
Andreas Kohlbecker
|
|
829 |
7663cd0b
|
Andreas Kohlbecker
|
}
|
830 |
|
|
|
831 |
|
|
|
832 |
|
|
$render_array['experts_table'] = array(
|
833 |
|
|
'#theme' => 'table',
|
834 |
|
|
'#header' => $header,
|
835 |
|
|
'#rows' => $rows,
|
836 |
|
|
);
|
837 |
|
|
|
838 |
|
|
|
839 |
|
|
return $render_array;
|
840 |
|
|
}
|
841 |
|
|
|
842 |
bf97c2e8
|
Andreas Kohlbecker
|
|
843 |
3f259ca3
|
Andreas Kohlbecker
|
/**
|
844 |
7663cd0b
|
Andreas Kohlbecker
|
* Manages the tabs to be hidden in the taxon page.
|
845 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
846 |
|
|
* The tabs are identified by their last menu link path element:
|
847 |
|
|
* - description
|
848 |
|
|
* - synonymy
|
849 |
|
|
* - images
|
850 |
|
|
* - specimens
|
851 |
|
|
* - key
|
852 |
|
|
*
|
853 |
|
|
* Internally the tabs are stored in a static variable which is
|
854 |
|
|
* managed by drupal_static().
|
855 |
|
|
*
|
856 |
|
|
* @param string $add_tab
|
857 |
7663cd0b
|
Andreas Kohlbecker
|
* Optional parameter. The given string will be added to the array of tabs
|
858 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
859 |
|
|
* @return
|
860 |
|
|
* The array of tabs
|
861 |
|
|
*/
|
862 |
|
|
function taxon_page_tabs_hidden($add_tab = NULL) {
|
863 |
0ae57522
|
Patric Plitzner
|
$tabs = &drupal_static(__FUNCTION__);
|
864 |
3f259ca3
|
Andreas Kohlbecker
|
|
865 |
0ae57522
|
Patric Plitzner
|
if(!isset($tabs)){
|
866 |
|
|
$tabs = array();
|
867 |
|
|
}
|
868 |
3f259ca3
|
Andreas Kohlbecker
|
|
869 |
0ae57522
|
Patric Plitzner
|
if (isset($add_tab) && !array_key_exists($add_tab, $tabs)) {
|
870 |
|
|
$tabs[] = $add_tab;
|
871 |
|
|
}
|
872 |
3f259ca3
|
Andreas Kohlbecker
|
|
873 |
0ae57522
|
Patric Plitzner
|
return $tabs;
|
874 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
875 |
|
|
|
876 |
|
|
/**
|
877 |
|
|
* Implements the hook_preprocess_HOOK() for theme_menu_local_tasks()
|
878 |
|
|
*
|
879 |
9438ad3a
|
Andreas Kohlbecker
|
* - Removes the tabs to be hidden, @see taxon_page_tabs_hidden()
|
880 |
|
|
* - Renames tabs according to the settings // TODO (this will replace the theme_cdm_taxonpage_tab() function !!!)
|
881 |
3f259ca3
|
Andreas Kohlbecker
|
*
|
882 |
|
|
* @param array $variables
|
883 |
|
|
* The variables array
|
884 |
|
|
*/
|
885 |
|
|
function cdm_dataportal_preprocess_menu_local_tasks(&$variables) {
|
886 |
|
|
|
887 |
0ae57522
|
Patric Plitzner
|
$hidden_tabs = taxon_page_tabs_hidden();
|
888 |
3f259ca3
|
Andreas Kohlbecker
|
|
889 |
0ae57522
|
Patric Plitzner
|
if (is_array($variables['primary'])) {
|
890 |
|
|
foreach ($variables['primary'] as $key => &$element) {
|
891 |
6f1a217c
|
Andreas Kohlbecker
|
|
892 |
0ae57522
|
Patric Plitzner
|
// 1. Remove the tabs to be hidden
|
893 |
|
|
foreach ($hidden_tabs as $tab) {
|
894 |
|
|
if ($element['#link']['path'] == 'cdm_dataportal/taxon/%/' . $tab) {
|
895 |
|
|
// remove the tab
|
896 |
|
|
unset($variables['primary'][$key]);
|
897 |
9438ad3a
|
Andreas Kohlbecker
|
}
|
898 |
0ae57522
|
Patric Plitzner
|
}
|
899 |
3f259ca3
|
Andreas Kohlbecker
|
}
|
900 |
0ae57522
|
Patric Plitzner
|
}
|
901 |
6f1a217c
|
Andreas Kohlbecker
|
}
|
902 |
|
|
|
903 |
|
|
|
904 |
|
|
|
905 |
|
|
/**
|
906 |
|
|
* Implements the hook_preprocess_HOOK() for theme_menu_local_task()
|
907 |
|
|
*
|
908 |
|
|
*
|
909 |
|
|
* @param array $variables
|
910 |
|
|
* An associative array containing:
|
911 |
|
|
* - element: A render element containing:
|
912 |
|
|
* #link: A menu link array with 'title', 'href', and 'localized_options' keys.
|
913 |
|
|
* #active: A boolean indicating whether the local task is active.
|
914 |
|
|
*
|
915 |
|
|
*/
|
916 |
|
|
function cdm_dataportal_preprocess_menu_local_task(&$variables) {
|
917 |
|
|
|
918 |
0ae57522
|
Patric Plitzner
|
$link = $variables['element']['#link'];
|
919 |
|
|
if (preg_match('/cdm_dataportal\/.*\/refresh$/', $link['href'])) {
|
920 |
|
|
$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']) . '"/>';
|
921 |
|
|
$link['localized_options']['html'] = TRUE;
|
922 |
6f1a217c
|
Andreas Kohlbecker
|
|
923 |
0ae57522
|
Patric Plitzner
|
$variables['element']['#link'] = $link;
|
924 |
|
|
}
|
925 |
f19f47fa
|
Andreas Kohlbecker
|
}
|
926 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
927 |
|
|
/* =================== block composition ===================== */
|
928 |
|
|
|
929 |
|
|
/**
|
930 |
23ad16a1
|
Andreas Kohlbecker
|
* Composes and returns an render array for the classification breadcrumbs of the given taxon.
|
931 |
f9a3d0f6
|
Andreas Kohlbecker
|
*
|
932 |
|
|
* @param taxon
|
933 |
|
|
*
|
934 |
|
|
* @return array
|
935 |
|
|
* A Drupal render array for a table with the experts
|
936 |
|
|
*
|
937 |
|
|
* @ingroup compose
|
938 |
|
|
*/
|
939 |
|
|
function compose_classification_breadcrumbs($taxon_uuid) {
|
940 |
|
|
|
941 |
b0adfd32
|
Andreas Kohlbecker
|
_add_js_taxonomic_children('#classification-breadcrumbs .taxonomic-children-button');
|
942 |
d0d23caa
|
Andreas Kohlbecker
|
|
943 |
f9a3d0f6
|
Andreas Kohlbecker
|
$render_array = array();
|
944 |
|
|
|
945 |
|
|
$render_array['#theme'] = 'item_list';
|
946 |
|
|
$render_array['#type'] = 'ul';
|
947 |
|
|
$render_array['#attributes'] = array(
|
948 |
|
|
'id' => 'classification-breadcrumbs',
|
949 |
|
|
'class' => 'breadcrumbs inline',
|
950 |
|
|
);
|
951 |
|
|
|
952 |
|
|
$items = array();
|
953 |
|
|
|
954 |
38da4e54
|
Andreas Kohlbecker
|
$parent_taxon_nodes = null;
|
955 |
|
|
if($taxon_uuid){
|
956 |
|
|
$parent_taxon_nodes = cdm_ws_taxonomy_pathFromRoot($taxon_uuid);
|
957 |
|
|
}
|
958 |
f9a3d0f6
|
Andreas Kohlbecker
|
|
959 |
38da4e54
|
Andreas Kohlbecker
|
$classifications = cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY);
|
960 |
|
|
// find current classification in list
|
961 |
|
|
$classification = null;
|
962 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
963 |
|
|
foreach ($classifications as $classification){
|
964 |
|
|
if($classification->uuid == $current_classification_uuid){
|
965 |
|
|
break;
|
966 |
b0adfd32
|
Andreas Kohlbecker
|
}
|
967 |
38da4e54
|
Andreas Kohlbecker
|
}
|
968 |
b0adfd32
|
Andreas Kohlbecker
|
|
969 |
38da4e54
|
Andreas Kohlbecker
|
$node_name = '';
|
970 |
|
|
if(count($classifications) > 1 ){
|
971 |
|
|
// need to add the current classification as first label
|
972 |
0af3ce28
|
Andreas Kohlbecker
|
|
973 |
|
|
$label = $classification->titleCache;
|
974 |
|
|
if(strlen($label) > 20){
|
975 |
|
|
$label = substr($label, 0, strpos($label, ' ', 15)) . '...';
|
976 |
|
|
}
|
977 |
|
|
$node_name = font_awesome_icon_markup('fa-th-list') . ' ' . l($label, '#', array(
|
978 |
|
|
'attributes' => array(
|
979 |
|
|
'class' => 'taxonomic-children-button classification-chooser',
|
980 |
|
|
'data-destination-uri' => drupal_get_destination(),
|
981 |
|
|
'data-cdm-align-with' => array('prev')
|
982 |
|
|
),
|
983 |
|
|
'html' => true
|
984 |
|
|
));
|
985 |
f9a3d0f6
|
Andreas Kohlbecker
|
}
|
986 |
b0adfd32
|
Andreas Kohlbecker
|
|
987 |
38da4e54
|
Andreas Kohlbecker
|
$rank_limit_uuid = variable_get(TAXONTREE_RANKLIMIT, TAXONTREE_RANKLIMIT_DEFAULT);
|
988 |
0af3ce28
|
Andreas Kohlbecker
|
|
989 |
|
|
$rank_separator = '<span> '
|
990 |
38da4e54
|
Andreas Kohlbecker
|
. font_awesome_icon_markup('fa-chevron-right')
|
991 |
|
|
. ' </span>';
|
992 |
0af3ce28
|
Andreas Kohlbecker
|
$more_children_icon = font_awesome_icon_markup('fa-sitemap fa-rotate-270');
|
993 |
38da4e54
|
Andreas Kohlbecker
|
|
994 |
0af3ce28
|
Andreas Kohlbecker
|
$items[] = $node_name;
|
995 |
38da4e54
|
Andreas Kohlbecker
|
|
996 |
0af3ce28
|
Andreas Kohlbecker
|
$more_children_for = null;
|
997 |
e3235962
|
Andreas Kohlbecker
|
if($parent_taxon_nodes){
|
998 |
0af3ce28
|
Andreas Kohlbecker
|
foreach ($parent_taxon_nodes as $node) {
|
999 |
38da4e54
|
Andreas Kohlbecker
|
|
1000 |
|
|
$is_first_item = count($items) == 0;
|
1001 |
0af3ce28
|
Andreas Kohlbecker
|
$is_last_item = count($items) == count($parent_taxon_nodes);
|
1002 |
38da4e54
|
Andreas Kohlbecker
|
$node_name = cdm_dataportal_shortname_of($node);
|
1003 |
|
|
$path = path_to_taxon($node->taxonUuid);
|
1004 |
|
|
|
1005 |
0af3ce28
|
Andreas Kohlbecker
|
if($node->taxonomicChildrenCount > 0) {
|
1006 |
|
|
$more_children_for = $node->taxonUuid;
|
1007 |
|
|
} else {
|
1008 |
|
|
$more_children_for = null;
|
1009 |
38da4e54
|
Andreas Kohlbecker
|
}
|
1010 |
|
|
|
1011 |
0af3ce28
|
Andreas Kohlbecker
|
// 'fa-sitemap'
|
1012 |
|
|
|
1013 |
38da4e54
|
Andreas Kohlbecker
|
$items[] =
|
1014 |
0af3ce28
|
Andreas Kohlbecker
|
($is_first_item ? '' : ' ')
|
1015 |
|
|
. $rank_separator
|
1016 |
|
|
. l(
|
1017 |
|
|
$node_name,
|
1018 |
|
|
$path,
|
1019 |
|
|
array(
|
1020 |
|
|
'attributes' => array(
|
1021 |
|
|
'class' => array('taxonomic-children-button'),
|
1022 |
|
|
'data-cdm-taxon-uuid' => array($node->taxonUuid),
|
1023 |
|
|
'data-cdm-classification-mode' => array('siblings'),
|
1024 |
|
|
'data-cdm-align-with' => array('prev')
|
1025 |
|
|
)
|
1026 |
|
|
)
|
1027 |
|
|
);
|
1028 |
|
|
}
|
1029 |
38da4e54
|
Andreas Kohlbecker
|
}
|
1030 |
0af3ce28
|
Andreas Kohlbecker
|
|
1031 |
|
|
// add more button to the end
|
1032 |
|
|
if(!$parent_taxon_nodes) {
|
1033 |
|
|
// not taxon focused yet, adding button to make the root nodes available
|
1034 |
|
|
$items[] = '<span class="taxonomic-children-button" data-classification-uuid="' . $current_classification_uuid
|
1035 |
|
|
. '" data-rank-limit-uuid="' . $rank_limit_uuid . '" > '
|
1036 |
|
|
. $more_children_icon
|
1037 |
|
|
. ' </span>';
|
1038 |
|
|
} else if($more_children_for){
|
1039 |
|
|
// last parent item has child taxon nodes
|
1040 |
|
|
$items[] = ' <span class="taxonomic-children-button" data-cdm-taxon-uuid="' .$more_children_for
|
1041 |
|
|
. '" data-cdm-classification-mode="children" >'
|
1042 |
|
|
. $more_children_icon
|
1043 |
|
|
. ' </span>';
|
1044 |
|
|
|
1045 |
e3235962
|
Andreas Kohlbecker
|
}
|
1046 |
b0adfd32
|
Andreas Kohlbecker
|
|
1047 |
0af3ce28
|
Andreas Kohlbecker
|
|
1048 |
|
|
|
1049 |
f9a3d0f6
|
Andreas Kohlbecker
|
$render_array['#items'] = $items;
|
1050 |
|
|
|
1051 |
|
|
return $render_array;
|
1052 |
|
|
|
1053 |
|
|
}
|