function tft_tree in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 tft.module \tft_tree()
1 call to tft_tree()
- tft_manage_folders_form in ./
tft.admin.inc - Reorganise terms under the given term tid.
1 string reference to 'tft_tree'
- tft_install in ./
tft.install - Implements hook_install().
File
- ./
tft.module, line 1098 - Module hooks.
Code
function tft_tree($tid = 0, $inclusive = FALSE) {
$folders = array();
$content = tft_folder_content($tid);
foreach ($content as $item) {
$folders[$item['id']]['weight'] = isset($item['weight']) ? $item['weight'] : 0;
$folders[$item['id']]['parent'] = $tid ? $tid : 0;
$folders[$item['id']]['type'] = $item['type'];
if ($item['type'] == 'term' && tft_term_access($item['id'])) {
$folders[$item['id']]['tid'] = $item['id'];
$folders[$item['id']]['name'] = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
':tid' => $item['id'],
))
->fetchField();
if ($child_terms = tft_tree($item['id'])) {
$folders[$item['id']]['children'] = $child_terms;
}
}
elseif ($item['type'] == 'node' && node_access('view', node_load($item['id']))) {
$folders[$item['id']]['nid'] = $item['id'];
$folders[$item['id']]['name'] = db_query("SELECT v.title FROM {node} n LEFT JOIN {node_revision} v ON v.vid = n.vid WHERE n.nid = :nid", array(
':nid' => $item['id'],
))
->fetchField();
}
}
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,
'type' => 'term',
'children' => $folders,
),
);
}
return $folders;
}