Revision 589a392b
Added by Alexander Oppermann over 10 years ago
7.x/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module | ||
---|---|---|
278 | 278 |
will render at the taxon profile page."), |
279 | 279 |
); |
280 | 280 |
|
281 |
$featureTrees = get_csv_featureTree_as_options(TRUE);
|
|
281 |
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
|
282 | 282 |
$form['feature_trees'][CDM_CSV_FEATURETREE_UUID] = array( |
283 |
'#type' => 'radios', |
|
284 |
'#title' => t('CSV Export Feature Tree sections') . ':', |
|
285 |
'#default_value' => variable_get(CDM_CSV_FEATURETREE_UUID, NULL), |
|
286 |
'#options' => $featureTrees['options'], |
|
287 |
'#field_suffix' => $featureTrees['treeRepresentations'], |
|
283 |
'#type' => 'radios', |
|
284 |
'#title' => t('CSV Export Feature Tree sections') . ':', |
|
285 |
'#default_value' => variable_get(CDM_CSV_FEATURETREE_UUID, NULL), |
|
286 |
'#options' => $featureTrees['options'], |
|
287 |
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'), |
|
288 |
'#options_suffixes' => $featureTrees['treeRepresentations'], |
|
289 |
'#description' => t('Select the Feature Tree to be displayed at the taxon |
|
290 |
profile. Click "Show Details" to see the Feature Tree elements.' |
|
291 |
), |
|
288 | 292 |
); |
289 | 293 |
return system_settings_form($form); |
290 | 294 |
} |
... | ... | |
314 | 318 |
} |
315 | 319 |
} |
316 | 320 |
return $csv_featureTree; |
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Returns an array with all available Feature |
|
321 |
* Trees and the representations of the selected |
|
322 |
* Feature Tree as a detail view. |
|
323 |
* |
|
324 |
* @param boolean $add_default_feature_free |
|
325 |
* @return array |
|
326 |
* associative array with following keys: |
|
327 |
* -options: Returns an array with all available Feature Trees |
|
328 |
* -treeRepresentations: Returns representations of the selected Feature Tree as a detail view |
|
329 |
* |
|
330 |
*/ |
|
331 |
|
|
332 |
function get_csv_featureTree_as_options($add_default_feature_tree = FALSE) { |
|
333 |
$feature_trees = array(); |
|
334 |
|
|
335 |
// Set tree that contains all features. |
|
336 |
if ($add_default_feature_tree) { |
|
337 |
$feature_trees[UUID_DEFAULT_FEATURETREE] = t('Default Featuretree (contains all features)'); |
|
338 |
} |
|
339 |
|
|
340 |
// Get features from database. |
|
341 |
$persisted_trees = cdm_ws_get(CDM_WS_FEATURETREES); |
|
342 |
$tree_representation = NULL; |
|
343 |
if (is_array($persisted_trees)) { |
|
344 |
|
|
345 |
foreach ($persisted_trees as $featureTree) { |
|
346 |
// Do not add the DEFAULT_FEATURETREE again, |
|
347 |
if ($featureTree->uuid == UUID_DEFAULT_FEATURETREE) { |
|
348 |
continue; |
|
349 |
} |
|
350 |
$feature_trees[$featureTree->uuid] = $featureTree->titleCache; |
|
351 |
} |
|
352 |
} |
|
353 |
//Feature Tree Details |
|
354 |
$selected_feature_tree = get_csv_featureTree(); |
|
355 |
// $tree_representation = $selected_feature_tree->titleCache; |
|
356 |
$tree_representation = ''; |
|
357 |
if (is_array($selected_feature_tree->root->children) && count($selected_feature_tree->root->children) > 0) { |
|
358 |
|
|
359 |
// Render the hierarchic tree structure. |
|
360 |
$treeDetails = '<div class="featuretree_structure">' |
|
361 |
. theme('FeatureTree_hierarchy', array('FeatureTreeUuid' => $selected_feature_tree->uuid)) |
|
362 |
. '</div>'; |
|
363 |
|
|
364 |
$form = array(); |
|
365 |
$form['featureTree-' . $selected_feature_tree->uuid] = array( |
|
366 |
'#type' => 'fieldset', |
|
367 |
'#title' => 'Show details', |
|
368 |
'#attributes' => array('class' => array('collapsible collapsed')), |
|
369 |
); |
|
370 |
$form['featureTree-' . $selected_feature_tree->uuid]['details'] = array( |
|
371 |
'#markup' => $treeDetails, |
|
372 |
); |
|
373 |
$tree_representation .= drupal_render($form); |
|
374 |
} |
|
375 |
return array('options' => $feature_trees, 'treeRepresentations' => $tree_representation); |
|
376 |
} |
|
321 |
} |
Also available in: Unified diff
cdm_csv_export.module