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