function tft_folder_tree in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 tft.module \tft_folder_tree()
Construct the folder tree.
Parameters
int $tid = 0: The taxonomy term tid
boolean $inclusive = FALSE: Wether the current term should be included as well
Return value
array The folder tree
2 calls to tft_folder_tree()
- tft_block_view in ./
tft.module - tft_form_alter in ./
tft.module - Implementation of hook_form_alter()
File
- ./
tft.module, line 1058 - Module hooks.
Code
function tft_folder_tree($tid = 0, $inclusive = FALSE) {
$folders = array();
$content = tft_folder_content($tid, TRUE);
foreach ($content as $term) {
if (tft_term_access($term['id'])) {
$folders[$term['id']]['tid'] = $term['id'];
$folders[$term['id']]['name'] = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
':tid' => $term['id'],
))
->fetchField();
$folders[$term['id']]['weight'] = $term['weight'];
$folders[$term['id']]['parent'] = $tid ? $tid : 0;
if ($child_terms = tft_folder_tree($term['id'])) {
$folders[$term['id']]['children'] = $child_terms;
}
}
}
if ($inclusive) {
if ($tid == 0) {
$name = t("Root");
}
else {
$name = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
}
$folders = array(
$tid => array(
'name' => $name,
'tid' => $tid,
'weight' => 0,
'parent' => 0,
'children' => $folders,
),
);
}
return $folders;
}