Revision 75b05e16
Added by Francisco Revilla almost 14 years ago
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module | ||
---|---|---|
17 | 17 |
*/ |
18 | 18 |
function cdm_taxontree_menu($may_cache) { |
19 | 19 |
|
20 |
$items = array();
|
|
21 |
if ($may_cache) {
|
|
22 |
|
|
23 |
$items[] = array(
|
|
20 |
$items = array();
|
|
21 |
if ($may_cache) {
|
|
22 |
|
|
23 |
$items[] = array(
|
|
24 | 24 |
'path' => 'cdm_taxontree/set', |
25 | 25 |
'callback' => 'cdm_taxontree_set', |
26 | 26 |
'access' => true, |
27 | 27 |
'type' => MENU_CALLBACK, |
28 |
);
|
|
29 |
|
|
30 |
$items[] = array(
|
|
31 |
|
|
28 |
);
|
|
29 |
|
|
30 |
$items[] = array(
|
|
31 |
|
|
32 | 32 |
'path' => 'cdm_taxontree/filter', |
33 | 33 |
'callback' => 'cdm_taxontree_view_filter', |
34 | 34 |
'access' => true, |
35 | 35 |
'type' => MENU_CALLBACK, |
36 |
);
|
|
37 |
|
|
38 |
$items[] = array(
|
|
36 |
);
|
|
37 |
|
|
38 |
$items[] = array(
|
|
39 | 39 |
'path' => 'cdm_taxontree/taxonomy/children', |
40 | 40 |
'callback' => 'cdm_taxontree_taxonomy_children', |
41 | 41 |
'access' => true, |
42 | 42 |
'type' => MENU_CALLBACK, |
43 |
);
|
|
44 |
|
|
45 |
} else {
|
|
46 |
|
|
47 |
// DISABLED since the taxontree-widged is no longer being used!!! |
|
48 |
// |
|
49 |
// if(variable_get('cdm_taxontree_cache', 0)){ |
|
50 |
// $items[] = array('path' => 'admin/settings/cdm_dataportal/clear_cache', |
|
51 |
// 'title' => t('Empty CDM Taxontree Cache'), |
|
52 |
// 'callback' => 'cdm_taxontree_cache_clear', |
|
53 |
// 'access' => user_access('administer cdm_dataportal'), |
|
54 |
// 'weight' => 2, |
|
55 |
// 'type' => MENU_NORMAL_ITEM, |
|
56 |
// ); |
|
57 |
// } |
|
58 |
|
|
59 |
}
|
|
60 |
return $items;
|
|
43 |
);
|
|
44 |
|
|
45 |
} else {
|
|
46 |
|
|
47 |
// DISABLED since the taxontree-widged is no longer being used!!!
|
|
48 |
//
|
|
49 |
// if(variable_get('cdm_taxontree_cache', 0)){
|
|
50 |
// $items[] = array('path' => 'admin/settings/cdm_dataportal/clear_cache',
|
|
51 |
// 'title' => t('Empty CDM Taxontree Cache'),
|
|
52 |
// 'callback' => 'cdm_taxontree_cache_clear',
|
|
53 |
// 'access' => user_access('administer cdm_dataportal'),
|
|
54 |
// 'weight' => 2,
|
|
55 |
// 'type' => MENU_NORMAL_ITEM,
|
|
56 |
// );
|
|
57 |
// }
|
|
58 |
|
|
59 |
}
|
|
60 |
return $items;
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
/** |
... | ... | |
67 | 67 |
* @param int $delta |
68 | 68 |
*/ |
69 | 69 |
function cdm_taxontree_block($op='list', $delta=0, $edit = array()) { |
70 |
if ($op == "list") {
|
|
71 |
$block['cdm_tree']["info"] = t('CDM taxon tree');
|
|
72 |
$block['filters']["info"] = t('Active filters');
|
|
70 |
if ($op == "list") {
|
|
71 |
$block['cdm_tree']["info"] = t('CDM taxon tree');
|
|
72 |
$block['filters']["info"] = t('Active filters');
|
|
73 | 73 |
$block[1]["info"] = t('Drupal taxonomy tree'); |
74 |
return $block;
|
|
75 |
}
|
|
76 |
else if ($op == 'view') {
|
|
77 |
switch($delta){
|
|
78 |
case 'cdm_tree':
|
|
79 |
$block['subject'] = t('Classification');
|
|
80 |
$taxonUuid_inFocus = _cdm_get_taxonuuid();
|
|
81 |
$tree = cdm_taxontree_build_tree($taxonUuid_inFocus);
|
|
82 |
$magicbox_enable = variable_get('cdm_taxontree_magicbox_enable', 0);
|
|
83 |
|
|
84 |
if(count(cdm_get_taxontrees_as_options()) > 1){
|
|
85 |
$block['content'] = cdm_taxonomictree_selector();
|
|
86 |
}
|
|
87 |
$block['content'] .= theme('cdm_taxontree_block', $tree, $delta, FALSE, 'cdm_taxontree_node_concept_switch');
|
|
88 |
// java script
|
|
89 |
$verticalSroller = $magicbox_enable ? 'cdm_taxontree_scroller_x' : 'cdm_taxontree_scroller_xy';
|
|
90 |
theme('cdm_taxontree_add_scripts');
|
|
91 |
drupal_add_js('
|
|
74 |
return $block;
|
|
75 |
}
|
|
76 |
else if ($op == 'view') {
|
|
77 |
switch($delta){
|
|
78 |
case 'cdm_tree':
|
|
79 |
$block['subject'] = t('Classification');
|
|
80 |
$taxonUuid_inFocus = _cdm_get_taxonuuid();
|
|
81 |
$tree = cdm_taxontree_build_tree($taxonUuid_inFocus);
|
|
82 |
$magicbox_enable = variable_get('cdm_taxontree_magicbox_enable', 0);
|
|
83 |
|
|
84 |
if(count(cdm_get_taxontrees_as_options()) > 1){
|
|
85 |
$block['content'] = cdm_taxonomictree_selector();
|
|
86 |
}
|
|
87 |
$block['content'] .= theme('cdm_taxontree_block', $tree, $delta, FALSE, 'cdm_taxontree_node_concept_switch');
|
|
88 |
// java script
|
|
89 |
$verticalSroller = $magicbox_enable ? 'cdm_taxontree_scroller_x' : 'cdm_taxontree_scroller_xy';
|
|
90 |
theme('cdm_taxontree_add_scripts');
|
|
91 |
drupal_add_js('
|
|
92 | 92 |
if (Drupal.jsEnabled) { |
93 | 93 |
$(document).ready(function() |
94 | 94 |
{ |
95 | 95 |
$(\'ul.cdm_taxontree\').cdm_taxontree(); |
96 | 96 |
$(\'div.'.$verticalSroller.'\').scrollTo($(\'.focused\'), 400, {over:-3});}); |
97 | 97 |
}', 'inline'); |
98 |
return $block;
|
|
99 |
|
|
100 |
case 'filters':
|
|
101 |
$block['subject'] = t('Active filters');
|
|
102 |
$block['content'] = cdm_taxontree_view_filter('list');
|
|
103 |
return $block;
|
|
104 |
|
|
105 |
case 1:
|
|
106 |
$block['subject'] = t('Taxonomy tree');
|
|
107 |
$term_inFocus = arg(0) == 'taxonomy' && arg(1) == 'term' ? arg(2) : 0;
|
|
108 |
$tree = cdm_taxontree_build_tree($term_inFocus, true, variable_get('cdm_taxontree_block_1_vid', 0));
|
|
109 |
$block['content'] = theme('cdm_taxontree_block', $tree, $delta, FALSE);
|
|
110 |
theme('cdm_taxontree_add_scripts');
|
|
111 |
drupal_add_js('
|
|
98 |
return $block;
|
|
99 |
|
|
100 |
case 'filters':
|
|
101 |
$block['subject'] = t('Active filters');
|
|
102 |
$block['content'] = cdm_taxontree_view_filter('list');
|
|
103 |
return $block;
|
|
104 |
|
|
105 |
case 1:
|
|
106 |
$block['subject'] = t('Taxonomy tree');
|
|
107 |
$term_inFocus = arg(0) == 'taxonomy' && arg(1) == 'term' ? arg(2) : 0;
|
|
108 |
$tree = cdm_taxontree_build_tree($term_inFocus, true, variable_get('cdm_taxontree_block_1_vid', 0));
|
|
109 |
$block['content'] = theme('cdm_taxontree_block', $tree, $delta, FALSE);
|
|
110 |
theme('cdm_taxontree_add_scripts');
|
|
111 |
drupal_add_js('
|
|
112 | 112 |
if (Drupal.jsEnabled) { |
113 | 113 |
$(document).ready(function() |
114 | 114 |
{ |
... | ... | |
116 | 116 |
$(\'div.cdm_taxontree_scroller_x\').scrollTo($(\'.active\'), 400, {over:-3});}); |
117 | 117 |
}', 'inline'); |
118 | 118 |
|
119 |
return $block;
|
|
120 |
}
|
|
121 |
} else if ($op == 'configure') {
|
|
122 |
switch($delta){
|
|
123 |
case 1:
|
|
124 |
$vocs = taxonomy_get_vocabularies();
|
|
125 |
$options = array();
|
|
126 |
foreach($vocs as $voc){
|
|
127 |
$options[$voc->vid] = $voc->name;
|
|
128 |
}
|
|
129 |
$form['vid'] = array(
|
|
119 |
return $block;
|
|
120 |
}
|
|
121 |
} else if ($op == 'configure') {
|
|
122 |
switch($delta){
|
|
123 |
case 1:
|
|
124 |
$vocs = taxonomy_get_vocabularies();
|
|
125 |
$options = array();
|
|
126 |
foreach($vocs as $voc){
|
|
127 |
$options[$voc->vid] = $voc->name;
|
|
128 |
}
|
|
129 |
$form['vid'] = array(
|
|
130 | 130 |
'#type' => 'select', |
131 | 131 |
'#title' => t('Category'), |
132 | 132 |
'#default_value' => variable_get('cdm_taxontree_block_1_vid', 0), |
133 | 133 |
'#options' => $options, |
134 |
);
|
|
135 |
return $form;
|
|
136 |
}
|
|
137 |
} else if ($op == 'save') {
|
|
138 |
switch($delta){
|
|
139 |
case 1:
|
|
140 |
variable_set('cdm_taxontree_block_1_vid', $edit['vid']);
|
|
134 |
);
|
|
135 |
return $form;
|
|
136 |
}
|
|
137 |
} else if ($op == 'save') {
|
|
138 |
switch($delta){
|
|
139 |
case 1:
|
|
140 |
variable_set('cdm_taxontree_block_1_vid', $edit['vid']);
|
|
141 | 141 |
return; |
142 | 142 |
} |
143 | 143 |
} |
... | ... | |
202 | 202 |
} |
203 | 203 |
return l($term->name, $link.$term->tid); |
204 | 204 |
|
205 |
default:
|
|
206 |
$name = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $item['tid']));
|
|
207 |
return $name;
|
|
205 |
default: |
|
206 |
$name = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $item['tid'])); |
|
207 |
return $name; |
|
208 | 208 |
} |
209 | 209 |
} |
210 | 210 |
|
... | ... | |
259 | 259 |
|
260 | 260 |
function cdm_taxontree_set($key, $value){ |
261 | 261 |
|
262 |
if(is_string($key)){
|
|
263 |
$_SESSION['cdm']['taxontree'][$key] = $value;
|
|
264 |
}
|
|
262 |
if(is_string($key)){
|
|
263 |
$_SESSION['cdm']['taxontree'][$key] = $value;
|
|
264 |
}
|
|
265 | 265 |
|
266 |
if($_REQUEST['destination']){
|
|
267 |
$destination = $_REQUEST['destination'];
|
|
268 |
unset($_REQUEST['destination']);
|
|
269 |
drupal_goto($destination);
|
|
270 |
}
|
|
266 |
if($_REQUEST['destination']){
|
|
267 |
$destination = $_REQUEST['destination'];
|
|
268 |
unset($_REQUEST['destination']);
|
|
269 |
drupal_goto($destination);
|
|
270 |
}
|
|
271 | 271 |
} |
272 | 272 |
|
273 | 273 |
|
... | ... | |
278 | 278 |
* @return unknown |
279 | 279 |
*/ |
280 | 280 |
function cdm_taxontree_secRefTitle_for($secUuid){ |
281 |
|
|
282 |
$reference = cdm_api_secref_cache_get($secUuid);
|
|
283 |
if($reference){
|
|
284 |
$cit = $reference->titleCache;
|
|
285 |
} else {
|
|
286 |
$cit = '[no title for:'.$secUuid.']';
|
|
287 |
}
|
|
288 |
return $cit;
|
|
281 |
|
|
282 |
$reference = cdm_api_secref_cache_get($secUuid);
|
|
283 |
if($reference){
|
|
284 |
$cit = $reference->titleCache;
|
|
285 |
} else {
|
|
286 |
$cit = '[no title for:'.$secUuid.']';
|
|
287 |
}
|
|
288 |
return $cit;
|
|
289 | 289 |
} |
290 | 290 |
|
291 | 291 |
|
... | ... | |
297 | 297 |
* @return values (left | right | <empty>) |
298 | 298 |
*/ |
299 | 299 |
function _get_block_region($delta){ |
300 |
global $user, $theme_key;
|
|
301 |
|
|
302 |
$result = db_fetch_array(db_query("SELECT DISTINCT b.region FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (%s) OR r.rid IS NULL) AND b.module = '%s' AND b.delta = '%s'", $theme_key, implode(',', array_keys($user->roles)), 'cdm_taxontree', $delta));
|
|
303 |
return $result['region'];
|
|
300 |
global $user, $theme_key;
|
|
301 |
|
|
302 |
$result = db_fetch_array(db_query("SELECT DISTINCT b.region FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (%s) OR r.rid IS NULL) AND b.module = '%s' AND b.delta = '%s'", $theme_key, implode(',', array_keys($user->roles)), 'cdm_taxontree', $delta));
|
|
303 |
return $result['region'];
|
|
304 | 304 |
} |
305 | 305 |
|
306 | 306 |
/** |
... | ... | |
310 | 310 |
*/ |
311 | 311 |
function _get_compact_mode(){ |
312 | 312 |
|
313 |
if(!isset($_SESSION['cdm']['taxontree']['compact_mode'])){
|
|
314 |
$_SESSION['cdm']['taxontree']['compact_mode'] = 'expanded';
|
|
315 |
}
|
|
316 |
return $_SESSION['cdm']['taxontree']['compact_mode'];
|
|
313 |
if(!isset($_SESSION['cdm']['taxontree']['compact_mode'])){
|
|
314 |
$_SESSION['cdm']['taxontree']['compact_mode'] = 'expanded';
|
|
315 |
}
|
|
316 |
return $_SESSION['cdm']['taxontree']['compact_mode'];
|
|
317 | 317 |
} |
318 | 318 |
|
319 | 319 |
|
... | ... | |
326 | 326 |
* term => cdm tree node |
327 | 327 |
* ------------------------------------ |
328 | 328 |
* tid -> uuid |
329 |
name -> titleCache
|
|
330 |
taggedName
|
|
331 |
secUuid
|
|
332 |
isAccepted
|
|
333 |
taxonomicChildrenCount
|
|
334 |
alternativeConceptRefs
|
|
329 |
name -> titleCache |
|
330 |
taggedName |
|
331 |
secUuid |
|
332 |
isAccepted |
|
333 |
taxonomicChildrenCount |
|
334 |
alternativeConceptRefs |
|
335 | 335 |
* |
336 | 336 |
* @param unknown_type $terms |
337 | 337 |
*/ |
338 | 338 |
function cdm_taxontree_terms2treenodes(&$terms){ |
339 |
foreach($terms as &$term){
|
|
340 |
$term->uuid = $term->tid;
|
|
341 |
$term->titleCache = $term->name;
|
|
342 |
$term->taxonomicChildrenCount = count(taxonomy_get_children($term->tid, $term->vid));
|
|
343 |
}
|
|
344 |
return $terms;
|
|
339 |
foreach($terms as &$term){
|
|
340 |
$term->uuid = $term->tid;
|
|
341 |
$term->titleCache = $term->name;
|
|
342 |
$term->taxonomicChildrenCount = count(taxonomy_get_children($term->tid, $term->vid));
|
|
343 |
}
|
|
344 |
return $terms;
|
|
345 | 345 |
} |
346 | 346 |
|
347 | 347 |
/** |
... | ... | |
352 | 352 |
* @param unknown_type $theme |
353 | 353 |
*/ |
354 | 354 |
function cdm_taxontree_taxonomy_children($tid, $vid, $theme){ |
355 |
$args = func_get_args();
|
|
356 |
$tid = array_shift($args);
|
|
357 |
$vid = array_shift($args);
|
|
358 |
$theme = array_shift($args);
|
|
359 |
|
|
360 |
$children = cdm_taxontree_get_children($tid, $vid);
|
|
361 |
$children = cdm_taxontree_terms2treenodes($children);
|
|
362 |
array_unshift($args, $theme, $children);
|
|
363 |
print call_user_func_array('theme', $args);
|
|
355 |
$args = func_get_args();
|
|
356 |
$tid = array_shift($args);
|
|
357 |
$vid = array_shift($args);
|
|
358 |
$theme = array_shift($args);
|
|
359 |
|
|
360 |
$children = cdm_taxontree_get_children($tid, $vid);
|
|
361 |
$children = cdm_taxontree_terms2treenodes($children);
|
|
362 |
array_unshift($args, $theme, $children);
|
|
363 |
print call_user_func_array('theme', $args);
|
|
364 | 364 |
} |
365 | 365 |
|
366 | 366 |
/** |
... | ... | |
371 | 371 |
* @return unknown |
372 | 372 |
*/ |
373 | 373 |
function cdm_taxontree_get_root($vid = null){ |
374 |
if(is_numeric($vid)){
|
|
375 |
// vid, $parent = 0, $depth = -1, $max_depth = NULL) {
|
|
376 |
$terms = taxonomy_get_tree($vid, 0, -1, 1);
|
|
377 |
return cdm_taxontree_terms2treenodes($terms);
|
|
378 |
} else {
|
|
379 |
return cdm_ws_taxonomy();
|
|
380 |
}
|
|
374 |
if(is_numeric($vid)){
|
|
375 |
// vid, $parent = 0, $depth = -1, $max_depth = NULL) {
|
|
376 |
$terms = taxonomy_get_tree($vid, 0, -1, 1);
|
|
377 |
return cdm_taxontree_terms2treenodes($terms);
|
|
378 |
} else {
|
|
379 |
return cdm_ws_taxonomy();
|
|
380 |
}
|
|
381 | 381 |
} |
382 | 382 |
|
383 | 383 |
/** |
... | ... | |
389 | 389 |
*/ |
390 | 390 |
function cdm_taxontree_get_children($uuid, $vid = null){ |
391 | 391 |
|
392 |
if(is_numeric($vid)){
|
|
393 |
$terms = taxonomy_get_children($uuid, $vid);
|
|
394 |
return cdm_taxontree_terms2treenodes($terms);
|
|
395 |
} else {
|
|
396 |
//FIXME replace $uuid by path of parent $uuids
|
|
397 |
|
|
398 |
return cdm_ws_taxonomy($uuid);
|
|
399 |
}
|
|
392 |
if(is_numeric($vid)){
|
|
393 |
$terms = taxonomy_get_children($uuid, $vid);
|
|
394 |
return cdm_taxontree_terms2treenodes($terms);
|
|
395 |
} else {
|
|
396 |
//FIXME replace $uuid by path of parent $uuids
|
|
397 |
|
|
398 |
return cdm_ws_taxonomy($uuid);
|
|
399 |
}
|
|
400 | 400 |
} |
401 | 401 |
|
402 | 402 |
/** |
... | ... | |
407 | 407 |
*/ |
408 | 408 |
function cdm_taxontree_get_parents($uuid){ |
409 | 409 |
|
410 |
if(!is_uuid($uuid)){
|
|
411 |
// using Drupal taxonomy
|
|
412 |
$terms = taxonomy_get_parents($uuid);
|
|
413 |
array_push($terms, taxonomy_get_term($uuid));
|
|
414 |
$terms = array_reverse($terms);
|
|
415 |
return cdm_taxontree_terms2treenodes($terms);
|
|
416 |
} else {
|
|
417 |
// using cdm
|
|
418 |
$terms = cdm_ws_taxonomy_pathFromRoot($uuid);
|
|
419 |
if(!$terms){
|
|
420 |
return;
|
|
421 |
}
|
|
422 |
$terms = array_reverse($terms);
|
|
423 |
return $terms;
|
|
424 |
}
|
|
410 |
if(!is_uuid($uuid)){
|
|
411 |
// using Drupal taxonomy
|
|
412 |
$terms = taxonomy_get_parents($uuid);
|
|
413 |
array_push($terms, taxonomy_get_term($uuid));
|
|
414 |
$terms = array_reverse($terms);
|
|
415 |
return cdm_taxontree_terms2treenodes($terms);
|
|
416 |
} else {
|
|
417 |
// using cdm
|
|
418 |
$terms = cdm_ws_taxonomy_pathFromRoot($uuid);
|
|
419 |
if(!$terms){
|
|
420 |
return;
|
|
421 |
}
|
|
422 |
$terms = array_reverse($terms);
|
|
423 |
return $terms;
|
|
424 |
}
|
|
425 | 425 |
} |
426 | 426 |
|
427 | 427 |
/** |
... | ... | |
435 | 435 |
* @return unknown |
436 | 436 |
*/ |
437 | 437 |
function cdm_taxontree_build_tree($taxonUuid = null, $hideOtherConcepts = true, $vid = null){ |
438 |
//TODO remove $hideOtherConcepts from method signature
|
|
439 |
|
|
440 |
if(is_null($vid)){
|
|
441 |
|
|
442 |
if($taxonUuid){
|
|
443 |
$taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
|
|
444 |
}
|
|
445 |
|
|
446 |
$compact_tree = cdm_taxontree_filters_active() && _get_compact_mode() != 'expanded';
|
|
447 |
}
|
|
448 |
/* valid compact_modes: 'expanded', 'compact', 'flattened' */
|
|
449 |
|
|
450 |
// get the root level
|
|
451 |
$root_tree = cdm_taxontree_get_root($vid);
|
|
452 |
// if(!$root_tree || !is_array($root_tree)){ |
|
453 |
// return array(); |
|
454 |
// } |
|
455 |
$root_tree = _cdm_resultset2nodelist($root_tree, cdm_taxontree_filters_active());
|
|
456 |
|
|
457 |
|
|
458 |
if(cdm_taxontree_filters_active()){
|
|
459 |
// the paths up to active filters are inactive in the user interface and
|
|
460 |
// thus cannot be browsed by expanding nodes
|
|
461 |
// therefore we need to build up the branches for all nodes which are set as filters
|
|
462 |
// the branches are merged with the root
|
|
463 |
foreach(cdm_taxontree_filters_get() as $uuid=>$filter){
|
|
464 |
$branch = cdm_taxontree_build_path($uuid, TRUE, ($compact_tree === false ? true :null));
|
|
465 |
$root_tree = _cdm_taxontree_merge($root_tree, $branch);
|
|
466 |
}
|
|
467 |
}
|
|
468 |
|
|
469 |
// build the the branch for the focused node and merge it with the root
|
|
470 |
if($taxonUuid){
|
|
471 |
$branch = cdm_taxontree_build_path($taxonUuid, NULL, (cdm_taxontree_filters_active() ? NULL : TRUE), TRUE);
|
|
472 |
$root_tree = _cdm_taxontree_merge($root_tree, $branch);
|
|
473 |
}
|
|
474 |
|
|
475 |
//reorder siblings & populate expanded nodes with children and propagate the filter attribute
|
|
476 |
$root_tree = cdm_taxontree_populate($root_tree, $compact_tree === false);
|
|
477 |
|
|
478 |
// flatten tree
|
|
479 |
if($compact_tree){
|
|
480 |
if( _get_compact_mode() == 'flattened'){
|
|
481 |
$root_tree = cdm_taxontree_flatten($root_tree);
|
|
482 |
} else if(_get_compact_mode() == 'compact') {
|
|
483 |
foreach($root_tree as $uuid => $node){
|
|
484 |
if( $node->filter == 'excluded' && !$node->children){
|
|
485 |
unset($root_tree[$uuid]);
|
|
486 |
}
|
|
487 |
}
|
|
488 |
}
|
|
489 |
}
|
|
490 |
|
|
491 |
return $root_tree;
|
|
438 |
//TODO remove $hideOtherConcepts from method signature
|
|
439 |
|
|
440 |
if(is_null($vid)){
|
|
441 |
|
|
442 |
if($taxonUuid){
|
|
443 |
$taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
|
|
444 |
}
|
|
445 |
|
|
446 |
$compact_tree = cdm_taxontree_filters_active() && _get_compact_mode() != 'expanded';
|
|
447 |
}
|
|
448 |
/* valid compact_modes: 'expanded', 'compact', 'flattened' */
|
|
449 |
|
|
450 |
// get the root level
|
|
451 |
$root_tree = cdm_taxontree_get_root($vid);
|
|
452 |
// if(!$root_tree || !is_array($root_tree)){
|
|
453 |
// return array();
|
|
454 |
// }
|
|
455 |
$root_tree = _cdm_resultset2nodelist($root_tree, cdm_taxontree_filters_active());
|
|
456 |
|
|
457 |
|
|
458 |
if(cdm_taxontree_filters_active()){
|
|
459 |
// the paths up to active filters are inactive in the user interface and
|
|
460 |
// thus cannot be browsed by expanding nodes
|
|
461 |
// therefore we need to build up the branches for all nodes which are set as filters
|
|
462 |
// the branches are merged with the root
|
|
463 |
foreach(cdm_taxontree_filters_get() as $uuid=>$filter){
|
|
464 |
$branch = cdm_taxontree_build_path($uuid, TRUE, ($compact_tree === false ? true :null));
|
|
465 |
$root_tree = _cdm_taxontree_merge($root_tree, $branch);
|
|
466 |
}
|
|
467 |
}
|
|
468 |
|
|
469 |
// build the the branch for the focused node and merge it with the root
|
|
470 |
if($taxonUuid){
|
|
471 |
$branch = cdm_taxontree_build_path($taxonUuid, NULL, (cdm_taxontree_filters_active() ? NULL : TRUE), TRUE);
|
|
472 |
$root_tree = _cdm_taxontree_merge($root_tree, $branch);
|
|
473 |
}
|
|
474 |
|
|
475 |
//reorder siblings & populate expanded nodes with children and propagate the filter attribute
|
|
476 |
$root_tree = cdm_taxontree_populate($root_tree, $compact_tree === false);
|
|
477 |
|
|
478 |
// flatten tree
|
|
479 |
if($compact_tree){
|
|
480 |
if( _get_compact_mode() == 'flattened'){
|
|
481 |
$root_tree = cdm_taxontree_flatten($root_tree);
|
|
482 |
} else if(_get_compact_mode() == 'compact') {
|
|
483 |
foreach($root_tree as $uuid => $node){
|
|
484 |
if( $node->filter == 'excluded' && !$node->children){
|
|
485 |
unset($root_tree[$uuid]);
|
|
486 |
}
|
|
487 |
}
|
|
488 |
}
|
|
489 |
}
|
|
490 |
|
|
491 |
return $root_tree;
|
|
492 | 492 |
} |
493 | 493 |
|
494 | 494 |
/** |
... | ... | |
503 | 503 |
*/ |
504 | 504 |
function cdm_taxontree_build_path($taxonUuid, $is_filter_path = null, $is_expanded = null, $is_focused = FALSE){ |
505 | 505 |
|
506 |
$branch_path = array();
|
|
507 |
|
|
508 |
$parents = cdm_taxontree_get_parents($taxonUuid);
|
|
509 |
if(!$parents){
|
|
510 |
if($is_filter_path){
|
|
511 |
// remove invalid filter
|
|
512 |
cdm_taxontree_filters_remove($taxonUuid);
|
|
513 |
}
|
|
514 |
return false;
|
|
515 |
}
|
|
516 |
|
|
517 |
$parents = _cdm_resultset2nodelist($parents, NULL);
|
|
518 |
$lastParent = null;
|
|
519 |
foreach($parents as $pnode){
|
|
520 |
$pnode->focused = false;
|
|
521 |
if($lastParent){
|
|
522 |
$pnode->children = array($lastParent->taxonUuid => $lastParent);
|
|
523 |
if(!is_null($is_filter_path)){
|
|
524 |
$pnode->filter = ($is_filter_path ? 'excludes' : 'included');
|
|
525 |
}
|
|
526 |
if(!is_null($is_expanded)){
|
|
527 |
$pnode->expanded = ($is_expanded ? 'expanded' : 'collapsed');
|
|
528 |
}
|
|
529 |
} else {
|
|
530 |
// the uppermost node of branch
|
|
531 |
if(!is_null($is_filter_path)){
|
|
532 |
$pnode->filter = ($is_filter_path ? 'on' : 'includes');
|
|
533 |
}
|
|
534 |
// uppermost node is always expanded if it has children
|
|
535 |
$pnode->focused = $is_focused;
|
|
536 |
$pnode->expanded = ($pnode->taxonomicChildrenCount ? 'expanded' : 'collapsed');
|
|
537 |
}
|
|
538 |
$lastParent = $pnode;
|
|
539 |
}
|
|
540 |
$branch_path[$pnode->taxonUuid] = $pnode;
|
|
541 |
return $branch_path;
|
|
506 |
$branch_path = array();
|
|
507 |
|
|
508 |
$parents = cdm_taxontree_get_parents($taxonUuid);
|
|
509 |
if(!$parents){
|
|
510 |
if($is_filter_path){
|
|
511 |
// remove invalid filter
|
|
512 |
cdm_taxontree_filters_remove($taxonUuid);
|
|
513 |
}
|
|
514 |
return false;
|
|
515 |
}
|
|
516 |
|
|
517 |
$parents = _cdm_resultset2nodelist($parents, NULL);
|
|
518 |
$lastParent = null;
|
|
519 |
foreach($parents as $pnode){
|
|
520 |
$pnode->focused = false;
|
|
521 |
if($lastParent){
|
|
522 |
$pnode->children = array($lastParent->taxonUuid => $lastParent);
|
|
523 |
if(!is_null($is_filter_path)){
|
|
524 |
$pnode->filter = ($is_filter_path ? 'excludes' : 'included');
|
|
525 |
}
|
|
526 |
if(!is_null($is_expanded)){
|
|
527 |
$pnode->expanded = ($is_expanded ? 'expanded' : 'collapsed');
|
|
528 |
}
|
|
529 |
} else {
|
|
530 |
// the uppermost node of branch
|
|
531 |
if(!is_null($is_filter_path)){
|
|
532 |
$pnode->filter = ($is_filter_path ? 'on' : 'includes');
|
|
533 |
}
|
|
534 |
// uppermost node is always expanded if it has children
|
|
535 |
$pnode->focused = $is_focused;
|
|
536 |
$pnode->expanded = ($pnode->taxonomicChildrenCount ? 'expanded' : 'collapsed');
|
|
537 |
}
|
|
538 |
$lastParent = $pnode;
|
|
539 |
}
|
|
540 |
$branch_path[$pnode->taxonUuid] = $pnode;
|
|
541 |
return $branch_path;
|
|
542 | 542 |
} |
543 | 543 |
|
544 | 544 |
/** |
... | ... | |
551 | 551 |
*/ |
552 | 552 |
function cdm_taxontree_populate($tree, $expand_excluded, $filter_default = null){ |
553 | 553 |
|
554 |
if(!is_array($tree)){
|
|
555 |
return false;
|
|
556 |
}
|
|
557 |
foreach(array_keys($tree) as $uuid){
|
|
558 |
|
|
559 |
if(!isset($tree[$uuid]->filter) && !is_null($filter_default)){
|
|
560 |
$tree[$uuid]->filter = $filter_default;
|
|
561 |
}
|
|
562 |
|
|
563 |
if( $tree[$uuid]->expanded == 'expanded' && ($expand_excluded || $tree[$uuid]->filter != 'excluded')){
|
|
564 |
$children = cdm_taxontree_get_children($uuid, $tree[$uuid]->vid);
|
|
565 |
$children = _cdm_resultset2nodelist($children, ($tree[$uuid]->filter == 'excludes'));
|
|
566 |
|
|
567 |
// store the children of the node for later processing
|
|
568 |
if(is_array($tree[$uuid]->children)){
|
|
569 |
$pnode_children = $tree[$uuid]->children;
|
|
570 |
} else {
|
|
571 |
$pnode_children = false;
|
|
572 |
}
|
|
573 |
// replace the children by the newly retrieved child nodes
|
|
574 |
$tree[$uuid]->children = $children;
|
|
575 |
|
|
576 |
if($pnode_children){
|
|
577 |
// recurse into the childtree which was stored before
|
|
578 |
$pnode_children = cdm_taxontree_populate($pnode_children, $expand_excluded ,$tree[$uuid]->filter);
|
|
579 |
// recombine
|
|
580 |
foreach($pnode_children as $childUuid=>$cnode){
|
|
581 |
$tree[$uuid]->children[$childUuid] = $cnode;
|
|
582 |
}
|
|
583 |
}
|
|
584 |
} else {
|
|
585 |
// reorder nodes which are not expanded, expanded nodes are reordered implicitly above
|
|
586 |
if(isset($tree[$uuid]->children) && count($tree[$uuid]->children) > 1) {
|
|
587 |
// copy the children into an array which can be sorted by its keys
|
|
588 |
$ordered = array();
|
|
589 |
foreach($tree[$uuid]->children as $cnode){
|
|
590 |
// concatenate full name and uid
|
|
591 |
$reordered[str_pad($cnode->titleCache, 255, '-').$cnode->taxonUuid] = $cnode;
|
|
592 |
}
|
|
593 |
// sort
|
|
594 |
ksort($reordered);
|
|
595 |
// move the children back into the parent node
|
|
596 |
$tree[$uuid]->children = array();
|
|
597 |
foreach($reordered as $cnode){
|
|
598 |
$tree[$uuid]->children[$cnode->taxonUuid] = $cnode;
|
|
599 |
}
|
|
600 |
}
|
|
601 |
$tree[$uuid]->children = cdm_taxontree_populate($tree[$uuid]->children, $expand_excluded, $tree[$uuid]->filter);
|
|
602 |
}
|
|
603 |
}
|
|
604 |
return $tree;
|
|
554 |
if(!is_array($tree)){
|
|
555 |
return false;
|
|
556 |
}
|
|
557 |
foreach(array_keys($tree) as $uuid){
|
|
558 |
|
|
559 |
if(!isset($tree[$uuid]->filter) && !is_null($filter_default)){
|
|
560 |
$tree[$uuid]->filter = $filter_default;
|
|
561 |
}
|
|
562 |
|
|
563 |
if( $tree[$uuid]->expanded == 'expanded' && ($expand_excluded || $tree[$uuid]->filter != 'excluded')){
|
|
564 |
$children = cdm_taxontree_get_children($uuid, $tree[$uuid]->vid);
|
|
565 |
$children = _cdm_resultset2nodelist($children, ($tree[$uuid]->filter == 'excludes'));
|
|
566 |
|
|
567 |
// store the children of the node for later processing
|
|
568 |
if(is_array($tree[$uuid]->children)){
|
|
569 |
$pnode_children = $tree[$uuid]->children;
|
|
570 |
} else {
|
|
571 |
$pnode_children = false;
|
|
572 |
}
|
|
573 |
// replace the children by the newly retrieved child nodes
|
|
574 |
$tree[$uuid]->children = $children;
|
|
575 |
|
|
576 |
if($pnode_children){
|
|
577 |
// recurse into the childtree which was stored before
|
|
578 |
$pnode_children = cdm_taxontree_populate($pnode_children, $expand_excluded ,$tree[$uuid]->filter);
|
|
579 |
// recombine
|
|
580 |
foreach($pnode_children as $childUuid=>$cnode){
|
|
581 |
$tree[$uuid]->children[$childUuid] = $cnode;
|
|
582 |
}
|
|
583 |
}
|
|
584 |
} else {
|
|
585 |
// reorder nodes which are not expanded, expanded nodes are reordered implicitly above
|
|
586 |
if(isset($tree[$uuid]->children) && count($tree[$uuid]->children) > 1) {
|
|
587 |
// copy the children into an array which can be sorted by its keys
|
|
588 |
$ordered = array();
|
|
589 |
foreach($tree[$uuid]->children as $cnode){
|
|
590 |
// concatenate full name and uid
|
|
591 |
$reordered[str_pad($cnode->titleCache, 255, '-').$cnode->taxonUuid] = $cnode;
|
|
592 |
}
|
|
593 |
// sort
|
|
594 |
ksort($reordered);
|
|
595 |
// move the children back into the parent node
|
|
596 |
$tree[$uuid]->children = array();
|
|
597 |
foreach($reordered as $cnode){
|
|
598 |
$tree[$uuid]->children[$cnode->taxonUuid] = $cnode;
|
|
599 |
}
|
|
600 |
}
|
|
601 |
$tree[$uuid]->children = cdm_taxontree_populate($tree[$uuid]->children, $expand_excluded, $tree[$uuid]->filter);
|
|
602 |
}
|
|
603 |
}
|
|
604 |
return $tree;
|
|
605 | 605 |
} |
606 | 606 |
|
607 | 607 |
/** |
... | ... | |
612 | 612 |
* @return unknown |
613 | 613 |
*/ |
614 | 614 |
function cdm_taxontree_flatten($tree, &$new_root = null){ |
615 |
if(!$new_root){
|
|
616 |
$new_root = array();
|
|
617 |
}
|
|
618 |
foreach($tree as $node){
|
|
619 |
if($node->filter == 'on'){
|
|
620 |
$new_root[$node->taxonUuid] = $node;
|
|
621 |
} else if(is_array($node->children)){
|
|
622 |
cdm_taxontree_flatten($node->children, $new_root);
|
|
623 |
}
|
|
624 |
}
|
|
625 |
return $new_root;
|
|
615 |
if(!$new_root){
|
|
616 |
$new_root = array();
|
|
617 |
}
|
|
618 |
foreach($tree as $node){
|
|
619 |
if($node->filter == 'on'){
|
|
620 |
$new_root[$node->taxonUuid] = $node;
|
|
621 |
} else if(is_array($node->children)){
|
|
622 |
cdm_taxontree_flatten($node->children, $new_root);
|
|
623 |
}
|
|
624 |
}
|
|
625 |
return $new_root;
|
|
626 | 626 |
} |
627 | 627 |
|
628 | 628 |
|
... | ... | |
637 | 637 |
*/ |
638 | 638 |
function _cdm_taxontree_merge($tree, $branch) { |
639 | 639 |
|
640 |
if(!$branch){
|
|
641 |
return $tree;
|
|
642 |
}
|
|
643 |
|
|
644 |
foreach(array_keys($tree) as $uuid) {
|
|
645 |
// check if node exists in $branch
|
|
646 |
if(!empty($branch[$uuid])) {
|
|
647 |
// preserve filter property
|
|
648 |
if(isset($tree[$uuid]->filter) && !(isset($branch[$uuid]->filter) && $branch[$uuid]->filter == 'on') ){
|
|
649 |
$branch[$uuid]->filter = $tree[$uuid]->filter;
|
|
650 |
} else if(isset($branch[$uuid]->filter)){
|
|
651 |
$tree[$uuid]->filter = $branch[$uuid]->filter;
|
|
652 |
}
|
|
653 |
// preserve expanded property
|
|
654 |
if(isset($tree[$uuid]->expanded)){
|
|
655 |
$branch[$uuid]->expanded = $tree[$uuid]->expanded;
|
|
656 |
} else if(isset($branch[$uuid]->expanded)){
|
|
657 |
$tree[$uuid]->expanded = $branch[$uuid]->expanded;
|
|
658 |
}
|
|
659 |
// $Uuid exists check if the node in tree1 or tree2 contains children
|
|
660 |
if(is_array($branch[$uuid]->children) && is_array($tree[$uuid]->children)) {
|
|
661 |
// merge recursive
|
|
662 |
$tree[$uuid]->children = _cdm_taxontree_merge($tree[$uuid]->children, $branch[$uuid]->children);
|
|
663 |
} else if(is_array($branch[$uuid]->children)){
|
|
664 |
$tree[$uuid] = $branch[$uuid];
|
|
665 |
}
|
|
666 |
unset($branch[$uuid]);
|
|
667 |
}
|
|
668 |
}
|
|
669 |
// append remaining items from branch to tree
|
|
670 |
foreach(array_keys($branch) as $uuid){
|
|
671 |
$tree[$uuid] = $branch[$uuid];
|
|
672 |
}
|
|
673 |
return $tree;
|
|
640 |
if(!$branch){
|
|
641 |
return $tree;
|
|
642 |
}
|
|
643 |
|
|
644 |
foreach(array_keys($tree) as $uuid) {
|
|
645 |
// check if node exists in $branch
|
|
646 |
if(!empty($branch[$uuid])) {
|
|
647 |
// preserve filter property
|
|
648 |
if(isset($tree[$uuid]->filter) && !(isset($branch[$uuid]->filter) && $branch[$uuid]->filter == 'on') ){
|
|
649 |
$branch[$uuid]->filter = $tree[$uuid]->filter;
|
|
650 |
} else if(isset($branch[$uuid]->filter)){
|
|
651 |
$tree[$uuid]->filter = $branch[$uuid]->filter;
|
|
652 |
}
|
|
653 |
// preserve expanded property
|
|
654 |
if(isset($tree[$uuid]->expanded)){
|
|
655 |
$branch[$uuid]->expanded = $tree[$uuid]->expanded;
|
|
656 |
} else if(isset($branch[$uuid]->expanded)){
|
|
657 |
$tree[$uuid]->expanded = $branch[$uuid]->expanded;
|
|
658 |
}
|
|
659 |
// $Uuid exists check if the node in tree1 or tree2 contains children
|
|
660 |
if(is_array($branch[$uuid]->children) && is_array($tree[$uuid]->children)) {
|
|
661 |
// merge recursive
|
|
662 |
$tree[$uuid]->children = _cdm_taxontree_merge($tree[$uuid]->children, $branch[$uuid]->children);
|
|
663 |
} else if(is_array($branch[$uuid]->children)){
|
|
664 |
$tree[$uuid] = $branch[$uuid];
|
|
665 |
}
|
|
666 |
unset($branch[$uuid]);
|
|
667 |
}
|
|
668 |
}
|
|
669 |
// append remaining items from branch to tree
|
|
670 |
foreach(array_keys($branch) as $uuid){
|
|
671 |
$tree[$uuid] = $branch[$uuid];
|
|
672 |
}
|
|
673 |
return $tree;
|
|
674 | 674 |
} |
675 | 675 |
|
676 | 676 |
|
... | ... | |
685 | 685 |
*/ |
686 | 686 |
function _cdm_resultset2nodelist($resultset, $excluded = null, $expanded = null){ |
687 | 687 |
|
688 |
if(! is_array($resultset)) {
|
|
689 |
return false;
|
|
690 |
}
|
|
691 |
|
|
692 |
$tree = array();
|
|
693 |
foreach($resultset as $treeNode){
|
|
694 |
if(!is_null($excluded)){
|
|
695 |
$treeNode->filter = ($excluded ? 'excluded': 'included');
|
|
696 |
}
|
|
697 |
if(!is_null($expanded)){
|
|
698 |
$treeNode->expanded = ($expanded ? 'expanded': 'collapsed');
|
|
699 |
}
|
|
700 |
$tree[$treeNode->taxonUuid] = $treeNode;
|
|
701 |
}
|
|
702 |
return $tree;
|
|
688 |
if(! is_array($resultset)) {
|
|
689 |
return false;
|
|
690 |
}
|
|
691 |
|
|
692 |
$tree = array();
|
|
693 |
foreach($resultset as $treeNode){
|
|
694 |
if(!is_null($excluded)){
|
|
695 |
$treeNode->filter = ($excluded ? 'excluded': 'included');
|
|
696 |
}
|
|
697 |
if(!is_null($expanded)){
|
|
698 |
$treeNode->expanded = ($expanded ? 'expanded': 'collapsed');
|
|
699 |
}
|
|
700 |
$tree[$treeNode->taxonUuid] = $treeNode;
|
|
701 |
}
|
|
702 |
return $tree;
|
|
703 | 703 |
} |
704 | 704 |
|
705 | 705 |
|
... | ... | |
707 | 707 |
|
708 | 708 |
|
709 | 709 |
function theme_cdm_taxontree_add_scripts(){ |
710 |
$path_cdm_taxontree = drupal_get_path('module', 'cdm_taxontree');
|
|
711 |
$path_preferred_module = drupal_get_path('module', 'cdm_dataportal') ? drupal_get_path('module', 'cdm_dataportal') : $path_cdm_taxontree;
|
|
712 |
drupal_add_css($path_cdm_taxontree.'/cdm_taxontree.css');
|
|
713 |
drupal_add_js($path_preferred_module.'/js/jquery.dimensions.js');
|
|
714 |
drupal_add_js($path_cdm_taxontree.'/js/cdm_taxontree.js');
|
|
715 |
drupal_add_js($path_cdm_taxontree.'/js/jquery.scrollTo.js');
|
|
710 |
$path_cdm_taxontree = drupal_get_path('module', 'cdm_taxontree');
|
|
711 |
$path_preferred_module = drupal_get_path('module', 'cdm_dataportal') ? drupal_get_path('module', 'cdm_dataportal') : $path_cdm_taxontree;
|
|
712 |
drupal_add_css($path_cdm_taxontree.'/cdm_taxontree.css');
|
|
713 |
drupal_add_js($path_preferred_module.'/js/jquery.dimensions.js');
|
|
714 |
drupal_add_js($path_cdm_taxontree.'/js/cdm_taxontree.js');
|
|
715 |
drupal_add_js($path_cdm_taxontree.'/js/jquery.scrollTo.js');
|
|
716 | 716 |
} |
717 | 717 |
|
718 | 718 |
|
... | ... | |
733 | 733 |
*/ |
734 | 734 |
function theme_cdm_taxontree_block($tree, $delta, $magicbox = false, $show_filter_switch = false, $tree_node_callback = false){ |
735 | 735 |
|
736 |
// THEMERS: change the line below according the specific regions of your theme
|
|
737 |
$left_expand_region = 'right';
|
|
738 |
|
|
739 |
$out = '';
|
|
740 |
if(cdm_taxontree_filters_active()){
|
|
741 |
$out .= theme('cdm_taxontree_contoller', _get_compact_mode());
|
|
742 |
}
|
|
743 |
if($magicbox){
|
|
744 |
if(is_numeric($magicbox) || is_string($magicbox)){
|
|
745 |
$region = _get_block_region($magicbox);
|
|
746 |
}
|
|
747 |
// the magicbox expands to the right by default,
|
|
748 |
// if the class 'expand-left' to the cdm_taxontree_scroller_x the box will expand to the left
|
|
749 |
$expand_direction = $region == 'right' ? 'expand-left' : '';
|
|
750 |
$out .= '<div class="cdm_taxontree_scroller_x '.$expand_direction.'"><div class="cdm_taxontree_container"><div class="cdm_taxontree_scroller_y">';
|
|
751 |
} else {
|
|
752 |
$out .= '<div class="cdm_taxontree_scroller_xy">';
|
|
753 |
}
|
|
754 |
|
|
755 |
$out .= theme('cdm_taxontree', $tree, !cdm_taxontree_filters_active(), $show_filter_switch , $tree_node_callback);
|
|
756 |
|
|
757 |
if($magicbox){
|
|
758 |
$out .= '</div></div></div>';
|
|
759 |
} else {
|
|
760 |
$out .= '</div>';
|
|
761 |
}
|
|
762 |
return $out;
|
|
736 |
// THEMERS: change the line below according the specific regions of your theme
|
|
737 |
$left_expand_region = 'right';
|
|
738 |
|
|
739 |
$out = '';
|
|
740 |
if(cdm_taxontree_filters_active()){
|
|
741 |
$out .= theme('cdm_taxontree_contoller', _get_compact_mode());
|
|
742 |
}
|
|
743 |
if($magicbox){
|
|
744 |
if(is_numeric($magicbox) || is_string($magicbox)){
|
|
745 |
$region = _get_block_region($magicbox);
|
|
746 |
}
|
|
747 |
// the magicbox expands to the right by default,
|
|
748 |
// if the class 'expand-left' to the cdm_taxontree_scroller_x the box will expand to the left
|
|
749 |
$expand_direction = $region == 'right' ? 'expand-left' : '';
|
|
750 |
$out .= '<div class="cdm_taxontree_scroller_x '.$expand_direction.'"><div class="cdm_taxontree_container"><div class="cdm_taxontree_scroller_y">';
|
|
751 |
} else {
|
|
752 |
$out .= '<div class="cdm_taxontree_scroller_xy">';
|
|
753 |
}
|
|
754 |
|
|
755 |
$out .= theme('cdm_taxontree', $tree, !cdm_taxontree_filters_active(), $show_filter_switch , $tree_node_callback);
|
|
756 |
|
|
757 |
if($magicbox){
|
|
758 |
$out .= '</div></div></div>';
|
|
759 |
} else {
|
|
760 |
$out .= '</div>';
|
|
761 |
}
|
|
762 |
return $out;
|
|
763 | 763 |
} |
764 | 764 |
|
765 | 765 |
function theme_cdm_taxontree_contoller($compact_mode){ |
766 | 766 |
|
767 |
static $modes = array('expanded', 'compact', 'flattened');
|
|
767 |
static $modes = array('expanded', 'compact', 'flattened');
|
|
768 | 768 |
|
769 |
$out = '<div class="settings">';
|
|
770 |
foreach($modes as $mode){
|
|
771 |
if($compact_mode == $mode){
|
|
772 |
$out .= t($mode);
|
|
773 |
} else {
|
|
774 |
$out .= l(t($mode), 'cdm_taxontree/set/compact_mode/'.$mode, array(), drupal_get_destination());
|
|
775 |
}
|
|
776 |
$out .= ' ';
|
|
777 |
}
|
|
769 |
$out = '<div class="settings">';
|
|
770 |
foreach($modes as $mode){
|
|
771 |
if($compact_mode == $mode){
|
|
772 |
$out .= t($mode);
|
|
773 |
} else {
|
|
774 |
$out .= l(t($mode), 'cdm_taxontree/set/compact_mode/'.$mode, array(), drupal_get_destination());
|
|
775 |
}
|
|
776 |
$out .= ' ';
|
|
777 |
}
|
|
778 | 778 |
|
779 |
return $out.'</div>';
|
|
779 |
return $out.'</div>';
|
|
780 | 780 |
} |
781 | 781 |
|
782 | 782 |
function theme_cdm_taxontree($tree, $filterIncludes = null, $show_filter_switch = false, $tree_node_callback = false, $element_name = false){ |
783 | 783 |
|
784 |
if(!is_array($tree)) {
|
|
785 |
// $out = '<ul class="cdm_taxontree">'; |
|
786 |
// $out .= '<li>----------------------------NO TREE---------------------------------------</li>'; |
|
787 |
// $out .= '</ul>'; |
|
788 |
// return $out; |
|
789 |
return false;
|
|
790 |
}
|
|
784 |
if(!is_array($tree)) {
|
|
785 |
// $out = '<ul class="cdm_taxontree">';
|
|
786 |
// $out .= '<li>----------------------------NO TREE---------------------------------------</li>';
|
|
787 |
// $out .= '</ul>';
|
|
788 |
// return $out;
|
|
789 |
return false;
|
|
790 |
}
|
|
791 | 791 |
|
792 |
if(is_null($filterIncludes)){
|
|
793 |
// set $filterIncludes true if no filters are set.
|
|
794 |
$filterIncludes = !cdm_taxontree_filters_active();
|
|
795 |
}
|
|
792 |
if(is_null($filterIncludes)){
|
|
793 |
// set $filterIncludes true if no filters are set.
|
|
794 |
$filterIncludes = !cdm_taxontree_filters_active();
|
|
795 |
}
|
|
796 | 796 |
|
797 | 797 |
// append element name to get multiple taxontrees on one page working |
798 | 798 |
$out = '<ul class="cdm_taxontree' . (($element_name) ? ' ' . $element_name : '') . '">'; |
799 |
foreach($tree as $node){
|
|
800 |
$out .= theme('cdm_taxontree_node', $node, $filterIncludes, $show_filter_switch, $tree_node_callback);
|
|
801 |
}
|
|
802 |
$out .= '</ul>';
|
|
803 |
return $out;
|
|
799 |
foreach($tree as $node){
|
|
800 |
$out .= theme('cdm_taxontree_node', $node, $filterIncludes, $show_filter_switch, $tree_node_callback);
|
|
801 |
}
|
|
802 |
$out .= '</ul>';
|
|
803 |
return $out;
|
|
804 | 804 |
} |
805 | 805 |
|
806 | 806 |
function theme_cdm_taxontree_node($node, $filterIncludes, $show_filter_switch = false, $tree_node_callback = false){ |
807 | 807 |
|
808 |
$is_leaf = !$node->taxonomicChildrenCount || $node->taxonomicChildrenCount == 0; |
|
809 |
$is_expanded = isset($node->expanded) && $node->expanded = 'expanded'; |
|
810 |
|
|
811 |
if($node->tid){ |
|
812 |
$node_name = $node->name; |
|
813 |
$path = "taxonomy/term/".$node->tid; |
|
814 |
// disable filterswitch |
|
815 |
$show_filter_switch = false; |
|
816 |
|
|
817 |
} else if(module_exists('cdm_dataportal')){ |
|
818 |
$node_name = cdm_dataportal_shortname_of($node); |
|
819 |
$path = path_to_taxon($node->taxonUuid); |
|
820 |
} else { |
|
821 |
$node_name = "module cdm_dataportal missing"; |
|
822 |
$path = ""; |
|
823 |
} |
|
824 |
|
|
825 |
if($filterIncludes){ |
|
808 |
$is_leaf = !$node->taxonomicChildrenCount || $node->taxonomicChildrenCount == 0; |
|
809 |
$is_expanded = isset($node->expanded) && $node->expanded = 'expanded'; |
|
810 |
/* |
|
811 |
if($node->taxonUuid == '1a0bb171-9461-4713-b98d-d0a5f03dfcb1'){ |
|
812 |
var_dump('ACHTUNG ##########!!!!!!!!!!!!'); |
|
813 |
} |
|
814 |
*/ |
|
815 |
if($node->tid){ |
|
816 |
$node_name = $node->name; |
|
817 |
$path = "taxonomy/term/".$node->tid; |
|
818 |
// disable filterswitch |
|
819 |
$show_filter_switch = false; |
|
820 |
|
|
821 |
} else if(module_exists('cdm_dataportal')){ |
|
822 |
$node_name = cdm_dataportal_shortname_of($node); |
|
823 |
$path = path_to_taxon($node->taxonUuid); |
|
824 |
} else { |
|
825 |
$node_name = "module cdm_dataportal missing"; |
|
826 |
$path = ""; |
|
827 |
} |
|
828 |
|
|
829 |
if($filterIncludes){ |
|
826 | 830 |
$name = l($node_name, $path); |
827 | 831 |
// no names for terms in filter widget; as discussed with A. Müller |
828 | 832 |
//$name = ''; |
829 |
|
|
833 |
|
|
830 | 834 |
$filter_class = 'filter_included'; |
831 |
} else { |
|
832 |
if($node->filter == 'on') { |
|
833 |
$name = l($node_name, $path); |
|
834 |
$filter_class = 'filter_on'; |
|
835 |
} else { |
|
836 |
$name .= $node_name; |
|
837 |
$filter_class = 'filter_excluded'; |
|
838 |
} |
|
839 |
} |
|
840 |
$nextLevelIncluded = $node->filter == 'on' || $filterIncludes; |
|
841 |
|
|
842 |
$ahah_url = false; |
|
843 |
if(!$is_leaf && !$is_expanded && $filter_class != 'filter_excluded'){ |
|
844 |
if($node->tid){ |
|
845 |
$ahah_url = url('cdm_taxontree/taxonomy/children/'.$node->tid.'/'.$node->vid.'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback); |
|
846 |
} else if(module_exists('cdm_dataportal')) { |
|
847 |
$ws_url = cdm_compose_taxonomy_path($node->taxonUuid); |
|
848 |
$ahah_url = url('cdm_api/proxy/'.urlencode($ws_url).'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback); |
|
849 |
} |
|
850 |
} |
|
851 |
|
|
852 |
// list item |
|
853 |
$out = '<li class="' |
|
854 |
.($node->focused ? 'focused ' : '') |
|
855 |
.($is_leaf ? 'leaf ':($is_expanded ?'expanded ':'collapsed ')) |
|
856 |
.$filter_class.'"' |
|
857 |
.($ahah_url ? 'ref="'.$ahah_url.'"' : '') |
|
858 |
.'>'; |
|
859 |
|
|
860 |
if($show_filter_switch){ |
|
861 |
// filter icon |
|
862 |
$out .= theme('cdm_taxontree_node_filter_switch', $node, $filter_class); |
|
863 |
} |
|
864 |
|
|
865 |
// taxon name |
|
866 |
$out .= $name; |
|
867 |
|
|
868 |
// concept_switch or other theme callbacks |
|
869 |
if($tree_node_callback){ |
|
870 |
$out .= theme($tree_node_callback, $node); |
|
871 |
} |
|
872 |
|
|
873 |
if($node->children && is_array($node->children)){ |
|
874 |
$out .= theme('cdm_taxontree', $node->children, $nextLevelIncluded, $show_filter_switch, $tree_node_callback); |
|
875 |
} |
|
876 |
$out .= '</li>'; |
|
877 |
|
|
878 |
return $out; |
|
835 |
} else { |
|
836 |
if($node->filter == 'on') { |
|
837 |
$name = l($node_name, $path); |
|
838 |
$filter_class = 'filter_on'; |
|
839 |
} else { |
|
840 |
$name .= $node_name; |
|
841 |
$filter_class = 'filter_excluded'; |
|
842 |
} |
|
843 |
} |
|
844 |
$nextLevelIncluded = $node->filter == 'on' || $filterIncludes; |
|
845 |
|
|
846 |
$ahah_url = false; |
|
847 |
if(!$is_leaf && !$is_expanded && $filter_class != 'filter_excluded'){ |
|
848 |
if($node->tid){ |
|
849 |
$ahah_url = url('cdm_taxontree/taxonomy/children/'.$node->tid.'/'.$node->vid.'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback); |
|
850 |
} else if(module_exists('cdm_dataportal')) { |
|
851 |
$ws_url = cdm_compose_taxonomy_path($node->taxonUuid); |
|
852 |
$ahah_url = url('cdm_api/proxy/'.urlencode($ws_url).'/cdm_taxontree/'.($nextLevelIncluded ? 1 : 0).'/'.($show_filter_switch ? 1 : 0).'/'.$tree_node_callback); |
|
853 |
} |
|
854 |
} |
|
855 |
|
|
856 |
// list item |
|
857 |
$out = '<li class="' |
|
858 |
.($node->focused ? 'focused ' : '') |
|
859 |
.($is_leaf ? 'leaf ':($is_expanded ?'expanded ':'collapsed ')) |
|
860 |
.$filter_class.'"' |
|
861 |
.($ahah_url ? 'ref="'.$ahah_url.'"' : '') |
|
862 |
.'>'; |
|
863 |
|
|
864 |
if($show_filter_switch){ |
|
865 |
// filter icon |
|
866 |
$out .= theme('cdm_taxontree_node_filter_switch', $node, $filter_class); |
|
867 |
} |
|
868 |
|
|
869 |
// taxon name |
|
870 |
$out .= $name; |
|
871 |
|
|
872 |
// concept_switch or other theme callbacks |
|
873 |
if($tree_node_callback){ |
|
874 |
$out .= theme($tree_node_callback, $node); |
|
875 |
} |
|
876 |
|
|
877 |
/* |
|
878 |
foreach ($node->children as $element){ |
|
879 |
$nameStr = ''; |
|
880 |
foreach($element->taggedTitle as $tagtxt){ |
|
881 |
if($tagtxt->type == 'name' || $tagtxt->type == 'rank'){ |
|
882 |
$nameStr .= ($nameStr ? ' ' : '').$tagtxt->text; |
|
883 |
} |
|
884 |
} |
|
885 |
$nameStr = trim($nameStr); |
|
886 |
if (stristr(strtolower($tagtxt->text), 'incertae sedis') !== FALSE || |
|
887 |
stristr(strtolower($tagtxt->text), 'nomina excludenda') !== FALSE){ |
|
888 |
var_dump('PREMIO'); |
|
889 |
var_dump($element); |
|
890 |
} |
|
891 |
} |
|
892 |
*/ |
|
893 |
|
|
894 |
if($node->children && is_array($node->children)){ |
|
895 |
$out .= theme('cdm_taxontree', $node->children, $nextLevelIncluded, $show_filter_switch, $tree_node_callback); |
|
896 |
} |
|
897 |
$out .= '</li>'; |
|
898 |
|
|
899 |
return $out; |
|
879 | 900 |
} |
880 | 901 |
|
881 | 902 |
function theme_cdm_taxontree_node_filter_switch(&$node, $filter_class){ |
882 |
if(!module_exists('cdm_dataportal')) {
|
|
883 |
return '';
|
|
884 |
}
|
|
885 |
|
|
886 |
$out = '';
|
|
887 |
switch($filter_class){
|
|
888 |
case 'filter_included':
|
|
889 |
$filter_icon = 'visible_implicit_small.gif';
|
|
890 |
break;
|
|
891 |
case 'filter_excluded':
|
|
892 |
$filter_icon = 'invisible_small.gif';
|
|
893 |
break;
|
|
894 |
case 'filter_on':
|
|
895 |
$filter_icon = 'visible_small.gif';
|
|
896 |
break;
|
|
897 |
}
|
|
898 |
|
|
899 |
$filter_op = $node->filter == 'on' ? 'remove' : 'add';
|
|
900 |
|
|
901 |
$out .= ' '
|
|
902 |
.l('<img src="'.drupal_get_path('module', 'cdm_taxontree').'/'.$filter_icon.'" alt="[f]" />',
|
|
903 |
if(!module_exists('cdm_dataportal')) {
|
|
904 |
return '';
|
|
905 |
}
|
|
906 |
|
|
907 |
$out = '';
|
|
908 |
switch($filter_class){
|
|
909 |
case 'filter_included':
|
|
910 |
$filter_icon = 'visible_implicit_small.gif';
|
|
911 |
break;
|
|
912 |
case 'filter_excluded':
|
|
913 |
$filter_icon = 'invisible_small.gif';
|
|
914 |
break;
|
|
915 |
case 'filter_on':
|
|
916 |
$filter_icon = 'visible_small.gif';
|
|
917 |
break;
|
|
918 |
}
|
|
919 |
|
|
920 |
$filter_op = $node->filter == 'on' ? 'remove' : 'add';
|
|
921 |
|
|
922 |
$out .= ' '
|
|
923 |
.l('<img src="'.drupal_get_path('module', 'cdm_taxontree').'/'.$filter_icon.'" alt="[f]" />',
|
|
903 | 924 |
'cdm_taxontree/filter/'.$filter_op.'/'.$node->taxonUuid, array('class'=>'filter_'.$filter_op), |
904 | 925 |
'destination='.path_to_taxon($node->taxonUuid), |
905 |
null, false, true);
|
|
906 |
|
|
907 |
return $out;
|
|
926 |
null, false, true);
|
|
927 |
|
|
928 |
return $out;
|
|
908 | 929 |
} |
909 | 930 |
|
910 | 931 |
/** |
911 |
*
|
|
932 |
* |
|
912 | 933 |
* @param unknown_type $node |
913 | 934 |
* @return unknown_type |
914 | 935 |
*/ |
915 | 936 |
function theme_cdm_taxontree_node_concept_switch(&$node){ |
916 |
$out = '';
|
|
937 |
$out = '';
|
|
917 | 938 |
|
918 |
if(isset($node->alternativeConceptRefs[0])){
|
|
919 |
$out = l(
|
|
939 |
if(isset($node->alternativeConceptRefs[0])){
|
|
940 |
$out = l(
|
|
920 | 941 |
'<img src="'.drupal_get_path('module', 'cdm_taxontree').'/concept_switch.gif" alt="[->]" />', |
921 | 942 |
'cdm_dataportal/taxon/alternative/'.$node->taxonUuid, |
922 |
array('rel'=>'cdm_dataportal/taxon/alternative/'.$node->taxonUuid, 'class'=>'concept_switch'),
|
|
923 |
null, null, false, true);
|
|
924 |
}
|
|
925 |
return $out;
|
|
943 |
array('rel'=>'cdm_dataportal/taxon/alternative/'.$node->taxonUuid, 'class'=>'concept_switch'),
|
|
944 |
null, null, false, true);
|
|
945 |
}
|
|
946 |
return $out;
|
|
926 | 947 |
} |
927 | 948 |
|
928 | 949 |
// ----------------- FILTERS -------------------------- // |
... | ... | |
937 | 958 |
* @return unknown |
938 | 959 |
*/ |
939 | 960 |
function cdm_taxontree_view_filter($op, $taxonUuid = null){ |
940 |
|
|
941 |
if(!isset($_SESSION['cdm']['filters'])){
|
|
942 |
$_SESSION['cdm']['filters'] = array();
|
|
943 |
}
|
|
944 |
if($taxonUuid || $op == 'list'){
|
|
945 |
switch($op){
|
|
946 |
case 'add':
|
|
947 |
cdm_taxontree_filters_add($taxonUuid);
|
|
948 |
break;
|
|
949 |
case 'remove':
|
|
950 |
cdm_taxontree_filters_remove($taxonUuid);
|
|
951 |
break;
|
|
952 |
case 'list':
|
|
953 |
//TODO put in cdm_dataportal_theme to decouple both modules by this!!!
|
|
954 |
$out = '<ul>';
|
|
955 |
foreach($_SESSION['cdm']['filters'] as $uuid=>$node){
|
|
956 |
$out .= '<li>'.cdm_dataportal_shortname_of($node).' '.l('[x]', 'cdm_dataportal/filter/remove/'.$uuid, array(), drupal_get_destination()).'</li>';
|
|
957 |
}
|
|
958 |
$out .= '</ul>';
|
|
959 |
return $out;
|
|
960 |
}
|
|
961 |
}
|
|
962 |
if($_REQUEST['destination']){
|
|
963 |
$destination = $_REQUEST['destination'];
|
|
964 |
unset($_REQUEST['destination']);
|
|
965 |
drupal_goto($destination);
|
|
966 |
}
|
|
961 |
|
|
962 |
if(!isset($_SESSION['cdm']['filters'])){
|
|
963 |
$_SESSION['cdm']['filters'] = array();
|
|
964 |
}
|
|
965 |
if($taxonUuid || $op == 'list'){
|
|
966 |
switch($op){
|
|
967 |
case 'add':
|
|
968 |
cdm_taxontree_filters_add($taxonUuid);
|
|
969 |
break;
|
|
970 |
case 'remove':
|
|
971 |
cdm_taxontree_filters_remove($taxonUuid);
|
|
972 |
break;
|
|
973 |
case 'list':
|
|
974 |
//TODO put in cdm_dataportal_theme to decouple both modules by this!!!
|
|
975 |
$out = '<ul>';
|
|
976 |
foreach($_SESSION['cdm']['filters'] as $uuid=>$node){
|
|
977 |
$out .= '<li>'.cdm_dataportal_shortname_of($node).' '.l('[x]', 'cdm_dataportal/filter/remove/'.$uuid, array(), drupal_get_destination()).'</li>';
|
|
978 |
}
|
|
979 |
$out .= '</ul>';
|
|
980 |
return $out;
|
|
981 |
}
|
|
982 |
}
|
|
983 |
if($_REQUEST['destination']){
|
|
984 |
$destination = $_REQUEST['destination'];
|
|
985 |
unset($_REQUEST['destination']);
|
|
986 |
drupal_goto($destination);
|
|
987 |
}
|
|
967 | 988 |
} |
968 | 989 |
|
969 | 990 |
/** |
... | ... | |
973 | 994 |
* @return true if any filter is active |
974 | 995 |
*/ |
975 | 996 |
function cdm_taxontree_filters_active(){ |
976 |
return isset($_SESSION['cdm']['filters']) && count($_SESSION['cdm']['filters']) > 0;
|
|
997 |
return isset($_SESSION['cdm']['filters']) && count($_SESSION['cdm']['filters']) > 0;
|
|
977 | 998 |
} |
978 | 999 |
|
979 | 1000 |
/** |
... | ... | |
982 | 1003 |
* @return a reference on the filters array stored in the SESSION |
983 | 1004 |
*/ |
984 | 1005 |
function &cdm_taxontree_filters_get(){ |
985 |
if(!isset($_SESSION['cdm']['filters'])){
|
|
986 |
$_SESSION['cdm']['filters'] = array();
|
|
987 |
}
|
|
988 |
return $_SESSION['cdm']['filters'];
|
|
1006 |
if(!isset($_SESSION['cdm']['filters'])){
|
|
1007 |
$_SESSION['cdm']['filters'] = array();
|
|
1008 |
}
|
|
1009 |
return $_SESSION['cdm']['filters'];
|
|
989 | 1010 |
} |
990 | 1011 |
|
991 | 1012 |
/** |
... | ... | |
995 | 1016 |
*/ |
996 | 1017 |
function cdm_taxontree_filters_add($taxonUuid){ |
997 | 1018 |
|
998 |
$parents = cdm_ws_taxonomy_pathFromRoot($taxonUuid);
|
|
999 |
|
|
1000 |
$parents = array_reverse($parents);
|
|
1001 |
|
|
1002 |
// pop off last element since this is the TreeNode object for $taxonUuid!
|
|
1003 |
$this_node = array_pop($parents);
|
|
1004 |
// will contain the uuid of the parent nodes excluding the $taxonUuid node itself
|
|
1005 |
$parent_uuids = array();
|
|
1006 |
|
|
1007 |
// children override parents rule: remove all parent filters,
|
|
1008 |
foreach($parents as $pnode){
|
|
1009 |
unset($_SESSION['cdm']['filters'][$pnode->taxonUuid]);
|
|
1010 |
$parent_uuids[] = $pnode->taxonUuid;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
// search for potential children of this $taxonUuid
|
|
1014 |
foreach($_SESSION['cdm']['filters'] as $uuid=>$node){
|
|
1015 |
if(in_array($taxonUuid, $node->parentUuids)){
|
|
1016 |
unset($_SESSION['cdm']['filters'][$node->taxonUuid]);
|
|
1017 |
}
|
|
1018 |
}
|
|
1019 |
// finally add this $taxonUuid as new filter
|
|
1020 |
$this_node->parentUuids = $parent_uuids;
|
|
1021 |
$_SESSION['cdm']['filters'][$taxonUuid] = $this_node;
|
|
1019 |
$parents = cdm_ws_taxonomy_pathFromRoot($taxonUuid);
|
|
1020 |
|
|
1021 |
$parents = array_reverse($parents);
|
|
1022 |
|
|
1023 |
// pop off last element since this is the TreeNode object for $taxonUuid!
|
|
1024 |
$this_node = array_pop($parents);
|
|
1025 |
// will contain the uuid of the parent nodes excluding the $taxonUuid node itself
|
|
1026 |
$parent_uuids = array();
|
|
1027 |
|
|
1028 |
// children override parents rule: remove all parent filters,
|
|
1029 |
foreach($parents as $pnode){
|
|
1030 |
unset($_SESSION['cdm']['filters'][$pnode->taxonUuid]);
|
|
1031 |
$parent_uuids[] = $pnode->taxonUuid;
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
// search for potential children of this $taxonUuid
|
|
1035 |
foreach($_SESSION['cdm']['filters'] as $uuid=>$node){
|
|
1036 |
if(in_array($taxonUuid, $node->parentUuids)){
|
|
1037 |
unset($_SESSION['cdm']['filters'][$node->taxonUuid]);
|
|
1038 |
}
|
|
1039 |
}
|
|
1040 |
// finally add this $taxonUuid as new filter
|
|
1041 |
$this_node->parentUuids = $parent_uuids;
|
|
1042 |
$_SESSION['cdm']['filters'][$taxonUuid] = $this_node;
|
|
1022 | 1043 |
} |
1023 | 1044 |
|
1024 | 1045 |
/** |
... | ... | |
1027 | 1048 |
* @param UUID $taxonUuid |
1028 | 1049 |
*/ |
1029 | 1050 |
function cdm_taxontree_filters_remove($taxonUuid){ |
1030 |
unset($_SESSION['cdm']['filters'][$taxonUuid]);
|
|
1051 |
unset($_SESSION['cdm']['filters'][$taxonUuid]);
|
|
1031 | 1052 |
} |
1032 | 1053 |
|
1033 | 1054 |
|
... | ... | |
1043 | 1064 |
*/ |
1044 | 1065 |
function _cdm_get_taxonuuid(){ |
1045 | 1066 |
|
1046 |
//TODO make the path configurable
|
|
1047 |
if (arg(0)=="cdm_dataportal" && arg(1)=="taxon" && arg(2)!==0){
|
|
1048 |
$taxon_uuid = arg(2);
|
|
1049 |
} else {
|
|
1050 |
$taxon_uuid = $_SESSION['cdm_dataportal']['tree']['taxon_uuid'];
|
|
1051 |
}
|
|
1052 |
return $taxon_uuid;
|
|
1067 |
//TODO make the path configurable
|
|
1068 |
if (arg(0)=="cdm_dataportal" && arg(1)=="taxon" && arg(2)!==0){
|
|
1069 |
$taxon_uuid = arg(2);
|
|
1070 |
} else {
|
|
1071 |
$taxon_uuid = $_SESSION['cdm_dataportal']['tree']['taxon_uuid'];
|
|
1072 |
}
|
|
1073 |
return $taxon_uuid;
|
|
1053 | 1074 |
} |
1054 | 1075 |
|
Also available in: Unified diff
formatting lectotypes #1272