Revision 092744e1
Added by Andreas Kohlbecker about 10 years ago
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module | ||
---|---|---|
263 | 263 |
$profile_featureTree = cdm_ws_get(CDM_WS_FEATURETREE, UUID_DEFAULT_FEATURETREE); |
264 | 264 |
} |
265 | 265 |
} |
266 |
|
|
266 | 267 |
return $profile_featureTree; |
267 | 268 |
} |
268 | 269 |
|
... | ... | |
1306 | 1307 |
* The CDM FeatureTree to be used as template |
1307 | 1308 |
* @param $taxon_uuid |
1308 | 1309 |
* The UUID of the taxon |
1310 |
* @param $excludes |
|
1311 |
* UUIDs of features to be excluded |
|
1309 | 1312 |
* @return$feature_tree |
1310 | 1313 |
* The CDM FeatureTree wich was given as parameter merged tree wheras the |
1311 | 1314 |
* CDM FeatureNodes are extended by an additinal field 'descriptionElements' |
1312 | 1315 |
* witch will hold the accoding $descriptionElements. |
1313 | 1316 |
*/ |
1314 |
function cdm_ws_descriptions_by_featuretree($feature_tree, $taxon_uuid) { |
|
1317 |
function cdm_ws_descriptions_by_featuretree($feature_tree, $taxon_uuid, $exclude_uuids = array()) {
|
|
1315 | 1318 |
|
1316 | 1319 |
if (!$feature_tree) { |
1317 | 1320 |
drupal_set_message(check_plain(t("No 'FeatureTree' has been set so far. |
... | ... | |
1322 | 1325 |
|
1323 | 1326 |
$merged_trees = array(); |
1324 | 1327 |
|
1325 |
$description_elemens = cdm_ws_fetch_all(CDM_WS_DESCRIPTIONELEMENT_BY_TAXON, |
|
1328 |
$description_elements = cdm_ws_fetch_all(CDM_WS_DESCRIPTIONELEMENT_BY_TAXON,
|
|
1326 | 1329 |
array( |
1327 | 1330 |
'taxon' => $taxon_uuid, |
1328 |
'features' => cdm_featureTree_elements_toString($feature_tree->root, ',', 'uuid') |
|
1331 |
'features' => cdm_featureTree_elements_toString($feature_tree->root, ',', 'uuid', $exclude_uuids)
|
|
1329 | 1332 |
), |
1330 | 1333 |
'POST' |
1331 | 1334 |
); |
1332 | 1335 |
|
1333 | 1336 |
// Combine all descripions into one feature tree. |
1334 |
$merged_nodes = _mergeFeatureTreeDescriptions($feature_tree->root->childNodes, $description_elemens); |
|
1337 |
$merged_nodes = _mergeFeatureTreeDescriptions($feature_tree->root->childNodes, $description_elements);
|
|
1335 | 1338 |
$feature_tree->root->childNodes = $merged_nodes; |
1336 | 1339 |
|
1337 | 1340 |
return $feature_tree; |
... | ... | |
1416 | 1419 |
} |
1417 | 1420 |
} |
1418 | 1421 |
|
1422 |
/** |
|
1423 |
* finds and returns the FeatureNode denoted by the given $feature_uuid |
|
1424 |
* |
|
1425 |
* @param $feature_tree_nodes |
|
1426 |
* The nodes contained in CDM FeatureTree entitiy: $feature->root->childNodes |
|
1427 |
* @param $feature_uuid |
|
1428 |
* The UUID of the Feature |
|
1429 |
* @return returns the FeatureNode or null |
|
1430 |
*/ |
|
1431 |
function &cdm_feature_tree_find_node($feature_tree_nodes, $feature_uuid){ |
|
1432 |
|
|
1433 |
// 1. scan this level |
|
1434 |
foreach ($feature_tree_nodes as $node){ |
|
1435 |
if($node->feature->uuid == $feature_uuid){ |
|
1436 |
return $node; |
|
1437 |
} |
|
1438 |
} |
|
1439 |
|
|
1440 |
// 2. descend into childen |
|
1441 |
foreach ($feature_tree_nodes as $node){ |
|
1442 |
if(is_array($node->childNodes)){ |
|
1443 |
$node = cdm_feature_tree_find_node($node->children); |
|
1444 |
if($node) { |
|
1445 |
return $node; |
|
1446 |
} |
|
1447 |
} |
|
1448 |
} |
|
1449 |
|
|
1450 |
return null; |
|
1451 |
} |
|
1452 |
|
|
1419 | 1453 |
/** |
1420 | 1454 |
* Merges the given featureNodes structure with the descriptionElements. |
1421 | 1455 |
* |
... | ... | |
1839 | 1873 |
* The character to be used as glue for concatenation, default is ', ' |
1840 | 1874 |
* @param $field_name |
1841 | 1875 |
* The field name of the CDM Features |
1876 |
* @param $excludes |
|
1877 |
* Allows defining a set of values to be excluded. This refers to the values |
|
1878 |
* in the field denoted by the $field_name parameter |
|
1879 |
* |
|
1842 | 1880 |
*/ |
1843 |
function cdm_featureTree_elements_toString($root_node, $separator = ', ', $field_name = 'representation_L10n') { |
|
1881 |
function cdm_featureTree_elements_toString($root_node, $separator = ', ', $field_name = 'representation_L10n', $excludes = array()) {
|
|
1844 | 1882 |
$out = ''; |
1845 | 1883 |
|
1846 | 1884 |
$pre_child_separator = $separator; |
... | ... | |
1848 | 1886 |
|
1849 | 1887 |
foreach ($root_node->childNodes as $feature_node) { |
1850 | 1888 |
$out .= ($out ? $separator : ''); |
1851 |
$out .= $feature_node->feature->$field_name; |
|
1852 |
if (is_array($feature_node->childNodes) && count($feature_node->childNodes) > 0) { |
|
1853 |
$childlabels = cdm_featureTree_elements_toString($feature_node, $separator, $field_name); |
|
1854 |
if (strlen($childlabels)) { |
|
1855 |
$out .= $pre_child_separator . $childlabels . $post_child_separator; |
|
1889 |
if(!in_array($feature_node->feature->$field_name, $excludes)) { |
|
1890 |
$out .= $feature_node->feature->$field_name; |
|
1891 |
if (is_array($feature_node->childNodes) && count($feature_node->childNodes) > 0) { |
|
1892 |
$childlabels = cdm_featureTree_elements_toString($feature_node, $separator, $field_name); |
|
1893 |
if (strlen($childlabels)) { |
|
1894 |
$out .= $pre_child_separator . $childlabels . $post_child_separator; |
|
1895 |
} |
|
1856 | 1896 |
} |
1857 | 1897 |
} |
1858 | 1898 |
} |
Also available in: Unified diff
dataportal now uses the DescriptionInfoDTO service - a lot refactoring, old stuff left for now as reference