function _taxonomy_csv_check_vocabulary_hierarchy in Taxonomy CSV import/export 6.4
Same name and namespace in other branches
- 6.5 taxonomy_csv.vocabulary.api.inc \_taxonomy_csv_check_vocabulary_hierarchy()
- 6.2 taxonomy_csv.vocabulary.api.inc \_taxonomy_csv_check_vocabulary_hierarchy()
- 6.3 taxonomy_csv.vocabulary.api.inc \_taxonomy_csv_check_vocabulary_hierarchy()
- 7.4 taxonomy_csv.vocabulary.api.inc \_taxonomy_csv_check_vocabulary_hierarchy()
Check and update hierarchy flag of a given vocabulary.
Drupal hierarchy check function bugs with vocabularies without hierarchy.
Parameters
$vocabulary: The vocabulary array to check and to update.
$changed_term: (Optional) Useless. Kept for compatibility with taxonomy D6 function.
Return value
Updated hierarchy level.
1 call to _taxonomy_csv_check_vocabulary_hierarchy()
- _taxonomy_csv_info_vocabulary in import/
taxonomy_csv.import.result.inc - Check created vocabularies and return formatted info on them.
File
- ./
taxonomy_csv.vocabulary.api.inc, line 169 - Prepare and manage vocabularies.
Code
function _taxonomy_csv_check_vocabulary_hierarchy($vocabulary, $changed_term = array(
'tid' => 0,
)) {
$tree = taxonomy_get_tree($vocabulary['vid']);
$hierarchy = 0;
foreach ($tree as $term) {
// Check this term's parent count.
if (count($term->parents) > 1) {
$hierarchy = 2;
break;
}
elseif (count($term->parents) == 1 && 0 != array_shift($term->parents)) {
$hierarchy = 1;
}
}
if ($hierarchy != $vocabulary['hierarchy']) {
$vocabulary['hierarchy'] = $hierarchy;
taxonomy_save_vocabulary($vocabulary);
}
return $hierarchy;
}