Revision 1e87f89f
Added by Andreas Kohlbecker about 4 years ago
modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
115 | 115 |
array($taxon->uuid, 'associatedFieldUnits'), |
116 | 116 |
$by_associatedtaxon_query . '&pageSize=' . variable_get('cdm_dataportal_compressed_specimen_derivate_table_page_size') |
117 | 117 |
); |
118 |
|
|
118 | 119 |
if (isset($pager_field_units->records[0])) { |
119 | 120 |
$field_unit_uuids = array(); |
120 | 121 |
foreach ($pager_field_units->records as $field_unit) { |
121 | 122 |
$field_unit_uuids[] = $field_unit->uuid; |
122 | 123 |
} |
123 | 124 |
} |
124 |
// get icon images |
|
125 |
$expand_icon = font_awesome_icon_markup( |
|
126 |
'fa-plus-square-o', |
|
127 |
array( |
|
128 |
'alt'=>'Show details', |
|
129 |
'class' => array('expand_icon') |
|
130 |
) |
|
131 |
); |
|
132 |
$collapse_icon = font_awesome_icon_markup( |
|
133 |
'fa-minus-square-o', |
|
134 |
array( |
|
135 |
'alt'=>'Show details', |
|
136 |
'class' => array('collapse_icon') |
|
137 |
) |
|
138 |
); |
|
139 |
$detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>'; |
|
140 |
$checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>'; |
|
141 |
$sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>'; |
|
142 |
$character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>'; |
|
143 |
if (isset($pagerFieldUnits->records[0])) { |
|
144 |
$rowcount = 0; |
|
145 |
foreach ($field_unit_uuids as $field_unit_uuid) { |
|
146 |
//get derivate hierarchy for the FieldUnit |
|
147 |
$derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy')); |
|
148 |
if($derivateHierarchy){ |
|
149 |
//summary row |
|
150 |
$rows[] = array( |
|
151 |
'data' => array( |
|
152 |
array( |
|
153 |
'data' => $expand_icon . $collapse_icon, |
|
154 |
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column') |
|
155 |
), |
|
156 |
array( |
|
157 |
'data' => $derivateHierarchy->country, |
|
158 |
'class' => array('summary_row_cell') |
|
159 |
), |
|
160 |
array( |
|
161 |
'data' => $derivateHierarchy->date, |
|
162 |
'class' => array('summary_row_cell') |
|
163 |
), |
|
164 |
array( |
|
165 |
'data' => $derivateHierarchy->collection, |
|
166 |
'class' => array('summary_row_cell') |
|
167 |
), |
|
168 |
array( |
|
169 |
'data' => $derivateHierarchy->herbarium, |
|
170 |
'class' => array('summary_row_cell') |
|
171 |
), |
|
172 |
array( |
|
173 |
'data' => $derivateHierarchy->hasType? $checked_box_icon:"", |
|
174 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
175 |
), |
|
176 |
array( |
|
177 |
'data' => $derivateHierarchy->hasSpecimenScan? $checked_box_icon:"", |
|
178 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
179 |
), |
|
180 |
array( |
|
181 |
'data' => ($derivateHierarchy->hasDna? $sequence_icon :"")." " |
|
182 |
.($derivateHierarchy->hasDetailImage?$detail_image_icon:"")." " |
|
183 |
.($derivateHierarchy->hasCharacterData?$character_data_icon:""), |
|
184 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
185 |
) |
|
186 |
), |
|
187 |
'id' => ('derivate_summary' . $rowcount), // summary row id |
|
188 |
'class' => array('summary_row'), |
|
189 |
); |
|
190 | 125 |
|
191 |
//assemble field unit details |
|
192 |
$detail_html = ""; |
|
193 |
// - citation |
|
194 |
if ($derivateHierarchy->citation) { |
|
195 |
$detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>"; |
|
196 |
} |
|
197 |
//assemble specimen details |
|
198 |
if($derivateHierarchy->preservedSpecimenDTOs){ |
|
199 |
foreach($derivateHierarchy->preservedSpecimenDTOs as $preservedSpecimenDTO) { |
|
200 |
$detail_html .= "<br>"; |
|
201 |
$detail_html .= render_cdm_specimen_page($preservedSpecimenDTO); |
|
202 |
} |
|
203 |
} |
|
204 |
$detail_html .= "<br>"; |
|
205 |
//detail row resp. one BIG detail cell |
|
206 |
$rows[] = array( |
|
207 |
'data' => array( |
|
208 |
array( |
|
209 |
'data' => "", //empty first column |
|
210 |
'class' => array('expand_column') |
|
211 |
), |
|
212 |
array( |
|
213 |
'data' => $detail_html, |
|
214 |
'colspan' => 7, |
|
215 |
), |
|
216 |
), |
|
217 |
'id' => ('derivate_details' . $rowcount),//details row ID |
|
218 |
'class' => array('detail_row'), |
|
219 |
); |
|
220 |
$rowcount++; |
|
221 |
} |
|
222 |
} |
|
126 |
$render_array['derivate_hierarchy_table'] = render_derivate_hierarchy_table($field_unit_uuids); |
|
223 | 127 |
|
224 |
$tableId = "derivate_hierarchy_table"; |
|
225 |
$derivateHierarchyTable = array( |
|
226 |
"#theme" => "table", |
|
227 |
"#weight" => 2, |
|
228 |
"#header" => array( |
|
229 |
array( |
|
230 |
'data' => "", |
|
231 |
'class' => array('expand_column') |
|
232 |
), |
|
233 |
"Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"), |
|
234 |
"#rows" => $rows, |
|
235 |
"#attributes" => array( |
|
236 |
"id" => $tableId, |
|
237 |
"border" => 2 |
|
238 |
) |
|
239 |
); |
|
240 |
|
|
241 |
//add toggle functionality to derivate hierarchy table |
|
242 |
drupal_add_js_rowToggle("#".$tableId); |
|
243 |
|
|
244 |
$render_array['derivate_hierarchy_table'] = $derivateHierarchyTable; |
|
245 |
$render_array['pager'] = markup_to_render_array( |
|
246 |
theme('cdm_pager', array( |
|
247 |
'pager' => $pager_field_units, |
|
248 |
'path' => $_REQUEST['q'], |
|
249 |
'parameters' => $_REQUEST |
|
250 |
)), |
|
251 |
10 // weight |
|
252 |
); |
|
253 |
} |
|
128 |
$render_array['pager'] = markup_to_render_array( |
|
129 |
theme('cdm_pager', array( |
|
130 |
'pager' => $pager_field_units, |
|
131 |
'path' => $_REQUEST['q'], |
|
132 |
'parameters' => $_REQUEST |
|
133 |
)), |
|
134 |
10 // weight |
|
135 |
); |
|
254 | 136 |
} |
255 | 137 |
else{ |
256 | 138 |
//BOTTOM-UP-SPECIMEN-TABLE |
... | ... | |
258 | 140 |
$specimen_table = array( |
259 | 141 |
'#theme' => 'table', |
260 | 142 |
'#weight' => 2, |
261 |
// prefix attributes and rows with '#' to let it pass to the theme function, |
|
143 |
// prefix attributes and rows with '#' to let it pass toF the theme function,
|
|
262 | 144 |
// otherwise it is handled as child render array |
263 | 145 |
'#attributes' => array('class' => 'specimens'), |
264 | 146 |
'#rows' => array(), |
... | ... | |
358 | 240 |
RenderHints::popFromRenderStack(); |
359 | 241 |
return $render_array; |
360 | 242 |
} |
361 |
|
|
243 |
|
|
244 |
/** |
|
245 |
* Creates the drupal render array for the derivate_hierarchy_table |
|
246 |
* |
|
247 |
* @param $field_unit_uuids array |
|
248 |
* An array of uuids for cdm FieldUnit entities. |
|
249 |
* |
|
250 |
* @return array |
|
251 |
* A drupal render array for a table |
|
252 |
* |
|
253 |
* @ingroup compose |
|
254 |
*/ |
|
255 |
function compose_derivate_hierarchy_table($field_unit_uuids) |
|
256 |
{ |
|
257 |
// get icon images |
|
258 |
$expand_icon = font_awesome_icon_markup( |
|
259 |
'fa-plus-square-o', |
|
260 |
array( |
|
261 |
'alt' => 'Show details', |
|
262 |
'class' => array('expand_icon') |
|
263 |
) |
|
264 |
); |
|
265 |
$collapse_icon = font_awesome_icon_markup( |
|
266 |
'fa-minus-square-o', |
|
267 |
array( |
|
268 |
'alt' => 'Show details', |
|
269 |
'class' => array('collapse_icon') |
|
270 |
) |
|
271 |
); |
|
272 |
$detail_image_icon = '<img title="Detail Image" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/detail_image_derivate-16x16-32.png' . '"/>'; |
|
273 |
$checked_box_icon = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/step_done.gif' . '"/>'; |
|
274 |
$sequence_icon = '<img title="Molecular Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/sequence_derivate-16x16-32.png' . '"/>'; |
|
275 |
$character_data_icon = '<img title="Character Data" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/character_data_derivate-16x16-32.png' . '"/>'; |
|
276 |
|
|
277 |
$rowcount = 0; |
|
278 |
$rows = array(); |
|
279 |
|
|
280 |
foreach ($field_unit_uuids as $field_unit_uuid) { |
|
281 |
|
|
282 |
//get derivate hierarchy for the FieldUnit |
|
283 |
$derivateHierarchy = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, array($field_unit_uuid, 'derivateHierarchy')); |
|
284 |
if ($derivateHierarchy) { |
|
285 |
//summary row |
|
286 |
$rows[] = array( |
|
287 |
'data' => array( |
|
288 |
array( |
|
289 |
'data' => $expand_icon . $collapse_icon, |
|
290 |
'class' => array('summary_row_cell', 'summary_row_icon', 'expand_column') |
|
291 |
), |
|
292 |
array( |
|
293 |
'data' => $derivateHierarchy->country, |
|
294 |
'class' => array('summary_row_cell') |
|
295 |
), |
|
296 |
array( |
|
297 |
'data' => $derivateHierarchy->date, |
|
298 |
'class' => array('summary_row_cell') |
|
299 |
), |
|
300 |
array( |
|
301 |
'data' => $derivateHierarchy->collection, |
|
302 |
'class' => array('summary_row_cell') |
|
303 |
), |
|
304 |
array( |
|
305 |
'data' => $derivateHierarchy->herbarium, |
|
306 |
'class' => array('summary_row_cell') |
|
307 |
), |
|
308 |
array( |
|
309 |
'data' => $derivateHierarchy->hasType ? $checked_box_icon : "", |
|
310 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
311 |
), |
|
312 |
array( |
|
313 |
'data' => $derivateHierarchy->hasSpecimenScan ? $checked_box_icon : "", |
|
314 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
315 |
), |
|
316 |
array( |
|
317 |
'data' => ($derivateHierarchy->hasDna ? $sequence_icon : "") . " " |
|
318 |
. ($derivateHierarchy->hasDetailImage ? $detail_image_icon : "") . " " |
|
319 |
. ($derivateHierarchy->hasCharacterData ? $character_data_icon : ""), |
|
320 |
'class' => array('summary_row_cell', 'summary_row_icon') |
|
321 |
) |
|
322 |
), |
|
323 |
'id' => ('derivate_summary' . $rowcount), // summary row id |
|
324 |
'class' => array('summary_row'), |
|
325 |
); |
|
326 |
|
|
327 |
//assemble field unit details |
|
328 |
$detail_html = ""; |
|
329 |
// - citation |
|
330 |
if ($derivateHierarchy->citation) { |
|
331 |
$detail_html .= create_label("Citation") . $derivateHierarchy->citation . "<br>"; |
|
332 |
} |
|
333 |
//assemble specimen details |
|
334 |
if ($derivateHierarchy->preservedSpecimenDTOs) { |
|
335 |
foreach ($derivateHierarchy->preservedSpecimenDTOs as $preservedSpecimenDTO) { |
|
336 |
$detail_html .= "<br>"; |
|
337 |
$detail_html .= render_cdm_specimen_page($preservedSpecimenDTO); |
|
338 |
} |
|
339 |
} |
|
340 |
$detail_html .= "<br>"; |
|
341 |
//detail row resp. one BIG detail cell |
|
342 |
$rows[] = array( |
|
343 |
'data' => array( |
|
344 |
array( |
|
345 |
'data' => "", //empty first column |
|
346 |
'class' => array('expand_column') |
|
347 |
), |
|
348 |
array( |
|
349 |
'data' => $detail_html, |
|
350 |
'colspan' => 7, |
|
351 |
), |
|
352 |
), |
|
353 |
'id' => ('derivate_details' . $rowcount),//details row ID |
|
354 |
'class' => array('detail_row'), |
|
355 |
); |
|
356 |
$rowcount++; |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
$tableId = "derivate_hierarchy_table"; |
|
361 |
$derivateHierarchyTable = array( |
|
362 |
"#theme" => "table", |
|
363 |
"#weight" => 2, |
|
364 |
"#header" => array( |
|
365 |
array( |
|
366 |
'data' => "", |
|
367 |
'class' => array('expand_column') |
|
368 |
), |
|
369 |
"Country", "Date", "Collector + collecting number", "Herbaria", "Type", "Scan", "Derivatives"), |
|
370 |
"#rows" => $rows, |
|
371 |
"#attributes" => array( |
|
372 |
"id" => $tableId, |
|
373 |
"border" => 2 |
|
374 |
) |
|
375 |
); |
|
376 |
|
|
377 |
//add toggle functionality to derivate hierarchy table |
|
378 |
drupal_add_js_rowToggle("#" . $tableId); |
|
379 |
|
|
380 |
return $derivateHierarchyTable; |
|
381 |
} |
|
382 |
|
|
362 | 383 |
function create_html_link($link, $openInExternalWindow=false){ |
363 | 384 |
$html = ""; |
364 | 385 |
if($link->uri && $link->uri!=""){ |
Also available in: Unified diff
ref #7495 extracting derivate_hierarchy_table creating as compose method