Revision 0af3ce28
Added by Andreas Kohlbecker almost 8 years ago
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module | ||
---|---|---|
460 | 460 |
* When building the tree, the instances are extended by some fields: |
461 | 461 |
* - $node->filter: values ( 'on', 'excluded', 'included' ) |
462 | 462 |
* - $node->expanded: values ( 'expanded', 'collapsed' ) |
463 |
* $node->focused: values ( TRUE, FALSE ) |
|
464 | 463 |
* |
465 | 464 |
* @param string $taxonUuid |
466 | 465 |
* |
... | ... | |
500 | 499 |
if ($taxonUuid) { |
501 | 500 |
$taxon_in_current_tree = taxon_in_current_classification($taxonUuid); |
502 | 501 |
if ($taxon_in_current_tree) { |
503 |
$branch = cdm_taxontree_build_path($taxonUuid, NULL, (cdm_taxontree_filters_active() ? NULL : TRUE), TRUE);
|
|
502 |
$branch = cdm_taxontree_build_path($taxonUuid, NULL, (cdm_taxontree_filters_active() ? NULL : TRUE)); |
|
504 | 503 |
$root_tree = _cdm_taxontree_merge($root_tree, $branch); |
505 | 504 |
} |
506 | 505 |
} |
... | ... | |
538 | 537 |
* Whether the upmost node of this path is mapped by an active filter. |
539 | 538 |
* @param bool $is_expanded |
540 | 539 |
* Whether all nodes along the tree are expanded. |
541 |
* @param bool $is_focused |
|
542 |
* Whether to upper most element of this branch is set as filter. |
|
543 | 540 |
* |
544 | 541 |
* @return mixed |
545 | 542 |
* A subtree. |
546 | 543 |
*/ |
547 |
function cdm_taxontree_build_path($taxonUuid, $is_filter_path = NULL, $is_expanded = NULL, $is_focused = FALSE) {
|
|
544 |
function cdm_taxontree_build_path($taxonUuid, $is_filter_path = NULL, $is_expanded = NULL) { |
|
548 | 545 |
|
549 | 546 |
$branch_path = array(); |
550 | 547 |
|
... | ... | |
561 | 558 |
$lastParent = NULL; |
562 | 559 |
|
563 | 560 |
foreach ($parents as $pnode) { |
564 |
$pnode->focused = FALSE; |
|
565 |
|
|
566 |
// TODO to be replaced by ($pnode->taxonUuid == $taxonUuid); ?? |
|
567 |
// compare usage of $is_focused. |
|
568 | 561 |
if ($lastParent) { |
569 | 562 |
$pnode->children = array($lastParent->taxonUuid => $lastParent); |
570 | 563 |
if (!is_null($is_filter_path)) { |
... | ... | |
579 | 572 |
if (!is_null($is_filter_path)) { |
580 | 573 |
$pnode->filter = ($is_filter_path ? 'on' : 'includes'); |
581 | 574 |
} |
582 |
// Uppermost node is always expanded if it has children. |
|
583 |
$pnode->focused = $is_focused; |
|
584 | 575 |
$pnode->expanded = ($pnode->taxonomicChildrenCount ? 'expanded' : 'collapsed'); |
585 | 576 |
} |
586 | 577 |
$lastParent = $pnode; |
... | ... | |
738 | 729 |
elseif (isset($branch[$uuid]->expanded)) { |
739 | 730 |
$tree[$uuid]->expanded = $branch[$uuid]->expanded; |
740 | 731 |
} |
741 |
// Preserve focused property. |
|
742 |
if (isset($tree[$uuid]->focused)) { |
|
743 |
$branch[$uuid]->focused = $tree[$uuid]->focused; |
|
744 |
} |
|
745 |
elseif (isset($branch[$uuid]->focused)) { |
|
746 |
$tree[$uuid]->focused = $branch[$uuid]->focused; |
|
747 |
} |
|
748 | 732 |
// $Uuid exists check if the node in tree1 or tree2 contains children. |
749 | 733 |
if (isset($branch[$uuid]->children) && is_array($branch[$uuid]->children) && isset($tree[$uuid]->children) && is_array($tree[$uuid]->children)) { |
750 | 734 |
// Merge recursive. |
... | ... | |
958 | 942 |
'node' => $node, |
959 | 943 |
'filterIncludes' => $filterIncludes, |
960 | 944 |
'show_filter_switch' => $show_filter_switch, |
961 |
'tree_node_callback' => $tree_node_callback,
|
|
945 |
'tree_node_callback' => $tree_node_callback |
|
962 | 946 |
)); |
963 | 947 |
} |
964 | 948 |
$out .= '</ul>'; |
... | ... | |
974 | 958 |
$filterIncludes = $variables['filterIncludes']; |
975 | 959 |
$show_filter_switch = $variables['show_filter_switch']; |
976 | 960 |
$tree_node_callback = $variables['tree_node_callback']; |
961 |
|
|
977 | 962 |
$is_leaf = !$node->taxonomicChildrenCount || $node->taxonomicChildrenCount == 0; |
978 | 963 |
$is_expanded = isset($node->expanded) && $node->expanded = 'expanded'; |
979 | 964 |
|
965 |
$focused_taxon_uuid = get_current_taxon_uuid(); |
|
966 |
|
|
980 | 967 |
if (isset($node->tid)) { |
981 | 968 |
$node_name = $node->name; |
982 | 969 |
$path = "taxonomy/term/" . $node->tid; |
... | ... | |
1006 | 993 |
$filter_class = 'filter_on'; |
1007 | 994 |
} |
1008 | 995 |
else { |
1009 |
$name .= $node_name;
|
|
996 |
$name = $node_name; |
|
1010 | 997 |
$filter_class = 'filter_excluded'; |
1011 | 998 |
} |
1012 | 999 |
} |
... | ... | |
1025 | 1012 |
|
1026 | 1013 |
// List item. |
1027 | 1014 |
$out = '<li class="' |
1028 |
. (isset($node->focused) && $node->focused === TRUE ? 'focused ' : '')
|
|
1015 |
. ($node->taxonUuid == $focused_taxon_uuid ? 'focused ' : '')
|
|
1029 | 1016 |
. ($is_leaf ? 'leaf ' : ($is_expanded ? 'expanded ' : 'collapsed ')) |
1030 | 1017 |
. $filter_class . '"' |
1031 | 1018 |
. ($ahah_url ? ' data-cdm-ahah-url="' . $ahah_url . '"' : '') |
... | ... | |
1137 | 1124 |
'filterIncludes' => NULL, |
1138 | 1125 |
'show_filter_switch' => FALSE, |
1139 | 1126 |
'tree_node_callback' => FALSE, |
1140 |
'element_name' => FALSE,
|
|
1127 |
'element_name' => FALSE |
|
1141 | 1128 |
)), |
1142 | 1129 |
'cdm_taxontree_block' => array('variables' => array( |
1143 | 1130 |
'tree' => NULL, |
... | ... | |
1151 | 1138 |
'node' => NULL, |
1152 | 1139 |
'filterIncludes' => NULL, |
1153 | 1140 |
'show_filter_switch' => FALSE, |
1154 |
'tree_node_callback' => FALSE,
|
|
1141 |
'tree_node_callback' => FALSE |
|
1155 | 1142 |
)), |
1156 | 1143 |
'cdm_taxontree_node_concept_switch' => array('variables' => array('node' => NULL)), |
1157 | 1144 |
'cdm_taxontree_node_filter_switch' => array('variables' => array('node' => NULL, 'filter_class' => NULL)), |
... | ... | |
1284 | 1271 |
* |
1285 | 1272 |
* @return string |
1286 | 1273 |
* The taxon id found, or FALSE. |
1274 |
* |
|
1275 |
* @deprecated use get_current_taxon_uuid() instead |
|
1287 | 1276 |
*/ |
1288 | 1277 |
function _cdm_get_taxonuuid() { |
1289 |
// TODO Make the path configurable. |
|
1278 |
|
|
1290 | 1279 |
if (arg(0) == "cdm_dataportal" && arg(1) == "taxon" && arg(2) !== 0) { |
1291 | 1280 |
$taxon_uuid = arg(2); |
1292 | 1281 |
} |
1293 | 1282 |
else { |
1294 | 1283 |
$taxon_uuid = FALSE; |
1295 |
|
|
1284 |
// TODO is this SESSION variable ['cdm_dataportal']['tree']['taxon_uuid'] use at all? |
|
1296 | 1285 |
if (isset($_SESSION['cdm_dataportal']['tree']['taxon_uuid'])) { |
1297 | 1286 |
$taxon_uuid = $_SESSION['cdm_dataportal']['tree']['taxon_uuid']; |
1298 | 1287 |
} |
Also available in: Unified diff
#5887 #5852 classification breadcrumbs navigation implemented