Revision eaf50304
Added by Alexander Oppermann about 11 years ago
7.x/modules/cdm_dataportal/cdm_csv_export/cdm_csv_export.module | ||
---|---|---|
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
|
22 |
|
|
23 |
define('CDM_WS_TERM', 'term/$0'); |
|
24 |
define('CDM_CSV_FEATURETREE_UUID', 'cdm_csv_featuretree_uuid'); |
|
25 |
|
|
26 |
|
|
27 |
|
|
22 | 28 |
/** |
23 | 29 |
* |
24 | 30 |
* @param unknown $path |
... | ... | |
104 | 110 |
); |
105 | 111 |
|
106 | 112 |
// ---- LAYOUT PER FEATURE ---- // |
107 |
$feature_tree = get_profile_featureTree();
|
|
113 |
$feature_tree = get_csv_featureTree();
|
|
108 | 114 |
if (isset($feature_tree->root->children)) { |
109 | 115 |
foreach ($feature_tree->root->children as $featureNode) { |
110 | 116 |
if (isset($featureNode->feature)) { |
... | ... | |
152 | 158 |
|
153 | 159 |
|
154 | 160 |
|
155 |
define('CDM_WS_TERM', 'term/$0'); |
|
161 |
|
|
156 | 162 |
$term = cdm_ws_get(CDM_WS_TERM, $country); |
157 | 163 |
$cdmRepresentationTitleCache = cdm_term_representation($term); |
158 | 164 |
if($country != null){ |
... | ... | |
213 | 219 |
} |
214 | 220 |
|
215 | 221 |
/** |
216 |
* Generate the HTML form for the CSV Export Settings. |
|
222 |
* Generates the HTML form for the CSV Export Settings.
|
|
217 | 223 |
*/ |
218 | 224 |
function cdm_csv_export_admin() { |
219 | 225 |
|
... | ... | |
263 | 269 |
); |
264 | 270 |
|
265 | 271 |
// ---- FEATURE TREE ---- // |
266 |
$form['taxon_profile'] = array(
|
|
272 |
$form['feature_trees'] = array(
|
|
267 | 273 |
'#type' => 'fieldset', |
268 | 274 |
'#title' => t('Features'), |
269 | 275 |
'#collapsible' => TRUE, |
... | ... | |
274 | 280 |
will render at the taxon profile page."), |
275 | 281 |
); |
276 | 282 |
|
277 |
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
|
278 |
$form['taxon_profile']['feature_trees'][CDM_PROFILE_FEATURETREE_UUID] = array(
|
|
283 |
$featureTrees = get_csv_featureTree_as_options(TRUE);
|
|
284 |
$form['feature_trees'][CDM_CSV_FEATURETREE_UUID] = array(
|
|
279 | 285 |
'#type' => 'radios', |
280 |
'#title' => t('Taxon profile sections') . ':',
|
|
281 |
'#default_value' => variable_get(CDM_PROFILE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE),
|
|
286 |
'#title' => t('CSV Export Feature Tree sections') . ':',
|
|
287 |
'#default_value' => variable_get(CDM_CSV_FEATURETREE_UUID, NULL),
|
|
282 | 288 |
'#options' => $featureTrees['options'], |
283 |
// Comment @WA: because #options are sanitized in D7, it would |
|
284 |
// strip html like <fieldset>, so we put the fieldset in a suffix. |
|
285 | 289 |
'#field_suffix' => $featureTrees['treeRepresentations'], |
286 |
'#description' => t('Select the Feature Tree to be displayed at the taxon |
|
287 |
profile. Click "Show Details" to see the Feature Tree elements.' |
|
288 |
), |
|
289 | 290 |
); |
290 |
|
|
291 | 291 |
return system_settings_form($form); |
292 | 292 |
} |
293 |
|
|
294 |
/** |
|
295 |
* Returns the chosen FeatureTree for the CSV Export Module. |
|
296 |
* |
|
297 |
* The returned CSV FeatureTree, has been set in the |
|
298 |
* CSV Export Module settings (CDM CSV EXPORT -> FEATURES). |
|
299 |
* If the chosen FeatureTree is not found in the database, |
|
300 |
* the standard feature tree (UUID_DEFAULT_FEATURETREE) will be returned. |
|
301 |
* |
|
302 |
* @return mixed |
|
303 |
* A cdm FeatureTree object. |
|
304 |
*/ |
|
305 |
|
|
306 |
function get_csv_featureTree() { |
|
307 |
static $csv_featureTree; |
|
308 |
|
|
309 |
if($csv_featureTree == NULL) { |
|
310 |
$csv_featureTree = cdm_ws_get( |
|
311 |
CDM_WS_FEATURETREE, |
|
312 |
variable_get(CDM_CSV_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE) |
|
313 |
); |
|
314 |
if (!$csv_featureTree) { |
|
315 |
$csv_featureTree = cdm_ws_get(CDM_WS_FEATURETREE, UUID_DEFAULT_FEATURETREE); |
|
316 |
} |
|
317 |
} |
|
318 |
return $csv_featureTree; |
|
319 |
} |
|
320 |
|
|
321 |
/** |
|
322 |
* Returns an array with all available Feature |
|
323 |
* Trees and the representations of the selected |
|
324 |
* Feature Tree as a detail view. |
|
325 |
* |
|
326 |
* @param string $add_default_feature_tree |
|
327 |
* @return multitype:Ambigous <NULL, string> multitype:NULL |
|
328 |
*/ |
|
329 |
|
|
330 |
function get_csv_featureTree_as_options($add_default_feature_tree = FALSE) { |
|
331 |
$feature_trees = array(); |
|
332 |
|
|
333 |
// Set tree that contains all features. |
|
334 |
if ($add_default_feature_tree) { |
|
335 |
$feature_trees[UUID_DEFAULT_FEATURETREE] = t('Default Featuretree (contains all features)'); |
|
336 |
} |
|
337 |
|
|
338 |
// Get features from database. |
|
339 |
$persisted_trees = cdm_ws_get(CDM_WS_FEATURETREES); |
|
340 |
$tree_representation = NULL; |
|
341 |
if (is_array($persisted_trees)) { |
|
342 |
|
|
343 |
foreach ($persisted_trees as $featureTree) { |
|
344 |
// Do not add the DEFAULT_FEATURETREE again, |
|
345 |
if ($featureTree->uuid == UUID_DEFAULT_FEATURETREE) { |
|
346 |
continue; |
|
347 |
} |
|
348 |
$feature_trees[$featureTree->uuid] = $featureTree->titleCache; |
|
349 |
} |
|
350 |
} |
|
351 |
//Feature Tree Details |
|
352 |
$selected_feature_tree = get_csv_featureTree(); |
|
353 |
// $tree_representation = $selected_feature_tree->titleCache; |
|
354 |
$tree_representation = ''; |
|
355 |
if (is_array($selected_feature_tree->root->children) && count($selected_feature_tree->root->children) > 0) { |
|
356 |
|
|
357 |
// Render the hierarchic tree structure. |
|
358 |
$treeDetails = '<div class="featuretree_structure">' |
|
359 |
. theme('FeatureTree_hierarchy', array('FeatureTreeUuid' => $selected_feature_tree->uuid)) |
|
360 |
. '</div>'; |
|
361 |
|
|
362 |
$form = array(); |
|
363 |
$form['featureTree-' . $selected_feature_tree->uuid] = array( |
|
364 |
'#type' => 'fieldset', |
|
365 |
'#title' => 'Show details', |
|
366 |
'#attributes' => array('class' => array('collapsible collapsed')), |
|
367 |
); |
|
368 |
$form['featureTree-' . $selected_feature_tree->uuid]['details'] = array( |
|
369 |
'#markup' => $treeDetails, |
|
370 |
); |
|
371 |
$tree_representation .= drupal_render($form); |
|
372 |
} |
|
373 |
return array('options' => $feature_trees, 'treeRepresentations' => $tree_representation); |
|
374 |
} |
Also available in: Unified diff
*Added an own FeatureTree variable for the CSV plugin so that this feature tree can be used independently from the rest of the dataportal